1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Nearest attackable target.

Discussion in 'Original Unreal Tournament' started by Vatcilli zeitchef, Feb 17, 2008.

  1. Vatcilli zeitchef

    Vatcilli zeitchef Dead and back

    Joined:
    May 16, 2005
    Messages:
    665
    Likes Received:
    0
    Confusing title?
    No?

    Ah well to further confuse you.
    I'm looking for a small script to add to a monster, making them able to
    see the player wherever they are.
    So they will, like bots look for their target.

    Now in one of my maps I added this:
    Code:
    function Trigger( actor Other, pawn EventInstigator )
    {
    	seeplayer(EventInstigator);
    }
    
    It would cause my monsters to look for what triggered them
    and attack it.

    It was far from perfect though as the player had to trigger the monster.
    I need a way to get the monsters to have a more bot like AI and track down the nearest target that can be attacked.

    Is there anyone who can help me with that?
    If so please answer so I can finally get this map that has been on hold for ages out.
     
  2. Zur

    Zur surrealistic mad cow

    Joined:
    Jul 8, 2002
    Messages:
    11,702
    Likes Received:
    4
    There's a method of which I've forgotten the name that allows you to "scan" for objects of a certain type within a given radius. You could probably use that.
     
  3. Vatcilli zeitchef

    Vatcilli zeitchef Dead and back

    Joined:
    May 16, 2005
    Messages:
    665
    Likes Received:
    0
    That does sound interesting, and it would fix my problem.
    I still have no idea however how I can call for that function.
    *checks unrealwiki again*
     
  4. Chew-This

    Chew-This New Member

    Joined:
    Jan 23, 2008
    Messages:
    42
    Likes Received:
    0
    Are Monsters like bots....where you can set them at different
    levels of skill or aggression?
     
  5. Zur

    Zur surrealistic mad cow

    Joined:
    Jul 8, 2002
    Messages:
    11,702
    Likes Received:
    4
    In object oriented programming functions are called methods (as in a method offered by an object). Anyway, here's what I was thinking of :

    http://wiki.beyondunreal.com/wiki/Iterator
    It's an iterator so I don't think it would be wise using it in a constant fashion. There probably needs to be some trigger like when a monster gets shot and suddenly "wakes up".
     
  6. Vatcilli zeitchef

    Vatcilli zeitchef Dead and back

    Joined:
    May 16, 2005
    Messages:
    665
    Likes Received:
    0
    Wow.. excellent that was exactly what I was looking for

    To answer Chew This
    You could indeed set monsters to different difficulty levels in Unreal
    but I'm pretty sure that changed overal defense health and damage
    In UT does not work anamore AFAIK

    Not needed as these monsters are spawned exactly when I need them ;)
     
  7. FXD|Shadow

    FXD|Shadow Mad Man, really

    Joined:
    Feb 11, 2006
    Messages:
    148
    Likes Received:
    0
    umm just iterate through all playerpawns within a given radius and then say to attack that bastard..

    Code:
    var pawn p;
    var playerpawn pp;
    var float radius;
    
    function Tick(float T)
    {
        for (p=level.nextpawn;p.isa('playerpawn');p=p.nextpawn)
            pp=playerpawn(p);
    
        if (vsize(pp.location+location) <= radius)
        {
            // AttackCode
        }
    }
    
    This searches the player each tick and activates attack code when teh player is within given radius.

    Of course never use iterators for pawns (and of course players), mutators, inventory or navigationpoints since they can be accessed through the faster for loop!
     
    Last edited: Feb 18, 2008

Share This Page