Commit 67ebed08 authored by Mikleo's avatar Mikleo

--

parent cf05a8c5
Pipeline #9388 passed with stages
in 14 seconds
#Scenario Scripting
# Scenario Scripting
## Basics
##Basics
Scenario scripts are basically like a chain of sourcemod commands. The chain begins with the default forwards. e.g. OnScenarioLoaded, OnGameStart and ends when there are no more commands in the chain.
The Run command can run other named scripts, even several at the same time.
"OnGameStart" "Every 10 -> Run Message1 message2"
"Message1" "ChatText *Hello World*"
"message2" "ChatText *Hi*"
"OnGameStart" "Every 10 -> Run Message1 Message2"
"Message1" "ChatText *Hello World*"
"Message2" "ChatText *Hi*"
This will print both these messages every 10 seconds. Notice that we are using '*' instead of speech marks, it works the same way speech marks work in sourcemod commands, this is only because keyvalues are already delimited by speech marks.
......@@ -18,23 +17,26 @@ You can check the commandlist.md file for a list of commands.
Every command in the chain will run with a SINGLE associated entity. The default forwards will start with emp_params as their assosiated entity.
Inputs and Outputs of entities are very useful, you can look at Empires\bin\Empires.FGD for details of inputs and outputs.
"OnGameStart" "After 600 -> Input InputNFWin"
"OnGameStart" "After 600 -> Input InputNFWin"
This works because the starting entity is emp_params and it has an input of InputNFWin. here is a copy of very useful emp_params inputs from Empires.FGD.
// Inputs
InputNFWin(void), InputImpWin(void),
SetNFTickets(integer), SetBETickets(integer),
ModifyNFTickets(integer), ModifyBETickets(integer),
SetNFResources(float),SetBEResources(float)
ModifyNFResources(float), ModifyBEResources(float)
"OnGameStart" "Run HookDeath"
"HookDeath" "TargetName Destructable -> OnOutput OnBreak -> TargetParams -> Input SetNFTickets 0"
InputNFWin(void), InputImpWin(void),
SetNFTickets(integer), SetBETickets(integer),
ModifyNFTickets(integer), ModifyBETickets(integer),
SetNFResources(float),SetBEResources(float)
ModifyNFResources(float), ModifyBEResources(float)
Example:
"OnGameStart" "Run HookDeath"
"HookDeath" "TargetName Destructable -> OnOutput OnBreak -> TargetParams -> Input SetNFTickets 0"
You can use TargetName to change the associated entity of the next command. . Note here that OnBreak is only an output of a dynamic prop.
"OnGameStart" "After 100 -> DestroyAllTanks"
"DestroyAllTanks" "TargetClassnameAll emp_vehicle -> Input Kill -> ChatText *I killed a tank*"
"OnGameStart" "After 100 -> DestroyAllTanks"
"DestroyAllTanks" "TargetClassnameAll emp_vehicle -> Input Kill -> ChatText *I killed a tank*"
Using TargetClassnameAll and TargetNameAll you can target multiple entities which Runs a seperate chain for each one found. In this example the chat message will be spammed for every tank the script found.
......@@ -43,22 +45,23 @@ Using TargetClassnameAll and TargetNameAll you can target multiple entities whic
Deferred Commands are commands like After, Every and onOutput. These commands will be cleared on OnGameEnd and OnMapEnd, so most of the time you don't need to worry about them.
However you can also specify an identifier so that you can cancel these commands at any time.
"OnGameStart" "Run StartMessages -> After 60 -> Run StopMessages"
"StartMessages" "Every 10 HelloWorldIdentifier -> ChatText *Hello World*"
"StopMessages" "Cancel HelloWorldIdentifier"
"OnGameStart" "Run StartMessages -> After 60 -> Run StopMessages"
"StartMessages" "Every 10 HelloWorldIdentifier -> ChatText *Hello World*"
"StopMessages" "Cancel HelloWorldIdentifier"
This will repeat the message until after 60 seconds when it will stop.
It is important to note that while this command is totally valid:
"DoSomething" "After 5 -> Run DoSomething"
"DoSomething" "After 5 -> Run DoSomething"
This command (or any chain that only uses non-deferred statements) will cause the script to break. Don't do this:
"DoSomethingStupid" "Input Kill -> Run DoSomethingStupid"
"DoSomethingStupid" "Input Kill -> Run DoSomethingStupid"
##Error checking
## Error checking
You don't want to have to test the scenario to see if there are obvious errors in the scripts.
Pay attention to chat when you load a scenario, it will say if it has found errors and you can look at the console for details.
This will catch
......@@ -69,22 +72,28 @@ This will catch
However it will not catch problems with your command arguments.
##Variables (advanced)
## Variables (advanced)
You can inject entity properties into strings on most commands. These properties are not the scenario properties but entity properties.
You can see the assosiated entprops in entdata.txt. some common examples
$[m_iTeamNum]
$[m_iHealth]
$[m_iName]
... many more
"OnGameStart" "TargetName artifact -> ChatText *My name is $[m_iName], my health is $[m_iHealth]*"
$[m_iTeamNum]
$[m_iHealth]
$[m_iName]
... many more
Example:
It will check If the property exists, if it doesent, it wont replace the text.
"OnGameStart" "TargetName artifact -> ChatText *My name is $[m_iName], my health is $[m_iHealth]*"
It will check If the property exists, if it doesn't, it wont replace the text.
Another example:
"OnGameStart" "TargetNameAll resbox -> OnOutput OnBreak _ TargetActivator -> RunIf $[m_iTeam] == 2 NFKilled ELSE BEKilled"
"NFKilled" "ChatText *NF killed resbox and gets 1000 resources* -> TargetParams -> Input ModifyNFResources 1000"
"BEKilled" "ChatText *BE killed resbox and gets 1000 resources* -> TargetParams -> Input ModifyBEResources 1000"
"OnGameStart" "TargetNameAll resbox -> OnOutput OnBreak _ TargetActivator -> RunIf $[m_iTeam] == 2 NFKilled ELSE BEKilled"
"NFKilled" "ChatText *NF killed resbox and gets 1000 resources* -> TargetParams -> Input ModifyNFResources 1000"
"BEKilled" "ChatText *BE killed resbox and gets 1000 resources* -> TargetParams -> Input ModifyBEResources 1000"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment