EF_BOUNCE for Player [Ball] [solved]

Locked
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

EF_BOUNCE for Player [Ball] [solved]

Post by Landix »

Hi there,

i want to make my ball a lttle bounce when it hits the ground.

I think the effect is EF_BOUNCE, works for grenades etc...!?

When the the player (Ball) hit the ground where to put exactly the event
EF_BOUNCE to do that?

when he fall to far, he is naturally explode in 6239657,32 tiles. :)

Anybody?

BTW there is a new VID for my MOD here:

http://www.q3geoball.quakeit.de/loads/q3geoball3.wmv
Last edited by Landix on Mon Mar 26, 2007 7:21 pm, edited 1 time in total.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

It don't work quite that way. EF_BOUNCE and its cousin EF_BOUNCE_HALF only apply to missiles.

You might want to take a look at the G_RunMissile() and G_BounceMissile() functions in g_missile.c and integrate some of that code into bg_pmove.c.

Mind you, you can't call those functions from the pmove module directly because they don't exist on the client.

PS: your mod looks like fun. Well done.
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

^misantropia^ wrote:It don't work quite that way. EF_BOUNCE and its cousin EF_BOUNCE_HALF only apply to missiles.

You might want to take a look at the G_RunMissile() and G_BounceMissile() functions in g_missile.c and integrate some of that code into bg_pmove.c.

Mind you, you can't call those functions from the pmove module directly because they don't exist on the client.
Then, you mean this function?:

Code: Select all

	// check for bounce
	if ( !other->takedamage &&
		( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {
		G_BounceMissile( ent, trace );
		G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );
		return;
^misantropia^ wrote: PS: your mod looks like fun. Well done.
Thx, i hope much others think so, too.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Landix wrote:Then, you mean this function?:

Code: Select all

	// check for bounce
	if ( !other->takedamage &&
		( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {
		G_BounceMissile( ent, trace );
		G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );
		return;
Yep, and more specifically the code in G_BounceMissile() that does the actual bouncing.
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

Seems so that i need a more experienced coder then my self, for make some goodies.

I was thinking about "bounce player" then came the thinking about "push boxes".

Something went terrible wrong in my head. :icon28:

I see "push boxes" in the code of ET.

I hope i found someone in the near future for helping me out with that. :icon23:
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

I have tried this!:

Code: Select all

	// calculate the exact velocity on landing
	dist = pm->ps->origin[2] - pml.previous_origin[2];
	vel = pml.previous_velocity[2];
	acc = -pm->ps->gravity;
	//newq3ball
	pm->ps->velocity[2] = -vel;
    //endnew
But now the ball is bouncing all the time and not standing still.


Someone can help me out with the bounce?

I try some things out, but all runs in a disaster.

plz
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Hmm, can't you multiply vel with e.g. 0.9? That'll stop the bouncing over time. Tip: set the velocity explicitly to zero when it nears zero or you'll end up with micro-bouncing (because the number will get smaller and smaller but never zero).
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

pm->ps->velocity[2] = *vel 0.9; //!?

then... How set it to zero after 0.1
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

OkOk i do it this way:

Code: Select all

pm->ps->velocity[2] = -vel * 0.5;
the ball is stopping!

Do i need set it to 0 or not?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Not if the net result works good enough for you, no. Something like the snippet below won't hurt though.

Code: Select all

if (pm->ps->velocity[2] <= 0.001) {
  pm->ps->velocity[2] = 0;
}
Landix
Posts: 123
Joined: Wed Feb 28, 2007 5:57 pm

Post by Landix »

^misantropia^ wrote:Not if the net result works good enough for you, no. Something like the snippet below won't hurt though.

Code: Select all

if (pm->ps->velocity[2] <= 0.001) {
  pm->ps->velocity[2] = 0;
}
Thx a lot i put it in.
Locked