How to make a person move in direction of a grenade?

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

How to make a person move in direction of a grenade?

Post by xeno » February 25th, 2010, 8:37 am

How do you make a person move in the same way/direction a grenade would if they threw it; if necessary, how to make a special weapon file / grenade that when used it causes them to be attached to the nade or whatever.
Image

matt101harris
PC Team
PC Team
Posts: 2369
Joined: March 30th, 2008, 4:21 pm
Location: South England
Contact:

Re: How to make a person move in direction of a grenade?

Post by matt101harris » February 25th, 2010, 11:36 am

xeno wrote:How do you make a person move in the same way/direction a grenade would if they threw it; if necessary, how to make a special weapon file / grenade that when used it causes them to be attached to the nade or whatever.
Im not quite sure what you mean, but in promod there is a little "ready up" period, where u can have a certain mod called "warm up" mode or something, there you can follow your nade in mid air to see where it is going.
PeЧĐuĐe@CoDJumper.com: put your cock away, you sick man
Matty@CoDJumper.com: hahaha
PeЧĐuĐe@CoDJumper.com: (while i whip mine out)
Matty@CoDJumper.com: lol
PeЧĐuĐe@CoDJumper.com: just kidding
PeЧĐuĐe@CoDJumper.com: ... i don't have one :(

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Re: How to make a person move in direction of a grenade?

Post by xeno » February 25th, 2010, 6:29 pm

Well I want to be able to make a person move like a grenade being thrown. How it has the arch motion and such. By attaching/linking the player to the nade or some other method.
Image

matt101harris
PC Team
PC Team
Posts: 2369
Joined: March 30th, 2008, 4:21 pm
Location: South England
Contact:

Re: How to make a person move in direction of a grenade?

Post by matt101harris » February 25th, 2010, 7:14 pm

xeno wrote:Well I want to be able to make a person move like a grenade being thrown. How it has the arch motion and such. By attaching/linking the player to the nade or some other method.
Yes for that do the thing as i said above, ill try and find you a link on the mod, 1 second.

http://www.filefront.com/9469714/AM4PAM ... dmiralMOD/

here is a mod you can download, haven't tested it, but im sure it will work.
PeЧĐuĐe@CoDJumper.com: put your cock away, you sick man
Matty@CoDJumper.com: hahaha
PeЧĐuĐe@CoDJumper.com: (while i whip mine out)
Matty@CoDJumper.com: lol
PeЧĐuĐe@CoDJumper.com: just kidding
PeЧĐuĐe@CoDJumper.com: ... i don't have one :(

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Re: How to make a person move in direction of a grenade?

Post by xeno » February 26th, 2010, 12:10 am

Well, it's for cod1. Not cod4, so don't know if that will work.
Image

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: How to make a person move in direction of a grenade?

Post by waywaaaard » February 26th, 2010, 1:00 am

xeno wrote:Well, it's for cod1. Not cod4, so don't know if that will work.
Get the script and just try it out. I guess it could work most likely.
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: How to make a person move in direction of a grenade?

Post by Drofder2004 » February 26th, 2010, 8:26 pm

The script was actually quite easy when I created a private test mod, but I cannot find my scripting for it :/

The idea is very simple:

Create a loop to detect grenades being thrown.
when the frag is found, create a new loop to monitor the origin of the frag (I created a quick array that basically stored all the values of the frag origin)
Then just force the player origin to follow the frag using a little maths to detect direction. (anglestoup and anglestoforward, I think)
Then force those angles upon the player.

I may try recreate the code, it didnt take me long last time...
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: How to make a person move in direction of a grenade?

Post by Drofder2004 » February 26th, 2010, 10:43 pm

Nades are tracked differently in vCoD, they are tracked as basic entities

Code: Select all

getentarray("grenade","classname");
That will create a list of all the current grenades been thrown, it is slightly more complicated to keep track of multiple nades, and I cannot remember how (if possible) you track who threw which...

But this is how it looks for CoD4.
This will give you the exact view the nade gets. Unlike Nade Training in promod, this will automatically realign the camera to follow the trajectory of the nade.

With a little cross-threading you can easily access the recorded data as it is being recorded, allowing you to watch the nade in the air...

the movement however is alot jerkier, but this is due to single origins being processed every 0.05 seconds (giving the illusion of 20 fps).

Do as you wish with it, I was on the verge of relasing a tactics mod several years back in CoD2, but I didn't bother bringing it forward any further as the interest in setnades dropped.

(you must call the checkForNades() function on a player, not on the level entity).

Code: Select all

checkForNades()
{
	for(;;)
	{
		self waittill ( "grenade_fire", grenade);
		grenade tracknade(self);
	}
}

tracknade(player)
{
	org = [];
	ang = [];
	
	while(isDefined(self))
	{
		org[org.size] = self getOrigin();
		ang[ang.size] = self.angles;
		
		wait 0.05;
	}
	
	for(i=1;i<org.size;i++)
	{
		player setPlayerangles(vectortoangles(org[i] - org[i-1]));
		player setOrigin(org[i-1]);
		wait 0.05;
	}
}
(For smoothness set your sv_fps to 125, although this does do some strange other things, but works well for smoothness :P)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

xeno
CJ Wannabe
CJ Wannabe
Posts: 38
Joined: October 31st, 2007, 12:37 am
Location: United States - GA

Re: How to make a person move in direction of a grenade?

Post by xeno » February 27th, 2010, 7:06 am

This?

Code: Select all

checkForNades()
{
	iprintln("IN checkForNades");
	for(;;)
	{
		//self waittill ( "grenade_fire", grenade);
		grenadesthrown = getentarray("mpweapon_fraggrenade", "classname");
		if(grenadesthrown.size>0)
		{
			iprintln("IN if statement");
			grenadesthrown[0] tracknade(self);
		}
	}
}

tracknade(player)
{
	iprintln("IN tracknade");
   org = [];
   ang = [];
   
   while(isDefined(self))
   {
      org[org.size] = self getOrigin();
      ang[ang.size] = self.angles;
      
      wait 0.05;
   }
   
   for(i=1;i<org.size;i++)
   {
      player setPlayerangles(vectortoangles(org[i] - org[i-1]));
      player setOrigin(org[i-1]);
      wait 0.05;
   }
}
Image

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: How to make a person move in direction of a grenade?

Post by Drofder2004 » February 28th, 2010, 12:56 am

Not exactly

1. do not use "weapon_..." just simply "grenade"
2. you for(;;) is infinite, it needs a wait statement
3. your code should work but it is not very friendly. This would not work as a mod in its current form as it only detects the one nade. (also, if you are the only person using it, there is no need for the array. I have code here for how to track multiple nades using a tag system, if you cannot get this too work.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests