Thread for spawning explosive crates in stock maps.

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Thread for spawning explosive crates in stock maps.

Post by tltrude »

It's messy but, by god, it works great!!! And, you can make as many as you like by just changing the index numbers of all the parts and the name of the thread. All the threads should be started in prespawn, but the threads themselves should be stuck to the end of the script.


Code: Select all


level waittill prespawn

thread boomcrate1

//--------------------------------------------------->

// EXPLOSIVE CRATE SPAWN THREADS

//--------------------------------------------------->

 boomcrate1:

	local.crate1 = spawn script_model
	local.crate1.targetname = "explosive_crate1"
	local.crate1 model "models/static/indycrate.tik" 
	local.crate1.origin = ( -500 1388 0 )
	local.crate1.angles = (0 0 0) // if angles changed, adjust trigger setsize
	spawn script_origin targetname "killspot1"
	$killspot1.origin = (local.crate1.origin + (0 0 64))
	spawn trigger_multiple targetname "crate_trigger1" "spawnflags" "128" "health" "1"
	$crate_trigger1.origin = (local.crate1.origin)
	$crate_trigger1 setsize ( -27 -38 0) (27 38 49)
	$crate_trigger1 waittill trigger

	spawn "animate/fx_explosion_mine" targetname "explode_crate1" angle "-1" origin local.crate1.origin
	$explode_crate1 anim start
	radiusdamage $killspot1 250 256 // numbers are damage and radius
	local.crate1 hide
	$crate_trigger1 remove  // may not be needed because trigger is killed
	$killspot1 remove
	wait 20
	$explode_crate1 remove
	local.crate1 show
	local.crate1 remove
	thread boomcrate1

end

The crate respawns after 20 seconds.
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 »

Looks cool :)

I however want to give some useful hints (or maybe I just like to disturb the fun ;)).

Using targetnames is best to be avoided, since there always is a risk of multiple entities using the same targetname, resulting in an unwanted array. Therefore targetnames should only be set in Radiant, since there is no other way to 'get' entities from a map by script. However when using spawn commands it's better to simply set a variable, like this:

local.myobject = spawn object

One obvious advantage when using this in your script is that you can simply copy and paste the thread without having to alter the targetnames for the killspots and crate_triggers.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

something like this can be used several times just give it differnt origins

Code: Select all

level waittill prespawn 

thread boomcrate ( 0 1234 5678 )// origin

thread boomcrate ( 111 222 5678 )// origin

//---------------------------------------------------> 

// EXPLOSIVE CRATE SPAWN THREADS 

//---------------------------------------------------> 

 boomcrate local.origin: 

   local.crate = spawn script_model 
   local.crate model "models/static/indycrate.tik" 
   local.crate.origin = local.origin
   local.crate.angles = (0 0 0) // if angles changed, adjust trigger setsize 

   local.trigger = spawn trigger_multiple "spawnflags" "128" "health" "1" 
   local.trigger.origin = local.origin 
   local.trigger setsize ( -27 -38 0) (27 38 49)

   local.trigger waittill trigger

   exec global/model.scr local.origin // default is explosion mine
   radiusdamage (local.origin + ( 0 0 64)) 250 256 // numbers are damage and radius 
   local.crate remove
   wait 20 
   thread boomcrate local.origin

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

Post by jv_map »

Even better :D
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

20 20 hindsight

Post by tltrude »

Yeah that works great, but players can be trapped if they stand where a crate respawns. That is why I did the hide and show stuff--to block players.

Also It would be nice if there was an automattic setsize thing for the trigger--if the angles were changed. That would probably be a math problem. And, changing the angles would change all the crates to those angles with your generic thread.
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You are right with that script all the angles will be the same but it easy to fix

Code: Select all

level waittill prespawn 

thread boomcrate ( 0 1234 5678 ) 90 // origin angle

thread boomcrate ( 111 222 5678 )  180 // origin angle

//---------------------------------------------------> 

// EXPLOSIVE CRATE SPAWN THREADS 

//---------------------------------------------------> 

 boomcrate local.origin local.angle: 

   local.crate = spawn script_model 
   local.crate model "models/static/indycrate.tik" 
   local.crate.origin = local.origin 
   local.crate.angle = local.angle 
   local.crate notsolid
   local.trigger = spawn trigger_multiple "spawnflags" "128" "health" "1" 
   local.trigger.origin = local.origin 
   local.trigger setsize ( -27 -38 0) (27 38 49) 
   local.tigger.angle = local.angle 

   local.trigger waittill trigger 

   exec global/model.scr local.origin // default is explosion mine 
   radiusdamage (local.origin + ( 0 0 64)) 250 256 // numbers are damage and radius 
   local.crate remove 
   wait 20 
   thread boomcrate local.origin 

end 
I made the crate notsolid in the script and set an angle for the trigger will it work ?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Re: 20 20 hindsight

Post by jv_map »

tltrude wrote:Also It would be nice if there was an automattic setsize thing for the trigger--if the angles were changed. That would probably be a math problem.
I think math difficulties can be avoided this way:

Code: Select all

local.trigger = spawn Trigger
local.trigger setsize ( -20 -40 0) (30 50 60)
local.trigger origin (2342 256 -241)
local.trigger.rotatedbbox = 1
local.trigger.angles = (0 35 0)
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Angle

Post by tltrude »

Angle does not work on the model. I guess it has to be "angles". This seems to work, but the trigger angles are not changing with the crate. Making the crate non solid is cheating, ha ha.

Code: Select all

	level waittill prespawn

	thread boomcrate ( -500 1388 0 ) (0 0 0) // origin and angles 
	thread boomcrate ( -500 1888 0 ) (0 90 0) // origin and angles

==============================================

//---------------------------------------------------> 

// EXPLOSIVE CRATE SPAWN THREAD 

//---------------------------------------------------> 

boomcrate local.origin local.angles: 

   local.crate = spawn script_model 
   local.crate model "models/static/indycrate.tik" 
   local.crate.origin = local.origin 
   local.crate.angles = local.angles
   local.crate notsolid 
   local.trigger = spawn trigger_multiple "spawnflags" "128" "health" "1" 
   local.trigger.origin = local.origin 
   local.trigger setsize ( -27 -38 0) (27 38 49)
   local.trigger.rotatedbbox = 1 
   local.tigger.angle = local.angles[2] 

   local.trigger waittill trigger 

   exec global/model.scr local.origin // default is explosion mine 
   radiusdamage (local.origin + ( 0 0 64)) 250 256 // numbers are damage and radius 
   local.crate remove 
   wait 20 
   thread boomcrate local.origin local.angles

end 

I tried it with "local.tigger.angles = local.angles" too and still didnt work. Does a trigger_multiple even have a bounding box?
Tom Trude,

Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

hey fellow scripters :D

just noticed a typo

level waittill prespawn

thread boomcrate ( -500 1388 0 ) (0 0 0) // origin and angles
thread boomcrate ( -500 1888 0 ) (0 90 0) // origin and angles

==============================================

//--------------------------------------------------->

// EXPLOSIVE CRATE SPAWN THREAD

//--------------------------------------------------->

boomcrate local.origin local.angles:

local.crate = spawn script_model
local.crate model "models/static/indycrate.tik"
local.crate.origin = local.origin
local.crate.angles = local.angles
local.crate notsolid
local.trigger = spawn trigger_multiple "spawnflags" "128" "health" "1"
local.trigger.origin = local.origin
local.trigger setsize ( -27 -38 0) (27 38 49)
local.trigger.rotatedbbox = 1
local.trigger.angles = local.angles[2]

local.trigger waittill trigger

exec global/model.scr local.origin // default is explosion mine
radiusdamage (local.origin + ( 0 0 64)) 250 256 // numbers are damage and radius
local.crate remove
wait 20
thread boomcrate local.origin local.angles

end

if the model being spawned anlges are changed, using local.trigger.angles = local.crate.angles should change the rotation of the trigger

if not though and you just want to change 1 angle (the Z angle), you will need to use
local.trigger.angles = (0 0 (local.crate.angles[2] + 45)) //or the needed rotational addition
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Hey

Post by tltrude »

That fixed it!!! Thanks nuggets! Here is my solid crate version which will boot a player off the respawning spot. The crate pops up out of the ground! It even works with the crate standing on end (first crate).

Code: Select all


   level waittill prespawn 

   thread boomcrate ( -500 1388 38 ) (0 0 90) // origin and angles 
   thread boomcrate ( -500 1888 0 ) (0 90 0) // origin and angles
   thread boomcrate ( -500 2388 23 ) (90 0 0) // origin and angles 

============================================== 

//---------------------------------------------------> 

// EXPLOSIVE CRATE SPAWN THREAD 

//---------------------------------------------------> 

boomcrate local.origin local.angles: 

   local.crate = spawn script_model 
   local.crate model "models/static/indycrate.tik" 
   local.crate.origin = local.origin + ( 0 0 -80 )
   local.crate.angles = local.angles
   local.crate time 0.001
   local.crate moveUp 80
   local.crate move 
   local.trigger = spawn trigger_multiple "spawnflags" "128" "health" "1" 
   local.trigger.origin = local.origin 
   local.trigger setsize ( -27 -38 0) (27 38 49)
   local.trigger.rotatedbbox = 1 
   local.trigger.angles = local.angles 

   local.trigger waittill trigger 

   exec global/model.scr local.origin // default is explosion mine 
   radiusdamage (local.origin + ( 0 0 64)) 250 256 // numbers are damage and radius 
   local.crate remove 
   wait 20 
   thread boomcrate local.origin local.angles

end 

Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Thats ok no need to thank me for my time . :cry:
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Help

Post by tltrude »

I did kinda, just not here which I should have.

http://www.modtheater.com/forum/showthr ... 493&page=2

THANKS bdbodger, and Jv_map!!!!!!!!!!!!!!
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

:oops: :lol:
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

np's matey :D

how is it working though that it can't respawn at a player location?
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

All fixed now

Post by tltrude »

If a player stood where a crate respawned, it would trap him--could not move. bdbodger's solution was to make the crates non-solid. I fixed it by spawning the crates underground and having them pop up to boot players off the spot. Works great now!!!
Tom Trude,

Image
Post Reply