How would I go about a "attack towards" on animals?

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.

Moderator: POL Developer

Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

How would I go about a "attack towards" on animals?

Post by Poi »

I want to make a fairly simple "town raiding" script, basically I set what monsters to spawn, how many, and where they spawn, then where they should attack to(so I can set them to spawn out of town and attack/walk into town)

So I need to know how I could go about making a monster attack from one location to another(by this I mean walk towards the second location unless there is a player to attack, then stop walking and start attacking him)

Does anyone have any suggestions about how I could do this?


Question number two: How would I go about create a "multi"(Like I don't want it to be a house with a sign or anything, basically I just need to create one of the multis I can find in insideuo or uofiddler :)
Last edited by Poi on Sat May 07, 2011 1:47 pm, edited 1 time in total.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: How would I go about a "attack towards" on animals?

Post by Poi »

So I thought about possibly using parts from the herding skill script, and it works on sheep, but not most monsters like dragons and what not, any ideas? Heres what I got so far

Code: Select all

use os;
use uo;
use cfgfile;

include "include/client";
include "include/eventID";
include "include/attributes";
include "include/skillPoints";
var i := 0;

program textcmd_raidtown( who, template )

    var props array;
    props.+facing := who.facing;
SendSysMessage(who, "Where would you like to spawn the raiders?");
    var spawn := TargetCoordinates(who);

SendSysMessage(who, "Where would you like to spawn the raiders to attack?");
    var attack := TargetCoordinates(who);

	while(i < 15)

    var result := CreateNpcFromTemplate( template, spawn.x, spawn.y, spawn.z, props );
    if (!result)
        SendSysMessage( who, "NPC Creation Failed: " + result.errortext );
return 0;
    endif

var holder := {};
                holder.append(attack.x);
                holder.append(attack.y);
                var ev := struct;
                ev.+type := EVID_HERDING;
                ev.+data := holder;
                SendEvent(result, ev);
i := i + 1;

endwhile

endprogram
mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: How would I go about a "attack towards" on animals?

Post by mr bubbles »

First question is simple enough. Just have the npc walk towards the destination. If there is anyone to attack on the way, then attack. Nothing to attack, continue walking.

And the multi you want to use has been converted into your multis.cfg? Just use the createmulti() function.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: How would I go about a "attack towards" on animals?

Post by Poi »

mr bubbles wrote:First question is simple enough. Just have the npc walk towards the destination. If there is anyone to attack on the way, then attack. Nothing to attack, continue walking.

And the multi you want to use has been converted into your multis.cfg? Just use the createmulti() function.
Your right, just have the npc walk towards the destination, I was asking more of how to do that :)

And thanks, didn't know about a createmulti function :)
mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: How would I go about a "attack towards" on animals?

Post by mr bubbles »

Poi wrote:Your right, just have the npc walk towards the destination, I was asking more of how to do that
Ah ok. Well I take it you want to use existing NPCs, and not create unique raider NPCS?

I guess, depending how your AI is scripted you would want to alter the main ai loop. That being when the npc is doing nothing, just 'waiting for an event', wandering, etc.

For example, your main ai loop might look something like

Code: Select all

while (1)
#wander
#waiting for an event
enwhile
So i suppose something like

Code: Select all

while (1)
var raider := IsARaider(me);
if (raider) // can be a cprop on the npc, with destination info to use to walk towards
 walk towards the raid co-ordinates for a few steps
endif
endwhile
You only want the npc to take a few steps towards his destination, so the script can be running through and checking for hostiles etc.

Like i said, it all depends on your current AI scripts. But something like the above is a start.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Re: How would I go about a "attack towards" on animals?

Post by Poi »

Ah alright, that helps a lot, thank you :)
Post Reply