I made this tutorial some years ago. My english was not really good back then, but it is understandable. I think that it's a great tutorial for anyone that wants to learn how to make triggers in StarForge with no programming knowledge.
=========================================================================
Triggers in Starforge
By: Clokr_IntroductionHow many times I heard "how SF triggers run?" or "I don't understand SF triggers, I will use SCXE"?. First you must know that SF triggers are faster to make than SCXE ones. Yes, but, are they harder? Nope, it's just practice, but if you know any programming language it will be easier. Anyway, let's start!
Some stuff before start-GlosaryFunction: This is a word with wich you will become familiar using SF triggers. In SCXE or StarEdit each function is called "action" or "condition". In the SF they will be a little different and called functions.
Parameters: Each one of the values that a function needs. In SCXE or StarEdit the parameters are 'where', 'unit', 'quantity', 'switch', 'for', etc.
Syntax: The information of what parameters are used and how they will be ordened. In SCXE or StarEdit the syntax was a sentence like 'Give
quantity units owned by
player at
location to
player.'
Now just press Save button, press Close and save the map. If you open that map in StarEdit/SCXE you can that the trigger is right!
Don't continue without knowing what this words mean. I will use the three words in this tutorial.
-Explaining differences between StarEdit and SF function syntaxesFor this I'm going to use the Give units example. See:
SCXE/StarEdit syntax: 'Give
quantity units owned by
player at
location to
player.'
StarForge syntax: 'GiveUnits(
Count,
Unit,
Owner,
Where,
NewOwner);'
As you can see the parameters are the same.
Now I will start talking about the SF funtion syntax. As you can see you don't need to select the name of the action/condition, you must write it. After the function name ALWAYS goes a bracket '('. After the bracket goes the parameters, separated by commas. At the ends always goes a bracked ')' and a semicolon ';'. So the syntax is this:
FunctionName(
Param1,
Param2,
Param3, ...);
(For write a function in SF, just replace the FunctionName by the name of the function needed and the ParamX with the parameter that this function needs. You can see the parameters that each function needs in it syntax.)
-StarForge function syntaxes listTrigger conditions:NoCondition();
CountdownTimer(Comparison, Time);
Command(Player, Comparison, Number, Unit);
Bring(Player, Comparison, Number, Unit, Location);
Accumulate(Player, Comparison, Number, ResourceType);
Kills(Player, Comparison, Number, Unit);
CommandMost(Unit);
CommandMostAt(Unit, Location);
MostKills(Unit);
HighestScore(ScoreType);
MostResources(ResourceType);
Switch(Switch, State);
ElapsedTime(Comparison, Time);
Briefing();
Opponents(Player, Comparison, Number);
Deaths(Player, Comparison, Number, Unit);
CommandLeast(Unit);
CommandLeastAt(Unit, Location);
LeastKills(Unit);
LowestScore(ScoreType);
LeastResources(ResourceType);
Score(Player, ScoreType, Comparison, Number);
Always();
Never();
Trigger actions:NoAction();
Victory();
Defeat();
PreserveTrigger();
Wait(Number Time);
PauseGame();
UnpauseGame();
Transmission(Unit, Where, WAVName, TimeModifier, Time, Text, AlwaysDisplay);
PlayWAV(String WAVName);
DisplayText(Text, AlwaysDisplay);
CenterView(Where);
CreateUnitWithProperties(Count, Unit, Where, Player, Properties);
SetMissionObjectives(Text);
SetSwitch(Switch, SwitchState);
SetCountdownTimer(TimeModifier, Time);
RunAIScript(Script);
RunAIScriptAt(Script, Where);
LeaderBoardControl(Unit, Label);
LeaderBoardControlAt(Unit, Location, Label);
LeaderBoardResources(ResourceType, Label);
LeaderBoardKills(Unit, Label);
LeaderBoardScore(ScoreType, Label);
KillUnit(Unit, Player);
KillUnitAt(Count, Unit, Where, ForPlayer);
RemoveUnit(Unit, Player);
RemoveUnitAtLocation(Count, Unit, ForPlayer, Where);
SetResources(Player, Modifier, Amount, ResourceType);
SetScore(Player, Modifier, Amount, ScoreType);
MinimapPing(Where);
TalkingPortrait(Unit, Time);
MuteUnitSpeech();
UnMuteUnitSpeech();
LeaderBoardComputerPlayers(State);
LeaderBoardGoalControl(Goal, Unit, Label);
LeaderBoardGoalControlAt(Goal, Unit, Location, Label);
LeaderBoardGoalResources(Goal, ResourceType, Label);
LeaderBoardGoalKills(Goal, Unit, Label);
LeaderBoardGoalScore(Goal, ScoreType, Label);
MoveLocation(Location, OnUnit, Owner, DestLocation);
MoveUnit(Count, UnitType, Owner, StartLocation, DestLocation);
LeaderBoardGreed(Goal);
SetNextScenario(ScenarioName);
SetDoodadState(State, Unit, Owner, Where);
SetInvincibility(State, Unit, Owner, Where);
CreateUnit(Number, Unit, Where, ForPlayer);
SetDeaths(Player, Modifier, Number, Unit);
Order(Unit, Owner, StartLocation, Order, DestLocation);
Comment(Text);
GiveUnits(Count, Unit, Owner, Where, NewOwner);
ModifyUnitHitPoints(Count, Unit, Owner, Where, Percent);
ModifyUnitEnergy(Count, Unit, Owner, Where, Percent);
ModifyUnitShields(Count, Unit, Owner, Where, Percent);
ModifyUnitResourceAmount(Count, Owner, Where, NewValue);
ModifyUnitHangarCount(Add, Count, Unit, Owner, Where);
PauseTimer();
UnpauseTimer();
Draw();
SetAllianceStatus(Player, Status);
Briefing actions:NoAction();
Wait(Time);
PlayWAV(WAVName, WAVTime);
TextMessage(Text, Time);
MissionObjectives(Text);
ShowPortrait(Unit, Slot);
HidePortrait(Slot);
SpeakingPortrait(Slot, Time);
Transmission(Slot, WAVName, TimeModifier, Time, Text);
Loop functions:This section is not done yet on SF. I will update it when heimdal does it in SF.
My first trigger-Starting, the trigger main windowTime to start making the first trigger. It will be this trigger, but made in SF:
Players: All players
Conditions: Always
Actions: Modify resources for
current player:
Set to
50 minerals.
I'm using again colors for do it easier.
Ok, now open SF, start a new map and go to Scenario->Triggers on menu. The trigger editor will open. That windows is like the StarEdit/SCXE one, the biggest different is the trigger list. In StarEdit/SCXE each trigger have like a "graphic". In SF each trigger is just an element of a list. Other difference is how SF shows the triggers in that list. StarEdit/SCXE uses comment and if there is not comment it shows a section of the trigger text. SF uses
always comments and if it found a trigger without comment, the trigger is just called 'No Comment'. That means that for work with SF triggers
all the triggers must be commented.
-The trigger editor window (attachment)Once you know that, click the New button for begin making the trigger. A new window will open. I explain this window in the attachment. Open the attachment and continue this tutorial.
Don't worry because the window is very different that the StarEdit/SCXE one, because that don't mean harder.
Changing the player that the trigger is for:At top is where you can select for what player the trigger will be (Green square on attachment). How I said before, check
All Players.
Changing the functions:Now we must create an 'Always' condition and a 'Set Resources' action. For this just type in the conditions textbox (dark blue square on attachment) this text:
Always(StarForge will show the syntax for the Always function. It is between players checkboxes and conditions textbox (light blue square on attachment):
Always();As you can see this function have no parameters (there is nothing between brackets), so type the last characters:
);Don't forgot the semicolon at end!
Once you did that you must have wrote this:
Always();The condition is done
Ok, there is the action left. It is a 'Set Resources' action. I copy it here again for reference:
Modify resources for
current player:
Set to
50 minerals.
Go to the action textbox (red square on attachment) and type this:
SetResources(Now StarForge shows the syntax for the SetResources function. It is a little harder than the syntax for the Always function:
SetResources(Player, Modifier, Amount, ResourceType);See this:
Modify resources for
current player:
Set to
50 minerals.
SetResources(Player, Modifier, Amount, ResourceType);Just replace the parameters by the values, and type
); at end. You must have typed this:
SetResources(CurrentPlayer, SetTo, 50, Ore);How you must noted, if the parameter is not a number, SF shows the available options at right, in the list. This list is used too for some features that allows you typing faster the function and that are explained in the help, and I explain in the next point.
ShortcutsOnce you understood the last point, and you know how StarForge triggers work, start with this point. Here I explain some things that let you write and make the triggers faster, because write everything is really slow. Once you control this point you will start to like the SF Trigger System.
-Copy/PasteWell, I think that this method is not hard. Is not nothing new, just the copy and paste features of all text editors. Is posible to copy a full trigger, copy the only actions, copy only the conditions or copy one function with copy/paste. I think that everybody must know this, anyway I write it here:
Copy: Select the text and press
CNTRL+C.
Cut: Select the text and press
CNTRL+X or
SHIFT+DELETE.
Paste: Select the text and press
CNTRL+V or
SHIFT+INSERT.
That seems a joke, but it's really useful when the triggers are text.
-Item List·This method is useful when you don't know what posibilities you have. The item list shows the posibilities that you have and selects the one that is more alike to what you type. So, if you type
C StarForge will select
CenterView, if you type
Cr it will select
CreateUnit and if you type
CreateUnitW it will selecte
CreateUnitWithProperties.
Example:If you type in the actions texbox
SetResources(CurrentPlayer, and you don't remember what to type, the list shows it (it will show
Add,
SetTo and
Subtract).
Example2:If you don't know what the Run AI Script At Location function is in StarForge, but you think that it will start with 'RunAI' you can type that and StarForge will select
RunAIScript and down this element is
RunAIScriptAt. So you can see it and type it.
·There is another posibility when using the list. You can double click on an element of the list and StarForge will add it where the keyboard cursor is.
Example:If you click on the actions textbox and then you double click on
SetResources, it will write that into the actions textbox. Then you type
(CurrentPlayer, and it will show in the list the posibilites (
Add,
SetTo and
Subtract). If you double click on Add it will add this text and you will get:
SetResources(CurrentPlayer, Add·The last thing that you can do with the item list is change a function/parameter. If you double click an element when the keyboard cursor is in the middle of a function/parameter StarForge will replace it.
Example:If you already typed in the actions textbox
SetResources(CurrentPlayer, SetTo, 50, Ore); and you want to change the SetTo parameter, click on that word for put the keyboard cursor there and the item list will show the posibilities (
Add,
SetTo and
Subtract). If you double click on Add StarForge will replace it and you will get:
SetResources(CurrentPlayer, Add, 50, Ore);This works for function names too.
-AutocompleteThis is the best shortcut. It let you write a word typing only some letters. How its name says, it autocompletes the words.
How I said in the first point of
Item List shortcut, the item list selects the element that is more alike to what you type. If when StarForge selected the element that you want to type you press one of the
token characters it will add the text.
Token character: Character that have a special meaning in StarForge, that is not just text. There are only three token characters:
·Open bracket '
('
·Close bracket '
)'
·Comma '
,'
Example:If in the actions textbox you type
C StarForge will select
CenterView. If now you press
( StarForge will write this:
CenterView(If you type
Cr StarForge will select
CreateUnit and when you press
( it will write that function.
This work too for parameters:
If you type
SetResources(C StarForge will select
CurrentPlayer. If now you press
, StarForge will write:
SetResources(CurrentPlayer,For the last parameter just press
) instead of
,.
If you don't think that it is a good shortcut see this:
For get the line:
GiveUnits(All,Marine,P1,Anywhere,P2); You only must type:
g(a,mar,p,a,p2);.
That is 21 characters less. Test it if you want!
NOTE: If you are using a keyboard that is not american you could have problems with token characters. If you have problems contact Heimdal.
Once you control this point (ShortCuts) you are able to use StarForge triggers in your maps. I recommend create a new map and practice the triggers once you control ShortCuts.
Parameter types-Number:You must type a number, nothing is showed on the list. Letters and characters are not valid.
Example: Bring(P1, AtLeast, 20, Arbiter, Anywhere);-List:You must select one of the options of the list. Number, letters and characters allowed if they are in the list.
Example: Bring(P1, AtLeast, 20, Arbiter, Anywhere);-String:You must select or create one string. Strings are just text.
"Marine: Hello civilian" can be a string. The strings in StarForge have
always a
" before and a
" after.
Example: LeaderBoardResources(Ore, "<< Best Player");You can select one string from the list if it already exists or create one new. For create one new just type the new string and when you click
Save StarForge will add that string to the map. Remember that the strings start by
" and ends by
", but that characters are not showed in game (the last example would show
<< Best Player).
But, what I must do if I want to show in StarCraft this string:
Marine: "Hello civilian"? You cannot type in Starforge:
"Marine: "Hello civilian"", that's illegal. So, how can I do that?
Well, you can do it using
escape characters.
Escape characters: A character combination that merges into another character.
NOTE: This feature is buggy in StarForge. So I will not end it until it runs ok.
-UnitPropertiesSlot:Example: CreateUnitWithProperties(20, Academy, Anywhere, P1, 5);NOTE: This feature is not done in StarForge. So I will not explain it until it is done.
-Flags:Example: DisplayText("Destroy all enemy buildings.", 4);If I am right the values are this:
DisplayText:
·0 Always display off
·4 Always display on
Transmission:
·16 Always display off
·20 Always display on
NOTE: I don't know if that values are right so someone test please. Change that values and open the map with staredit or SCXE and see what happened.
NOTE2: I don't know if StarForge will handle that values as that or Heimdal will change it.
I have done the sections that work properly in SF. If heimdal fixes/adds more things I'll continue this tutorial.