|
Post by Stanenberg on Mar 7, 2024 2:18:37 GMT 1
Hey Blitzkriegers,
while playing around with aircraft and lua in the editor I found something very interesting:
Lets assume we give the player (player 0) a flight of 8 Stukas, the number doesnt really matter. In the editor we assign 8 Stukas to player 0 and a flight size of 8. Once the Stukas are used I want to disable them, but this doesnt work as long as some Stukas are still on the map! DisableAviation(0, 3) only works once the Stukas are off the map or if there are more aircraft available - however as long as all available aircraft of one type are in the air, its not possible to disable them.
I have never heard about this before. It messes with some LaPlata campaigns for example, where it results in infinite paratroopers.
Does anyone have a good lua idea how to deal with this problem?
|
|
|
Post by keepitsimple on Mar 7, 2024 20:25:44 GMT 1
Hi Stanenberg , The most simple solution is to repeat the command disable x times Runscript ("DisableGroundAttack",3000,60) Function DisableGroundAttack() DisableAviation(0, 3) end 60 x 3s (=3000) = 3 minutes which should be longer than the time the planes are on the map. In theory a player might see for a second or 2 that he can send the planes out again. I reality he will miss it.
|
|
kaoz
General
inter faesces et urinam nascimur
Posts: 1,112
|
Post by kaoz on Mar 7, 2024 23:20:00 GMT 1
Yeah, this has always been a difficult one for me too.
It is a great tip from keepitsimple to repeat the function every x secs. I hadn't thought of that one. I've been looking for any usable GetUnitState to link the DisableAviation to, but there's only 3 states for planes and they're not very useful in this case. Pity.
I had a few successes when setting the relax time longer than the planes being on the map and using the DisableAviation after like a minute or so, or timed just when planes were flying home. So i'm a bit surprised to hear you say: 'as long as planes are on the map', but maybe this is because i've used a long relax time.
In some experiences, i noticed that DisableAviation(0, -1) all planes, worked better than one type of plane DisableAviation(0, 3), but it's hard to explain as i never found any logic for this.
|
|
|
Post by Stanenberg on Mar 8, 2024 10:29:37 GMT 1
Thanks for the answers guys. Im glad i am not crazy and other people have encountered this before... I have also tried kaoz route with GetAviationState but there is no state for when no planes are in the skies... This is my solution so far: function Aircraft() EnableAviation(0, 3); if ((GetNUnitsOfType("avia_bomber", 0)) > 0) then RunScript("Off", 500); Suicide(); end; end; function Off() if ((GetNUnitsOfType("avia_bomber", 0)) == 0) then DisableAviation(0, 3); Suicide(); end; end; Problem is that the scripter/mapper has to know which type of aviation he is using. It wasnt obvious to me for example weather Stukas are ground attack or bomber type... Another problem is that this doesnt work for all aircraft types. The Stukas from MK bomb indiviually, so if they return back their number wont be 0 immediately, but it could be that one Stuka throws his bombs early, while the others keep looking for targets... Maybe the truly easiest solution is to just give extra planes so the problem doesnt arise in the first place
|
|
|
Post by keepitsimple on Mar 8, 2024 11:38:52 GMT 1
Hi kaoz , The reason why DisableAviation(0, -1) works and DisableAviation(0, 3) doesn't work is I assumed related to fact the in the first cases the timer which runs in background to give the player after x seconds again the possiblity to call in airpower simply is put on hold. The airplanes in the air can finish their action but player gets no new airplane to send. In second cases the timer to give the player again air power must still run. The command DisableAviation(0, 3) is good for inital setting but not intented to stop the player from getting this air power. In some older maps you get in first couple of seconds the possibilty to send all planes, if you are quick and you do send them then hence you can keep using of this airplanes. That is why in my script I start this command -which stops a type of air power- in less then second so the player can beat the system .
|
|