View Tags

May 27, 2015

Tutorial: Making a Telepath Tactics Campaign, Part 18

<< Continued from Part 17

A. Creating a destructible object

Destructible objects are the inanimate, interactive things you see on the battlefield: walls, doors, bushes, boulders, bridges, barricades, and so on. Anything that isn’t a character–but can still be damaged or destroyed–is a destructible object.

As it happens, we already know 95% of what we need to know about creating destructible objects–we create destructible objects in pretty much the same way as we create characters, except that we do it in ObjClasses.xml instead of CharClasses.xml! That’s because, as far as the game is concerned, destructible objects are just characters that have no name, never get a turn, always face the direction None, and belong to team 99.

There are a few other differences, though. First: a destructible object’s charname is always “none”, and its race and sex are both “None”.

Because destructible objects  have no name, the game decides which destructible objects to spawn based on their spritetype, and decides what to call each object when the player mouses over it based on its classname. Thus, each destructible object variation must be tied to a unique sprite via its spritetype, but groups of them can share the same classname (see e.g. the game’s various doors and walls).

Because objects don’t move, their move property isn’t used to refer to how the object moves–instead, it tells the game which characters and attacks can pass through the object’s space. The various passibility types are:

  • all – the object lies flat on the ground; all characters can move through this space. Ranged attacks can pass through this space.
  • flying – only flying characters can move through this space. Ranged attacks can pass through this space.
  • shoot through – no characters can move through this space; the only way through is teleportation. Ranged attacks can still pass through this space, though. (Used with barricades and with walls containing open windows.)
  • none – no characters can move through this space; the only way through is teleportation. Even ranged attacks cannot pass through this space. (Used with walls.)
  • closed – used exclusively with doors and gates. This behaves like none, except that a character adjacent to the object may change its passability to open by using the Open / Close Door action.
  • open – used exclusively with doors and gates. This behaves like all, except that a character adjacent to the object may change its passability to closed by using the Open / Close Door action.
  • locked – used exclusively with doors and gates. The same as closed, except that characters may not change its passability to open unless they use a key. Doors may be changed to locked from open or closed using the using the Lock script action.

Once you’ve set the object’s passability via its move property, you’ll want to adjust your object’s hp, pushable, and various resistance properties as well to determine how hard it is to destroy, which types of attacks are effective, and whether characters can shove, pull, or throw the object during battle.

This, just as an example, is what the parameters for the Bush object looks like:

<Obj charname=”none” spritetype=”Bush” portrait=”” race=”None” sex=”None” classname=”Bush” move=”flying” hurtParticle=”Wood” shadowType=”Big” shadowY=”32″ charY=”12″ lighting=”” ctr=”None” onDeath=”None” defaultAtkAnim=”” atk1=”” atk2=”” atk3=”” atk4=”” atk5=”” atk6=”” atk7=”” atk8=”” hp=”6″ en=”0″ spd=”0″  ctrLimit=”0″ dodge=”0″ str=”0″ per=”0″ psyP=”0″ psyD=”0″ prcRes=”30″ slshRes=”0″ crshRes=”30″ mnRes=”100″ htRes=”-20″ cdRes=”-20″ ltRes=”25″ shRes=”0″ poiRes=”100″ acc=”100″ lvl=”0″ exp=”0″ pushable=”false” tags=””></Obj>

Bushes can be passed over by flying characters, they have only 6 health, and they cannot be pushed. They’re weak to heat and cold, have no resistance to slashing, and are somewhat resistant to light, crush, and pierce.

Another thing you’ll want to mess around with are the shadowType, shadowY, and charY properties. Adjust these to give the object a shadow, and to get the object and its shadow each spawning in a position that looks good in-game. Above, you can see that the Bush has a big shadow, is placed 12 pixels down within its tile, and has its shadow placed 32 pixels down.

Feel free to go digging around in the ObjClasses.xml file in The Vengeance of Emma Strider for examples of other destructible objects to work off of!

B. Creating a destructible object sprite

Because each destructible object is tied to a different sprite, whenever we make a new destructible object, we need to make a new sprite for it. If you don’t already have one, download some pixel editing software. (There are a lot of good options, and many of them free–here are a few popular ones: PyxelEdit, Asesprite, GIMP, GraphicsGale, and Pixie.)

To create a new destructible object sprite, open up your pixel editing program and create a new image with a transparent background. The image can be as short or as tall as you want, up to 96 pixels high–but it should always be 64 pixels wide.

Now draw the object sprite! (Note: don’t include a shadow–an object’s shadow is rendered separately from the object, and is defined by the shadowType property in ObjClasses.xml.) Here, for example, is the sprite for a treasure chest:

As you can see, it’s 64 pixels wide and 68 pixels high, with a transparent background and no shadow.

Whenever you’re done, save the sprite as a .png file in the subdirectory Data > Objects. Make sure you then set the spritetype property of your destructible object to the filename you used, minus the .png file extension. (For instance: if you just created a wooden carriage object sprite called Carriage.png, you’d use the spritetype Carriage to tie it to your destructible object class.)

C. Making your destructible object use attacks

Most destructible objects just kinda sit there, inert, until a character moves them or destroys them. You can spice an object up a bit, however, by giving it counterattacks or an “on death” attack!

The Spiked Barricade is a good example of the former. Whenever a Spiked Barricade is attacked at melee range, it damages the attacker. To make a destructible object counterattack like this, we do a few things:

(1) we set the object’s defaultAtkAnim to Rest so the game doesn’t glitch out from expecting (and not finding) an actual attack animation;

(2) we give the object an attack within atk1 (or atk2, or atk3, etc.) that has the damage multiplier, element, and range we want (creating a new one within Attacks.xml if necessary);

(3) we set its counter to that attack;

(4) we give it a str (or psyP, or psyD) value appropriate to the damage we want it to deal; and

(5) we set its ctrLimit to 999 (or some other ludicrously large number that ensures it’ll never run out of counterattacks in a given turn).

As for objects with “on death” attacks, the most obvious example would have to be Charges–when they hit 0 health, they use Explode. This is even easier to set up than the counterattack:

(1) we set the object’s onDeath property to the attack we want it to use as it’s dying. (This doesn’t even have to be an attack within atk1, atk2, etc.–it just has to be an attack with a minRng and maxRng of 0); and

(2) we give it a str (or psyP, or psyD) value appropriate to the damage we want it to deal.

Note that on death attacks always self-target, so you’ll want to pick an attack with an AOE pattern other than single.

 

All right–now you know everything there is to know about creating destructible objects! In the next part, we’ll talk about assigning triggers to objects so you can trigger scripts with them. See you next time!

 


Continued in Part 19 >>