Thursday, July 29, 2010

Enemy Spells

Despite power blackouts at home and new workloads in my day job, I've managed to get some progress done so I'm uploading a new video today. Enemies can now cast spells and have enchantments. I've started by giving the fire element an immolation enchantment and the ability to cast firebolt. The nice thing is that it takes very little data to set up, so I should be able to go crazy with enemy enchantments.  The fire elements data is fairly simple:

  < enemy name="fire.element" desc="fire.element" sprite="fire.element" lvl="5" str="15" dex="2" con="15" int="10" fireresist="100" coldresist="-100"  >
    < drop chance="10" minCount="50" maxCount="100" name="gold" / >
    < enchant name="IMMOLATE" / >
    < spell name="FIREBOLT" cond="(randomPercent 50) and (inRange self target 2 4)" / >
  < / enemy >

A simple condition script determines when they should fire the firebolt. This one is a simple random chance when in range of the player.  I can make them more complex if needed.

The immolate spell is also just a simple script:

  < enchant name="IMMOLATE" desc="IMMOLATE" longdesc="Inflicts 2 points of fire damage to any nearby enemies per move and increases fire resistance by 10" >
    < req name="ruby" / >
    < req name="abrusseed" quantity="2" / >
    < req name="bloodroot" quantity="3" / >
    < event name="OnSecondaryStats" script="addStat fireresist (power * 10)" / >
    < event name="OnTick" script="foreachneighbour 2 (doDamage it fire (power * 2) immolate)" / >
  < /enchant >

The enchantment increases your fire resist whenever the secondary stats are calculated,  and does damage to all neighbouring actors, regardless of friend or foe. I think friendly fire is usually a good thing so I'm letting the fire elements kill other creatures if they go too close. I'm hoping this will create some interesting strategies and dynamics.  Creatures will be able to attack other creatures. There will be charisma based spells that can influence creatures into going passive or attacking other creatures.

Firebolts, on the other hand, are still quite hard coded.  I'm still conflicted with which way to go with them. Moving them to script would be good, though the visual effects tend to be very specific per spell so I'll need to think it over more to see if it a few generic systems could cover a lot of spells.

I've also added tabs to the universal inventory screen. The number of elements in the menu was always going to be quite large and scrolling through pages of entries is far too tedious. Splitting into 4 groups seems to cover it well for now. Hopefully I can get by with only four,  though I think it may be necessary to split them up further when there are a lot more spells, enchants, missions and beasts.

1 comment:

  1. I'm a developer, and was curious about your script format. Do you have a script parser of some kind, or did you write a custom one? If you wrote your own, can you talk a little bit about it works?

    I've always simplified items in my RPG style games, because I couldn't figure out the best way to represent all the different effects. I've considered writing a 'script engine' but wasn't sure the best way to start.