|
Post by LouisXIV on Aug 5, 2010 0:40:11 GMT 1
Frustrating!
I have a mission that is giving me the "You Won" message about 5 seconds after it starts. I've double-checked it to find something wrong, but nada. The ScriptID units are there. The map is calling the proper script. I can't find anything wrong with the script. Perhaps someone with better eyes than I can can spot something wrong:
function RevealObjective0() ObjectiveChanged(0, 0); Suicide(); end;
function Objective0() ObjectiveChanged(0, 1); Suicide(); end; ----------------------------------------------------------------------- function RevealObjective1() ObjectiveChanged(1, 0); Suicide(); end;
function Objective1() if ( GetNUnitsInScriptGroup(11, 1) <= 0) then SetIGlobalVar("GameObjective1", 1); ObjectiveChanged(1, 1); Suicide(); end; if ( GetNUnitsInScriptGroup(12, 1) <= 0) then SetIGlobalVar("GameObjective1", 1); ObjectiveChanged(1, 1); Suicide(); end; end; ----------------------------------------------------------------------- function RevealObjective2() ObjectiveChanged(2, 0); Suicide(); end;
function Objective2() if ( GetNUnitsInScriptGroup(17, 1) <= 0) then SetIGlobalVar("GameObjective2", 1); ObjectiveChanged(2, 1); Suicide(); end; end; ----------------------------------------------------------------------- function RevealObjective3() ObjectiveChanged(3, 0); Suicide(); end;
function Objective3() if ( GetNUnitsInScriptGroup(15, 1) <= 0) then SetIGlobalVar("GameObjective3", 1); ObjectiveChanged(3, 1); Suicide(); end; end; ----------------------------------------------------------------------- function ToWin() if ((GetIGlobalVar("GameObjective1", 0) * GetIGlobalVar("GameObjective2", 0) * GetIGlobalVar("GameObjective3", 0)) == 1) then Win(0); Suicide(); end; end;
function TobeDefeated() if ( GetNUnitsInScriptGroup(1000, 0) <= 0) then Loose(); Suicide(); end; end; ----------------------------------------------------------------------- function Init() RunScript( "RevealObjective0", 2000); RunScript( "Objective0", 16000); RunScript( "RevealObjective1", 17000); RunScript( "Objective1", 5000); RunScript( "RevealObjective2", 23000); RunScript( "Objective2", 5500); RunScript( "RevealObjective3", 28000); RunScript( "Objective3", 6000); RunScript( "ToWin", 6100); RunScript( "TobeDefeated", 4000); end;
|
|
|
Post by jeffcanada on Aug 5, 2010 18:00:45 GMT 1
Have you tried to replace the * by "and" in your "ToWin" function?
|
|
|
Post by danzig70 on Aug 10, 2010 16:19:02 GMT 1
There doesnt seem to be any conditions for the objective0. It will just be marked as complete when called. Other than that, check to see if there are units with the script ids for the other objectives.
|
|
|
Post by LouisXIV on Aug 10, 2010 23:15:30 GMT 1
There are no conditions for Objective 0. It displays a message of the situation at the beginning of the mission for 14 seconds and then is gone. You can read it again any time.
|
|
|
Post by danzig70 on Aug 10, 2010 23:43:39 GMT 1
Then it could be the if statement in the ToWin function. There appears to be a leading parenthis with no trailing one. Its good to count parentheses when checking scripts.
I think the SciTe editor has a debug tool to catch syntax errors.
|
|
|
Post by LouisXIV on Aug 11, 2010 12:31:45 GMT 1
Save your .lua file and press F-5 to get a syntax error check.
I appreciate your help, and your taking the time to look this over.
If you count, there are five leading and five trailing parenthises in the ToWin statement.
I honestly think that it is something to do with the chapter creation.
(This must be bugging you too.)
|
|
|
Post by commander on Aug 11, 2010 13:51:36 GMT 1
If the Map works as a single Mission and in the Chapter not (you win) you must Clear the Variable at start of the Map. Example:
function Clearvar() SetIGlobalVar("GameObjective1", 0); SetIGlobalVar("GameObjective2", 0); SetIGlobalVar("GameObjective3", 0); Suicide(); end;
function Init() RunScript( "Clearvar", 1000);
end;
|
|
|
Post by LouisXIV on Aug 11, 2010 14:00:29 GMT 1
Okay, CC, I'll try that.
One thing I was noticing: in the chapter 1.xml there is a reference to where to find the script file. In the mission 1.xml there is no reference to the script file. Thus presumabley the script file must be located via the mission map, neh?
|
|
|
Post by LouisXIV on Aug 11, 2010 14:46:12 GMT 1
Thanks, commander, that did the trick! I actually got a 2-mission chapter working!
Thanks to everyone for all their help and suggestions.
Next step: adding the third and fourth missions...after I create them.
|
|
|
Post by danzig70 on Aug 11, 2010 22:05:45 GMT 1
If the Map works as a single Mission and in the Chapter not (you win) you must Clear the Variable at start of the Map. Example: function Clearvar() SetIGlobalVar("GameObjective1", 0); SetIGlobalVar("GameObjective2", 0); SetIGlobalVar("GameObjective3", 0); Suicide(); end; function Init() RunScript( "Clearvar", 1000); end; Thats interesting. I have had variables not cleared when I test a map twice consecutively but are cleared when I exit to windows.
|
|
|
Post by Major Pain on Aug 12, 2010 0:50:25 GMT 1
If the Map works as a single Mission and in the Chapter not (you win) you must Clear the Variable at start of the Map. Example: function Clearvar() SetIGlobalVar("GameObjective1", 0); SetIGlobalVar("GameObjective2", 0); SetIGlobalVar("GameObjective3", 0); Suicide(); end; function Init() RunScript( "Clearvar", 1000); end; Thats interesting. I have had variables not cleared when I test a map twice consecutively but are cleared when I exit to windows. Inside the game, variables (GlobalVar) are carried over between missions. Each mission must have the variables reset or cleared if the same variables or "name references" are used. Variables can be as simple as a letter "A" or as complex as "Allied343". If you recall your geometry and algebra, x - y = n, the principal is the same. This is handy when you must use a variable several times, but you may never know exactly what it will need to be. You can use the variable "Army" to check a Script ID number to determine which Script unit has entered a location (area). Then through scripting, you can mount an appropriate response. Army represents the unit entering the location. Responder represents the unit(s) moving to counter Army. if (GetNScriptUnitsInArea(Army, Location) > 0) then RunScript ("Deploy", 1000); Suicide(); end; function Deploy() Cmd(0, Responder, GetScriptAreaParams(Location); RunScript("Attack", 1000); Suicide(); end; You can use an array to store location names and unit script numbers. So it doesn't matter which army and which location, the simple script can be used over and over to check multiple situations. You can build a function that LandsReinforcements in a specific area and moves it to the challenge location. The Reinforcement type or mix can also be defined within an array. Example: If Army = ScriptID 1003 (3 M4A3(75) and 2 squads), then counter with Script Army ID 2003 PzIV. (This isn't the correct syntax but used to illustrate the purpose.) It doesn't matter how many times an army enters the Location, the Script ID of the Army determines the response. This type of function/script can replace multiple function checks and cmd scripts. The same type of script can be used to check objectives for completion. Just keep the script easy to read and check for bugs. Just a suggestion.
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Aug 12, 2010 17:51:11 GMT 1
If the Map works as a single Mission and in the Chapter not (you win) you must Clear the Variable at start of the Map. Mmm, that might just be my (chapter) problem too! Thx, good tip!
|
|
|
Post by LouisXIV on Oct 2, 2010 1:40:09 GMT 1
What is wrong with this code?
function SendAttack() LandReinforcement(2010); RunScript("SendEmIn",9000); end;
function SendEmIn() GiveCommand(3,2010,12953,8666); Suicide(); end; ------------------------------------------------------------------------------------ function Init() SetIGlobalVar("GameObjective0", 0); SetIGlobalVar("GameObjective1", 0); SetIGlobalVar("GameObjective2", 0); RunScript("SendAttack",240000); end; I want the attack group 2010 to arrive and put in their attack every four minutes. With this code, the units arrive on location, but nine seconds later when commanded to attack, they just sit. What have I missed?
The x and y co-ordinates are on the map. There is no blockage of any kind on the map preventing them from attaining their goal. Group 2010 is both infantry and SPG. Neither move.
|
|
Ocelo
General
Map Artist/Eastern Front enthusiast
Posts: 1,400
|
Post by Ocelo on Oct 2, 2010 4:33:20 GMT 1
Sorry I haven't read the entire topic (feeling a bit sick today), just note that if you're using Global Vars in the script, just drab on a couple minutes at mission start before activating the win check function (ie: RunScript( "ToWin", 60000);
|
|
|
Post by Major Pain on Oct 2, 2010 13:52:55 GMT 1
What is wrong with this code?function SendAttack() LandReinforcement(2010); RunScript("SendEmIn",9000); end;
function SendEmIn() GiveCommand(3,2010,12953,8666); Suicide(); end; ------------------------------------------------------------------------------------ function Init() SetIGlobalVar("GameObjective0", 0); SetIGlobalVar("GameObjective1", 0); SetIGlobalVar("GameObjective2", 0); RunScript("SendAttack",240000); end; I want the attack group 2010 to arrive and put in their attack every four minutes. With this code, the units arrive on location, but nine seconds later when commanded to attack, they just sit. What have I missed?
The x and y co-ordinates are on the map. There is no blockage of any kind on the map preventing them from attaining their goal. Group 2010 is both infantry and SPG. Neither move. Louis: You might have to put a longer delay in between the LandReinforcements and the swarm function. The script units may not be on the map when the swarm command is given. I have run into this before. You might change: GiveCommand(3,2010,12953,8666); to Cmd(3, 2010, 12953, 8666); Serves the same purpose.
|
|