Enemies and Spawners
Enemy types
An enemy type is a name with a body and numbers. The body is either a character document with a model in assets/enemies/ (<Name>.vfa or <Name>/<Name>.vfa), or a baked sprite character (.pvc) of the same name. The numbers are in assets/data/enemies.vfa.
Every new project starts with one type, Foe: a plain body with the default numbers. Outliner > Add… > Enemy opens a list of your types, then New Enemy Type, which makes a new type's document in assets/enemies/.
Renaming a type's document in the Content Drawer renames the type everywhere it is named: its spawn zones and placed spawns on every map, its row of the Enemy Types table, its drop list and Drop Stock, and the events, dialog and quest kill counts that name it. A save made before the rename keeps the old name.
The ENEMIES pages
The ENEMIES group of Edit > Project Settings has five pages:
- Types
- Pick a type, open its model and animations in the asset manager, make a New Enemy, and place them on this map. On death names an event that runs once each time an enemy of the type dies in play, and On spawn one that runs once each time an enemy of the type is made in play (both None by default); see On death and On spawn below. When attacked is what a calm character of the type does when the player attacks it: Project (the default), Stay calm, Fight back or Flee; a placed character's own choice comes first, then its type's, then the project's (Calm Characters). Under HEALTH BARS, Enemy names and Enemy bar size (Enemy Health Bars). Under NAMES OVER CHARACTERS, NPC names (Names Over Characters). Under CALM CHARACTERS, When attacked (Calm Characters).
- Enemy Types
- Every type as a table, edited by clicking. See below.
- Stats
- The picked type's hit points, swing dice, Attack and Defense (see Attack and Defense below), {renown} (the renown a player wins for felling one, spent in a skill tree that asks for it), experience, Description (what the {bestiary} says of the type, up to 199 letters), tier, category, behavior and voice, with Play to hear the voice. Under NAME, Show name (Never, Always, Near or After a hit) and Name distance in metres: when the type's name floats over a character of it in play (Names Over Characters). Under DEATH, how a body of the type leaves when it dies (see Death below). Under ON NOTICE, what the type does when it notices her (see On notice below).
- Spawns
- How many enemies and zones this map has, Draw for a new spawn zone, and each zone with Select.
- Loot
- What the picked type drops: its own drop list and Drop Stock, the gold picture, and the loot ladder for types with no list. See Loot Per Enemy.
The Enemy Types table
One row per type: Enemy, HP, Dice, Attack %, Defense, XP, {renown|Fame}, Tier, Behavior and Voice. Attack % and Defense are the same numbers as the Stats page's rows. Click a cell to change it: numbers are typed, and names are picked from lists. Add names a new type, and Delete, Up and Down work on the picked row.
Under the table, the picked type's other fields: Body (its own files, or a body a character type lends it), Faction, Weapon, Gun range, Gun sound, Shot speed, Melee reach, Lead %, MP and MP a second, what it Resists, is Immune to and is Weak to, and its senses (see Hunters below). Its Skills and Saves are lists of their own, each with its own Add and Delete.
Every change is written to enemies.vfa at once. The page also renames the word your players read for Foe.
Every row of the table is an enemy type in every list that offers types: Types, Stats, Loot, a spawn zone's Enemy types and the Quest Book. A row with nothing to wear says why beside its name, and is drawn as nothing in play until it has a body:
- No body: Body names no file and assets/enemies holds no Wolf. (for a row named Wolf) Give the row a Body, or put a character document of that name in
assets/enemies/. - No body: <file> is not there. The file its Body names is missing.
- No body: <file> is not a character, a .pvc or a sprite sheet. The file its Body names cannot be worn.
The game holds 64 enemy types. A row it has no room for says Not read: the game holds 64 enemy types.
The stat row
One kind row per type, its numbers as fields:
comp kind goblin_3 -1 -
field hp 55
field dice 1d8+5
field fame 1
field xp 22
field tier eliteA type with no row is a common raider with 30 hit points and 1d6+4 dice. The tier is regular, elite, legendary, mythical or boss; it sets what the type drops (see The Loot Forge). A row can also carry resist, immune and vulnerable (element ids; resist and immune may also name a condition or a kind), save (a save id and its bonus, one field each), sound (its sound set), faction, gun (range in pixels, then a wav), gunspeed, behavior, body (a file a character type lends it), showname (never, always, near or hit) and namedist (metres).
Fighting at range, and skills
More fields on the same row:
comp kind zinx -1 -
field weapon hunting_bow
field melee 60
field lead 50
field mp 10 0.5
field skill firebolt range=400 cd=3
field skill mend below=50- weapon
- An
items.vfaweapon with a range. The enemy fires it the way the player fires hers: arc, muzzle, shot speed, splash, pellets and effects all apply. - melee
- Swing reach in pixels. 0 means it never swings.
- lead
- How much of the player's movement a travelling shot aims ahead of her, 0 to 100.
- mp
- Its mana, and how fast it comes back each second. 0 means its skills cost nothing.
- skill
- A
magic.vfaspell it can cast, up to six, tried in order.range=,cd=(cooldown seconds),below=(heal when health falls under this percent) andsecs=are optional.
Everything else about a skill (damage, heal, buff or debuff, its target, dice, save, effect) comes from its spell row. An enemy out of mana for its skills closes in and swings instead.
From a script, enemydef <kind> <key> <value> sets any of these (hp, dice, attack, defense, ondeath, fame, xp, tier, behavior, weapon, melee, lead, mp, mpregen, skill, unskill, death, deathfx, desc), and enemydef <kind> reads them back. savedata enemies writes the table.
Attack and Defense
Swing dice are what a blow of the type rolls (1d6+4 rolls one six-sided die and adds 4); a type carrying a weapon rolls the weapon's dice instead. Attack is a percent added to every blow the type lands: damage = rolled damage x (100 + Attack) / 100, rounded down, never under 1. Attack 50 makes a roll of 10 a blow of 15, and Attack 100 a blow of 20; the player's armor and saving throw then apply as before. Defense is taken off every blow the type takes, from the player or a companion, by weapon or spell: damage = blow - Defense, never under 1. Both are 0 in a type that does not set them, which leaves every number as it was. In a script: enemydef Wolf attack 50, enemydef Wolf defense 5.
On notice
When an enemy notices her, its voice's notice sound plays. The Stats page's ON NOTICE rows add to that moment: On notice names an event (its list ends with New, which makes <type>_notice with its [notice] section waiting, and Edit File opens the picked one), Notice words a line it says, and Notice picture a picture from assets/portraits shown beside the words. All are None by default. They fire with the notice sound: once when it first notices her, and again only after it has lost her and noticed her anew.
Notice words holds up to 159 letters. The words open the dialog box, as the speak verb does: write Guard : Halt! to name the speaker, or the words alone and the type's name speaks. When the box is closed the event runs: its [notice] section, or with none its first section that holds a line. In the event, noticex, noticey and noticez are where the enemy stood, {noticex}, {noticey}, {noticez} and {noticetype} fill in on any line, at notice is that place and at self is where the enemy stands now. In a script: enemydef Wolf onnotice wolf_saw, enemydef Wolf noticewords Halt! Who goes there?, enemydef Wolf noticepic assets/portraits/guard.png, each with none to clear it.
On death
The On death list ends with New, which makes an event for the type (<type>_death, its [death] section waiting), picks it and opens it in the text editor; Edit File under the list opens the picked event. The event picked on the Types page's On death row runs once for each enemy of the type that dies in play, whoever killed it: its [death] section, or with none its first section that holds a line. It does not run for an enemy that leaves without dying (a map change, a fall out of the world, object destroy). Deaths in the same moment run one after another, oldest first. In the event, deathx, deathy and deathz are where the enemy fell (in an if or a set), and {deathx}, {deathy}, {deathz} and {deathtype} fill in on any line, so spawn Rat {deathx} {deathy} or object create barrier wall1 at death puts something there. In a script: enemydef Wolf ondeath wolf_died, enemydef Wolf ondeath none.
[death]
add wolves 1
object destroy gateOn spawn
The On spawn row on the Types page works as On death does: its list ends with New (<type>_spawn, its [spawn] section waiting) and Edit File opens the picked event. The event runs once for each enemy of the type that is made in play: one a spawn zone makes, one placed on the map when the map starts (and when a test begins), one made by spawn or object create enemy, and one put back when the field resets. Several made at once run one after another, in the order they were made. Its [spawn] section runs, or with none its first section that holds a line. In the event, spawnx, spawny and spawnz are where the enemy was made, {spawnx}, {spawny}, {spawnz} and {spawntype} fill in on any line, at spawn is that place and at self is where the enemy stands now. A type with no event runs nothing, and a project that never sets one saves its enemies as before. In a script: enemydef Wolf onspawn wolf_born, enemydef Wolf onspawn none.
[spawn]
add wolves_out 1
object create light lamp at self 80Death
Under DEATH on the Stats page, Death is how a body of the type leaves when it dies:
- Fall
- It falls with its death clip, then fades. The default.
- Vanish
- It is gone at once.
- Burst
- It is gone at once in a burst of particles. Burst effect, open only with Burst, picks the effect from the project's effects: death_burst unless another is picked.
Whichever it is, its death sound, its drops, the experience and its On death event come as before. A model with no death clip is gone as it falls, instead of standing in its idle pose. In a script: enemydef Wolf death burst, enemydef Wolf deathfx <effect> (none goes back to death_burst), enemydef Wolf death fall.
Description
Description on the Stats page is what the {bestiary} says of the type, under its picture. In a script, desc takes the rest of the line, and none clears it:
enemydef Wolf desc Hunts in packs at dusk. Fire keeps it back.
enemydef Wolf desc noneThe {bestiary}
The game counts every enemy the player defeats, by type, keeps the count in the save and can list it on a game screen. LOOK > Game Screens > Show Bestiary turns the screen on; it is off by default. See Bestiary.
Hunters
Give a type any of the senses fields and it hunts instead of charging straight at you. It sees in a cone, loses you in the dark, hears your noise, grows suspicious before it gives chase, and searches where it last knew you were.
- sight
- How far it sees, in pixels.
- cone
- How wide it sees, in degrees.
- darkness
- How much the dark hides you, in percent.
- hearing
- How far it hears, in pixels.
- notice
- Seconds it must see you before it gives chase; 0 is at once. 1.5 when it says nothing.
- search
- Seconds it searches before it goes back to its route. 10 when it says nothing.
On the Enemy Types page they are Sight px, Cone, Dark hides %, Hearing px, Notice s and Search s, each picked from a list. A prop whose Interactable > Type is Hide is a hiding place. A placed enemy walks a patrol you give it in its Properties: up to eight points, each with a wait.
A model enemy
asset new character assets/enemies/Zinx/Zinx.vfa- Open it in the asset manager and import the model onto its Mesh component.
- Check its idle, walk, attack, hit and death clips.
- Give it numbers on the Enemy Types page, or with
enemydefand thensavedata enemies.
It walks with its walk clip, swings with its attack clip, flinches with hit and falls with death. The model wears its own pictures, a .glb's included, whatever rows the enemy's document held before the model was given to it.
Putting enemies on a map
- Spawn points
- Single enemies at chosen spots. Outliner > Add… > Enemy, then a type's name (such as Foe), sets one down in the middle of the view, already selected; drag it where it should stand. On the Types page, Place drops one per click; turn on Place many to keep placing. In Properties a placed enemy has its type, category, Aggressive, Killable (Killable Characters), faction, its own Stats (below), battle place and patrol.
- Spawn zones
- Areas that keep making enemies while the game runs, always on walkable ground. Outliner > Add… > Spawn Zone sets a square one in the middle of the view, already selected, that makes the project's first enemy type; drag it by its body to move it. The Spawns page can also draw one (Draw). Select a zone to set in Properties which enemy types it makes (each spawn picks one of the ticked types, up to eight), how many are Alive at once (1 to 768), how often it spawns (1 to 120 seconds), its elite chance, a flag it waits for, Killable, its battle place, and its own Stats (below). Its right-click menu steps the same settings.
Killable on a spawn zone is ticked by default. Untick it and every body the zone makes, an NPC type's included, takes no harm and does not die. In a script: spawner killable 0 off.
One enemy's own numbers
A placed enemy's Properties and a spawn zone's each have a Stats section: Health, Attack (a percent), Defense and Experience. A blank box is the type's own number, shown dim in the box; on a zone whose types have different numbers, the dim word is Type's. Type a number to give that one enemy, or every body the zone makes, its own; empty the box to go back to the type's. Use it to bring an early type back late in the game, stronger, without making a new type.
Attack and Defense work as the type's do (see Attack and Defense above), Health is scaled by the difficulty as the type's is, and Experience is what the player wins for felling it. Only the numbers you set are saved, with the map. The {bestiary} and the Enemy Types table keep showing the type's own numbers.
For a spawn zone in a script, spawner stats <zone> hp|attack|defense|xp <number>, and - for the type's. The map's zones are counted from 0, the first made first:
spawner stats 0 hp 120
spawner stats 0 attack 50
spawner stats 0 xp -Enemies and spawn zones can sit in Outliner folders: right-click one and choose Move to Folder. The Outliner's search and sort find them again (see The Editor).
A spawner whose first type is a model shows that model standing in the middle of the zone in the editor. Spawners save with the map (its spawner rows) and ship with exports.