On and off trigger script

Post your scripting questions / solutions here

Moderator: Moderators

bodybagger
Sergeant
Posts: 52
Joined: Mon Jan 06, 2003 5:27 pm

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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!
Image
bodybagger
Sergeant
Posts: 52
Joined: Mon Jan 06, 2003 5:27 pm

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
bodybagger
Sergeant
Posts: 52
Joined: Mon Jan 06, 2003 5:27 pm

Post 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 :?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hmm that doesn't seem possible. Are you sure you copied both threads exactly?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Timer?

Post 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"?
Last edited by tltrude on Mon May 05, 2003 1:55 pm, edited 2 times in total.
Tom Trude,

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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 :?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

targetname

Post by tltrude »

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

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Otherwise it would crash like your escalator script did ;)
Image
bodybagger
Sergeant
Posts: 52
Joined: Mon Jan 06, 2003 5:27 pm

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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 ;)
Image
bodybagger
Sergeant
Posts: 52
Joined: Mon Jan 06, 2003 5:27 pm

Post 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
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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
Image
Post Reply