Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Creating custom weapons - VScript: Difference between revisions

From TF2 Classified Wiki
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{stub}}
{{stub}}
{{todo| write an actual page, and maybe make it more beginner friendly? Also I'm sorry Static for writing this page for you out of the blue but I was hit with a wave of "autistic inspiration" I guess.}}
{{todo|Make the page more beginner friendly:
 
Start simple
 
Give plenty of examples that each go through multiple new things
 
 
Add explanations for detecting actions like attack, attack2 and reload
}}


TF2C extends TF2 and MapBase's VScripting, making anything possible in either of them mostly possible in TF2C.
TF2C extends TF2 and MapBase's VScripting, making anything possible in either of them mostly possible in TF2C.


Vscript in TF2C uses [https://en.wikipedia.org/wiki/Squirrel_(programming_language) Squirrel] <sup>{{tooltip|Note|as of writing the actual squirrel website is inaccessible for whatever reason, so the wikipedia page will have to do for now I suppose}}</sup>, which is also used by TF2 and MapBase for their Vscripting as well.
VScript in TF2C uses [https://en.wikipedia.org/wiki/Squirrel_(programming_language) Squirrel] <sup>{{tooltip|Note|as of writing the actual squirrel website is inaccessible for whatever reason, so the Wikipedia page will have to do for now I suppose}}</sup>, which is also used by TF2 and MapBase for their VScripting as well.


= Hooks =
= Hooks =
A hook in modding is when you get the game to run a function, so you can perform custom behavior or replace existing behavior. We can't actually replace TF2C's code directly of course, so instead we use a tool provided to us by Valve and the TF2C team called Vscript.<br>
A hook in modding is when you get the game to run a function, so you can perform custom behavior or replace existing behavior. We can't actually replace TF2C's code directly of course, so instead we use a tool provided to us by Valve and the TF2C team called VScript.<br>
Hooking can be done in two ways, a table and collector (making a table of functions and collecting them) and a direct hook to the game's events. As of writing, the writer here has no idea what the difference is.
Hooking can be done in two ways, a table and collector (making a table of functions and collecting them) and a direct hook to the game's events. As of writing, the writer here has no idea what the difference is.
== Table and collector method ==
== Table and collector method ==
Heres an example table that disables medic's health regen when he's holding a weapon that has a custom, schema defined attribute.
Here's an example table that disables Medic's health regen when he's holding a weapon that has a custom, schema defined attribute.
<pre>
<pre>
::AttributeTable <- {
::AttributeTable <- {
Line 59: Line 67:


== Direct hook method ==
== Direct hook method ==
The direct hook method is the same way the Official April Fools Mod does it's VScript attributes <sub>{{tooltip|Todo|should we link this?}}</sub>
The direct hook method is the same way the official April Fools weapon pack does its VScript attributes <sub>{{tooltip|Todo|should we link this?}}</sub>
For example we're going to pick apart one of them, specifically the "mod shoot self" attribute.
For example we're going to pick apart one of them, specifically the "mod shoot self" attribute.
<pre>
<pre>