prevent axis respawn

Post your scripting questions / solutions here

Moderator: Moderators

agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

yeah same i go to bed 5:00 am here damn script and Thx strafer for the help i am trying a new thing with waittil death .

hope to see you tomorrow :D
Deadly and slient.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Hello there, if you are calling a thread and need to pass information to the new thread then it would be something like; $myobject thread newthread - or - $myobject thread newthread local.player. The thread 'newthread' will then have a lable such as, newthread local.player:
If you are using self in the newthread self would be $myobject and if refering to local.player, that would the local.player identified at the time when the thread was called.

A clip from part of your script;
thread bomb_waittill_defuse2
thread bomb_waittill_explode2

self.live = 1

end
}
}
if (local.counter > 0)
local.player stopwatch 0
}
end


bomb_waittill_defuse2:
while ( $(self.trigger_name) )
{
self.trigger_name waittill trigger


What you have here is the reason for NIL listener self is not passed to the new thread, os the new thread cant find a listener for commands like waittill trigger etc.... So in other words you need to pass the "bomb" targetname to the new thread, it will then become 'self'

Grassy
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

dunno if i am wrong but the self refer to the bomb .

Code: Select all

bomb_thinker2:





	level.bomb_defuse_time = 40 //tenths of a second
	level.bomb_set_time = 50  //tenths of a second
	level.bomb_tick_time = 15  //seconds
	level.bomb_explosion_radius = 1054  //quake units
	level.bomb_use_distance = 128 //quake units
	level.bomb_damage = 200
	level.bombusefov = 30

	level.subtitleX = 100
	level.subtitleY = 50
	
	self.live = 0

	if (self.target != NIL && self.target != NULL && $(self.target) != NULL)
	{
		self.target.collisionent = self.target.target
		self.target notsolid
	}

	$bomb2 thread bomb_waittill_set2
end

bomb_waittill_set2 $bomb2:
	self model items/pulse_explosive.tik
	while ( $(self.trigger_name) )
	{
		self.trigger_name waittill trigger
		local.player = parm.other

	        if (local.player.dmteam != allies) 
		{
		goto bomb_waittill_set2 $bomb2
		println "failed dmteam check" local.player.dmteam	
		}

		local.counter = 0
		while ( (Isalive local.player) && (local.player cansee self level.bombusefov level.bomb_use_distance) && (local.player.useheld == 1) && self.live == 0 )
		{
			if (local.counter == 0)
				local.player stopwatch (level.bomb_set_time * .1)
				
			local.counter++
			wait 0.1

			if (local.counter >= level.bomb_set_time)
			{
				iprintlnbold ( loc_convert_string "The Allies have planted a bomb!" )
				if (level.planting_team == "allies")
					self playsound dfr_objective_o
				else
					self playsound den_objective_o

				$bomb2 thread bomb_waittill_defuse2
				$bomb2 thread bomb_waittill_explode2

				self.live = 1

				end
			}
		}
		if (local.counter > 0)
			local.player stopwatch 0
	}
end


bomb_waittill_defuse2 $bomb2:
	while ( $(self.trigger_name) )
	{
		self.trigger_name waittill trigger

		local.player = parm.other
	
	if (local.player.dmteam != axis)
	{      
		println "failed dmteam check" local.player.dmteam
		goto bomb_waittill_defuse2 $bomb2
		}
	
		local.counter = 0
		while ( (Isalive local.player) && (local.player cansee self level.bombusefov  level.bomb_use_distance) && (local.player.useheld == 1) && self.live == 1 )
		{
			if (local.counter == 0)
				local.player stopwatch (level.bomb_defuse_time * .1)
			
			local.counter++
			wait 0.1

			if (local.counter >= level.bomb_defuse_time)
			{
				iprintlnbold ( loc_convert_string "The Allies bomb has been defused!" )
				if (level.defusing_team == "allies")
					self playsound dfr_diffused_d
				else
					self playsound den_diffused_d
				thread bomb_waittill_set2 $bomb2//start first thread again
				self.live = 0
				end
			}
		}
		if (local.counter > 0)
			local.player stopwatch 0
	}
end

bomb_waittill_explode2 $bomb2:
	self model items/explosive.tik
	self playsound plantbomb
	self loopsound bombtick
	
	local.start_time = level.time

	while (level.time < (local.start_time + level.bomb_tick_time) )
	{
		wait 0.1
		if (self.live != 1)
		{
			self stoploopsound
			end
		}
		if (level.time == (local.start_time + level.bomb_tick_time - 10) )
		{
			self stoploopsound
			self loopsound final_countdown
		}
 	}
 	self stoploopsound
	$bomb2 thread bomb_explode2
end

bomb_explode2 $bomb2:
//self.trigger_name remove

	thread global/obj_dm.scr::jitter_large 0
	
	if (self.exploder_set != NIL)
	{
		thread global/exploder.scr::explode self.exploder_set
	}
	
	if (self.explosion_fx != NIL)
		self thread global/obj_dm.scr::spawn_fx self.explosion_fx
	
	if (self.explosion_sound != NIL)
		self playsound self.explosion_sound

	if (self.target != NIL && self.target != NULL && self.target != "" && self.target.size == 1)
	{
		if (self.target.destroyed_model != NIL)
		{
			local.damaged = self.target thread spawn_damaged self.target.destroyed_model
		}

		if (self.exploder_set == NIL)
		{
			self.target remove
		}

		waitframe
	}
	radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
	if (self.killarea != NIL)
	{
		self.killarea volumedamage 1000
	}
	self hide
	self notsolid
//self remove
	$exploder2 remove
iprintlnbold "Subatomic energy destroyed.Earth is saved"

	self.live = 0


	level.allies_obj++ 
	$bomb2.exploded = 1


	wait 0.5

end

check_axis_bomb: 

while(1) 
{ 
for(local.i=1;local.i<=$player.size;local.i++) 
{ 
   if(($bomb2.exploded == 1) && $player[local.i].dmteam=="axis")
{ 
  $player[local.i] waittill death 
}
                   
if($player[local.i].dead == 0) 
                   
{ 

                       
$player[local.i].dead = 1 

}

else
{
$player[local.i] thread prevent_axis_spawn
}


wait .1

}

}
end


  
prevent_axis_spawn: 

while(1) 
{ 

   if($player[local.i].dead == 1) 
   { 
      $player[local.i] takeall 
      $player[local.i] hide 
      $player[local.i] notsolid 
      $player[local.i] noclip 
   } 
wait .1 
} 

end 

error :

Bad parameter value "bomb_explode2 $bomb2"
Bad parameter value "bomb_waitill_explode2 $bomb2"

.......all my theread sets with bomb2 are wrong then..
Deadly and slient.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

You have mixed up some things.

To pass the bomb info to the new thread and have it as self in the new thread do this.

Method 1;

//the call statement
$bomb thread bomb_waittill_defuse2 //<<you got this one right

//the thread label
bomb_waittill_defuse2: //<< $bomb will be self in this thread


Further down your script you have;
//call statement
thread bomb_waittill_set2 $bomb2

//thread label
bomb_waittill_explode2 $bomb2: //<< not correct

To make this thread work without too much fuss change the lable to this;
bomb_waittill_explode2 local.bomb:
//and add this line under the label
local.bomb = self
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

still same error :/..... i ll try to think about an another architecture......
Deadly and slient.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Maybe this will work for you take out the red parts and add the green parts
bomb_thinker2:

level.bomb_defuse_time = 40 //tenths of a second
level.bomb_set_time = 50 //tenths of a second
level.bomb_tick_time = 15 //seconds
level.bomb_explosion_radius = 1054 //quake units
level.bomb_use_distance = 128 //quake units
level.bomb_damage = 200
level.bombusefov = 30

level.subtitleX = 100
level.subtitleY = 50

self.live = 0

if (self.target != NIL && self.target != NULL && $(self.target) != NULL)
{
self.target.collisionent = self.target.target
self.target notsolid
}

$bomb2 thread bomb_waittill_set2
end

bomb_waittill_set2 $bomb2:
self model items/pulse_explosive.tik
while ( $(self.trigger_name) )
{
self.trigger_name waittill trigger
local.player = parm.other

if (local.player.dmteam != allies)
{
goto bomb_waittill_set2 $bomb2
println "failed dmteam check" local.player.dmteam
}

else
{

local.counter = 0
while ( (Isalive local.player) && (local.player cansee self level.bombusefov level.bomb_use_distance) && (local.player.useheld == 1) && self.live == 0 )
{
if (local.counter == 0)
local.player stopwatch (level.bomb_set_time * .1)

local.counter++
wait 0.1

if (local.counter >= level.bomb_set_time)
{
iprintlnbold ( loc_convert_string "The Allies have planted a bomb!" )
if (level.planting_team == "allies")
self playsound dfr_objective_o
else
self playsound den_objective_o

$bomb2 thread bomb_waittill_defuse2
$bomb2 thread bomb_waittill_explode2

self.live = 1

end
}
}
if (local.counter > 0)
local.player stopwatch 0
}
}
end


bomb_waittill_defuse2 $bomb2:
while ( $(self.trigger_name) )
{
self.trigger_name waittill trigger

local.player = parm.other

if (local.player.dmteam != axis)
{
println "failed dmteam check" local.player.dmteam
goto bomb_waittill_defuse2 $bomb2
}

else
{

local.counter = 0
while ( (Isalive local.player) && (local.player cansee self level.bombusefov level.bomb_use_distance) && (local.player.useheld == 1) && self.live == 1 )
{
if (local.counter == 0)
local.player stopwatch (level.bomb_defuse_time * .1)

local.counter++
wait 0.1

if (local.counter >= level.bomb_defuse_time)
{
iprintlnbold ( loc_convert_string "The Allies bomb has been defused!" )
if (level.defusing_team == "allies")
self playsound dfr_diffused_d
else
self playsound den_diffused_d
thread bomb_waittill_set2 $bomb2//start first thread again
self.live = 0
end
}
}
if (local.counter > 0)
local.player stopwatch 0
}
}
end

bomb_waittill_explode2 $bomb2:
self model items/explosive.tik
self playsound plantbomb
self loopsound bombtick

local.start_time = level.time

while (level.time < (local.start_time + level.bomb_tick_time) )
{
wait 0.1
if (self.live != 1)
{
self stoploopsound
end
}
if (level.time == (local.start_time + level.bomb_tick_time - 10) )
{
self stoploopsound
self loopsound final_countdown
}
}
self stoploopsound
$bomb2self thread bomb_explode2
end

bomb_explode2 $bomb2:
//self.trigger_name remove

thread global/obj_dm.scr::jitter_large 0

if (self.exploder_set != NIL)
{
thread global/exploder.scr::explode self.exploder_set
}

if (self.explosion_fx != NIL)
self thread global/obj_dm.scr::spawn_fx self.explosion_fx

if (self.explosion_sound != NIL)
self playsound self.explosion_sound

if (self.target != NIL && self.target != NULL && self.target != "" && self.target.size == 1)
{
if (self.target.destroyed_model != NIL)
{
local.damaged = self.target thread spawn_damaged self.target.destroyed_model
}

if (self.exploder_set == NIL)
{
self.target remove
}

waitframe
}
radiusdamage self.origin level.bomb_damage level.bomb_explosion_radius
if (self.killarea != NIL)
{
self.killarea volumedamage 1000
}
self hide
self notsolid
//self remove

$exploder2 remove ??????????

iprintlnbold "Subatomic energy destroyed.Earth is saved"

self.live = 0


level.allies_obj++
$bomb2.exploded = 1
self.exploded = 1


wait 0.5

end

check_axis_bomb:

while(1)
{
for(local.i=1;local.i<=$player.size;local.i++)
{
if(($bomb2.exploded == 1) && $player[local.i].dmteam=="axis")
{
$player[local.i] waittill death
}

if($player[local.i].dead == 0)

{


$player[local.i].dead = 1

}

else
{
$player[local.i] thread prevent_axis_spawn
}


wait .1

}

}
end



prevent_axis_spawn:

while(1)
{

if($player[local.i].dead == 1)
{
$player[local.i] takeall
$player[local.i] hide
$player[local.i] notsolid
$player[local.i] noclip
}
wait .1
}

end
Image
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

infinite LOOP.

Error " pssoible overflow"
Deadly and slient.
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

the loopis ok i ve added a wait .1, and i have none errors but none effects.

axis can still spawn .
Deadly and slient.
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

ok,im a terroist hijacker of topics :twisted:

but whaty if i have a documents and it needs stolen.
what would be the simplest code to have allies win after the documents have been stolen.
heres my style of code and usually when i use the local.stuff it corrupts my whole code.
(BTW this is for Destroyed Village Server Side)
it works besides when i try the local.documents.stolen ==1 bla bla
it corrupts??

Code: Select all

        level waittill prespawn 
//obj.

	level.dmrespawning = 1   // 1 **wave based** or 0 **round based**
	level.dmroundlimit = 5   // round time limit in minutes
	level.clockside = allies // set to axis, allies, kills, or draw

//threads

        thread spawn_switch
        thread spawn_switch1
        thread documents
        //thread prevent_player_spawn

//move objects

             $bomb_switch moveup 40
             $bomb_switch move
             $bomb_switch1 moveup 40
             $bomb_switch1 move
             $spawn_kill hide
             $spawn_kill1 hide

	//*** Precache Dm Stuff
	exec global/DMprecache.scr

	exec global/door_locked.scr::lock
	level.script = maps/dm/mohdm2.scr
	exec global/ambient.scr mohdm2	

	level waittill spawn

waitthread global/objectives.scr::add_objectives 1 2 "Get the documents." 
waitthread global/objectives.scr::current_objectives 1
end

//steal documents------------------------------------------------------------
objective1:
           $documents remove
           
           wait 5
           
           goto objective

end

//objective complete---------------------------------------------------------
objective:
waitthread global/objectives.scr::add_objectives 1 3 "Get the documents." 
waitthread global/objectives.scr::current_objectives 0
wait 3

end

//spawn_bomber---------------------------------------------------------------
spawn_switch:
             $bomb_trigger triggerable
             $bomb_trigger waittill trigger
             $bomb_trigger playsound alarm_switch
             $bomb_switch anim turnon
             $bomb_switch light 1 0 0 200
             $bomb_trigger playsound airplane6
             wait 5
             $spawn_kill anim start
             wait 3
             $bomb_switch anim turnoff
             $bomb_trigger playsound alarm_switch
             $spawn_kill anim remove
             $bomb_switch light 0 0 0 200
             $bomb_trigger nottriggerable
             wait 9
             goto spawn_switch

end

//spawn_bomber1--------------------------------------------------------------
spawn_switch1:
             $bomb_trigger1 triggerable
             $bomb_trigger1 waittill trigger
             $bomb_trigger1 playsound alarm_switch
             $bomb_switch1 anim turnon
             $bomb_switch1 light 1 0 0 200
             wait 5
             $bomb_trigger1 playsound airplane6
             wait 13
             $spawn_kill1 anim start
             wait 3
             $bomb_switch1 anim turnoff
             $bomb_trigger1 playsound alarm_switch
             $spawn_kill1 anim remove
             $bomb_switch1 light 0 0 0 200
             $bomb_trigger1 nottriggerable
             wait 9
             goto spawn_switch1

end
it doesnt end the map?
Image
Post Reply