Quake3World.com Forums
     Programming Discussion
        Event setting var in cgame module


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Event setting var in cgame module

Commander
Commander

Joined: 23 Oct 2007
Posts: 107
PostPosted: 08-20-2009 07:38 PM           Profile Send private message  E-mail  Edit post Reply with quote


I'm really, really, really confused. I'm trying to set a var in the cgame module everytime you die...
player_die:
Code:
PM_AddEvent(EV_RESET_ZOOM);

CG_EntityEvent:
Code:
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:
PM_AddEvent( EV_NOAMMO );

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



_________________
/callvote kick all_enemies


Top
                 

Mentor
Mentor

Joined: 12 Mar 2005
Posts: 3957
PostPosted: 08-21-2009 12:38 AM           Profile Send private message  E-mail  Edit post Reply with quote


Simple test to check if the event is received: set cg.zoomed = qfalse unconditionally.




Top
                 

Commander
Commander

Joined: 23 Oct 2007
Posts: 107
PostPosted: 08-21-2009 12:43 AM           Profile Send private message  E-mail  Edit post Reply with quote


Uh, the problem is, it IS set to qfalse... it should be set to false everytime you die but not if you kill someone.



_________________
/callvote kick all_enemies


Top
                 

Mentor
Mentor

Joined: 12 Mar 2005
Posts: 3957
PostPosted: 08-21-2009 02:42 AM           Profile Send private message  E-mail  Edit post Reply with quote


Then I'm not quite getting the problem, I fear. How and what are you trying to accomplish and what is bugging it?




Top
                 

Commander
Commander

Joined: 23 Oct 2007
Posts: 107
PostPosted: 08-21-2009 03:13 AM           Profile Send private message  E-mail  Edit post Reply with quote


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



_________________
/callvote kick all_enemies


Top
                 

Commander
Commander

Joined: 23 Oct 2007
Posts: 107
PostPosted: 08-29-2009 07:51 AM           Profile Send private message  E-mail  Edit post Reply with quote


Code:
G_AddEvent(self, EV_RESET_ZOOM, 0);

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



_________________
/callvote kick all_enemies


Top
                 

Recruit
Recruit

Joined: 01 Sep 2009
Posts: 1
PostPosted: 09-01-2009 02:13 PM           Profile Send private message  E-mail  Edit post Reply with quote


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




Top
                 

Commander
Commander

Joined: 23 Oct 2007
Posts: 107
PostPosted: 09-02-2009 12:42 AM           Profile Send private message  E-mail  Edit post Reply with quote


That did it thanks!



_________________
/callvote kick all_enemies


Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group