View previous topic :: View next topic |
Author |
Message |
Ghost_Fang
Joined: 12 Nov 2009 Posts: 162
|
Posted: Tue Jun 15, 2010 3:48 pm Post subject: Spawning Model to Block Player Movement |
|
|
I modified the grenade code to make a Halo 3 style deployable cover to block bullets and player movement. But as of right now it only blocks bullets. It is possible to spawn a model that'll block players too? I've tried all the SOLID_'s.
Code: | void() W_FireGrenade =
{
local entity missile, mpuff;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
self.punchangle_x = -2;
missile = spawn ();
missile.owner = self;
missile.movetype = MOVETYPE_STEP;
missile.solid = SOLID_BBOX;
missile.classname = "grenade";
// set missile speed
makevectors (self.v_angle);
if (self.v_angle_x)
missile.velocity = v_forward*500 + v_up * 00 + crandom()*v_right*10 + crandom()*v_up*10;
else
{
missile.velocity = aim(self, 10000);
missile.velocity = missile.velocity * 400;
missile.velocity_z = 300;
}
// set missile duration
missile.nextthink = time + 2;
missile.think = BecomeCover;
setmodel (missile, "progs/d_cover.mdl");
setsize (missile, '0 0 0', '0 0 0');
setorigin (missile, self.origin);
}; |
Code: | void() BecomeCover =
{
setmodel (self, "progs/cover.mdl");
self.solid = SOLID_BBOX;
self.movetype = MOVETYPE_STEP;
setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
self.nextthink = time + 15;
self.think = BecomeExplosion;
setorigin (self, self.origin);
}; |
One More thing, I deleted the
"missile.angles = vectoangles(missile.velocity);"
part of the code because if you looked up and threw it, the spawned the model facing up, and every other direction etc. But now no matter what way you face it spawns in the same direction, how would i change the missile angles to affect X & Y but not Z (if you know what i mean) so you can throw it and it only copies the direction you were facing but ignores if you were facing up or down. |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Tue Jun 15, 2010 5:53 pm Post subject: |
|
|
missile.angles = '0 1 0' * vectoyaw(missile.velocity);
or just
missile.angles = '0 1 0' * playerentity.angles_y; _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
Dr. Shadowborg Inside3D Staff

Joined: 16 Oct 2004 Posts: 726
|
Posted: Tue Jun 15, 2010 6:22 pm Post subject: |
|
|
Also, to make it block the player too, you need to switch the owner from the player to the world, or something.
i.e. in BecomeCover(); add a self.owner = world;
Beware though, you'll have to do some stuff to keep it from getting the player stuck inside of it if he's too close. _________________ "Roboto suggests Plasma Bazooka." |
|
Back to top |
|
 |
Mexicouger

Joined: 01 May 2010 Posts: 129
|
Posted: Tue Jun 15, 2010 7:27 pm Post subject: |
|
|
So you started working on this eh Ghost? Nice man. It isn't as complex as I thought It would be however. Good Luck. |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Wed Jun 16, 2010 12:31 am Post subject: |
|
|
Increasing the bbox suddenly (without doing any checks to see if it is now intersecting something) scares me. The entity should drop out of the world, or trigger satanic unsticking code, or something when you do that. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
Ghost_Fang
Joined: 12 Nov 2009 Posts: 162
|
Posted: Fri Jun 18, 2010 5:44 pm Post subject: |
|
|
Thanks Dr. Shadowborg worked perfectly. |
|
Back to top |
|
 |
|