.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
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 08:32..
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#2)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default Re: hacking monster_plugin - 09-11-2004

oh and server dont crash if I dont spawn any barneys if that helps...






  
Reply With Quote
Re: hacking monster_plugin
Old
  (#3)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: hacking monster_plugin - 09-11-2004

did you check if pev or pEnt is NULL?
[edit]
or maybe a memory error from somewhere else...
[/edit]

Last edited by sPlOrYgOn; 09-11-2004 at 08:38..
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#4)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default Re: hacking monster_plugin - 09-11-2004

first off keep in mind that I am a php dev and a newbie C hacker...

but

printf("*** MONSTER TEAM IS %i\n",pev->team);
printf(
"*** MONSTER'S ENEMY TEAM IS %i\n",pEnt->v.team);

these return data...






  
Reply With Quote
Re: hacking monster_plugin
Old
  (#5)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: hacking monster_plugin - 09-11-2004

comment out the part of the code that is causing the crashing and see if it still crashes..
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#6)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default Re: hacking monster_plugin - 09-11-2004

yeah did that. see code in first post? If I comment out the if statement all is fine... or if I dont comment it and dont spawn any barneys its fine so I know its that if statement...


// lets see if this monster shares same team as player if team based mod...
if ( ( pev->team != pEnt->v.team ) || ( pEnt->v.team == 0 ) )
{









Last edited by BAStumm; 09-11-2004 at 09:01..
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#7)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default Re: hacking monster_plugin - 09-11-2004

weird... this code is NOT crashing...

Code:
	  if ( UTIL_IsPlayer(pEnt) )
 	  {
 		 // it's a player...
 
 
 			  // lets see if this monster shares same team as player if team based mod...
 			  if((pev->team != pEnt->v.team) || (pEnt->v.team == 0))
 			  {
 				 // testing
 				 printf("*** MONSTER TEAM IS  %i\n",pev->team);
 				 printf("*** MONSTER'S ENEMY TEAM IS  %i\n",pEnt->v.team);
 			  }
 
 					    iDist = ( pEnt->v.origin - pev->origin ).Length();
 
 					    if ( iDist <= iNearest )
 					    {
 							    iNearest = iDist;
 							    iBestRelationship = R_NM; // player is always nemsis
 							    pReturn = pEnt;
 					    }
 	  }






  
Reply With Quote
Re: hacking monster_plugin
Old
  (#8)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hacking monster_plugin - 09-11-2004

i am not entirely sure why it crashes, though something tells me that somehow the information you try to print is not initialized properly.

Try this, first try to output the first sentence, but comment out the second one. Then try the second one only and comment out the first one. DO NOT change team data or whatever, simply try to print out the data.

If that crashes, it means the data is not initialized. Make sure it IS.

The piece of code in the latest post does a check on this data, thats why it is probably not crashing. Though i wonder if it works like you want it to work?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#9)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: hacking monster_plugin - 09-11-2004

shouldn't that be
Code:
				 printf("*** MONSTER TEAM IS %d\n",pev->team);
				 printf("*** MONSTER'S ENEMY TEAM IS %d\n",pEnt->v.team);
instead ?



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 09-11-2004 at 22:42..
  
Reply With Quote
Re: hacking monster_plugin
Old
  (#10)
BAStumm
Member
 
BAStumm's Avatar
 
Status: Offline
Posts: 138
Join Date: Jan 2004
Location: Spokane, WA USA
Default Re: hacking monster_plugin - 09-11-2004

I was under the impression that d and i are both int, but none the less that portion of the test code is working correctly...






  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com