Jump to content

Home

Dropping the Saber in MP


ZeR0SyN

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. =\

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 =\

Link to comment
Share on other sites

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 :))

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

I have this functionality working in my upcoming mod (Shameless Plug: http://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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...