Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Oct 2, 2009 0:01:27 GMT 1
Dear all. I have created a map that has three areas defined. They are area3, area14 and area2.
In each of these areas there are units that should land if the player enters the area.
In area3 there are 2 PAK's. One of them needs to be landed. They have been defined with scriptID's of 9000 and 9001.
In area14 there is a Flak18 and a pak40. They have been defined as 9100 and 9100
In area2 there is a flak18 and a PzKwIV. They have been defined as 9200 and 9201.
Will the following script work
Code function Threecheck() if GetNUnitsInArea(0, area3) 0 then RunScript(LandRandomReinforcement1, 8000); Suicide(); end; end; function Fourteencheck() if GetNUnitsInArea(0, area14) 0 then RunScript(LandRandomReinforcement2, 8000); Suicide(); end; end;
function Twocheck() if GetNUnitsInArea(0, area2) 0 then RunScript(LandRandomReinforcement3, 8000); Suicide(); end; end;
function LandRandomReinforcement1() local random_number; random_number=9000+(RandomInt(1)+1); -- one of 2 units LandReinforcement(random_number); Suicide(); end;
function LandRandomReinforcement2() local random_number; random_number=9100+(RandomInt(1)+1); -- one of 2 units LandReinforcement(random_number); Suicide(); end;
function LandRandomReinforcement3() local random_number; random_number=9200+(RandomInt(1)+1); -- one of 2 units LandReinforcement(random_number); Suicide(); end;
|
|
Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Oct 4, 2009 3:50:23 GMT 1
I looked at this for the first time now. It seems that this is not complete? I'm not sure if I copied everything.
|
|
|
Post by jeffcanada on Oct 4, 2009 4:49:30 GMT 1
Hi Desert.
First you miss the cotation for the condition like here:
Code function Threecheck() if GetNUnitsInArea(0, area3) > 0 then RunScript(LandRandomReinforcement1, 8000); Suicide(); end; end;
Secondly, the randomInt function start at 0, so when you get you Runscript like yours:
function LandRandomReinforcement1() local random_number; random_number=9000+(RandomInt(1)+1); -- one of 2 units LandReinforcement(random_number); Suicide(); end;
Your random_number answer could not be other than 1. In your example (RandomInt(1)+1), (1) is the first condition for the # of possible answer, so in RandomInt(1), you could only have 0 for possibility so with the rest of the line +1, your final answer will be 1. So the only possible result would be 9001, 9101 or 9201.
Just change it for this:
function LandRandomReinforcement1() local random_number; random_number=9000+(RandomInt(2)+1); -- one of 2 units LandReinforcement(random_number); Suicide(); end;
That way you will have the possibility between 0 or 1 for the RandomInt, and the final will be a 1 or 2 added to the ScriptId.
That drives us to the last observation, if you correct your Runscript like the last part, you'll have to change your scriptId for 9001 and 9002 instead of 9000 and 9001, because of the +1 part.
|
|
Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Oct 6, 2009 18:02:55 GMT 1
Hey Jeff.
This is not mine. I copied this from the BKHQ. But it looks like I copied just a question.
And I see that you finished this tutorial. That's great because I don't have the second part.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Nov 19, 2009 4:44:37 GMT 1
Great work Desert!!!
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Nov 19, 2009 23:07:42 GMT 1
Desert: a small tip when you use LandReinf the landing takes a few seconds, so make sure the area is triggered so that player doesn't run into it and gets the Reinf on top of his head... everyone plays a map differently and it happens that players take another way and that this might interfere your expected Reinf! just a consideration...
|
|
Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Nov 20, 2009 1:35:03 GMT 1
Thanks guys but this is not my post. This is a post from BKHQ.
It's one of the Leon's tutorials. I copied the question and forgot to copy the answer.
Thanks to Jeff Canada, we now have the answer too.
And now we have a good tip from Kaoz.
I, myself, hate when reinf pops up immediately.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
Post by bb on Nov 20, 2009 6:48:40 GMT 1
p.s. meaby this shoul be in the map session?
|
|
Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Nov 20, 2009 15:48:09 GMT 1
Here it is bb.
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Nov 20, 2009 18:26:49 GMT 1
Thanks guys but this is not my post. This is a post from BKHQ. It's one of the Leon's tutorials. oops...
|
|
Desert
Vojna Policija - Military Police
Posts: 1,230
|
Post by Desert on Nov 21, 2009 3:49:21 GMT 1
|
|
|
Post by Major Pain on Nov 29, 2009 5:42:11 GMT 1
A little trick I use on maps:
If the Reinforcements don't have to be located at a particular location, but must eventually get to a defined location, perhaps you might LandReinforcements as player 2, then move them to the new location before assigning them to player 0 or 1.
I used this on a map that will be released as soon as I get back home. The player trips triggers (map hot spots) that are defined in the game setup so you never will know what unit or where it is coming from, either yours or enemy. I use the name Trigger for a certain type of FUNCTION.
I also use arrays to store the contents of the random script number and hot spot locations. The array is built using a random function in the INIT part of the script. Makes for interesting situations. No map will ever play the same.
One piece of advice...
If you Land enemy units, you must include a trigger to change them to player 1 should they be encountered by your units... at which point they will immediately attack you with a vengence. The Trigger I use is called: ICU(E).
If you land your units, you can consider including a trigger to change new units to player 0 if they encounter enemy units. But remember, you can't see where your new units are coming from, and they will not be attacked until they are changed to player 0. But if you want a suprise when the enemy finds your reinforcements, include a trigger named UCme(M).
Lua has many functions and formulas that are not documented, but can be used without issue. If you are versed in C++, then you will see that most C++ functions do work in the LUA modules.
More on this if there is interest.
The Major
|
|
|
Post by jeffcanada on Nov 29, 2009 8:18:21 GMT 1
I do Doug.
|
|
|
Post by Major Pain on Nov 29, 2009 10:45:21 GMT 1
When I get back home I will send you a script to look at that uses the array and random builder.
The way it works.
Upon INIT: Defines the array by selecting the unit Script number and then the map location (by map script#). There are any number of places each unit can be sent. This is achieved by converting the map location name into a number, defined by map coordinates. The random function contains the conversion code to give it a map location number rather than name. The map still contains the location name. A 'translator' in the script handles the map and script conversion.
When a trigger is activated.... by event or unit entering a map hot spot, Translator selects a random unit by script number out of the array... then it uses the LandReInforcements function to place it on the map as player 2. Then the followup MOVENEWUNIT function moves it to the Map location that has been randomly selected by the INIT Translator earlier. If the unit encounters enemy, then it changes players and fights.
You get a prompt if it was your unit that changed. "The 232nd Tank Regiment has arrived in the Theater and is engaging the enemy."
If it does not encounter the enemy, (and it is yours), you are notified when it is changed to player 0 and ready for duty. This has the effect that if you have units in the area, you will see the unit drive or walk in to the specified location. Just like the real deal. You can't control it until it hits it mark and changes. Some of these are timed and depend on another action... like resupply or repair, as if the unit has been engaged. Some history can be added for each unit that gives you this info.
This type of script has been used very, very, very rarely in BK. I have only seen it in two other cases. It uses several arrays to store the script unit values, and if built into stacked missions (chapter/campaign), can be used to carry over units with the same parameters from the earlier mission. It does not use Global identifiers, only Locals, then converts this data into a Uni-Global Data File.
The unique thing about this type of array is each unit is assigned it's own unique name and it is remembered throughout the gameplay.; ie: 292nd IR/22nd ID or 21stAR/1stAD. A unit will be defined as a group of tanks or group of infantry. If you combine them, they still maintain their own identity; "combined arms". You just have to define the name of the units, regiments or divisions you want to use. This is stored in a 'data look-up table' contained in the script.
The script is in the final stage of development and still needs some minor beta, but the individual modules can be used and plugged into any script if you do the proper set-up and INIT.
Just a basic overview of how it works. I worked on the this for some time, and expanded some of the uses and keyword functions. It takes the ordinary mission to a new level. You never know if you will be rushed or if the enemy is on defense.
It has another side effect... you can modify the script so the enemy hunts down your 'designated' command unit and end the mission. This forces the human player to not delay any defense prep even if you are pushing or rushing.
Human rushes are counterattacked by a factor of 3x over 'line of sight' units in proximate locations. The AI calls up reinforcements to plug any gap or hole and tries to push back. This doesn't mean it meets you with 3x your force, it meets you with 3x what it previously had there. This simulates a rapid reaction to prevent breakouts or breakthroughs in a defensive line; ie: pushing up reserves once the assualt location is identified. This is much like the Battle of the Bulge effect. Units were pushed up and in once the bulge occurred.
This also has an effect on the AI in another way. If it is pushing or probing and finds a particular weakness, it will activate additonal units to join the action... at about 1.5 to 2 times original attached units. So in effect, the AI is much more agressive and reacts to most events.
The downside to this script design is its size; base script and translators is about 25kb without any functions. Functions are added as desired or needed in modules, much like a 'call' routine in C++ or Snobol. It treats it like a chunk and discards after use. This keeps the "System STACK" from overloading in gameplay. BK freezes, overloads, or blank-outs are usually due to stack overloads due to the overuse of script global and local variables as well as the game engine storing variables as to locations of units, objects, etc. This is why this system uses a translator and no new variable are added since they are defined in the INIT.
I have run this script on several PCs as old as 6 years, and it does bog down on 4 yo and older machines. It likes XP, and will not run under Win2000 or WIN98. I haven't tried VISTA or WIN7 yet, but in light of the VISTA issues, I think it is doubtful. We will see if WIN7 is an improvement, but since it does not share much of the XP parameters, I have little hope.
Stay tuned...
The Major
|
|