PDA

View Full Version : Dropping the Saber in MP


ZeR0SyN
06-20-2002, 10:17 AM
I saw this thread a while ago, but i no longer see it. =(

Anyone i was going through the source code and i found something intresting.

MakeDeadSaber();

This is what you see when you die and your saber flys out of your hand.

Perhaps you could use this when the saber hits a wall or another players saber. Only instead of spawning a dead saber, you could spawn a World Object Saber (kinda like in Jedi Master Gametype) Something you could pick up, or possible something another player could pick up. o_O

I dunno if that'd work. I sure dont know how you;d do it, it was just an idea. Any smart coders thing that its a step in the right direction.

Kranckor
06-21-2002, 10:18 AM
Do you mean you wish someone would

ZeR0SyN
06-21-2002, 12:34 PM
Heres the code that is used when you die when your saber is in the middle of a throw:

oid MakeDeadSaber(gentity_t *ent)
{ //spawn a "dead" saber entity here so it looks like the saber fell out of the air.
//This entity will remove itself after a very short time period.
vec3_t startorg;
vec3_t startang;
gentity_t *saberent;

if (g_gametype.integer == GT_JEDIMASTER)
{ //never spawn a dead saber in JM, because the only saber on the level is really a world object
G_Sound(ent, CHAN_AUTO, saberOffSound);
return;
}

saberent = G_Spawn();

VectorCopy(ent->r.currentOrigin, startorg);
VectorCopy(ent->r.currentAngles, startang);

saberent->classname = "deadsaber";

saberent->r.svFlags = SVF_USE_CURRENT_ORIGIN;
saberent->r.ownerNum = ent->s.number;

saberent->clipmask = MASK_PLAYERSOLID;
saberent->r.contents = CONTENTS_TRIGGER;//0;

VectorSet( saberent->r.mins, -3.0f, -3.0f, -3.0f );
VectorSet( saberent->r.maxs, 3.0f, 3.0f, 3.0f );

saberent->touch = SaberBounceSound;

saberent->think = DeadSaberThink;
saberent->nextthink = level.time;

VectorCopy(startorg, saberent->s.pos.trBase);
VectorCopy(startang, saberent->s.apos.trBase);

VectorCopy(startorg, saberent->s.origin);
VectorCopy(startang, saberent->s.angles);

VectorCopy(startorg, saberent->r.currentOrigin);
VectorCopy(startang, saberent->r.currentAngles);

saberent->s.apos.trType = TR_GRAVITY;
saberent->s.apos.trDelta[0] = Q_irand(200, 800);
saberent->s.apos.trDelta[1] = Q_irand(200, 800);
saberent->s.apos.trDelta[2] = Q_irand(200, 800);
saberent->s.apos.trTime = level.time-50;

saberent->s.pos.trType = TR_GRAVITY;
saberent->s.pos.trTime = level.time-50;
saberent->s.eFlags = EF_BOUNCE_HALF;
saberent->s.modelindex = G_ModelIndex("models/weapons2/saber/saber_w.glm");
saberent->s.modelGhoul2 = 1;
saberent->s.g2radius = 20;

saberent->s.eType = ET_MISSILE;
saberent->s.weapon = WP_SABER;

saberent->speed = level.time + 4000;

saberent->bounceCount = 12;

//fall off in the direction the real saber was headed
VectorCopy(ent->s.pos.trDelta, saberent->s.pos.trDelta);

saberMoveBack(saberent, qtrue);
saberent->s.pos.trType = TR_GRAVITY;

trap_LinkEntity(saberent);

}


I have edited my code for the saber throw, so instead of the saber comming back to you (after the throw) it instead does MakeDeadSaber, and the saber dropps the ground.

Perhaps if MakeDeadSaber was edited in such a way that it dropped an actually world object saber, everytime you dropped your saber (in death or whatnot) it would be on the ground for someone else to pick up.

anyone want to help out?

PS: I think if you used some sort of deriviate of how the saber returns to you in the first place when you throw it (BUTTON_ATTACK to trigger a return) the returing of the saber could be solved as well.

Subject452
06-21-2002, 05:03 PM
Just a lil side info: MakeDeadSaber is used when you've thrown the saber and someone kills you, then the saber just drops to the floor.

ZeR0SyN
06-22-2002, 12:22 AM
sorry i was a little tired when i wrote that reply.

What i was trying to say is i got a saber to drop without dying. I edited my code so it drops when it touches a wall . (just to test it)

C_T
06-22-2002, 09:52 AM
Zero when it touches a wall and it does the makedeadsaber(bla) you can't get the saber back right??

ZeR0SyN
06-22-2002, 10:09 AM
Nope. It just falls to teh ground, and usually disapears after 4 seconds... i have the time however so it disappears after a minute.

I am still working on using a similar function to spawn a real saber when it hits a wall or is de-activated (like in SP). If i can get that to work i think i can get it to come back, but we'll have to wait and see. =\

els.DarkLord
06-24-2002, 12:34 AM
ZeR0SyN , you said you had the 'time'. Do you mean you know how to shorten the amount of time it would take for a saber to respawn into the players hand after he looses it 8through the saber throw bug)?

Anyways, if you might have *any* idea how to solve my problem:
http://www.lucasforums.com/showthread.php?s=&threadid=62688

I'd be really happy to hear from you.

remark 666
06-24-2002, 01:34 AM
doesn't the attack button make the saber comeback in SP ?? shouldn't it do the same ?? maybe drop the saber and make it comeback and look at the code, maybe that will do something

sure sounds like a cool idea though, drop the saber....run around and comeback and pick it up (or if the opponents hit is hard enough it'll knock the saber out of your hand and then you can just pull it towards you, thus giving your opponent time to saber your head off) (have you tried force pull on the droped saber ?? pull usually retreats all the objects)

good luck, sure is worth the try


PS. this might be cool if other players can pick the saber (and later in the future someone will make the duel saber mode) so when the person picks up the saber he/she will be able to use both of them :D but I'm draging this too far now

ZeR0SyN
06-24-2002, 05:23 AM
I am currently working on something that will allow the saber to come back. Later on i will post the code im using, if it works.

If it doesnt work, then i will post my 2nd idea and hopefully get some feedback =D

els.DarkLord
06-24-2002, 05:49 AM
Now if *that* works (making saber droppable AND let them comeback) and if this might fix my issues as well you're my new hero.... really...

ZeR0SyN
06-24-2002, 10:05 AM
Im really close. My first idea didnt work, but perhaps someone could help me on my new idea.

First what i have been been able to do:

I Managed to get the saber to drop. As in, the code ive been testing on, When a saber is thrown and the Alt_attack realased after 500ms, a saber will drop. I commented out the part of the code where the animation of the saber returning. What i wanted to do was something like this:

when the "throw" is stopped (by letting off alt_attack) a saber drops. that saber (in my test code) remians in game for a minute.

What im trying to do this set up a loop... heres what i've tried:

for(i = 0; i >= level.time + 12000; i ++){
if (saberOwn->client->buttons & BUTTON_ATTACK) {
thrownSaberTouch(saberent, saberent, NULL); } }

goto runMin ;

Basically (what im trying to do, mind you i did this WAY late at night and havent looked at it for a day) is IF the Button_attack is pressed, RETURN the saber (finish the throw, show the saber comming back animation) If you dont press the button the loop will conitue till you do press the button, or the 12000 ms is finished, the it'd just return.

If this doesnt work, i mthinking about Once the saber drops, Remove the saber from your inventory. Once you call it back, add it to your inventory.

Im not sure which is best, ive been looking and playing in SP, and i think that once we get something like this to work, i acn implement it on different things (like if you deactive your saber and let it drop). Im even planning on letting the asber return at a CERTAIN DISTANCE, so you dont grab it from way across the map or some stuipid **** like that =P

Help me out, i know C but i dont all the workings of Q3 =\

remark 666
06-24-2002, 11:22 AM
you should try the polycount forums and ask them few questions, they should know almost anything about the Q3 engine :) http://dynamic.gamespy.com/~polycount/ubb/Ultimate.cgi?action=intro&BypassCookie=true

I wish you luck bud, sure would be great t osee something like this done :) (maybe ask around few coding threads, maybe ask the JK2 or even the Raven staff :))

ZeR0SyN
06-26-2002, 01:40 AM
<looks around>

*bump*

Dest
06-26-2002, 11:47 AM
Ok I've had some success with this problem, I've only had the sdk 2 days so its not a very pollished way of doing it. Basically the problem you are having with your current way is that by calling make dead saber you kill the saber and free its entity. So instead what you have to do is basically have to do is hide your saber, spawn a saber to fall to the ground, wait for a little bit, and then have your saber come back. There is probably some way to just have your actual saber fall to the ground but I havent found it yet. Here is the code I have. I basically combined the make dead saber and the thrownSaberTouch code. Rember this is just a hack job so I'm sure better things can be done, but it does work.



////Added this function to cause throws to be thrown down when blocked
void blockedSaberTouch (gentity_t *saberent, gentity_t *other, trace_t *trace)
{

vec3_t startorg;
vec3_t startang;
gentity_t *saberentb;
gentity_t *hitEnt = other;
int waitTime;
int grav1;
int grav2;
int grav3;

waitTime=Q_irand(1000, 6000);
grav1=Q_irand(200, 800);
grav2=Q_irand(200, 800);
grav3=Q_irand(200, 800);

if (g_gametype.integer == GT_JEDIMASTER)
{ //never spawn a dead saber in JM, because the only saber on the level is really a world object
G_Sound(saberent, CHAN_AUTO, saberOffSound);
return;
}

if (other && other->s.number == saberent->r.ownerNum)
{
return;
}

//this stuff spawns a dead saber
saberentb = G_Spawn();

VectorCopy(saberent->r.currentOrigin, startorg);
VectorCopy(saberent->r.currentAngles, startang);

saberentb->classname = "deadsaber";

saberentb->r.svFlags = SVF_USE_CURRENT_ORIGIN;
saberentb->r.ownerNum = saberent->s.number;

saberentb->clipmask = MASK_PLAYERSOLID;
saberentb->r.contents = CONTENTS_TRIGGER;//0;

VectorSet( saberentb->r.mins, -3.0f, -3.0f, -3.0f );
VectorSet( saberentb->r.maxs, 3.0f, 3.0f, 3.0f );

saberentb->touch = SaberBounceSound;

saberentb->think = DeadSaberThink;
//makes the spawned saber last for the wait time
saberentb->nextthink = level.time + waitTime;

VectorCopy(startorg, saberentb->s.pos.trBase);
VectorCopy(startang, saberentb->s.apos.trBase);

VectorCopy(startorg, saberentb->s.origin);
VectorCopy(startang, saberentb->s.angles);

VectorCopy(startorg, saberentb->r.currentOrigin);
VectorCopy(startang, saberentb->r.currentAngles);

saberentb->s.apos.trType = TR_GRAVITY;
saberentb->s.apos.trDelta[0] = grav1;
saberentb->s.apos.trDelta[1] = grav2;
saberentb->s.apos.trDelta[2] = grav3;
saberentb->s.apos.trTime = level.time-50;

saberentb->s.pos.trType = TR_GRAVITY;
saberentb->s.pos.trTime = level.time-50;
saberentb->s.eFlags = EF_BOUNCE_HALF;
saberentb->s.modelindex = G_ModelIndex("models/weapons2/saber/saber_w.glm");
saberentb->s.modelGhoul2 = 1;
saberentb->s.g2radius = 20;

saberentb->s.eType = ET_MISSILE;
saberentb->s.weapon = WP_SABER;

saberentb->speed = level.time;

saberentb->bounceCount = 12;

//fall off in the direction the real saber was headed
VectorCopy(saberent->s.pos.trDelta, saberentb->s.pos.trDelta);

saberMoveBack(saberentb, qtrue);
saberentb->s.pos.trType = TR_GRAVITY;

trap_LinkEntity(saberentb);



//this stuff makes your actual saber fall to the ground much like the fake dead saber
VectorClear(saberent->s.pos.trDelta);
saberent->s.pos.trType = TR_GRAVITY;
saberent->s.pos.trTime = level.time-50;
saberent->s.eFlags = EF_BOUNCE_HALF;
saberent->bounceCount = 12;

saberent->s.apos.trType = TR_GRAVITY;////TR_LINEAR;
saberent->s.apos.trDelta[0] = grav1;////0;
saberent->s.apos.trDelta[1] = grav2;////800;
saberent->s.apos.trDelta[2] = grav3;////0;
///saberent->s.apos.trTime = level.time-50;

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

//This is the important part.
//it sets the next think state to backtoowner
//and sets the time to a random time between 1 and 6 seconds
//so after that amount of time the saber will come back
//and the fake dead saber may or may not be gone
saberent->think = saberBackToOwner;
saberent->nextthink = level.time + waitTime;

if (other && other->r.ownerNum < MAX_CLIENTS &&
(other->r.contents & CONTENTS_LIGHTSABER) &&
g_entities[other->r.ownerNum].client &&
g_entities[other->r.ownerNum].inuse)
{
hitEnt = &g_entities[other->r.ownerNum];
}

// CheckThrownSaberDamaged(saberent, &g_entities[saberent->r.ownerNum], hitEnt, 256, 0);

saberent->speed = 0;
}

I have it so that the saber only gets thrown to the ground when it is blocked by someone else so I replaced one of the calls to thrownSaberTouch with this function.
edit: updated the code

ZeR0SyN
06-27-2002, 02:20 AM
I havent' been working on the code very often now, but we've all come to the same impass : How do we get the saber to come back?

I was thinking of doing something similar to saber throw. Im gonna hack around and see what i can do, but im figuring if i look at the saber throw code i can figure out how to return the saber.

Maybe when the saber falls, you can hide the saber. When you get it back, you can un-hide it... that seems like the best idea thus far.

I'll be working on it later tonight, after i get out of work.

Dest
06-27-2002, 02:34 AM
um when I posted my code I meant it worked 100%... the saber comes back and everything. You just need to set the next think state to sabercomeback or whatever it is and then set the next think time to whenever you want it to come back...

remark 666
06-27-2002, 10:35 AM
ohh, wow, it works ?? make a .pk3 or something so we can all try it out :)

Dest
06-27-2002, 10:38 AM
I will as soon as I fix one last bug... sometimes a droped saber entity gets spawned and the actual saber doesnt drop to the ground and its very strange.

That and I would really also like to have the actual non nerfed dammage values for backstabs. I don't like how all the mods nerf stuff.

ZeR0SyN
06-27-2002, 11:50 AM
I put that stub in my code. I cant get it to work, perhaps i messed up the parameters for saberblocktouch()

I'll look into it

ZeR0SyN
06-27-2002, 01:57 PM
G_Sound(ent, CHAN_AUTO, saberOffSound);

I added that to your fucntion so it does the saberoff sound.

remark 666
06-28-2002, 03:25 PM
so what you're saying is ... we throw our saber....press a button and it drops ?? then press another button and it comes back to us ?? or we throw the saber, it gets too far so it drops ? and then we press a button and it comes back ?? I'm a little confused, maybe a step by step example would do :)

ZeR0SyN
06-28-2002, 11:08 PM
Right now what we have is this:

When you throw a saber and it is blocked, it drops and automatically comes back. We havent finished it so it comes back by pressing a button.

BTW, since we got it to drop with being blocked, im sure we could implement it in different ways, not just that one.

Still working on it, but my time is limited this week since the fourth of july is comming up.

Veregon
06-28-2002, 11:59 PM
I have this functionality working in my upcoming mod (Shameless Plug: www.styleoversubstance.net). I'm not on my machine with my code base right now but here's a quick summary of how I accomplished it.

In the function that checks if a thrown saber can be blocked I added in code that if the saber is blocked there is a random chance of it falling to the floor. (Obviously for testing purposes I made that chance 100%). If the saber is to fall to the floor I set the saber's trType to TR_GRAVITY, set the flag for EF_BOUNCE_HALF, and most of the other settings that are set on the entity spawned in MakeDeadSaber(). So now our real saber will bounce down to the ground. I had to set bouncecount to -5 (otherwise it would call FreeEntity on itself once bouncecount hit 0, -5 is used for items that should be able to bounce forever), and also had to do a little hack in the touch_triggers function (I don't remember the name) so that if the owner of the saber touches it it's returned to him. When knocking down the saber I set the think function to DroppedSaberThink, a function I made which simply checks for the saber owner's death, disconnection, or a press of the attack button. If the attack button is pressed we call SaberTouch which starts the saber back to the owner.

There are some other little hacks I did, I used one of the variables that won't be used in my mod to describe the state of the thrown saber. It marks when the saber has been knocked down and when a dropped saber is returning. This is used to set the torso animation correctly when the saber falls (don't want the Jedi running with his hand out the whole time the saber is on the ground) and to insure the saber flying back doesn't do damage to anyone (since the blade is sheathed).

If you guys get really stuck on this let me know and I'll try to explain in more detail from my computer where I can look at my code.

els.DarkLord
06-29-2002, 05:05 AM
You seem to know the saber throw code and what it depends on very well... maybe you could help in our problem over here....
http://www.lucasforums.com/showthread.php?s=&postid=652552#post652552
http://www.lucasforums.com/showthread.php?s=&postid=652574#post652574 ??

Would be nice, if someone knew anything how to fix this :(

Sam
07-01-2002, 02:44 PM
Im confused will this mod let you drop your saber in multi player like sp

Dest
07-02-2002, 12:16 PM
I changed my code to work in the same way as veregons but now I cant get the saber to turn off when it hits the ground. Even when I have it turn off it just turns on again as soon as you hit attack. I even changed it so it wouldnt do that but it still did it! Is there like something on the client side that does the saber pull out sound and animation?

ZeR0SyN
07-02-2002, 11:49 PM
I'll look. I have less and less time to work on this, but i think i'll have time tonight.

remark 666
07-06-2002, 03:33 PM
any new news ?

Dest
07-06-2002, 03:42 PM
yes, its very hard to get the thing to turn off because of client side prediction :)

rut-wa jodar
07-06-2002, 05:55 PM
Originally posted by Veregon
I have this functionality working in my upcoming mod (Shameless Plug: www.styleoversubstance.net). I'm not on my machine with my code base right now but here's a quick summary of how I accomplished it.

In the function that checks if a thrown saber can be blocked I added in code that if the saber is blocked there is a random chance of it falling to the floor. (Obviously for testing purposes I made that chance 100%). If the saber is to fall to the floor I set the saber's trType to TR_GRAVITY, set the flag for EF_BOUNCE_HALF, and most of the other settings that are set on the entity spawned in MakeDeadSaber(). So now our real saber will bounce down to the ground. I had to set bouncecount to -5 (otherwise it would call FreeEntity on itself once bouncecount hit 0, -5 is used for items that should be able to bounce forever), and also had to do a little hack in the touch_triggers function (I don't remember the name) so that if the owner of the saber touches it it's returned to him. When knocking down the saber I set the think function to DroppedSaberThink, a function I made which simply checks for the saber owner's death, disconnection, or a press of the attack button. If the attack button is pressed we call SaberTouch which starts the saber back to the owner.

There are some other little hacks I did, I used one of the variables that won't be used in my mod to describe the state of the thrown saber. It marks when the saber has been knocked down and when a dropped saber is returning. This is used to set the torso animation correctly when the saber falls (don't want the Jedi running with his hand out the whole time the saber is on the ground) and to insure the saber flying back doesn't do damage to anyone (since the blade is sheathed).

If you guys get really stuck on this let me know and I'll try to explain in more detail from my computer where I can look at my code.

I hope this mod gets done because too many promising looking mods + TC`s get abandoned halfway through :(