RPG-style Combat Library 2.0

The Pixie
This library offers a relatively simple, but comprehensive, combat system, the basic mechanics being somewhat like D&D (d20, no hit locations). Version 2.0 has a lot of features added in, including dozens of weapons and monsters but is rather less suitable for customisation. This provides the rules and the monster manual, as it were, you just have to create the adventure, and hopefully subsequent posts will make it clear how to do that.



It is slightly adapted from the version I used for Deeper, so you can get a feel for the system by playing the game:
http://textadventures.co.uk/games/view/ ... tcg/deeper

I do not guarantee it is free of bugs, if you find an issue, let me know.

The Pixie
A - Setting Up

This assumes you already have a game, and you want to add this library to it.

Download the ZIP file, and copy all the files to your game folder (you should be able to just drag them across).

Open up your game, and go to the bottom of the left pane, to expand the Advanced node, then click on Included Libraries. You should see two (at least) there already. Click Add, and then you should see CombatLib.aslx at the top of the drop down list (not the Browse button).
lib.png

You will then see a yellow warning strip across the top; as directed, save your game, and then click the Reload button.
lib2.png

Go to the Script tab of the game object, and add a Start script. Add "Call function", and then type in "CombatInit" as the function name.
start2.png

The player needs to start in an empty room, and during the character creation process will be moved to a room called "start2". So, rename the room the player object is currently in to "start2", and then create a new room, perhaps called "start", and drag the player object to there.

That is about it. it would be a good idea now to start your game and check it is working. Then we can add stuff.

The Pixie
B. Adding Items

The library has numerous items already in it. To place an item like a weapon, you can clone it. To add a flail, for example, go to the Script tab of the room it should appear in. In the "After entering the room for the first time" script, click Add, and then select Clone Object and Move. Set it up like this:
cloneitem.png

In code it looks like this:
CloneObjectAndMove(flail, this)


So what can be cloned?

Bludging weapons:
club, crude_club, wooden_club, crude_morning_star, morning_star, mace, staff, quarterstaff, flail, war_mattock, twohanded_flail

Daggers:
curved_dagger, dagger, iron_dagger, rusty_dagger, stone_dagger, bone_dagger, knife

1H swords:
falchian, scimitar, cutlass, rapier, sabre, short_swort, broad_sword, backsword

2H swords:
long_sword, claymore, great_sword

Axes and spears:
axe, wood_axe, battle_axe, spear, crude_spear, basic_spear

Shields:
small_shield, target_shield, medium_shield, normal_shield, wall_shield, large_shield

Armour:
armour_light armour_medium armour_chain armour_plate armour_heavy_plate

Note that in these names, spaces have been replaces by underscores; this is true of monsters too.

The Pixie
C. Adding Generic Monsters

As with items, there are a whole bunch of monsters included, but they have their own special functions to clone them. As before, go to the Scripts tab of the room where you want the monsters, and look for the "After entering the room for the first time" bit. Click Add, and then select Call function. To place a fire zombie, you might set it up like this:
createfromprototype.png

In code view it looks like this:
CreateFromPrototype(fire_zombie, this)

This is how to set up unusual monsters. The more standard monsters are in lists, where they are sorted by level. There are eight lists:

kobold Goblin, orc, etc.
kobold_shaman As above but spell casting
ghost Non-corporeal undead
zombie Corporeal undead
fiend Humanoid demons
horror Non-humanoid demons
construct Built monsters such as scarecrow, automaton
dragon Snakes, drakes, etc.

Each list has 15 monsters, ranging from the pretty weak imps, snotlings and snakes, up to bonelords, ogre monarchs and ancient dragons. To place one of these you need the CreateFromPrototypeLevel, and you need to specify the list and the level (from 1 to 15):
createfromprototypelevel.png

In code it is like this:
CreateFromPrototypeLevel(ghost, 5, this)

For elementals, use this:
create fromprototypeelement.png

In code:
CreateFromPrototypeElement(fire, 3, this)

You can use any of the twelve built-in elements (some make sense more than others!). The level can range from 0 to 7.

Finally, here is the list of the unusual monsters, with special attacks or defences that you can use with the CreateFromPrototype function.

adherer weapons stick to it when they hit
rust_monster most weapons rust when they hit
wraith drain intelligence
shambling_mound gains HP from magic attacks
amorphous_blob forms smaller monsters on death
mushroomman explodes on death
dark_pixie reflects magical attacks
mimic appears to be a chest
iron_cobra one round to rear up, one to attack
lich casts spells, including one that targets intelligence in wizards and damage output of fighters
dire_hag
electric_skeleton
fire_zombie

You can use these functions several times in one room to give you a hoard of monsters, and you can mix them up to give variety to a group. For example:
CreateFromPrototypeLevel(kobold, 8, this)
CreateFromPrototypeLevel(kobold, 8, this)
CreateFromPrototypeLevel(kobold_shaman, 8, this)
CreateFromPrototype(dark_pixie, this)

Monsters generated via the various CreateFromPrototype functions will have treasure randomly added, if appropriate.

The Pixie
D. Custom Monsters

To make your game unique, you will probably want at least a few custom monsters, so let us go through how to do that.


The Combat Tab
Create an object as normal in the appropriate room, for instance, a lizardman. Go to the Combat tab, and select "Monster". Suddenly there is a huge form to fill in. Sorry, but RPG combat is complicated, and most of it does need to be filled in!

I am going to set my lizardman to be of the "Beast" type, and give him an armour of 1, as his scaled skin gives some protection.

Most of the rest is self-explanatory if you are familiar with RPGs hopefully, but some are less obvious:

Ticking "Attack as group" will have this monster attack if any other monster in the room is attacked, while "Attack on sight" will have him attack as soon as the player enters the room (otherwise it will only attack if attacked). If the creature has no physical form, such as a ghost, then tick "Non-corporeal". You might want to tick "No corpse on death" too.

By default, monsters are "Constrained" to the one room. You can set them to "Free" and they will chase after the player if she goes to another room (but not if she teleports). If set to "Forgetful", the monster is stuck in this room, and will forget that the player attacked it if she leaves the room.


The Description Tab
Now go to the Description tab. In the first box, put in a description of the monster (what you would normally put in the "Look" box on the Setup tab). The rest is all optional.

My lizard man attacks by biting, so the description when attacking I will change to:
% bites at you

You need to word this carefully, as text will be added to the end to indicate the result.

The revealed description and lore description can be used if your player can learn True Sight and Lore spells. Lore gets added to the basic text, the revealed description will replace it.

The description on death is useful for monsters that die in bizarre ways, such as dissolving away.


The Attributes Tab
For special effects, you can add scripts to the monster on the Attributes tab. These are the scripts you can add:

ondeath will run when the monster dies
onweaponhit will run when the monster is hit by a weapon
onsuccessfulattack will run when the monster has damaged the player
onfailedattack will run when the monster has failed to damage the player
onanyattack will run when the monster has failed to damage the player

You are pretty much on your own here; it depends what you want to happen.


Multi-attack Monsters
Say I want my lizardman to be attack with his claws as well as his teeth, or perhaps he is a shaman and can cast various spells. To set this up, go back to the Combat tab, and set him to be a "Multi-attack monster". You then need to add each attack as a separate object inside him.

Right click the monster, and select Add Object. Give the attack a name and in the drop down box, select the monster, then click Okay (if you forget to set the parent, you can just drag the attack on top of the monster).

Go to the Combat tab of the new attack, and set it to be a "Monster attack". Fill in the form as before.

You can add as many attacks as you like, and each turn one will be selected at random (if you do not want it to be random, you can edit the "selectattack" script on the monster as you like).

The following scripts can be added to an attack:

onsuccessfulattack will run when the monster has damaged the player
onfailedattack will run when the monster has failed to damage the player
onanyattack will run when the monster has failed to damage the player

To have an attack only ever happen once, you could set the "onanyattack" script to move the attack somewhere else. Or use the "onsuccessfulattack" if you want it to keep trying until successful. You could also use those scripts to move other attacks to the monster. By swapping attacks in and out you can construct a complex pattern of attacks.


Guarding an exit
A monster can be set to be "guarding" one or more exits. Each guarded exit must be locked, and the name of the exit must include the string "guard" (so you can have locked exits too; just do not have "guard" in the name of the exit). When the monster dies, the exits will be automatically unlocked. It is good idea to change the "Print message when locked" string to something like "That way is block by a monster". You can have several monsters guarding one room (like the frostguard and ice wyrm in the demo). Do not have the monster free to follow the player.

Note that if you have an Unlock spell, code it to not unlock exits with "guard" in the name.

If you want some generic or cloned monsters to be guarding an exit, use the SetGuards function, which will set every monster in the room to be guarding. Remember to do it after you place the monsters, so for example like this:
CreateFromPrototypeLevel (kobold, 8, this)
CreateFromPrototypeLevel (kobold, 8, this)
CreateFromPrototypeLevel (kobold_shaman, 8, this)
CreateFromPrototype (dark_pixie, this)
SetGuards (this)

The Pixie
E. Magic Items and Spells

There are various types of magic items in the library. From here on, I am going to be using code, but it is all easy code, and mostly just copy-and-pasting stuff. To toggle the code view, click the button marked below:
codeview.png

You can toggle back and forth from code view with that button, so you might like to do that with scripts you have already created in game to see what the code for them looks like.


Healing potions
To place a healing potion in the room, use this code:
CreateHealingPotion(this)



Protection potions
Protection potions protect against a specific element for a number of turns. To place a potion that will protect against one of frost, fire and necrotic, use one of these:
CloneObjectAndMove(potion_fire, this)
CloneObjectAndMove(potion_frost, this)
CloneObjectAndMove(potion_necrotic, this)



Rings and Talismans
Rings and talismans must be worn to have an effect, and give a boost to some facet of the player character. Only one ring can be worn at a time and only one talisman. The code to place one looks like this (the number is the bonus the item gives):
CreateLevelItem(talisman_of_combat, 3, this)


Options are:
talisman_of_defence
talisman_of_protection
talisman_of_combat
talisman_of_power
talisman_of_strength
ring_of_defence
ring_of_protection
ring_of_combat
ring_of_power
ring_of_strength


Scrolls
A scroll holds a single spell that produces an instant effect. Once the spell is used, the scroll is destroyed. There are a few built-in scrolls, and you can clone them as with other items:
CloneObjectAndMove(scrollhealing, this)


These are the scrolls available.
scrollhealing
scrollunlock
scrolluncurse
scrollunrust
scrollmindblast

Scrolls can potentially do anything. To create your own, set an object to be a scroll on the Combat tab, and add a script.


Spells
Spells have to be learnt, but can be cast as often as you like. You need a high enough intelligence to learn or cast the spell.

Place a spell by cloning it:
CloneObjectAndMove(spell_manastorm, this)

Spells available:
spell_cancel
spell_manastorm
spell_tongues
spell_unlock
spell_stoneskin
spell_banish_undead
spell_fire_immunity
spell_frost_immunity
spell_storm_immunity
spell_necrotic_immunity
spell_lore
spell_teleport
spell_mark

Attack spells have a level, which determines their damage, so use CreateLevelItem for them:
CreateLevelItem(spell_firebreath, 5)

Spells available:
spell_firebreath
spell_frostbreath
spell_divinebreath
spell_stormbreath


Magical Elements
The system has twelve elements built-in, in six opposed pairs.
fire - frost
storm - earthmight
shadow - rainbow
divine - necrotic
chaos - law
life - corruption
If you do not like a pair of elements, just do not use them in your game.

The Pixie
F. Custom Spells

There are four types of spells in this system, and they are set up quite differently. To create a new spell, create an object as normal, then, on the Combat tab, select the type of spell.

Whatever the spell type, you will find a box for a description; this gets used when the spell is cast. There will also be a level, which determines the intelligence required to learn or cast it. You can also set it to be single use, so it will disappear from the spell book once cast.

You should also add a description on the Setup tab.


Banishing spell
All creatures (or indeed anything) of the target type are banished. This is a powerful effect, use with caution (i.e., make high level). Note that if the creature is carrying anything, it will be lost - that could make the game unwinnable if you are not careful.

To set up a banishing spell, just put the type in the Target box.


Attack spell
An instant effect, attacking anything of the "monster" type (that is not dead) with elemental damage (damage is 1.5x the spell level).

To set up a banishing spell, just select the desired element (the drop down list has all the objects from the game, so you will have to search).


Non-attack spell
Instant effect, such as unlocking doors. You need to put in a script to make it do something. Given there are no power points, a healing spell is a bad idea by the way.

To set it up, click on "Make Editable Copy", then put in your own script. What you put in depends on the effect you want, so I cannot offer much help here.


Lasting spell

This causes an on-going spell effect. These last until another spell is cast (but you can set each spell to only last a set number of turns if you desire). Put in a "Status when active"; you can then test player.status to see it is active. For example, when the player looks at an ancient parchment check if (player.status = "Tongues"), to see if the Tongues spell is active, and the parchment can be read.

Additionally you can have it run a script when cast and when cancelled (you need to ensure whatever bonus is given is taken away when the spell ends).

Tick the "Cannot hold anything" box for an effect that stops the player holding anything (eg transformed into a mouse). You can also link to a special attack (e.g., a weapon called "Mouse Bite"). You are advised not to have a special attack unless "Cannot hold anything" is ticked as the system will get confused the player tries to equip another weapon.

The Pixie
G. The Player Character

The player's name is held in an attribute called "alias", while the "female" attribute is true if the player is female.

The character's total hits points are equal to 40 plus 10 times his stamina. Hit points are recovered primarily by drinking healing potions or using healing scrolls

The player does not have a level. The player gets XP by killing monsters; set how much on the monster's combat tab (zero by default). The simplest way to handle levelling is to give the player an extra point to spend on abilities after getting to a certain point in the game, by calling the LevelUp function. You will need to put in your own system for calling it (eg, when the player gets to a certain place, or in a change script for XP).


Character creation
To give a selection of bonus items at the start, create an attribute called "startoptions" on the game object, and set it to be a string list. You can have up to five. This will list the items in the start-up dialogue, now you need to actually give them to the player. To do that, create a function called AddBonusItem, have it take a single parameter (I used s), and no return type. The function needs to check the value of the parameter, and give items to the player accordingly. It will have a value of "bonus1" for the first selection and so on. It might look like this:
if (s = "bonus4") {
CloneObjectAndMove (medium_shield, player)
}
if (s = "bonus1") {
CloneObjectAndMove (masterhealingpotion, player)
CloneObjectAndMove (masterhealingpotion, player)
}
if (s = "bonus2") {
CloneObjectAndMove (sabre, player)
}
if (s = "bonus3") {
CloneObjectAndMove (spell_firebreath, player)
}
if (s = "bonus5") {
armour_light.parent = player
}

To change the number of points the player has at the start, go to the attributes tab of the player object and create a new attribute, "maxpoints". Set it to be an integer, and give it the new value.

To change the default character name, open Interface.xml in a text editor (such as Notepad), search for "Boris", and just replace "Boris" with your prefered name. Be careful not to accidentally delete any angle brackets.

To skip character creation, go to the Start script of the game object, and change CombatInit to:
CombatInitialise (false)

You can change the values in CombatStuff.xml.



Character status
To have values display for the character status, such as hit points, go to the attributes tab of the player. The top box determines what will be displayed. Click Add and you will be asked for two strings. The first is the attribute name (for example, "hitpoints"), the second is how it will be displayed, and you can use ! to stand in for the actual value (for example "Hits: !" or "Health: ! hps").

For score, you could use the XP points, so give "xp" as the attribute name, and "Score: !" as the display.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums