Spawning Model to Block Player Movement
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
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.
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.
- Code: Select all
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: Select all
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.
- Ghost_Fang
- Posts: 336
- Joined: Thu Nov 12, 2009 4:37 am
missile.angles = '0 1 0' * vectoyaw(missile.velocity);
or just
missile.angles = '0 1 0' * playerentity.angles_y;
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
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.
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.
-

Dr. Shadowborg - InsideQC Staff
- Posts: 1110
- Joined: Sat Oct 16, 2004 3:34 pm
So you started working on this eh Ghost? Nice man. It isn't as complex as I thought It would be however. Good Luck.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest