.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   hacking monster_plugin (http://forums.bots-united.com/showthread.php?t=2950)

BAStumm 09-11-2004 07:29

hacking monster_plugin
 
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

BAStumm 09-11-2004 07:36

Re: hacking monster_plugin
 
oh and server dont crash if I dont spawn any barneys if that helps...

sPlOrYgOn 09-11-2004 07:36

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

BAStumm 09-11-2004 07:50

Re: hacking monster_plugin
 
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...

sPlOrYgOn 09-11-2004 07:56

Re: hacking monster_plugin
 
comment out the part of the code that is causing the crashing and see if it still crashes..

BAStumm 09-11-2004 08:00

Re: hacking monster_plugin
 
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 ) )
{



BAStumm 09-11-2004 08:17

Re: hacking monster_plugin
 
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;
                                            }
          }


stefanhendriks 09-11-2004 18:58

Re: hacking monster_plugin
 
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?

Pierre-Marie Baty 09-11-2004 21:36

Re: hacking monster_plugin
 
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 ?

BAStumm 09-11-2004 22:35

Re: hacking monster_plugin
 
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...


All times are GMT +2. The time now is 04:34.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.