How to set up random enemy groups per turn? (Fire Emblem Tower Defense)

Hey guys. I am currently working on a total overhaul for Tequila’s Fire Emblem Tower Defense fangame.

It’s the one from 2018’s FEE3. He gave me permission to work on it.

I would like to make enemies a lot more random. Currently, I’m thinking of using the ingame skirmish randomization to make random enemies generate… but I kind of want something a little more predicable and fine-tuned.

Here is the event file I’m using to create enemies on a per-turn basis; note that this is a buildfile.

ALIGN 4
Enemy_Pointer_Table:
//each pointer = 1 turn
WORD 0
WORD 0
POIN Turn2
POIN Turn3
WORD 0
POIN Turn5
WORD 0
WORD 0
POIN Turn8
POIN Turn9
POIN Turn10
WORD 0
POIN Turn12
WORD 0
WORD 0
POIN Turn15
WORD 0
WORD 0
WORD 0
POIN Turn19
POIN Turn20
WORD 0
WORD 0
POIN Turn23
WORD 0
POIN Turn25
POIN Turn26
WORD 0
POIN Turn28
POIN Turn29
POIN Turn30
WORD 0
POIN Turn32
WORD 0
WORD 0
POIN Turn35
WORD 0
POIN Turn37
POIN Turn38
WORD 0
POIN Turn40
WORD 0
WORD 0
WORD 0
WORD 0
POIN Turn45
POIN Turn46
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0
WORD 0

// CharID, ClassID, LeaderID, Level(Number,Affiliation,Autoleveled?) [X, Y] ItemDrop 0 REDANums REDAs [Inventory] AI
Turn2:
UNIT Mook1 Soldier 0 Level(1,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA3 [IronLance] [0xA, 0, 0, 0]
UNIT Mook1 Soldier 0 Level(1,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA6 [Javelin] [0xA, 0, 0, 0]
UNIT Mook1 Soldier 0 Level(2,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [IronLance] [0xA, 0, 0, 0]
UNIT

Turn3:
UNIT Mook1 Soldier 0 Level(2,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA1 [SteelLance] [0xA, 0, 0, 0]
UNIT Mook1 Soldier 0 Level(2,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [IronLance] [0xA, 0, 0, 0]
UNIT

Turn5:
UNIT Mook1 Fighter 0 Level(3,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA2 [IronAxe] [0xA, 0, 0, 0]
UNIT Mook1 Fighter 0 Level(3,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA4 [HandAxe] [0xA, 0, 0, 0]
UNIT Mook1 Fighter 0 Level(2,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA6 [SteelAxe] [0xA, 0, 0, 0]
UNIT Mook1 Fighter 0 Level(3,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA8 [IronAxe] [0xA, 0, 0, 0]
UNIT

Turn8:
UNIT Mook1 Fighter 0 Level(3,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA1 [IronAxe] [0xA, 0, 0, 0]
UNIT Mook1 Fighter 0 Level(4,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [PoisonAxe] [0xA, 0, 0, 0]
UNIT

Turn9:
UNIT Mook1 Fighter 0 Level(3,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA5 [HandAxe] [0xA, 0, 0, 0]
UNIT

Turn10:
UNIT Mook1 Mage 0 Level(4,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [Fire] [0xA, 0, 0, 0]
UNIT Mook1 Mage 0 Level(4,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA2 [Elfire] [0xA, 0, 0, 0]
UNIT Mook1 Mage 0 Level(4,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [Fire, PureWater] [0xA, 0, 0, 0]
UNIT

Turn12:
UNIT Boss1 Mage 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA6 [Elfire] [0xA, 0, 0, 0]
UNIT

Turn15:
UNIT Mook1 Archer 0 Level(6,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA1 [IronBow, GoddessIcon] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA2 [SteelBow] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA3 [PoisonBow] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA5 [KillerBow] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [IronBow] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(5,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA8 [SteelBow] [0xA, 0, 0, 0]
UNIT Mook1 Archer 0 Level(6,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [IronBow] [0xA, 0, 0, 0]
UNIT

Turn19:
UNIT Assassin1 Archer 0 Level(7,Enemy,True) [StairE2X, StairE2Y] 0 0 1 StairE2REDA5 [IronBow] [0, 0, 0, 0]
UNIT

Turn20:
UNIT Mook1 Monk 0 Level(6,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA1 [Shine] [0xA, 0, 0, 0]
UNIT Mook1 Monk 0 Level(7,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA3 [Lightning] [0xA, 0, 0, 0]
UNIT Mook1 Monk 0 Level(6,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [Shine] [0xA, 0, 0, 0]
UNIT Mook1 Monk 0 Level(7,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [Lightning] [0xA, 0, 0, 0]
UNIT

Turn23:
UNIT Mook1 Monk 0 Level(7,Enemy,True) [StairE1X, StairE1Y] 0x2 0 1 StairE1REDA5 [Shine, Mend] [0xA, 0, 0, 0]
UNIT Mook1 Monk 0 Level(7,Enemy,True) [StairE2X, StairE2Y] 0 0 1 StairE2REDA5 [Shine] [0xA, 0, 0, 0]
UNIT Boss1 Monk 0 Level(7,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA5 [Resire, Shine] [0xA, 0, 0, 0]
UNIT

Turn25:
UNIT Mook1 Knight 0 Level(8,Enemy,True) [StairE2X, StairE2Y] 0x2 0 1 StairE2REDA5 [SteelLance, Vulnerary] [0xA, 0, 0, 0]
UNIT Mook1 Knight 0 Level(8,Enemy,True) [StairE2X, StairE2Y] 0 0 1 StairE2REDA2 [SteelSword] [0xA, 0, 0, 0]
UNIT

Turn26:
UNIT Boss1 Knight 0 Level(9,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA3 [LightBrand] [0xA, 0, 0, 0]
UNIT Mook1 Knight 0 Level(8,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [KillerAxe, HoplonShield] [0xA, 0, 0, 0]
UNIT

Turn28:
UNIT Mook1 Knight 0 Level(8,Enemy,True) [StairE1X, StairE1Y] 0 0 1 StairE1REDA5 [Axereaver] [0xA, 0, 0, 0]
UNIT

Turn29:
UNIT Mook1 Knight 0 Level(9,Enemy,True) [Spawn2X, Spawn2Y] 0x2 0 1 Spawn2REDA5 [ShortSpear] [0xA, 0, 0, 0]
UNIT

Turn30:
UNIT Mook1 Mercenary 0 Level(9,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA5 [Lancereaver] [0xA, 0, 0, 0]
UNIT Mook1 Mercenary 0 Level(8,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA8 [SteelSword] [0xA, 0, 0, 0]
UNIT Boss1 Mercenary 0 Level(9,Enemy,True) [StairE1X, StairE1Y] 0x2 0 1 StairE1REDA5 [KillingEdge] [0xA, 0, 0, 0]
UNIT Mook1 Mercenary 0 Level(8,Enemy,True) [StairE2X, StairE2Y] 0 0 1 StairE2REDA2 [LightBrand] [0xA, 0, 0, 0]
UNIT

Turn32:
UNIT Assassin1 Mercenary 0 Level(10,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA8 [PoisonSword] [0, 0, 0, 0]
UNIT

Turn35:
UNIT Mook1 Shaman 0 Level(11,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA2 [Flux] [0xA, 0, 0, 0]
UNIT Mook1 Shaman 0 Level(9,Enemy,True) [StairE1X, StairE1Y] 0 0 1 StairE1REDA5 [MachinShin, Antitoxin] [0xA, 0, 0, 0]
UNIT Mook1 Shaman 0 Level(10,Enemy,True) [StairE1X, StairE1Y] 0 0 1 StairE1REDA6 [Luna] [0xA, 0, 0, 0]
UNIT

Turn37:
UNIT Boss1 Shaman 0 Level(12,Enemy,True) [StairNEX, StairNEY] 0x2 0 1 StairNEREDA5 [Luna] [0xA, 0, 0, 0]
UNIT

Turn38:
UNIT Mook1 Shaman 0 Level(10,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA1 [MachinShin] [0xA, 0, 0, 0]
UNIT Boss1 Shaman 0 Level(12,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA5 [Luna] [0xA, 0, 0, 0]
UNIT Mook1 Shaman 0 Level(10,Enemy,True) [Spawn2X, Spawn2Y] 0 0 1 Spawn2REDA9 [MachinShin] [0xA, 0, 0, 0]
UNIT

Turn40:
UNIT Mook1 Thief 0 Level(13,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA1 [SteelSword] [0xA, 0, 0, 0]
UNIT Mook1 Thief 0 Level(11,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA3 [PoisonSword] [0xA, 0, 0, 0]
UNIT Boss1 Thief 0 Level(14,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA5 [Lancereaver] [0xA, 0, 0, 0]
UNIT Mook1 Thief 0 Level(13,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA7 [BraveSword] [0xA, 0, 0, 0]
UNIT Mook1 Thief 0 Level(12,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA9 [KillingEdge] [0xA, 0, 0, 0]
UNIT Mook1 Thief 0 Level(12,Enemy,True) [StairNEX, StairNEY] 0 0 1 StairNEREDA5 [SteelSword] [0xA, 0, 0, 0]
UNIT Mook1 Thief 0 Level(12,Enemy,True) [StairS1X, StairS1Y] 0 0 1 StairS1REDA5 [LightBrand] [0xA, 0, 0, 0]
UNIT

Turn45:
UNIT Mook1 Fighter 0 Level(14,Enemy,True) [Spawn1X, Spawn1Y] 0 0 1 Spawn1REDA5 [Swordreaver] [0xA, 0, 0, 0]
UNIT Mook1 Mage 0 Level(14,Enemy,True) [Spawn2X, Spawn2Y] 0x2 0 1 Spawn1REDA5 [Thunder] [0xA, 0, 0, 0]
UNIT Boss1 Soldier 0 Level(15,Enemy,True) [StairE2X, StairE2Y] 0x2 0 1 StairE2REDA5 [KillerLance] [0xA, 0, 0, 0]
UNIT Boss1 Archer 0 Level(15,Enemy,True) [StairS2X, StairS2Y] 0x2 0 1 StairS2REDA5 [KillerBow, Longbow] [0xA, 0, 0, 0]
UNIT

Turn46:
UNIT Assassin1 Monk 0 Level(13,Enemy,True) [StairNEX, StairNEY] 0x2 0 1 StairNEREDA5 [Shine, Resire] [0, 0, 0, 0]
UNIT Assassin1 Knight 0 Level(14,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA1 [Axereaver, KillerLance] [0, 0, 0, 0]
UNIT Assassin1 Shaman 0 Level(14,Enemy,True) [Spawn1X, Spawn1Y] 0x2 0 1 Spawn1REDA9 [MachinShin, Luna] [0, 0, 0, 0]
UNIT

I would like to set up an event that rolls a number between, say, 1 and 100, then picks from a group of pre-picked units for each wave. For example, maybe turn 7 could be a wave of guys with poison, or a bunch of Assassins, or a boss and some tanks, or a bunch of speedy pegasi, etc. I would fill in all of those wave types, and the game would pick one at random.

How can I set up a system like this? It must exist, but how would I format the event codes?

I actually have something very similar. I don’t know if you use FEBuilder, but it has a structure like this:


This is a turn event that happens from turn 1-255 every player phase. What it does is the following:

  1. Generate a number from 0 to 100 (64 in hexadecimal)
  2. If the number is higher than 75, generate X group of units (In this case a green phantom) and spawn a mine in those same coordinates. Otherwise, just continue.
  3. Rinse and repeat with 5 more groups of enemies.

If you want to tie which group spawns to a single calculation (Say, you want to roll only once and you want that roll to select from a group of enemies), you can use a command called SVAL to store the generated value in a memory slot. You can then use that value in commands such as “If value in slot X is higher than Y, then spawn group A. Otherwise (Goto command), if it’s higher than Z value, then spawn group B”, so on and so forth.

Be careful though, a lot of this is in hexadecimal, so if you type “100” it might end up meaning “256”. Hope this helps!

1 Like

You would want to use RANDOMNUMBER as suggested, then you can use that value to branch into different unit groups. You can also make those unit groups use the random monster group behavior for one extra layer, as well as more RANDOMNUMBERs if you want.

You don’t need to use SVAL, just use the “Imm” branches that do that for you. Though there’s no guarantee that memory slots persist after an event ends, so the above suggestion would be best done with counters. If you are already out of counters and/or or you want more than 16 different possibilitiess, you could load a unit to serve as a variable storage, essentially. Or you can just make the initial randomization set a flag, and the flag determines which unit groups to load.

1 Like

Why not use the Monster designation to randomize some of your unit groups? You can set 5 enemies per entry and a percentage chance of each, along with 1 equipment item chosen randomly from a list and 1 droppable also chosen randomly from another list.

Eg. Spawn either a Mogall or a Mauthe dog with their respective equipment
I think you’d have to look at the febuilder monster spawn and monster item rates menus to figure out the tables but I’m sure it wouldn’t be too hard to do in a buildfile

Just use the queue - it holds 30 entries of data identical to memory slots tbh except slower to access as you have to pull them out in the same order you stored them.

Say you store the values:
1, 5, 12, 27, 52, 70
If you want to then edit 12, you’d have to withdraw a few and store them back afterwards

Also the queue will let you store data in ram past 30 entries so be careful. It’d be writing to ram data past the queue so it’ll probably crash the game if you are writing garbage data to ram.

1 Like

That’s the Skirmish system, isn’t it? I’m looking for alternatives to it. I can use it, but it doesn’t suit my needs.

This system looks like what I want. Can you try the ‘export to file’ button on the bottom right of that window and see if it posts something in EA format I can use? I’m using a buildfile, not FEBuilder, so I need the exact code structure to examine.

This also works, but do you happen to have an EA formatted example?

image
This is just the event directly extracted from FEBuilder, since I don’t use EA/Buildfiles myself.

RANDOMNUMBER 0x2
SVAL 0x7 0x0
BGT 0x9000 0xC 0x7
LOAD1 0x1 0x8B3C50
ENUN
GOTO 0x9999
LABEL 0x9000
SVAL 0x7 0x1
BGT 0x9001 0xC 0x7
LOAD1 0x1 0x8B3E30
ENUN
GOTO 0x9999
LABEL 0x9001
LOAD1 0x1 0x8B3E94
ENUN
LABEL 0x9999
EVBIT_T 0x7
ENDA

1 Like

Ah, so you made a new event in FEB, then extracted it via the export option. Interesting. I’ll give this a look and see if I can rework it for my purposes. Thanks!

Not really.

This monster has an 82% chance of being the Revenant class, 3% Entombed, etc.
You can have any unit be loaded as 1 of 5 random classes this way. Their inventory is wiped and replaced with items from these lists:

image

image

5% of drop table 22
image

drop table 22 is vulnerary etc
image

There is quite a bit of randomization that you could configure with this.

You could very easily make a unit group load one of:

  • Knight with 1 of 5 lances
  • Myrmidon with 1 of 5 swords
  • Fighter with 1 of 5 axes

I use this quite a bit in Pokemblem.

I extracted the event I posted, here’s the EA format:

ORG $1958E18
CHECK_EVENTID 0xE
BEQ 0x1 0xC 0x0
CHECK_EVENTID 0x11
BNE 0x2 0xC 0x0
ENUT 0x11
TEXTSHOW 0x1555
TEXTEND
REMA
LABEL 0x2
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x3 0xC 0x7
SVAL 0x2 0x9957F84
CALL 0x9EE274
SVAL 0xB 0x30009
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x3
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x4 0xC 0x7
SVAL 0x2 0x9958158
CALL 0x9EE274
SVAL 0xB 0x14000A
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x4
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x5 0xC 0x7
SVAL 0x2 0x9958180
CALL 0x9EE274
SVAL 0xB 0x50010
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x5
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x6 0xC 0x7
SVAL 0x2 0x99581A8
CALL 0x9EE274
SVAL 0xB 0x7000A
SVAL 0x1 0x0
ASMC 0xF01411
SVAL 0xB 0x6000A
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x6
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x7 0xC 0x7
SVAL 0x2 0x99581F8
CALL 0x9EE274
SVAL 0xB 0x90013
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x7
RANDOMNUMBER 0x64
SVAL 0x7 0x4B
BLT 0x8 0xC 0x7
SVAL 0x2 0x99581D0
CALL 0x9EE274
SVAL 0xB 0x140004
SVAL 0x1 0x0
ASMC 0xF01411
LABEL 0x8
LABEL 0x1
EVBIT_T 0x7
ENDA

The first part of the code checks if a flag is set, if it is then it does a dialogue once (Textshow) and then starts spawning the groups. You can skip that part if you have no use for it or alternatively work with Shuusuke’s event.

1 Like

I’m like 95% sure your post and Shuusuke’s are exactly what I need. My only issue now is making it more readable, since I’m still learning how EA/Buildfiles work. I’ll have Pikmin or someone look at it and see if they can make it more Englishy and less machine-outputted.

Thanks!