View Single Post
hacking monster_plugin
Old
  (#1)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default hacking monster_plugin - 09-11-2004

ok so I guess I just dont get it...

I've decided I'd like to change monster_plugin in a way that allows for team based monsters. To just test things for now I've changed barney to be assigned to v.team = 1. This works, I see his v.team assignment when I query using pmtools...

so next step is to hack monsters.cpp in the BestVisibleEnemy() function to ignore players on same team as the monsters v.team right?

ok so here is a my modified chunk of that function...

Code:
  edict_t *CMBaseMonster :: BestVisibleEnemy ( void )
  {
 	 int					 iNearest;
 	 int					 iDist;
 	 int					 iBestRelationship;
     edict_t *pReturn;
     edict_t *pEnt;
     int edictList_index = 0;
  		
  		iNearest = 8192;// so first visible entity will become the closest.
     
  		iBestRelationship = R_NO;
  	  
     pReturn = NULL;
  
     while (edictList_index < m_edictList_count)
  		{
  	  pEnt = m_edictList[edictList_index];
    
  	  if ( UTIL_IsPlayer(pEnt) )
  	  {
  		 // it's a player...
  
  			  // testing
  			  printf("*** MONSTER TEAM IS  %i\n",pev->team);
 			 printf("*** MONSTER'S ENEMY TEAM IS %i\n",pEnt->v.team);
  
 			 // lets see if this monster shares same team as player if team based mod...
 			 if ( ( pev->team != pEnt->v.team ) || ( pEnt->v.team == 0 ) )
  			  {
 					 iDist = ( pEnt->v.origin - pev->origin ).Length();
     
 					 if ( iDist <= iNearest )
  					    {  
 							 iNearest = iDist;
 							 iBestRelationship = R_NM; // player is always nemsis
 							 pReturn = pEnt;
  					    }
  			  } // end team based checking...
  	  }
  	  else if (pEnt->v.euser4 != NULL)
You can see I am printing the monster team and player team to the console, that part works just fine... Just after that I have an if statement to determine if this enemy is actually an enemy (not on my team and not on no team) and it appears that it is THAT if statement that is causing my server to crash. What the heck am I doing wrong?

btw that testing console output does work...

*** MONSTER TEAM IS 1
*** MONSTER'S ENEMY TEAM IS 2

right now I have barneys team statically set to 1... I see no errors before crash, I dont even get that MONSTER TEAM IS part before crash unless I comment the if statement I added... I dont get it. pulling out hair here and know its something simple/stupid







Last edited by BAStumm; 09-11-2004 at 07:32..
  
Reply With Quote