Page 2 of 2

Posted: Sun May 04, 2003 9:53 am
by bodybagger
Ok guys, sorry to be a pain.
It kinda works.
However, when activating the trigger you have to press it 61 times for the airstrike to begin. Each time it is pressed the screen message prints:
60 second timer = 1
60 second timer = 2
and so on..
also the axis can't call off the airstike.
I am sorry i really don't understand scripts to well and really appreciate all the help you guys give
Thanks again
Craig

Posted: Sun May 04, 2003 1:43 pm
by jv_map
Hmm well tltrude seems to be quite happy with gotos but in fact they make scripts completely unreadable ;).

I have another script for you to try, as ever without a single goto 8)

Code: Select all

main:
	level waittill roundstart
	
	thread airstrikethread
end

airstrikethread:	
	// wait for allies trigger event
	while(1)
	{
		$airstriketrigger waittill trigger
		if(parm.other.dmteam == allies)
			break
	}
	// start the airstrike in 60 seconds, meanwhile the axis can yet call it off
	iprintlnbold_noloc "Allied air armada will arrive in 60 seconds!"
	thread airstrike
	
	// wait for axis trigger event
	while(1)
	{
		$airstriketrigger waittill trigger
		if(parm.other.dmteam == axis)
			break
	}
	iprintlnbold_noloc "The air strike was cancelled!"
	level.cancelled_airstrike = 1
end

airstrike:
	wait 60
	
	// run airstrikes until cancelled
	while(level.cancelled_airstrike != 1)
	{
		// example bomber line
		thread global/bomber.scr::bomb 40
		wait (randomfloat 4)
		wait 0.5
	}
end

This code just checks if the airstrike was cancelled before the strike commences, instead of checking this every second.

I assume the trigger has targetname 'airstriketrigger', if this trigger doesn't exist the script will crash to the main menu!

Posted: Sun May 04, 2003 7:34 pm
by bodybagger
thanks guys, that works great
Would it be hard to add one more thing.
When the trigger has been de-activated, it can't be re-activated.
would it be possible to keep switching it on and off, on and off as many times as i like?
Thanks again :D

Posted: Sun May 04, 2003 7:52 pm
by jv_map
Sure. There you go:

Code: Select all

main: 
	level waittill roundstart 
    
	thread airstrikethread 
end 

airstrikethread:
	while(1)
	{
		// wait for allies trigger event 
		while(1) 
		{ 
			$airstriketrigger waittill trigger 
			if(parm.other.dmteam == allies) 
				break 
		}
		// start the airstrike in 60 seconds, meanwhile the axis can yet call it off 
		iprintlnbold_noloc "Allied air armada will arrive in 60 seconds!" 
		thread airstrike 
	    local.airstrikethread = parm.previousthread
	    
		// wait for axis trigger event 
		while(1) 
		{ 
			$airstriketrigger waittill trigger 
			if(parm.other.dmteam == axis) 
				break 
		} 
		iprintlnbold_noloc "The air strike was cancelled!" 
		local.airstrikethread.cancel = 1
	}
end 

airstrike: 
   wait 60 
    
   // run airstrikes until cancelled 
   while(local.cancel != 1) 
   { 
      // example bomber line 
      thread global/bomber.scr::bomb 40 
      wait (randomfloat 4) 
      wait 0.5 
   } 
end
I used a slightly more advanced script here to prevent execution of multiple airstrike threads in a row.

Posted: Mon May 05, 2003 10:31 am
by bodybagger
Just been testing the script throughly and have just realized that the bombers don't actualy stop. The game message comes up as "the axis have cancelled the airstrike, but the airstikes still continue :?

Posted: Mon May 05, 2003 12:19 pm
by jv_map
Hmm that doesn't seem possible. Are you sure you copied both threads exactly?

Timer?

Posted: Mon May 05, 2003 1:20 pm
by tltrude
I have been looking at jv_map's script and for the life of me, I can't see the 60 second timer anywhere. It must be there if it works, but....... Oh, I see it now. It's a 60 second wait.

I think this line:

local.airstrikethread.cancel = 1

should be changed to:

local.cancel = 1

to fix it.

Also, the targetname of his trigger was "airstrike". Did he change it to "airstriketrigger"?

Posted: Mon May 05, 2003 1:54 pm
by jv_map
No, I used this construction to pass the value of cancel from airstrikethread: to the airstrike: thread (sorry for these names :oops: ).

This should work just fine :?

targetname

Posted: Mon May 05, 2003 1:56 pm
by tltrude
the targetname of his trigger was "airstrike". Did he change it to "airstriketrigger"?

Posted: Mon May 05, 2003 1:57 pm
by jv_map
Otherwise it would crash like your escalator script did ;)

Posted: Mon May 05, 2003 2:09 pm
by bodybagger
I did change the targetname,
I copied the script exactly. there was only one thing i changed was
wait (randomfloat 4)
to
wait (randomfloat 60)
because there would be a whole load of bombers spawn..
but the axis can't de-activate. the game message comes up, however the bombers still come

Posted: Mon May 05, 2003 2:22 pm
by jv_map
Ok, here's a debug script:

Code: Select all

main: 
   level waittill roundstart 
    
   thread airstrikethread 
end 

airstrikethread: 
   while(1) 
   { 
      // wait for allies trigger event 
      while(1) 
      { 
         $airstriketrigger waittill trigger 
         if(parm.other.dmteam == allies) 
            break 
      } 
      // start the airstrike in 60 seconds, meanwhile the axis can yet call it off 
      iprintlnbold_noloc "Allied air armada will arrive in 60 seconds!" 
      thread airstrike 
      local.airstrikethread = parm.previousthread 
      if !(local.airstrikethread)
          iprintln "ERROR: parm.previousthread failed"
      // wait for axis trigger event 
      while(1) 
      { 
         $airstriketrigger waittill trigger 
         if(parm.other.dmteam == axis) 
            break 
      } 
      iprintlnbold_noloc "The air strike was cancelled!" 
      if !(local.airstrikethread)
          iprintln "ERROR: airstrikethread doesn't exist"
      local.airstrikethread.cancel = 1 
   } 
end 

airstrike: 
   wait 60 
    
   // run airstrikes until cancelled 
   while(local.cancel != 1) 
   { 
      // example bomber line 
      iprintln "INFO: bomber run started"
      thread global/bomber.scr::bomb 40 
      wait (randomfloat 4) 
      wait 0.5 
   } 
   iprintln "INFO: airstrike ended"
end
See if this script generates any yellow error messages. Also test if the 'airstrike ended' message pops up (this could happen up to two minutes after you pressed the trigger). Use 'timescale 100' if you're impatient ;)

Posted: Mon May 05, 2003 3:12 pm
by bodybagger
seems to work fine now, maybe is was being impatient :oops: . Didn't realise that you had to wait for the script to stop.
Any how.
Thnx, it really apperciated
Craig

Posted: Mon May 05, 2003 3:35 pm
by jv_map
Well the bombings (if started) should stop immediately after the trigger was pressed by an Axis. But if it works I'm happy :D