Skills and Spells... Code Design


As a forewarning I’ve never dove into any established code-base.

Is there any tendency to hard-code skills and spells, or would they be scripted with some sort of behavior hierarchy?

Right now I am leaning toward and trialing a scripted setup where skills are not coded, but rather built in game like an editor, including skill name/level and such simple definitions, as well as specific requirements, behaviors and attributes.

So one part of the code would define a behavior of a healing spell, with flags/values that dictate one target, multiple, power of the spell, mana consumption, etc – so the one piece of code would supply that behavior to any spell in the in-game editor an admin wants to add it to — There may be a dozen different healing spells based on many combinations or magic types (not just healing, but perhaps a holy spell, necromancy spell, etc, such as a blood siphon spell that both damages and heals).

Any hoot, just curious what folks have driven toward for that dynamic approach rather than hard-coding hundreds of spells/skills (I have a lot mapped out in excel right now).


They both have their pros and cons. We use trigedit on tbaMUD so builders can do the scripting. It can simulate spells/skills by doing damage or cause an affect. You can send whatever message you want to the player. We have 1000’s of examples so very little programming knowledge is required. It gives the builder the ability to really customize their zones without having to touch the code. But for efficiency some things should be coded.

Rumble 9091


I think the best approach is to have a dynamic, in-game database for skills/spells. Even if it is just to add in the variables rather than the actual function, it may save you a lot of time/effort should you need to make changes.

It’ll be easier to make changes (mana cost, damage) through an in-game editor without having to reboot the code. Easier for testing purposes as well. Also, if you have to make sweeping changes, it’s a lot easier to run through the database with a simple script/function rather than having to change it by hand if hard-coded.


Here are a few examples:

Name: ‘Mob Command - spellcasting test’, VNum: [ 312], RNum: [ 234]
Trigger Intended Assignment: Mobiles
Trigger Type: Command , Numeric Arg: 100, Arg list: kill

  • This command trigger will disallow anyone from trying to
  • use the kill command, and will toss a magic missile at them
  • for trying.
    dg_cast ‘magic missile’ %actor%
    return 0

Name: ‘While Damage Example - Grenade O1301’, VNum: [ 23], RNum: [ 23]
Trigger Intended Assignment: Objects
Trigger Type: Drop , Numeric Arg: 100, Arg list: None

  • By Rumble of The Builder Academy 9091
  • A small script to make a grenade go off 3 seconds after it is dropped.
  • Set the rooms ID to a variable.
    set room_var
    wait 3 s
  • Send a message when the bomb goes off.
    %echo% The Grenade blasts into smithereens, striking everyone here.
  • Target the first char.
    set target_char %room_var.people%
  • Now loop through everyone in the room and hurt them.
    while %target_char%
    • Set the next target before this one perhaps dies.
      set tmp_target %target_char.next_in_room%
    • This is where the good/bad things are supposed to happen.
      %send% %target_char% The explosion hurts you.
    • Damage them… 30 hitpoints. To heal use -#.
      %damage% %target_char% 30
    • Set the next target.
      set target_char %tmp_target%
    • Loop back.
  • After we go through everyone get rid of the grenade.
    %purge% %self%