Could be asleep, typing random messages instead.

Coding monsters that attack bots

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar jaypeezy
Skaarj Berserker Skaarj Berserker
Posts: 317
Joined: 25 Sep 2010, 04:32

Subject: Coding monsters that attack bots

Post Posted: 15 Mar 2013, 01:17

I'm sure this has been asked plenty of times by now. My stock Unreal creatures (in UT) do not attack bots. I'm trying to figure out how to change this. I thought it would be as easy as changing some parameter:

Code: Select all

function eAttitude AttitudeToCreature(Pawn Other)
{
   if ( Other.IsA('Brute') )
      return ATTITUDE_Friendly;
   else if ( Other.IsA('Bot') ) //where Bot was originally Nali
      return ATTITUDE_Hate;
   else
      return ATTITUDE_Ignore;
}


But, it's not. I'm vaguely familiar with C++ now that I'm studying it in school, and I'm trying to actually make some custom pawns for neat MonsterSpawn lists but, it's just gonna be useless if I can't figure this out. So, Waffnuffly and MrLoathsome, this question is somewhat directed to you two, haha. But, if anyone else can point me in the right direction, it would be greatly appreciated. Thanks!

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: Coding monsters that attack bots

Post Posted: 15 Mar 2013, 02:50

Code: Select all

//======================================================================================================
// Some of this code donated by Asgard to enable bot attacks. THANK YOU SIR! Also: other stuff, possibly
//======================================================================================================
function bool SetEnemy( Pawn NewEnemy )
{
   local bool resultz;
   local eAttitude newAttitude, oldAttitude;
   local bool zzNoOldEnemyz;
   local float zzNewStrengthz;

   if ( !bCanWalk && !bCanFly && !NewEnemy.FootRegion.Zone.bWaterZone )
      return false;

   if ( (NewEnemy == Self) || (NewEnemy == None) || (NewEnemy.Health <= 0) || NewEnemy.bDeleteme || NewEnemy.IsA('FlockPawn') )
      return false;

   zznoOldEnemyz = (Enemy == None);
   resultz = false;
   newAttitude = AttitudeTo(NewEnemy);

//   log(self$" Attitude to potential enemy is "$newAttitude);

   if ( !zzNoOldEnemyz )
   {
      if (Enemy == NewEnemy)
         return true;

      else if ( NewEnemy.bIsPlayer && (AlarmTag != '') )
      {
         OldEnemy = Enemy;
         Enemy = NewEnemy;
         resultz = true;
      }

      else if ( newAttitude == ATTITUDE_Friendly )
      {
         if ( bIgnoreFriends )
            return false;

         if ( (NewEnemy.Enemy != None) && (NewEnemy.Enemy.Health > 0) )
         {
            if ( NewEnemy.Enemy.bIsPlayer && (NewEnemy.AttitudeToPlayer < AttitudeToPlayer) )
               AttitudeToPlayer = NewEnemy.AttitudeToPlayer;

            if ( AttitudeTo(NewEnemy.Enemy) < AttitudeTo(Enemy) )
            {
               OldEnemy = Enemy;
               Enemy = NewEnemy.Enemy;
               resultz = true;
            }
         }
      }

      else
      {
         oldAttitude = AttitudeTo(Enemy);
         if ( (newAttitude < oldAttitude)
            || ( (newAttitude == oldAttitude) && ((VSize(NewEnemy.Location - Location) < VSize(Enemy.Location - Location))
            || !LineOfSightTo(Enemy)) ) )
         {
            if ( bIsPlayer && Enemy.IsA('PlayerPawn') && !NewEnemy.IsA('PlayerPawn') )
            {
               zznewStrengthz = relativeStrength(NewEnemy);
               if ( (zznewStrengthz < 0.2) && (relativeStrength(Enemy) < FMin(0, zznewStrengthz)) 
                  && (IsInState('Hunting')) && (Level.TimeSeconds - HuntStartTime < 5) )
                  resultz = false;
               else
               {
                  resultz = true;
                  OldEnemy = Enemy;
                  Enemy = NewEnemy;
               }
            }
            else
            {
               resultz = true;
               OldEnemy = Enemy;
               Enemy = NewEnemy;
            }
         }
      }
   }

   else if ( newAttitude < ATTITUDE_Ignore )
   {
      resultz = true;
      Enemy = NewEnemy;
   }

   else if ( newAttitude == ATTITUDE_Friendly ) // Your enemy is my enemy
   {
//      log(self$" noticed a friend");
      if ( NewEnemy.bIsPlayer && (AlarmTag != '') )
      {
         Enemy = NewEnemy;
         resultz = true;
      }
      if (bIgnoreFriends)
         return false;

      if ( (NewEnemy.Enemy != None) && (NewEnemy.Enemy.Health > 0) )
      {
         resultz = true;
//       log(self$" his enemy is my enemy");
         Enemy = NewEnemy.Enemy;
         if ( NewEnemy.Enemy.bIsPlayer && (NewEnemy.AttitudeToPlayer < AttitudeToPlayer) )
            AttitudeToPlayer = NewEnemy.AttitudeToPlayer;
         else if ( NewEnemy.IsA('ScriptedPawn') && (ScriptedPawn(NewEnemy) != None) && (ScriptedPawn(NewEnemy).Hated == Enemy) )
             Hated = Enemy;
      }
   }

   if ( resultz )
   {
//      log(self$" has new enemy - "$enemy);
      LastSeenPos = Enemy.Location;
      LastSeeingPos = Location;
      EnemyAcquired();
      if ( !bFirstHatePlayer && Enemy.bIsPlayer && (FirstHatePlayerEvent != '') )
         TriggerFirstHate();
   }
   else if ( NewEnemy.bIsPlayer && (NewAttitude < ATTITUDE_Threaten) )
      OldEnemy = NewEnemy;

   return resultz;
}


This is all I'm aware of. This is in EXUScriptedPawn with a specialized version in EXUQueen to disable teleporting and a minor edit in EXUTentacle to compensate for immobility.
Image

redeye
Banned Banned
Posts: 1393
Joined: 08 Dec 2007, 06:55

Subject: Re: Coding monsters that attack bots

Post Posted: 15 Mar 2013, 04:03

In monsterhunt i think they do, maybe do some game-type setting ?
Just ban everyone

User avatar evilgrins
Skaarj Warlord Skaarj Warlord
Posts: 771
Joined: 31 Oct 2011, 10:41
Location: Palo Alto, CA
Contact:

Subject: Re: Coding monsters that attack bots

Post Posted: 16 Mar 2013, 01:15

I had a variation of this problem when I installed a newer version of ut99 on my system, while keeping the one I've literally had since 1999 in another directory. Really frustrating, though made for some fun online chatter.

Eventually I traced the problem to one of UT's key files (forget which one at the moment) in the /system folder. I simply copied that same file from my older UT to overwrite the newer one, and the monsters started attacking the bots again.

Weird.

For the record, the newer version of UT I got was from the Unreal Anthology package.

Also for the record, this wasn't a MonsterHunt issue. I've got tons of DM-maps with monsters on them, plus a number of monster mutators I regularly use.

User avatar Dr.Flay
Skaarj Lord Skaarj Lord
Posts: 222
Joined: 23 Aug 2012, 06:24
Location: Kernow, UK
Contact:

Subject: Re: Coding monsters that attack bots

Post Posted: 01 Apr 2013, 10:41

MrLoathsome has done much work fixing and improving the monsters in UT games.
http://ecoop.tk/load/1
He is rather fond of monsters and CoOp, so it's a subject close to his heart.


Who is online

Users browsing this forum: No registered users and 23 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited