Creating custom weapons - VScript: Difference between revisions
From TF2 Classified Wiki
More actions
mNo edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{stub}} | {{stub}} | ||
{{todo| | {{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. | |||
= 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 | 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 == | ||
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 | 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> | ||