Members | Sign In
All Forums > Mission Scripting
avatar

Branching Logic

posted Jul 24, 2011 17:28:12 by 5th_Wall_Gaming
How difficult would it be to enclose the IF tags? When I rewrote the away team code, I had to use a status for every event.. Is there any way that I can do...

<if_variable name="Test" condition=">" value="2">
<if_variable name="Test2" condition="=" value="3">
<set whatever>
<set whatever>
</if_variable name="Test2">
<set whatever>
<set whatever>
<set whatever>
<set whatever>
</if_variable name="Test">

This would allow me to always run the bottom conditions and run the top 2 only some of the times. :)

Hey.. YOU wanted to go the scripting route instead of the GM panel. :) I'm just asking for scripting to get advanced enough to handle the dynamic crew reactions. :)
http://www.5thWallGaming.com
We make dreams reality
page   1
2 replies
avatar
ThomRobertson said Jul 27, 2011 17:12:29
Well, that's certainly not how my code works now. Right now, I run straight down the list of event objects. For each one I run though all the conditionals, and if they're ALL TRUE, I run through again, doing all the commands.

Creator of Artemis
avatar
5th_Wall_Gaming said Jul 27, 2011 17:31:58
Right. I know that's how it works now. But it leaves me in the situation of doing this..

<event Name="Away Team: Trying to Capture Ship">
<if_variable name="AwayTeamStatus" comparator="=" value="2"/>
<if_timer_finished name="AwayTeamTimer"/>
<set_variable name="AwayTeamRoll" randomIntLow="1" randomIntHigh="20"/>
<set_variable name="AwayTeamStatus" value="3"/>
</event>
<event Name="Away Team: Trying to Capture Ship">
<if_variable name="AwayTeamStatus" comparator="=" value="3"/>
<if_variable name="awayteamRoll" comparator=">" value="14"/>
<set_timer name="AwayTeamTimer" seconds="240"/>
<set_variable name="AwayTeamStatus" value="4"/>
</event>

Instead of..

<event Name="Away Team: Trying to Capture Ship">
<if_timer_finished name="AwayTeamTimer"/>
<set_variable name="AwayTeamRoll" randomIntLow="1" randomIntHigh="20"/>
<if_variable name="awayteamRoll" comparator=">" value="14"/>
<set_timer name="AwayTeamTimer" seconds="240"/>
<set_variable name="AwayTeamStatus" value="4"/>
</if>
</if>
</event>

Which IMHO, is allot cleaner and allot more logical. As it is now, I need to make a variable for each "grouping" and update the status as well as check to see what the status is just to do a die roll and check to see what the value is..

To put it another way.. Let's say I have 3 things an enemy will want to do. Fight, Flee or Ignore.

As it is now, I would have to set the "Behavior" variable to a random number and "Behavior_Tracking" to 1

Then I have to make a new event that checks if the Behavior_tracking is 1. If so, check to see if the dice roll is 1 and then put what it will do for fighting (which may involve other events). I also have to then set Behavior_tracking to 2 so that it doesn't reactivate.

Then another event which checks to see if Behavior_tracking is 1. If so, check to see if the dice roll is 2 and then put what it will do for Fleeing (which may involve other events). I also have to then set Behavior_tracking to 2 so that it doesn't reactivate.

Then another event which checks to see if Behavior_tracking is 1. If so, check to see if the dice roll is 3 and then put what it will do for Ignore (which may involve other events). I also have to then set Behavior_tracking to 2 so that it doesn't reactivate.


Compare that to (PseudoCode here)

<if Behavior_tracking = 1>
<if Dice = 1>
Fight
</if>
<if Dice = 2>
Flee
</if>
<if Dice = 3>
Ignore
</if>
<set_variable Behavior_Tracking = 2>
</if>

See? Much more dynamic and cleaner.

Also, only 1 event. :)
[Last edited Jul 27, 2011 17:36:08]
http://www.5thWallGaming.com
We make dreams reality
Login below to reply: