bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
script
Aug 24, 2011 0:31:40 GMT 1
Post by bb on Aug 24, 2011 0:31:40 GMT 1
Well, I need some helpe here: I want to give to the player only one chance to use it's bombers, as mr.frost used to do in his campaign "Road to Stalingrad". Here is his script:
function Bomber() EnableAviation( 0,3 ); flu=GetAviationState(0); if (flu==4) then SwitchWeather(0); RunScript("BomberEnde",1000); Suicide(); end; end;
function BomberEnde() DisableAviation(0,3); Suicide(); end;
But to me is not running, anyone here knows why?
|
|
|
script
Aug 24, 2011 5:52:09 GMT 1
Post by Major Pain on Aug 24, 2011 5:52:09 GMT 1
bb: I would need to see the entire script to be able to answer with certainty.
But, I suspect that the function has not been "called" or activated in the INIT or another function. If it is called in another function, the condition must be met for it to be called. So it can be either reason.
The script itself looks fine...
Send the script to my email and I'll look at it...
MP
|
|
|
script
Aug 24, 2011 7:07:52 GMT 1
Post by danzig70 on Aug 24, 2011 7:07:52 GMT 1
I think you need to declare the variable "flu" as a local variable if running inside a function or a global varible if you want several functions to access it. You may want to set the weather before enabling the aviation also.
function Bomber() SwitchWeather(0); local flu = GetAviationState(0); etc..
Does this mean if the player has called aircraft the aviation state turns to 4 and then aviation is disabled for the player? What might happen is that the aircraft are recalled before completing their mission because aviation has been disabled. (like when it starts raining) You could use a timer and allow a certain amount of time before the aviation is disabled, maybe.
function MissionTimer() local minutes, seconds; minutes = GetIGlobalVar("TimerMinutes", 0); seconds = (10 + GetIGlobalVar("TimerSeconds", 0)); if(seconds == 60) then seconds = 0; minutes = 1 + minutes; SetIGlobalVar("TimerMinutes", minutes); end; SetIGlobalVar("TimerSeconds", seconds); -- if(seconds == 0) then -- DisplayTrace("Mission Time: %g:00", minutes, seconds); -- else -- DisplayTrace("Mission Time: %g:%g", minutes, seconds); -- end; end;
I commented out the display feature. You can enable it by erasing the dashes for testing. I havent made a map in such a long time I cant think of a better way. If I think of a better way I'll let you know.
|
|
|
script
Aug 24, 2011 8:01:33 GMT 1
Post by Major Pain on Aug 24, 2011 8:01:33 GMT 1
He doesn't need to localize or globalize the integer if only used once and not passed on. He would want to do this if the mission may be restarted since the value would be maintained.
I really think the issue is due to the function not being called or Initialized...
He didn't say anything about watching the bombers launching but being recalled. So since it is not working, it hasn't been called or another condition has not been met.
I have used this same function before and it works like stated. But if for some reason the weather does change, the mission ends... but the planes would say "returning to base".
What say you bb?
|
|
|
script
Aug 24, 2011 11:29:19 GMT 1
Post by commander on Aug 24, 2011 11:29:19 GMT 1
Hi i think the Error is in the if Function
function Bomber() EnableAviation( 0,3 ); flu=GetAviationState(0);-- <<< Check what Plane Player start if (flu==4) then -- flu=4 is Ground Attack Plane not Bomber Change it to 3 SwitchWeather(0); RunScript("BomberEnde",1000); Suicide(); end; end;
function BomberEnde() DisableAviation(0,3); Suicide(); end;
greetz
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
script
Aug 25, 2011 2:58:05 GMT 1
Post by bb on Aug 25, 2011 2:58:05 GMT 1
Thanks for your answer guys, I believe commander is right, I changed the "(flu==3)" for "(flu==4)", because I thought "4" was the numer of units...
I'll check later. ;p
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
script
Mar 20, 2014 5:58:46 GMT 1
Post by bb on Mar 20, 2014 5:58:46 GMT 1
Hi,
Someone here can help me with a simple script: I want make this simple condition: if a bridge is destroyed the player loose, but I dont have a clue... thanks, BB
|
|
|
script
Mar 20, 2014 7:22:11 GMT 1
Post by Major Pain on Mar 20, 2014 7:22:11 GMT 1
You must give the bridge a Script ID Number. Do this in the xml version of the map. Find the bridge parts and give them the same Script ID.
In the script function, you only have to check the bridges state to determine if it has zero HP. Typically, this will represented by 0 or -1 if not present. Sorry, my work station is down at the moment getting a new video card so I can't check my script notes and files. Refer to Calvin's for Unit State; GetUnitState(ScriptID), I think. The correct format and the codes are shown.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
script
Mar 20, 2014 18:03:29 GMT 1
Post by bb on Mar 20, 2014 18:03:29 GMT 1
thanks, I'll check today.
|
|
|
script
Mar 20, 2014 19:31:23 GMT 1
Post by keepitsimple on Mar 20, 2014 19:31:23 GMT 1
Hi bb, I think the command you should use is GetObjectHPs(iScriptID) If the bridge has HP X then the bridge is destroyed if HP are lower or equal to half X. So if Bridge has iScript 340 and has HP 500 if GetObjectHPs(340) <= 250 then ...
|
|
|
script
Mar 20, 2014 21:28:05 GMT 1
Post by Major Pain on Mar 20, 2014 21:28:05 GMT 1
Yes... that is also an option... Sorry, still working on my work system... I'll check this when I get back into it.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,362
|
script
Mar 21, 2014 1:48:40 GMT 1
Post by bb on Mar 21, 2014 1:48:40 GMT 1
The GetObjectHP runs well, thanks . Actually I imagined this was the right script, however I allways had the impression this script wasnt very reliable...
|
|
|
script
Mar 22, 2014 15:17:53 GMT 1
bb likes this
Post by keepitsimple on Mar 22, 2014 15:17:53 GMT 1
Hi bb, You are right that isn't always reliable. In my map BonaGona I make an airfield in the jungle by blowing up the trees. Every now and then there would remain some trees standing. I think the problems is that if the things that should explode are close together then sometimes an object won't exploded. This is the only time I came across it as not reliable. I solved it by numbering the trees differently form 1..6 and have every 2 seconds exploded just one group. function runway1() DamageObject(1,GetObjectHPs(1)); RunScript("runway2",1000); Suicide(); end; OR this is how I today would have done it. function runway1() DestroyObject(1); RunScript("runway2",1000); Suicide(); end; With below the function INIT the following --------------------------------------------------------- --------------- New command: DestroyObject ------------------ --------------------------------------------------------- function DestroyObject(iScriptID) DamageObject(iScriptID, GetObjectHPs(iScriptID)); end;
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 28, 2014 11:48:06 GMT 1
function Bridge_destruction_TNT_0() if GetNUnitsInArea(1,"TNT_0") > 0 or GetObjectHPs(2) < 10 then DamageObject(1,GetObjectHPs(1)); Suicide(); end; end;
Here is part of my script where if enemy unit gets in are zone "TNT_0" of object with ID "2" or "TNT" object gets damaged, the bridge with ID "1" gets destroyed.
|
|