|
Post by ftmch on Sept 19, 2014 22:52:24 GMT 1
Hello, I recently returned to playing blitzkrieg after not having touched it for many many years. I wanted to make a rather simple map where you hold a position against a stready stream of enemies coming from several directions. I know nothing about scripting and was wondering if theres' a good sample-map/script for this kind of thing. Basically I want squads of infantry to keep spawning and attacking the area I'm holding (and maybe a few tanks aswell with longer intervalls).
I would really appreciate some help!
|
|
|
Post by kosamja on Sept 19, 2014 22:56:41 GMT 1
|
|
|
Post by ftmch on Sept 19, 2014 23:11:19 GMT 1
Thank you for the quick reply! I will check it out.
|
|
|
Post by Major Pain on Sept 20, 2014 4:28:08 GMT 1
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Sept 21, 2014 0:38:20 GMT 1
LuaScriptingGuideThe 2nd example shows how to respawn enemy reinforcements after they die, so they keep on coming until a specific trigger occurs. Reading the rest of the guide might make lua scripting for BK a little more understandable...
|
|
|
Post by ftmch on Oct 15, 2014 21:29:13 GMT 1
Thanks Kaoz, good link! Now I'm trying to figure out how to get the enemy to spawn after a certain amount of time (I want to move into an area, then have about 10-15 minutes to prepare my defences before the enemy attacks), I'm guessing this should be a rather simple thing to add to the reinforcement function, but I haven't been able to find any info on how to do it yet, any tips?
Edit: Alright, I'm on the right track I suppose, right now, my simple reinforcement/counterattack script function Reinforcement()
Now I just want to add the condition that the area called "objective" has to be cleared of all enemies before the script is activated, and that the script should have a delay of about 10-15 minutes to give the player some time to prepare his defences. (this way I could also add multiple waves with different delays instead of respawning the enemy, since that probably suits the map better anyway).
Any help would be greatly appreciated!
I hope you'll have patience with me, haha, I remember getting this to work back then the game was new, and I was only 14-15 or something back then, I guess age has dulled my brain!
|
|
|
Post by keepitsimple on Oct 15, 2014 23:41:29 GMT 1
-- initialisation of parameter NumberOfWave --
function Start() SetIGlobalVar("NumberOfWave", 0); Suicide(); end;
-- First Wave start after a area "clear" has been clear of the enemy --
function Objective1() local AI = GetNUnitsInArea(1, "clear"); if (AI <= 1) then DisplayTrace("Hold the line"); LandReinforcement(1000); RunScript( "NextWave", 60000); <-- next wave starts after a minute want it to be 10 minutes just add a zero Suicide(); end; end;
-- Next wave comes till number is more the 4 which is after 5 waves--
function NextWave() local Num = GetIGlobalVar("NumberOfWave", 0); if (NUM <= 4) then LandReinforcement(1000); SetIGlobalVar("NumberOfWave", num+1); Suicide(); end; end;
function Init() RunScript( "Start", 10); RunScript( "Objective0", 12000); <-- 12000 is 0,25 minute. end;
|
|
|
Post by ftmch on Oct 16, 2014 7:03:57 GMT 1
Thanks man, I'll try it out! Edit: Hmm, strange, I can't get it to work, I copy that exact script and I have an area called "clear" with units belonging to the enemy (player 1) inside, nothing seems to happen after I clear the area though. I'm uploading my tiny testmap and the script so you can take a look. (thanks again for being patientThanks man, I'll try it out! www.mediafire.com/download/pjwaohnj1ea8qd4/testmap.zipEdit: Also, one more question, does this script add a delay to the first wave aswell? I'd prefer if it took a while before it showed up (and then the other waves could show up at shorter intervals afterwards)
|
|
|
Post by keepitsimple on Oct 16, 2014 8:11:15 GMT 1
Do you really have the same name? Clear <> clear <> CLEAR Also lookout that you don't have a blank in name in the map editor version (a very easy mistake to make, difficult to find).
I made a small mistake in the function NextWave. Let me explain. I left out 'else'.
In the above script, one minute after objective 1 is true the function NextWave is called. NumberOfWave=0 --> NUM = 0 (second mistake I had NUM, Num and num). Hence, Num<=4 is true and LandReinforment 1000 will come, NumberOfWave = 0+1=1 but now Suicide(). This means: do not repeat this any more. Hence it will stop now.
Below the function is correct. The command RunScript(NextWave,60000) means: repeat every 60000 = 1 minute this function. This will go on till it runs into a Suicide(). This is now true if NumberOfWave = 5 then it stop. The proces is stopped and this free's the compute engine time to do other things.
Next wave comes till number is more the 4 which is after 5 waves--
function NextWave()
local Num = GetIGlobalVar("NumberOfWave", 0); if (Num <= 4) then LandReinforcement(1000); SetIGlobalVar("NumberOfWave", Num+1); else Suicide(); end; end;
|
|
|
Post by ftmch on Oct 16, 2014 15:33:33 GMT 1
yup, I double checked, the area is called "clear" with just small letters, no blank in the name, nothing seems to happen when I kill all enemies in it (and they belong to side "1".
this is the current script I've loaded:
Not sure what I'm doing wrong really, is there something else I need to do to make sure that the map loads the script? Right now I have the .bzm-mapfile and the .lua file in the same folder just in "Run\data\maps" without any subfolders etc.
Edit: I tried to narrow it down a bit and used the old simple script that just spawned the reinforcements right away, and I added the condition about clearing the area "clear" so that it looked like this:
When I did that, the script stopped working, but as soon as I removed the "local AI = GetNUnitsInArea(1, "clear"); if (AI <= 1) then"-part the script worked fine. However, if I try using the more advanced script at the top of this post, and just removing the same part, the script doesn't work again.
|
|
|
Post by keepitsimple on Oct 16, 2014 19:52:56 GMT 1
Okay there was still a small mistake
SetIGlobalVar("NumberOfWave", (Num+1)); () were missing
I found out that there was mistake by starting with the DisplayTrace("Script Okay"); As long as there was scripting mistake I didn't get the display at the start of the game. Back to script till I found the mistake.
------------------------------------------------------------------------------------------------------------------------
DisplayTrace("Script Okay");
function Start() SetIGlobalVar("NumberOfWave", 0); Suicide(); end;
-- First Wave start after a area "clear" has been clear of the enemy --
function Objective0() local Num = GetNUnitsInArea(1, "clear"); if Num <= 1 then DisplayTrace("Hold the line"); LandReinforcement(1000); RunScript("NextWave", 60000); Suicide(); end; end;
-- Next wave comes till number is more the 4 which is after 5 waves--
function NextWave() local Num = GetIGlobalVar("NumberOfWave", 0); if Num <= 4 then LandReinforcement(1000); SetIGlobalVar("NumberOfWave", (Num+1)); else Suicide(); end; end;
function Init() RunScript( "Start", 10); RunScript( "Objective0", 12000); end;
-----------------------------------------------------------
Good luck
|
|
|
Post by ftmch on Oct 16, 2014 20:04:24 GMT 1
Yeees! that worked perfecly! Now, is there any way to make it so that the first wave is delayed aswell? If that's possible then I'll have everything I need
|
|
|
Post by keepitsimple on Oct 16, 2014 20:38:19 GMT 1
Simple.
Delete the LandReinforment in the function objective0
Or if you want a different time between the first wave then between waves.
function Objective0() local AI = GetNUnitsInArea(1, "clear"); if (AI <= 1) then DisplayTrace("Hold the line"); RunScript( "StartWave", 120000); <-- 1ste starts after 2 minutes Suicide(); end; end;
function StartWave() LandReinforcement(1000); RunScript( "NextWave", 60000); <-- next wave starts after a minute want it to be 10 minutes just add a zero Suicide(); end;
|
|
|
Post by ftmch on Oct 16, 2014 20:43:55 GMT 1
Thanks! that worked great, thanks again for all your help and your patience!
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Oct 19, 2014 0:38:27 GMT 1
Now I just want to add the condition that the area called "objective" has to be cleared of all enemies before the script is activated, and that the script should have a delay of about 10-15 minutes to give the player some time to prepare his defences. (this way I could also add multiple waves with different delays instead of respawning the enemy, since that probably suits the map better anyway). I hadn't seen your question until now, but keepitsimple has answered probably better than I could have. Multiple waves with delays always have less risk. However respawning is necessary when you want an enemy attack repeating until the player performs the action that would stop the respawning. As every player plays different, some will reach the objective sooner than others. In this cases, the outcome is unpredictable and this is when I used respawning over a certain amount of reinf's.
|
|