Event setting var in cgame module

Locked
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Event setting var in cgame module

Post by Rawing »

I'm really, really, really confused. I'm trying to set a var in the cgame module everytime you die...
player_die:

Code: Select all

PM_AddEvent(EV_RESET_ZOOM);
CG_EntityEvent:

Code: Select all

case EV_RESET_ZOOM:
		DEBUGNAME("EV_RESET_ZOOM");
		if ( es->number == cg.snap->ps.clientNum ) {
			cg.zoomed= qfalse;
		}
		break;
Result: Everytime you kill someone or die yourself, zoom will be reset. What's bugging me is, it's the same as EV_NOAMMO:

Code: Select all

PM_AddEvent( EV_NOAMMO );

Code: Select all

	case EV_NOAMMO:
		DEBUGNAME("EV_NOAMMO");
//		trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound );
		if ( es->number == cg.snap->ps.clientNum ) {
			CG_OutOfAmmoChange();
		}
		break;
And the outofammochange obviously works :confused:
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Event setting var in cgame module

Post by ^misantropia^ »

Simple test to check if the event is received: set cg.zoomed = qfalse unconditionally.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Event setting var in cgame module

Post by Rawing »

Uh, the problem is, it IS set to qfalse... it should be set to false everytime you die but not if you kill someone.
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Event setting var in cgame module

Post by ^misantropia^ »

Then I'm not quite getting the problem, I fear. How and what are you trying to accomplish and what is bugging it?
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Event setting var in cgame module

Post by Rawing »

Okay, okay:
When you die, cg.zoomed should be set to qfalse. So I've placed the PM_AddEvent line into player_die, and cgame should set cg.zoomed to qfalse.
The problem:
If you kill someone, player_die is run... and your zoom is reset though YOU didn't die. That's why there's the

Code: Select all

if ( es->number == cg.snap->ps.clientNum )
line, but it doesn't seem to do anything, which is strange coz it's the same as with CG_NoAmmoChange... (CG_NoAmmoChange obviously changes YOUR weapon and not someone else's...)
[color=#FF0000]/callvote kick all_enemies[/color]
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Event setting var in cgame module

Post by Rawing »

Code: Select all

G_AddEvent(self, EV_RESET_ZOOM, 0);

Code: Select all

case EV_RESET_ZOOM:
		DEBUGNAME("EV_RESET_ZOOM");
		//if ( cent->currentState.number == cg.snap->ps.clientNum )
			cg.zoomed= qfalse;
		break;
doesn't work, too :offended:
[color=#FF0000]/callvote kick all_enemies[/color]
ZTurtleMan
Posts: 1
Joined: Tue Sep 01, 2009 8:35 pm

Re: Event setting var in cgame module

Post by ZTurtleMan »

By adding the below code, cgame will zoom out when the active player dies. EV_OBITUARY is sent everytime a player dies so clients can show death messages.

Code: Select all

	case EV_OBITUARY:
		DEBUGNAME("EV_OBITUARY");
+		// check for death of the current clientNum
+		if ( es->otherEntityNum == cg.snap->ps.clientNum ) {
+			// if zoomed in, zoom out
+			CG_ZoomUp_f();
+		}
		CG_Obituary( es );
		break;
The above code was written by myself and may be used in the GPL or Q3 SDK source code.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Event setting var in cgame module

Post by Rawing »

That did it thanks!
[color=#FF0000]/callvote kick all_enemies[/color]
Locked