Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 5 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : General Gaming Topics
Category: General Gaming
General chat about gaming and such.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: [CODERS] Making smoother motion?
Nith Sahor~rb
General Member
Since: Dec 23, 2006
Posts: 24
Last: Dec 23, 2006
[view latest posts]
Level 1
Category: General Gaming
Posted: Tuesday, Feb. 4, 2003 09:25 am
Hey,
I recently changed teh functionality of the disruptor so that it creates two mace-spheres (mines) that spiral out first and blow up in 20 seconds (if they haven't already collided with something). The MakeMacesphere function has three arguments which are used to create the missile (self is the address of the parent client entity; direction is the direction the macesphere travels in at the beginning; origin is where the macesphere is created).

The think function, called every hundred milliseconds, changes the direction of the missile by rotating it 9 degrees on the yaw axis (theta[YAW] += 9.0f;) so that in ten seconds it should technicaly have rotated 90 degrees.

Code Sample

#define MACESPHERE_MAGNITUDE 140.0f

//---------------------------------------------------------
void macesphereThink( gentity_t *ent )
//---------------------------------------------------------
{
vec3_t newdir, targetdir,
up={0,0,1}, right;
vec3_t org;
float dot, dot2, dis;
int i;
float vel = ROCKET_VELOCITY;
vec3_t theta, deltanormalized;
float magnitude;

VectorCopy(ent->s.pos.trDelta, deltanormalized);
VectorNormalize(deltanormalized);
vectoangles(deltanormalized, theta);

theta[YAW] += 9.0f;

AngleVectors(theta, deltanormalized, NULL, NULL);

VectorCopy(deltanormalized, ent->movedir);
VectorScale(deltanormalized, MACESPHERE_MAGNITUDE, ent->s.pos.trDelta);

ent->nextthink = level.time + ROCKET_ALT_THINK_TIME; // Nothing at all spectacular happened, continue.
return;
}

//---------------------------------------------------------
void MakeMacesphere( gentity_t *ent, vec3_t origin, vec3_t direction)
//---------------------------------------------------------
{
int damage = ROCKET_DAMAGE;
int dif = 0;
float rTime;
gentity_t *missile;

missile = CreateMissile( origin, direction, IRONDOOM_MAGNITUDE, 10000, ent, qfalse );

missile->timestamp = level.time;
missile->think = macesphereThink;
missile->nextthink = level.time + ROCKET_ALT_THINK_TIME;

missile->classname = "rocket_proj";
missile->s.weapon = WP_ROCKET_LAUNCHER;

VectorSet( missile->r.maxs, 3, 3, 3);
VectorScale( missile->r.maxs, -1, missile->r.mins );

missile->damage = damage;
missile->dflags = DAMAGE_DEATH_KNOCKBACK;

missile->methodOfDeath = MOD_ROCKET;
missile->splashMethodOfDeath = MOD_ROCKET_SPLASH;

missile->clipmask = MASK_SHOT; // | CONTENTS_LIGHTSABER;

if (Q_irand(1,10) > 7)
{
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
}

missile->splashDamage = ROCKET_SPLASH_DAMAGE;
missile->splashRadius = ROCKET_SPLASH_RADIUS;

// we don't want it to ever bounce
missile->bounceCount = 0;
}


While the code does work (the missiles do travel in a curve) they are slightly... choppy. Is there a way of making them travel more smoothly? It's not the final code of course (ROCKET_SPLASH_DAMAGE will be replaced by my own values) - it's based on the rocket launcher code, so I'm puzzled why it doesn't work (the RL's homing missiles are much smoother than my macespheres). In the RL think code one of the lines is
ent->s.pos.trTime = level.time;
and I think it could have something to do with it but I'm not sure...

Thanks for your time,
Nith Sahor.
Share |
BinaryC~rb
General Member
Since: Dec 23, 2006
Posts: 20
Last: Dec 23, 2006
[view latest posts]
Level 1
Category: General Gaming
Posted: Tuesday, Feb. 4, 2003 04:08 pm
There are 2 problems here.  You never set the TR type, so it's defaulting to TR_STATIONARY.  This means client side prediction (and lerping) is not performed.  Basically you have a stationary object that keeps moving!  You should probably make it TR_LINEAR (since I doubt it speeds up or slows down as it's traveling).  The second problem is, like you said, you aren't setting trTime.  That's not a huge problem right now because it's stationary, so trTime is ignored, but it will be used when you change it to TR_LINEAR.

Quick background on the tr stuff:
>trBase needs to be set to the 'base' ie, the start position of the object, or the last known 'valid' position.
>trTime needs to be set to the level time in which the trBase was set.  That means every time you update trBase, you need to set trTime=level.time
>trDelta specifies basically how fast the object is moving, and the direction it's moving in.  The way it works is it multiplies trDelta by the difference between trTime and the current time, then adds it to the base.  So for example, if trTime is 4 and level.time is 10, then it multiplies trDelta by 6 and adds it to trBase.
>trType specifies the type of moving object this is.
>trDuration specifies how long the object moves.  This is mostly just used for doors that move a bit, then stop.  For most other things, you can set it to 0.

You can actually add your own trTypes.  I had to add TR_BALL for QPong to look even halfway decent.
Share |
Nith Sahor~rb
General Member
Since: Dec 23, 2006
Posts: 24
Last: Dec 23, 2006
[view latest posts]
Level 1
Category: General Gaming
Posted: Wednesday, Feb. 5, 2003 08:14 am
Thanks for the reply. I tried out what you said, and I found out that when CreateMissile is called (this is in Jedi Knight 2 by the way) trType is already set (to TR_LINEAR - I re-set it anyway, just to be sure).

I tried setting trTime to level.time at the end of the think function, but the missiles would move for a tenth of a second, then start at their beginning position. I tried some other stuff, can't remember now, but after some looking around in the RL's think code, I noticed it had

VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );

which my code didn't have. So I added it and now it is much better :) Thanks!
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : General Gaming Topics : General Gaming

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»