on the fly changing projectile?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

on the fly changing projectile?

Post by Elgan »

Code: Select all

hid:
iprintln "change"

		local.player=parm.other
		local.randnum = randomint 1000
		local.player weaponcommand dual targetname ("weap" + local.randnum)
		local.weap = $("weap" + local.randnum)
		// local.weap.targetname = ""

		iprintln local.weap

		local.weap.projetile = "models/arrow/project__explode.tik"

		local.weap.dmprojetile = "models/arrow/project__explode.tik"

		
end
//alternate
		parm.other take models/weapons/bazooka.tik
		
		local.player give models/weapons/bazooka2.tik

end

can i do anything like that? is there a way?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes I think you can change the projectile, not literally 'on the fly' but changes would take effect next time the weapon is fired. You just gotta spell it right (projectile ;)) and also use local.weap projectile someprojectile.tik instead of local.weap.projectile = someprojectile.tik :)
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

oops ( :wink:

:shock: :mrgreen: dman spelling. i tried that way first but i obv spelt it wrong .tut
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

I don't want to start a new topic so I'll post my question here.

I've got a custom weapon that shoots a custom projectile. What I'd like to do is when someone fires this weapon, replace the projectile with a health box (which IS NOT a projectile). I've done this so far:

Code: Select all

main:
   (...)
   level waittill spawn
   thread projectileWatch
   (...)
end

projectileWatch:
   local.trg = spawn trigger_multiple
   local.trg.spawnflags = 16
   local.trg.origin = (0 0 0)
   local.trg setsize (-8192 -8192 -8192) (8192 8192 8192)
   while (1) {
      local.trg waittill trigger
      local.prjctl = parm.other
      if (local.prjctl.model = "models/projectiles/my_custom_projectile.tik")
      {
         local.healthbox = spawn models/items/item_25_healthbox.tik origin local.prjctl.origin angles local.prjctl.angles
         local.healthbox item_droptofloor
         local.healthbox set_respawn 0
      }
      waitframe
   }
end
However, this doesn't work... :( Any ideas?
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Sorted the above thing out... Should be:

Code: Select all

main:
   (...)
   level waittill spawn
   thread projectileWatch
   (...)
end

projectileWatch:
   local.trg = spawn trigger_multiple spawnflags 20 origin ( 0 0 0 ) angles ( 0 0 0 )
   local.trg setsize ( -8192 -8192 -8192 ) ( 8192 8192 8192 )
   while (1) {
      local.trg waittill trigger
      local.prjctl = parm.other
      if (local.prjctl.model == "models/projectiles/my_custom_projectile.tik")
      {
         local.healthbox = spawn models/items/item_25_healthbox.tik origin local.prjctl.origin angles local.prjctl.angles
         local.healthbox item_droptofloor
         local.healthbox set_respawn 0
         local.prjctl delete
      }
      waitframe
   }
end
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

To Rookie One
Thats a big trigger, does it cover the whole map?

To Elgan,
So how did you go with your problem mate? Any news?

Grassy
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

as aboive it worked i just spelt projectile wrong.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Grassy wrote:To Rookie One
Thats a big trigger, does it cover the whole map?
Yeah, that's what I wanted to achieve. :) I looked up the farthest values on the grid in Radiant and that's how I got these dimensions.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

if its custom stuff why dont u just make a new projectile tik of a healthbox that is a projectile and shoot it.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Because if I set the model to healthcanteen.skd, the game crashes when I click fire. :? Already tried a few ways to do this including changing the explosion fx tik to the health canteen, but it doesn't give you any health, disappears after some 5 seconds and tends to levitate in the air. :?
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Post Reply