Page 1 of 1

Scripting AIs? ---> custom reaper

Posted: Fri Aug 17, 2007 2:01 am
by stranf
I would like to add two new simple AI types. I am not sure if they should be hardcoded, or coded via JS.

Type 1: Archer/Mage ----> Enemy is FROZEN in place, does not move, but throws spells and/or missle weapons until the PC is in range, then Melees. As soon as magic points go to zero, the mage attacks the enemy like default NPCAI = 2.

Reason? Too many weak, yet magically powerful mages, go and attack the PCs and get killed fast. Same with archers. This way the GM can set up ambushes where mages and archers are in the rear and warriors charge attacking PCs. If an archer is set to this AI type and has no magical ability, he will remain frozen indefinetly because he will have no MP to use up.


Type 2: Ultima IV style Reaper -----> Ultima IV had reapers that would NOT move, but would act as difficult barriers to get past. Using a varient on the above "type 1" AI, an enemy set to this AI would NOT move at all in combat. Instead he would throw magic (if allowed) or shoot his missle weapons.

Unless the C++ code is hardcoded that an NPC MUST chase a PC in combat mode, I wouldn't think these AI codes would be too difficult to code. I am just unsure where to begin. If necessary, I could "force" a paralyze spell on the NPC until MP is used up, and then remove the spell effect. There may be an easier way.

Thanks!

Posted: Sun Sep 09, 2007 8:43 pm
by stranf
While I didn't find a way to code an AI, I found a crude way around what I wanted to accomplish.

To create an Ultima IV style reaper (for those who would like to know), I first went to creatures.dfn and set the movement to WATER

Code: Select all

[CREATURE 0x2f]
{ Reaper
ICON=0x20fa
SOUND_STARTATTACK=0x1ba
SOUND_IDLE=0x1bb
SOUND_ATTACK=0x1bc
SOUND_DEFEND=0x1bd
SOUND_DIE=0x1be
MOVEMENT=WATER
}
This prevents the reaper from moving on land, although in theory the reaper can now move on water.....Kind of a side effect, but if you erase MOVEMENT the default is LAND, so you have to have water in this slot.

Next I toughened up the reaper. Here are the specs:

Code: Select all

[reaper]
{
NAME=a reaper
ID=0x002f
DIRECTION=N
BACKPACK
PACKITEM=0x0f90
GOLD=180 275
LOOT=highlevelscrolls
LOOT=randomgemsandjewelry
LOOT=randomgemsandjewelry
LOOT=randomgemsandjewelry
LOOT=randomgemsandjewelry
HPMAX=700 950
MPMAX=400 800
STR=88 125
DEX=66 75
INT=101 250
KARMA=-9500
FAME=9500
MAGERY=901 1000
EQUIPITEM=REAPERBOW
PACKITEM=REAPERARROWS
EVALUATINGINTEL=901 1000
MAGICRESISTANCE=1001 1250
TACTICS=900 950
ARCHERY=780 930
SWORDSMANSHIP=885 950
POISONSTRENGTH=2
POISONCHANCE=5
SPATTACK=7
SPADELAY=125000
DAMAGE=14 33
DEF=10
NPCAI=2
TOPROV=741
TOPEACE=741 5
NOMOVE
RACE=18
FLAG=NEUTRAL
}
You will notice the up-rate in hitpoints, two weapons, and 7th level magic. The reaper is designed to be an attacking barrier. A forest of these are almost sudden death. As a GM you can use the reaper to guard places, or guide your PCs down a certain path of the dungeon. An experienced group would be foolhardy to attack a forest of these, so expert use of reapers by GMs could create interesting player response.

There seems to be a bug with SPADELAY (or I just don't use it correctly) and the reaper seems to take a long time to use spells. In order to prevent a group of adventurers from simply staying behind and pelting the reaper with arrows, the reaper has been given archery skill and an archery weapon.

here is the weapon:

Code: Select all

[reaperbow] 
{
get=base_item
name=bow
id=0x13b1
weight=700
value=46,23
layer=2
poison=1
lodamage=18
hidamage=45
hp=60
spd=14
str=30
restock=10
movable=1
decay=1
TYPE=40
NEWBIE
}
You will notice its speed is fairly slow. According to Uox3 combat formulas, the reaper will attack around once every 6 seconds. This is plenty fast, as the reaper has the potential to do devestating damage. I gave it a POISON value, as U4 reapers were notorious for poisoning their enemies. Unfortunatly, this dosen't seem to work, as I have yet been poisoned.

Type 40 is a flag that I use in my global script to set the arrows to explode, using the flamestrike animation and doing between 3-24 extra damage points. This effect is random, I believe only 30% of the time. I use this TYPE for my dragons also. If anyone is interested how I set that up, I can explain. The NEWBIE flag, for those not familiar with it, deletes this bow when the reaper dies, so there will not be a bow on the corpse.

the second item is Reaper Arrows. Here is the code for that:

Code: Select all


[reaperarrows]
{
get=0x0f3f
id=0x0f3f
name=Reaper Branch
amount=30
}

This is simply arrows for a bow, renamed to REAPER BRANCH. The idea is that the reaper is simply "throwing" its branches at the PCs and occasionaly they magically explode on impact causing fire damage. These items (30 of them) are left on the corpse of the reaper. In effect, they work as simple arrows, so the PCs will be able to use them in their bows.

I was a little hesitant of giving a reaper "archery" ablility, but the reaper animation matches up quite sweetly with the theory. The reaper takes a dive towards the PC and the "arrow" flies at him. It was much better than I expected.

If anyone feels that UO PvM combat can get a little old after awhile, Reapers offer a different type of combat to add to the mix. A skilled GM could find this useful.

Posted: Sun Sep 09, 2007 10:57 pm
by Maarc
You have a few options.

There's an onAISliver or onAISlice event. It fires a couple of times a second (depending on your INI file), and is where you're supposed to supply the logic to determine how it 'thinks'.

You can set it to frozen (a priv value I believe).

You can define it as wandering in a box that is of size 1x1. Probably a circle of radius 1 too :)

Can't help with SPADELAY at the moment as I don't have the code in front of me. I *think* it is in 10ths of a second, but not sure.