Welcome! Please Login or Register!
April 10, 2020, 06:05:45 AM
Home Login Register
pftq Forums  |  Game Design  |  Age of Empires III  |  How to enter a string into a trigger condition in a RMS 0 Members and 1 Guest are viewing this topic. « previous next »
Latest News!VR Jetpack Game Trailer and Music(Jul 29, 2019)
Pages: [1] Print
Author Topic: How to enter a string into a trigger condition in a RMS  (Read 3309 times)
Svenyarsh
Member
*****
Offline Offline

Posts: 1

« on: July 14, 2011, 04:36:36 AM »

Hi
This is my first time posting and this is probably a simple question, but google didn't help me find the answer, so your help would be much appreciated.

I am trying to make a cat and mouse RMS where the computer is the cat (one of these may already exist although I didn't find any) I want one of the trigger conditions to use a QV but the code brings up the debugger and the trigger doesn't appear when I load it in the scenario editor.

This is the line that brings up the debugger (when I remove it it loads fine):
rmSetTriggerConditionParamInt("Count", "trQuestVarGet(\"QVpopLimit\")");
If I replace "trQuestVarGet(\"QVpopLimit\")" with a number then it loads fine.

Also if I make a scenario with this in (without the back slashes and the outermost quotes) it all does what I would expect.

For context here is the rest of my code:

//Triggers

rmCreateTrigger("QVpopLimitSet");
rmSwitchToTrigger(rmTriggerID("QVpopLimitSet"));
rmAddTriggerEffect("Quest Var Set");
 rmSetTriggerEffectParam("QVName", "QVpopLimit");
 rmSetTriggerEffectParamInt("Value", 20);

//Create Troops
int maxUnits=5;
int myArmyID=0;

for(i=0; <maxUnits) {
myArmyID=rmCreateArmy(1,"myarmy"+i);

rmCreateTrigger("createTroops"+i);
rmSwitchToTrigger(rmTriggerID("createTroops"+i));
 rmSetTriggerLoop(true);
 
 rmAddTriggerCondition("Army Is Dead");
  rmSetTriggerConditionParamArmy("SrcArmy", 1, myArmyID);
 rmAddTriggerCondition("XS - Player Population");
  rmSetTriggerConditionParamInt("PlayerID", 1);
  rmSetTriggerConditionParam("Op", "<");
  rmSetTriggerConditionParamInt("Count", "trQuestVarGet(\"QVpopLimit\")");

 rmAddTriggerEffect("Army Deploy");
  rmSetTriggerEffectParamArmy("SrcArmy", 1, myArmyID);
  rmSetTriggerEffectParam("ProtoName", "Cossack");
  rmSetTriggerEffectParam("Location", rmXFractionToMeters(0.5)+",1,"+rmZFractionToMeters(0.5));
  rmSetTriggerEffectParam("Count", "1");
}

Like I say I expect I have made a simple mistake, but if you could point it out to me that would be much appreciated.

Thanks
Svenyarsh
Logged
pftq
Administrator
*****
Offline Offline



Posts: 4124

WWW
« Reply #1 on: July 14, 2011, 02:49:53 PM »

This is a little tricky to explain but the "tr-" functions are actually supposed to be run in the environment where conditions/effects are defined and not put in as a condition/effect input.

So
rmSetTriggerConditionParamInt("Count", "trQuestVarGet(\"QVpopLimit\")");

should be
rmSetTriggerConditionParamInt("Count", "\"+trQuestVarGet(\"QVpopLimit\")+\"");

My RMS coding might be a little rusty so let me know if that doesn't work.  But that's the idea (to break the string within the parameter and insert a tr command).

A way to visualize this is:

1. Main Environment =  RMS (rmSomething, etc)
 - - 2. XS = Definitions of Conditions/Effects  (trQuestVar, etc)

The parameters to triggers you put in the Main Environment are enclosed in a string (" ") and are then sent to an interpreter which can be visualized as being the bigger program reading your RMS.  It *is* just a program though and ES was uncareful enough (or intentional) to also take in the parameters as strings.

Following the path of Quest Var Set for example:
1. rmSetTrigger...("Quest Var Set"), Param("this")
-- 2. trQuestVarSet("this")

You are basically tricking the game moving across the environments when you use "+code+".  The backslashes are there so the quotes get carried into the XS Environment.  It then becomes:

1. ("\"+code+\"")
-- 2. trQuestVarSet(""+code+"")

This way the code can be run in the XS environment and not just processed as text.
« Last Edit: July 14, 2011, 02:59:34 PM by pftq » Logged
Neuron
Member
*****
Offline Offline

Posts: 30

« Reply #2 on: April 02, 2013, 05:16:18 AM »

Hm, I saw in one of your maps (canonfodder) you used a send chat trigger to make the compiler get some commands using this method you explained here. Does that mean that you could for example use the regular chat to send commands to the compiler while you are in-game? Just a crazy idea..

I mean, if the compiler can read code for icons and customised text messages in-game, does that mean it could read other types of code and execute it too? That would be awesome.

Anyone tried this?  Grin Tongue Grin
« Last Edit: April 02, 2013, 05:18:50 AM by Neuron » Logged
pftq
Administrator
*****
Offline Offline



Posts: 4124

WWW
« Reply #3 on: April 03, 2013, 10:24:45 PM »

Don't think that would work.  My understanding is that being in the actual gameplay adds another protective layer that filters your chat/actions.  They were just sloppy on the RMS/Scenario layer of things.
Logged
Pages: [1] Print 
pftq Forums  |  Game Design  |  Age of Empires III  |  How to enter a string into a trigger condition in a RMS « previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines | RSS Feed Valid XHTML 1.0! Valid CSS!
Page created in 0.284 seconds with 21 queries.