Nearest attackable target.

  • 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.

Vatcilli zeitchef

Dead and back
May 16, 2005
665
0
0
35
Eindhoven, The Netherlands
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.
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
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.
 

Chew-This

New Member
Jan 23, 2008
42
0
0
Are Monsters like bots....where you can set them at different
levels of skill or aggression?
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
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*

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
VisibleCollidingActors (class<Actor> BaseClass, out Actor Actor, float Radius, optional vector Loc, optional bool bIgnoreHidden)
Fetches a list of actors within the specified Radius around the specified location from the collision hash. Then iterates over the resulting list of actors and performs a FastTrace from the specified location to the those actors whose class is a subclass of the BaseClass and (if told to bIgnoreHidden) that are not bHidden. If that trace does not report any collision with world geometry, the actor is returned.
If no location is specified, this actor's Location is used instead.

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".
 

Vatcilli zeitchef

Dead and back
May 16, 2005
665
0
0
35
Eindhoven, The Netherlands
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

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".

Not needed as these monsters are spawned exactly when I need them ;)
 

FXD|Shadow

Mad Man, really
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: