PDA

View Full Version : Sfl_stick_on_impact


keshire
12-05-2003, 07:27 AM
//#define SFL_STICK_ON_IMPACT (1<<?)//if set, the saber will stick in the wall when thrown and hits solid architecture (good for sabers that are meant to be thrown).

If I wanted to code this back in how would I go about doing it?


entityStates?

entityState_t->eType and eFlags

ET_MISSLE //To turn saber into missle? Does saberInFlight already do this?
EF_MISSILE_STICK //when touches wall?

and maybe EV_MISSILE_STICK //for a nice sound.

Or am I simplifying it too much?

keshire
12-06-2003, 07:46 AM
Ok this is what I have so far.

if (saberHitWall && !(self->client->saber[rSaberNum].saberFlags & SFL_BOUNCE_ON_WALLS) && (self->client->ps.saberInFlight))

{
saberent->s.eFlags = EF_MISSILE_STICK;
}

So it sticks to the wall. Which is what I want. But it also keeps spinning. And never returns. The returning part I think I can solve. But How do I keep it from spinning?

After I get this maybe I can reinstate the .sab flag.

razorace
12-06-2003, 08:38 AM
I beleive in JK2 the saber spinning was controlled client side.

keshire
12-06-2003, 08:46 AM
I've seen references to it.
Also sabermoveback does it without the spin. As long as the return damage flag isn't set. But I don't think thats what I'm looking for. I want it stationary. Preferably with z axis pointed towards wall.

if ( saberent->s.saberInFlight )

{//spinning
BG_EvaluateTrajectory( &saberEnt->s.pos, level.time+50, saberOrg );

BG_EvaluateTrajectory( &saberEnt->s.apos, level.time+50, saberAngles );
}

razorace
12-06-2003, 09:22 AM
My best guess would be set the model orientation to be perpendicular to the surface you impacted against (I think that data is in the trace structure.) Also, you'll need to dig thru the cgame code, find the saber spinning code and make it turn off for your SFL_STICK_ON_IMPACT flag.

keshire
12-06-2003, 09:28 AM
Here we go this was what I was looking for. And yes I've tracked down the "companion code" in the cgame.

void WP_SaberPositionUpdate( gentity_t *self, usercmd_t *ucmd )
{ //rww - keep the saber position as updated as possible on the server so that we can try to do realistic-looking contact stuff
//Note that this function also does the majority of working in maintaining the server g2 client instance (updating angles/anims/etc)

keshire
12-09-2003, 10:50 AM
Ok. It sticks, Its pointed in the right direction, it stops spinning (also made the regular throw vertical instead of horizontal), it also uses the STICK_ON_IMPACT flag.

One problem, the saber hilt explodes because it only works with ET_MISSILE.

Can I reroute the ET_GENERAL flag to use EF_MISSILE_STICK?

any other suggestions?



Here's my problem

void G_RunStuckMissile( gentity_t *ent )
{
if ( ent->takedamage )
{
if ( ent->s.groundEntityNum >= 0 && ent->s.groundEntityNum < ENTITYNUM_WORLD )
{
gentity_t *other = &g_entities[ent->s.groundEntityNum];

if ( (!VectorCompare( vec3_origin, other->s.pos.trDelta ) && other->s.pos.trType != TR_STATIONARY) ||
(!VectorCompare( vec3_origin, other->s.apos.trDelta ) && other->s.apos.trType != TR_STATIONARY) )
{//thing I stuck to is moving or rotating now, kill me
G_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH );
return;
}
}
}
// check think function
G_RunThink( ent );
}

Wudan
12-09-2003, 12:27 PM
What happens if you comment out the
"G_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH );"

I don't see why you can't change the entity flags, so that it's not an ET_MISSILE.

razorace
12-09-2003, 05:10 PM
If you want something to stick to moving entity like that, you're going to have a function that quickly updates the missile's position in addition to preventing it from dieing.

keshire
12-10-2003, 03:29 AM
Well it was dieing while connected to a wall. I think my problem is that I never declared it as a stationary. So technically the saber itself is still moving. Funny thing is as I was scouring the source for my answer I came upon both the lasertrap and the detpack. Which use different code for each. Plus there's code that causes anything stuck to players to explode to. Time to do some experimenting tonight.

keshire
12-10-2003, 04:45 AM
Ok here's what I have. And I figure its beta.

if (saberHitWall && (self->client->saber[rSaberNum].saberFlags & SFL_STICK_ON_IMPACT))

{
saberent->s.eType = ET_MISSILE; //ET_MISSILE Makes it self destruct, ET_GENERAL doesn't work. Keshire

saberent->s.eFlags = EF_MISSILE_STICK;

saberent->s.eType = ET_GENERAL; //Look at me, After I stick I revert to a general again!

WP_SaberAddG2Model( saberent, self->client->saber[0].model, self->client->saber[0].skin );

saberent->s.modelGhoul2 = 127;

VectorClear( saberent->s.apos.trDelta );
VectorClear( saberent->s.pos.trDelta );

saberent->s.apos.trType = TR_STATIONARY;
saberent->s.pos.trType = TR_STATIONARY;


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

VectorClear( saberent->s.apos.trDelta );
VectorClear( saberent->s.pos.trDelta );

VectorCopy( saberent->s.angles, saberent->r.currentAngles );
VectorCopy( saberent->s.angles, saberent->s.apos.trBase );

}


Behavior:

Stays stuck until short amount of time, or longer if throw button is held down.

Small amount of movement by guiding saber.

Won't stick unless directly facing wall. Also kinda glitchy in certain stances.

Doesn't stick at all if using dual, unless one is off.

keshire
12-12-2003, 04:58 AM
saberent->r.svFlags &= ~(SVF_NOCLIENT);
saberent->s.eType = ET_MISSILE;
VectorClear( saberent->s.apos.trDelta );
saberent->s.apos.trType = TR_STATIONARY;
saberent->s.pos.trType = TR_STATIONARY;
VectorCopy( saberent->r.currentOrigin, saberent->s.origin );
VectorCopy( saberent->r.currentOrigin, saberent->s.pos.trBase );
VectorClear( saberent->s.pos.trDelta );
VectorClear( saberent->s.apos.trDelta );
VectorCopy( saberent->s.angles, saberent->r.currentAngles );
VectorCopy( saberent->s.angles, saberent->s.apos.trBase );
WP_SaberAddG2Model( saberent, self->client->saber[0].model, self->client->saber[0].skin );
saberent->s.modelGhoul2 = 127;
saberent->parent = self;
saberent->s.eFlags = EF_MISSILE_STICK;
self->client->ps.saberEntityState = 1;
trap_LinkEntity(saberent);
saberent->s.eType = ET_GENERAL;
}

Does this all look correct? I pulled most of it from the detpack code.

It does a jabbing motion at the wall. Going through the code, I think its hitting a wall turning to missile, sticking, turning to general (negating the stick), trying to head back to the owner but saying its still hitting a wall. All until the max throw time (6 seconds) is hit.

How do I make the stick permanent and turn off the saber's owner?

Would all this work better as a touch or thinking function?

Maybe add an altered MISSILE_STICK flag and code specific to the saber?

any suggestions?

razorace
12-12-2003, 07:24 AM
It looks like you're making progress. My next move would be to check out the saber throw code because, like you stated, it sounds like some other code is trying to make the entity move somewhere.

keshire
12-12-2003, 07:26 AM
Yep. I'm moving it over to the saberthrow touch.

It has pointers to let me flip the saber around the plane it hits.

But invalidates my saber flag.

Give and take.

keshire
12-13-2003, 03:46 AM
Ok I streamlined my code.

Made the neccessary changes to keep the sabermoveback from interfering. So it stays put. Only problem is it stays put until you manually remove it from the wall.

It also reorients itself to point at the person throwing it if they move. I'm sure this is sabermoveback at work again but I'll pinpoint it and correct it.

also the saberknockdown is doing some interfering too if you turn it off while stuck.

I'll figure out a way to re-implement the saber flag before I release it but at the moment I'm definately happy with it.

keshire
12-13-2003, 05:34 AM
Hit wall, walk around it. It won't come back unless manually grabbed.

http://mediaservice.photoisland.com/auction/Dec/200312121295422724517322.jpg

http://mediaservice.photoisland.com/auction/Dec/200312124911928966278922.jpg

http://mediaservice.photoisland.com/auction/Dec/200312121327384883136469.jpg

Thrown high, ran up wall grabbing it. I'm especially proud of these.

http://mediaservice.photoisland.com/auction/Dec/200312121253800910685928.jpg

http://mediaservice.photoisland.com/auction/Dec/200312123170486087685237.jpg

http://mediaservice.photoisland.com/auction/Dec/200312124926454470993892.jpg

razorace
12-13-2003, 05:50 AM
Looking pretty good, but your screenies are tiny. It's very hard to see what is going on.

keshire
12-13-2003, 05:53 AM
Photo Island resizes them.

http://www.photoisland.com/servlet/GuestLogin?

USERNAME=keshire