Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Smooth turns...
Smooth turns...
2004-04-20, 1:34 AM #1
Hi!
I've decided to make a Redeemer Mod, making a weapon into a Redeemer from UT. Now, I want it to be as tough to steer as in UT, and I thought I had a solution. I looked at GOLEMs steering missles, and found that he used SetThingVel(), which made it easy to steer. I tried to change that a little and replaced STV for ApplyForce(). Problem was that the projectile sped up too quickly. Anyway I can do what I want without it going totally out of control?

/Edward
Edward's Cognative Hazards
2004-04-20, 7:02 AM #2
Whenever I did any pilotable misles, I always did something like the following...

Code:
Pulse:
	Speed = Speed + INC;
	SetThingVel(THING, Speed);
Stop;


..And of course, you need to add your missle realignment code in there too... The pulse needs to be fairly high, but the higher you set it, the smaller INC needs to be.


------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-20, 7:24 AM #3
I don't wish to increese the speed, I wish to make a projectile as tough to steer as a Redeemer rocket. Have you ever steered a Redeemer rocket before?

/Edward


[This message has been edited by Edward (edited April 20, 2004).]
Edward's Cognative Hazards
2004-04-20, 7:39 AM #4
Yes, and now I know what you mean... Its possible, you just need to, in each pulse, compare your new alignment vector with your old one, do some crazy vector math, and make the alignment change only a certain percentage of the new alignment...

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-20, 9:15 AM #5
*and just when you least expect it*


SetThingVel() is much easier, but ApplyForce() creates a nicer, more realistic effect. This code is taken from MW's pilotmissile.cog:

Code:
#------------------------------------------------------------
speed:	// Apply force to the missile, and slow it down when it turns so much.
	mode=0;
	vec=GetThingVel(missile);
	speed=VectorLen(vec);
	newlvec=Getthinglvec(missile);
	lvecdist=VectorDist(newlvec, oldlvec);
	oldlvec=newlvec;
	if(boostvar)
	{
		if(speed > 0.3 && lvecdist > 0.04) Setthingvel(missile, VectorScale(vec, 0.95));
		ApplyForce(missile, VectorScale(newlvec, 0.11));
	}
	else if(GetPhysicsFlags(player) & 0x10000)
	{
		if(speed > 0.3 && lvecdist > 0.012) Setthingvel(missile, VectorScale(vec, 0.93));
		ApplyForce(missile, VectorScale(newlvec, 0.01));
	}
	else
	{
		if(speed > 0.3 && lvecdist > 0.012) Setthingvel(missile, VectorScale(vec, 0.93));
		ApplyForce(missile, VectorScale(newlvec, 0.07));
	}

Return;
#------------------------------------------------------------



-----

Yeah, I still check the forums now and then... [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited April 20, 2004).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2004-04-20, 9:31 AM #6
Crazy vector math... Hm... Well, I'm no good at math, so I don't know how to change the direction bit by bit, so could you (or someone else) help me figure this. I think I only need the change in the velocity... The look vector I'd like an imediat update on. Here's what I've got so far:
Code:
pulse:
	look = FireProjectile(player, looker, -1, 8, '0 0 0', '0 0 0', 1, 0x0, 0, 0);
	SetThingLook(GetSenderRef(), GetThingLVec(look));
	SetThingVel(GetSenderRef(), VectorScale(GetThingLVec(GetSenderRef()), 1.5));
	ChangeSoundPitch(ch,2,0.1);
	DestroyThing(look);
        sm=CreateThing(smoke, GetSenderRef());
	SetThingVel(sm,VectorSet( (rand()*2.00)-1.00 , (rand()*2.00)-1.00 , (rand()*2.00)-1.00 ));
	SetCameraFocus(1,red);
	SetCameraFocus(0,red);
return;

Something to work from...

/Edward
Edward's Cognative Hazards
2004-04-20, 10:07 AM #7
You were quick SM... Nice that you are still around... And nice piece of code there, only... Not sure how to implement it in my pulse... Tell me... In what mod can I find this MW's pilotmissile.cog? I did a little search in the levels for a MW, but nothing with a missile piloting weapon. And who is MW?

/Edward
Edward's Cognative Hazards
2004-04-21, 1:47 PM #8
MW is something SM created a while back (?) now Edward - it's on one of his links on his web-site (see his sig [http://forums.massassi.net/html/wink.gif]) - all the code's available to download and is certainly worth downloading */ends plug* [http://forums.massassi.net/html/biggrin.gif]

And it's always good to see you SM [http://forums.massassi.net/html/smile.gif] - how's this whole "life" thing treating you? [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2004-04-22, 11:14 AM #9
I finaly tested this missile (took some time to find it since the site had Java and I'm running an old browser), and found it fun... Ready to study this code and see if I can understand it... I know SM provided the part that controls the smooth turns, but I'd liek to look at the rest of the context and see how to put it into my thing...

/Edward
Edward's Cognative Hazards
2004-04-22, 5:08 PM #10
Here's a breakdown of what the speed handler does:

speed=VectorLen(GetThingVel(missile));

Speed stores the speed of the missile in JKU's per second. The length (or magnitude) of a velocity tells us how quickly something is moving regardless of direction.

Code:
newlvec=Getthinglvec(missile);
lvecdist=VectorDist(newlvec, oldlvec);
oldlvec=newlvec;


An 'lvec' or lookvector is just another name for a normalized vector - this kind of vector has a length of one and is used to hold only a direction (check the DM's vector section for a good explanation of vectors - with pictures [http://forums.massassi.net/html/smile.gif]).

newlvec is where the missile is currently looking - we're assuming that the pulse which called speed: has already taken the player's lvec and given it to the missile. lvecdist is how far this missile has turned since the last time speed: was run. VectorDist() subtracts the second vector from the first and then returns the length of that vector.

Lastly, oldlvec is assigned to newlvec so that we can do this calculation again the next time speed: runs. Oldlvec should be initialized before speed is called for the first time.

Code:
if(speed > 0.3 && lvecdist > 0.04) Setthingvel(missile, VectorScale(vec, 0.95));
ApplyForce(missile, VectorScale(newlvec, 0.11));


The if conditions used here are checking to see if the missile is supposed to be traveling faster or slower than normal, but that's extra stuff we don't need.

The if condition here is trying to find out if the missile needs to be slowed down. If the missile is going faster than 0.3 JKUsps (which will be our min turning speed) and lvecdist is greater than 0.04 (which would mean that the player is trying to turn the missile), then the missile will be slowed down by 5% of its speed.

If we didn't have this condition to slow our missile, it would be hard to turn without the missile getting out of control. But whether or not the missile gets slowed down, we'll apply force in the new direction.

Feel free to take whatever parts of the code you want.

Life is good, BTW [http://forums.massassi.net/html/biggrin.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited April 22, 2004).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2004-04-23, 5:11 AM #11
OK, implemented it, and it seems OK, apart from... When I turn the slightest, the missile seems to come to a hault before going to the new direction. Anyway it keeps a 'continueous speed' when turning? Like with the redeemer?

/Edward
Edward's Cognative Hazards
2004-04-23, 9:13 AM #12
You need to adjust the constants used by the if statement: (speed > 0.3 && lvecdist > 0.04). If the missile is slowed down too much, raise the speed constant; if the missile is slowed down for turns that should be insignificant, raise the lvecdist constant.

Can't answer for the redeemer - never used it. [http://forums.massassi.net/html/frown.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2004-04-23, 10:31 AM #13
Thanks for that... I'll need to do alot of experiments before I get it just right.

Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
Can't answer for the redeemer - never used it. [http://forums.massassi.net/html/frown.gif]

</font>


Aw... What a shame... Do you have Unreal Tournament? I could send you a level that is Redeemer Only! Don't have UT at all? I guess I could burn you a copy
"SHH! None of that here!"
Who said that?
"Who do you think? It's me!"
Are you my conscience?
"Eh, yes! I am! We haven't spoken for a while... How have you been?"
Meh, can't complain...

/Edward


[This message has been edited by Edward (edited April 23, 2004).]
Edward's Cognative Hazards

↑ Up to the top!