Guide en_US - Paranoid-AF/trigger_purchase GitHub Wiki
trigger_purchase Manual
trigger_purchase is a custom point entity for mappers to make use of player scores, for example, you could make players spend 5 points for a shotgun, and you could also make them experience 15 seconds of moon's gravity, or just keep that gravity - It's all on you. It also comes with some error handling mechanics, preventing embarrassing scenarios like infinite purchase when player scores gets negative.
Download and Install
- Click here to download the bundle, and create a folder called
trigger_purchase
insvencoop/scripts/maps
, and unzip all the files there. - Open your mapping software, and add
trigger_purchase.fgd
from above to your Game Profile.
Add the Script to Your Map
Create a map and compile, find its .bsp
file in svencoop/maps
, and open the .cfg
file with the same name (create one if it doesn't exist). For example, if the map name is touhou_hakureijinja.bsp
, then create touhou_hakureijinja.cfg
If your map doesn't have custom scripts (In Most Cases)
Start a new line in the .cfg
file mentioned above, and add:
map_script trigger_purchase/INIT
If you've added custom scripts for your map (Advanced Users)
In your custom script (the location could be found in the .cfg
file mentioned above, and search for map_script
, the directory is right after it. Remember it's always located in /svencoop/scripts/maps
), include trigger_purchase/Activate
(the directory may vary, it's relative here.) with #include
, and add Trigger_Purchase::Activate();
in your void MapInit()
function.
Tips on Dirtributing the Map
Remember to keep that svencoop/scripts/maps/trigger_purchase
folder and the .cfg
file in your map bundle. Add models and sounds that are used to your .res
file.
Adding the Entity
In your mapping software, add a trigger_purchase
entity.
This entity will contain the following properties.
Name | Type | Description |
---|---|---|
Name | Entity Name | The name of the current entity. |
Target (Success) | Entity Name | Entity to trigger immediately if possible. |
Target (Later) | Entity Name | Entity to trigger after some time. |
Target (Command Error) | Entity Name | Entity to trigger if error occurrs. |
Target (Not Enough Score) | Entity Name | Entity to trgger if player doesn't have enough score. |
Echo command to execute immediately | String | Command to execute immediately if possible. |
Echo command to execute later | String | Command to execute after some time. |
Echo command to execute on error | String | Command to execute if error occurrs. |
Echo command to execute on not enough score | String | Command to execute if player doesn't have enough score. |
Interval for later command (second) | Float | That “some time” mentioned above. |
Score to cost | Float | Scores required to trigger this entity, and the scores will only be deducted if the player has enough score and the first command is executed successfully. |
You may feel confused about the process - that's OK, here's a flow chart for you:
Note: For ease of expression, it's not made clear. But keep in mind that if the very first command was not executed successfully, then the entity Entity (Success)
will also not be triggered, and scores will not be deducted.
Anyway, it's just about different operations for different scenarios.
So how should we make use of this? Well, I've got an example for 'ya.
Demo
We have a demo for you if it's necessary.
Echo Command
It should be clear that the "command" above is not CVAR of Sven Co-op. This command system was used in Ecco, but here's the mini version. All you need to know is right ahead.
The only thing that varies is that you could split multiple commands with |
, for ease of access (Well you could add some whitespace for readability, it does't matter). But what if we need to use |
? Just use a backslash: \|
.
Command List
Note: Arguments wrapped with []
is required, while those wrapped with ()
is optional.
Command | Description |
---|---|
maxhealth [Value] (Player Name) | Set the max health of a player. |
maxarmor [Value] (Player Name) | Set the max armor of a player. |
say [Text] | Add text to this player's chat box. |
broadcast [Text] | Add text to every player's chat box. |
give [Entity Type] (Player Name) | Give a weapon or item to a player. |
log [Text] | Add the text to the server's log. |
hurt (Value) (Player Name) | Kill (with the first argument empty) or hurt a player. |
heal (Value) (Player Name) | Completely heal (with the first argument empty) or partially heal a player. |
armor (Value) (Player Name) | Completely charge (with the first argument empty) or partially charge a player's armor. |
maxspeed [Float] (Player Name) | Set the maxium speed of the player. (No more than server's setting) |
gravity [Float] (Player Name) | Set the gravity of the player. |
Magic Text
Due to the limitation of the commands, you may need some variables, or special characters.
Magic Text | Description |
---|---|
%PLAYER% | Name of the player who triggered this entity. |
%RANDOMPLAYER% | Name of a random player. |
%SPACE% | Whitespace. |
They will be replaced with the target variables or characters when the command executes.
Echo Addons
Although it's a mini version, but addons is still supported. Click here (not translated yet) for further information.