New and improved items

I spent most of today writing code for items.  Most of it’s based on the general structure of items in RPG Maker 2000, but I threw a few new things in:

  • All items gain a few new attributes. Everything, including weapons and armor, now has a number of uses.  This can be used to create weapons or armor that are used directly (I have fond memories of invoking weapons’ special attacks in FFIV), or alternatively to create a “durability” system where weapons or armor get damaged with use.
  • All items also gained a “level” variable.  I don’t plan to do anything with it for the moment, but it’ll be accessible via scripts for people to play around with.  You can do all sorts of interesting things if items have levels. Just play Disgaea if you don’t believe me. 😉
  • I also added a set of four miscellaneous variables called “tags” to the basic item structure.  Again, they can be used for whatever you want.
  • I upgraded the “Switch items” to be able to handle other project global variables (integers or floats–yes, there will be a global array of floating-point variables, and another one for text strings), and perform basic arithmetic on them.
  • I added a new type of item, building on the concept of the Switch item: a script item.  Switch items were usually used either to change the state of an event tile in a level, such as opening doors, or to trigger a certain event script.  But why do it indirectly?  If the character uses a script item, it’ll call the associated script without needing to waste a switch on it.

Speaking of scripts and items, most items will have a way to attach scripts to them.  Want to create “special attacks” for weapons?  Write a script and attach it to the weapon’s OnAttack event:

procedure weaponAttack(character: TRpgCharacter; opponent: TRpgMonster; weapon: TRpgWeapon);
begin
if random(1, 100) < weapon.tag[1] then
useAttackSkill(character, opponent, weapon.tag[2]);
end;

This sample script illustrates how you could setup a weapon special: the percent chance of the special going off is stored in tag[1], and the skill number to use in tag[2].  This generic script could be attached to any weapon that has a special, or you could write more involved scripts for the ones with really special specials!

3 Responses to “New and improved items”

  1. DS says:

    The weapons uses sounds rather nifty.

    Strange you should mention FFIV – the remake came out last week, and is brilliant. ^_^

  2. Hmm… what remake? I know there have been several already, but I didn’t know they were doing another one. What system is this one for?