|
Post by finlander on Nov 4, 2010 17:44:38 GMT 1
I have a little anoying problem with one scripted unit. The unit has a script id, and its suppose to go and resupply other units. Easy..BUT this unit starts to multiply and soon the enemy has like a 20 trucks resupplying..any advice how to stop this breeding madness?
|
|
|
Post by LouisXIV on Nov 4, 2010 21:15:23 GMT 1
Find the paragraph where the reinforcement is landed and put a Suicide(); statement at the end of the pargraph, before the first end; statement.
|
|
|
Post by finlander on Nov 5, 2010 5:36:13 GMT 1
Paragraph? Do i have to change the script or ..? exactly where do i put the suicide note? I am a bit of a noob when it comes to scripting..
|
|
|
Post by LouisXIV on Nov 5, 2010 10:27:53 GMT 1
A paragraph starts with a function declaration and ends with an end statement. Here is a paragraph:
function Finlander1() LandReinforcement(1000); end; This will give you multiple occurrances of the same reinforcement arriving. If you don't want this repeating, it should be:
function Finlander1() LandReinforcement(1000); Suicide(); end; The suicide(); tells the compiler, "I'm finished with this paragraph. Don't run it again unless I call it again."
Each of your paragraphs should end with a Suicide(); unless you want it to run multiple times.
If you look at the standard paragraph checking to see if an objective has been fulfilled, you will see it looks something like this:
function Objective1() if ( GetNUnitsInScriptGroup(2020, 1) <= 33) then SetIGlobalVar("GameObjective1", 1); ObjectiveChanged(1, 1); RunScript( "RevealObjective2", 2000); RunScript( "Objective2", 5000); Suicide(); end; end;
Notice that the Suicide(); is inside the if-end statement. This means it will not be activated until the if statment is positive, meaning the condition is true and the objective has been achieved. This means this paragraph will keep repeating and checking the objective condition until you have accomplished it. Then it will stop running.
I found the concept of the Suicide(); a little confusing at first. Once you get the hang of it, you are half way there to good programming.
|
|
|
Post by finlander on Nov 5, 2010 20:32:05 GMT 1
Once again i thank you for your help Louie..
|
|