Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Sfl_stick_on_impact

Page: 1 of 1
 keshire
12-05-2003, 8:27 AM
#1
//#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, 8:46 AM
#2
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, 9:38 AM
#3
I beleive in JK2 the saber spinning was controlled client side.
 keshire
12-06-2003, 9:46 AM
#4
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, 10:22 AM
#5
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, 10:28 AM
#6
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, 11:50 AM
#7
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, 1:27 PM
#8
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, 6:10 PM
#9
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, 4:29 AM
#10
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, 5:45 AM
#11
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, 5:58 AM
#12
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, 8:24 AM
#13
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, 8:26 AM
#14
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, 4:46 AM
#15
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, 6:34 AM
#16
 razorace
12-13-2003, 6:50 AM
#17
Looking pretty good, but your screenies are tiny. It's very hard to see what is going on.
 keshire
12-13-2003, 6:53 AM
#18
Photo Island resizes them.

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

USERNAME=keshire
Page: 1 of 1