Adding goomba damage


(*Shadow* Commando) #1

Goomba damage is done like this:

Many thanks to /Demoman/

In g_active.c after

 else 
            damage = 5; // never used 
         VectorSet (dir, 0, 0, 1);

Add this:

			if ( ent->s.groundEntityNum == other->s.number && other->client ) {
				damage = 50;
				G_Damage (other, other, ent, NULL, NULL, damage, 0, MOD_GOOMBA);    
				other->pain_debounce_time = level.time + 200;   // no normal pain sound 
			}else { 
				G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);    
				ent->pain_debounce_time = level.time + 200;   // no normal pain sound 
			} 
			break;

Also in g_active.c
Change this:

   void ClientEvents( gentity_t *ent, int oldEventSequence ) {

Into this:

void ClientEvents( gentity_t *ent, int oldEventSequence, pmove_t *pm ) {

And add the following under:

	vec3_t		dir;
	gentity_t   *other = ent; 
    
	for (i = 0; i < pm->numtouch; i++) { 
		for (j = 0; j < i ; j++) { 
			if (pm->touchents[j] == pm->touchents[i] ) { 
            break; 
			} 
		} 
		if (j != i) { 
			continue;   // duplicated 
		} 
		other = &g_entities[ pm->touchents[i] ]; 
	} 

Also add:

	int			j;

After int i;
And finally change this:

	// execute client events
	if(level.match_pause == PAUSE_NONE) {
		ClientEvents( ent, oldEventSequence );
	}

Into this:

	// execute client events
	if(level.match_pause == PAUSE_NONE) {
		ClientEvents( ent, oldEventSequence, &pm );
	}

Also add MOD_GOOMBA to the following files:
g_combat.c
g_match.c
bg_public.h
g_stats.c (if you want to give xp for it)

And to show a message, in cg_event.c after
case MOD_SATCHEL

		case MOD_GOOMBA:
			message = "experienced death from above by";
			message2 = ".";
			break;

Good luck…


(Demolama) #2

            damage = 50; 

personally I dont like the idea of 50 damage for a short fall… my opinion is it should be removed… then you will give the other player the damage you would normally recieve if you fell


(Downright) #3

Am I miss something?

Where do you declare other? Is it already declared? Was playing around with your code and can’t seem to find it declared. Compiler complains.

Guess I will look into what it should be.

Thanks


(Downright) #4

I haven’t really looked closely but I’m guessing:

g_entity* other;

Should do the trick?


(bacon) #5

Just change the top of the function to this:

void ClientEvents( gentity_t *ent, int oldEventSequence, pmove_t *pm ) {
	int			i, j;
	int			event;
	gclient_t	*client;
	gentity_t	*other;
	int			damage;
	vec3_t		dir;

(Downright) #6

Goomba works fine since i added the g_entity. However, now whenever I fall normally it causes a game crash. Not entirely sure why this might be. Any way you could help me? Hate to sound like such a noob.


(Downright) #7

I bet:
other is coming up NULL when not hitting a person and is therefore causing a crash. Lemme test that. Such a simple error I missed if thats the case


(Downright) #8

Wasn’t a null pointer…its still crashing


(*Shadow* Commando) #9

maybe this will help, this is what i have

void ClientEvents( gentity_t *ent, int oldEventSequence, pmove_t *pm ) { 

	int			i;
	int			j;
	int			event;
	gclient_t	*client;
	int			damage;
	vec3_t		dir;
	gentity_t   *other = ent; 
    
	for (i = 0; i < pm->numtouch; i++) { 
		for (j = 0; j < i ; j++) { 
			if (pm->touchents[j] == pm->touchents[i] ) { 
            break; 
			} 
		} 
		if (j != i) { 
			continue;   // duplicated 
		} 
		other = &g_entities[ pm->touchents[i] ]; 
	} 

Maybe this will help.
I forgot to post 1 line, the line gentity_t *other=ent
I’ve changed it in the code posted before.

I had the same problem aswell. When normal falling the game crashed, this should fix it.


(*Shadow* Commando) #10

Downright, have you been able to finish goomba?
Or do you still have that problem?


(*Shadow* Commando) #11

How can i make goomba work if you do a normal jump. This to make it easier to goomba.