A complete overhaul of Warcraft 2 (Wargus version) that ponifies everything. Two different versions available.

Post tutorial Report RSS All-Team Organizer: Adding custom units

All-Team Organizer: How to add custom units based on existing ones. The guide does not cover the whole process, but elaborates several critical moments. Also sorry or my English and being in a hurry.

Posted by on - Intermediate Mapping/Technical

You might want to make a custom MLP map, and there are lots of images available to make new stuff. But how to start? This guide contains some useful info, but is not a step-by step tutorial. So, you'll have to experiment on editing stuff and failing occasionally.

Look at this cool guy: Urimas.deviantart.com. He has the package of sprites I used - download it. If you want to experiment with buildings, you might want to explore the MLP Gameloft wiki.

But this guide is about adding a custom pony.

Go to my mod folder\scripts. There are orc and human folders. Go to any of them and open the units.lua, in my case, with Notepad++.

Find the unit you like, for example the ex-footman (guard). Here's the code:

DefineUnitType "unit-footman", { Name = _("Guard"),
Image = {"file", "human/units/footman.png", "size", {96, 96}},
Animati, Icon = "icon-footman",
Costs = {"time", 60, "gold", 600},
Speed = 10,
HitPoints = 60,
DrawLevel = 40,
TileSize = {1, 1}, BoxSize = {60, 60},
SightRange = 8,
ComputerReacti
Pers /> Armor = 2,
BasicDamage = 6,
PiercingDamage = 3,
Missile = "missile-none",
MaxAttackRange = 1,
Priority = 60,
Points = 50,
Demand = 1,
Corpse = "unit-human-dead-body",
Type = "land",
RightMouseAction = "attack",
CanAttack = true,
CanTargetLand = true,
LandUnit = true,
organic = true,
SelectableByRectangle = true,
Sounds = {
"selected", "footman-selected",
"acknowledge", "peasant-acknowledge",
"ready", "footman-ready",
"help", "human_bad",
"dead", "human_bad"} } )

If you copy and paste this (duplicate), and change "unit-footman" to "unit-evil-pinkie-pie", you get the new unit. Now you have a responsibility if stuff crashes when you forgot to put a comma. If that happens, find your Stratagus folder, like C:\Program Files (x86)\Stratagus. Find stderr.txt - it' s supposed to help detect errors if something crashes. Keep backups anyway.

Okay, so you made a duplicate for this unit, but to add it to ur map you need to edit editor.lua

There are all my new units listed, like mr. "unit-megatree1", so you add the name of ur unit there, not forgetting to keep the right formatting with commas and stuff. Now ur unit is supposed to appear in the editor's list.

Let's look at the code again.

Name = _("Guard"),

This is unit's displayed name. Change to whatever you want to see ingame.

Image = {"file", "human/units/footman.png", "size", {96, 96}},

This is crucial. This shows the unit relies on footman.png on all tilesets. Some units use custom graphics for swamp/wasteland etc., which is specifically specified before the unit code.

Anyway, in this case they say the size is 96x96. It means, every frame has to be 96x96, but if you open the file you see it's 480x1344 = 5x96 x 14x96. Because we have 5 directions and 14 frames for each (7 frames moving, 5 frames attack, 2 frames death i guess). If you use urimas' sprites, that's very convenient: he puts each frame inside a square, so u just use the size of the square.

The png files used are special - they use indexed color. So, if you want to edit a file, first convert to rgb format (Photoshop: image - mode - rgb color). After the file is edited, you need to convert to indexed color: image- mode - indexed color.

Achtung: now be extra-careful. Warcraft does stuff it calls "color cycling". When u convert to indexed, you have 256 color, some of which are reserved to cycle. This is how water animation is done. If you just convert something to indexed color, the game will cycle specific colors, creating a narcotic experience. If you use Photoshop, do the following:

1. Palette: "Local: any u like".

2. Colors: 200. It means the image is not using colors 201+, which is good.

3. Click on Forced - Custom. Select first three rows (colors 1-48) and make them magenta, or whatever you'll never use.

This means, only colors 49 to 200 wil be used, with no cycling colors in that range.

Next code line:

Animations = "animations-footman", Icon = "icon-footman",

Icon is easy. Icons are in graphics\tilesets\swamp, or summer etc. (the graphic files). But if you want a new icon, use icons.lua, where icons are listed according to their position in the icons.png file. icon-footman is #2 or #3.

Animations is an exciting story though. There are anim.lua files in scripts\, scripts\orcs, scripts\human. animations-footman is in human. Here's the code for animations-footman:

DefineAnimations("animations-footman", {
Still = FootmanStill,
Move = FootmanMove,
Attack = {"unbreakable begin", "frame 35", "wait 3", "frame 40", "wait 3", "frame 45", "wait 3",
"frame 50", "attack", "sound footman-attack", "wait 5", "frame 55", "wait 10",
"frame 5", "unbreakable end", "wait 1",},
Death = FootmanDeath,
})

It refers to FootmanStill, FootmanMove, FootmanDeath listed separately. The attack sequence however is described and can be edited.

"unbreakable begin" / end - leave that be. "frame 35" means, that depending on unit's direction it will use the proper column (one of the 5). So "frame 35" means a specific row. 0 means row 1, 5 means row 2, 10 means row 3... 35 means row 8. Truly, guard's attack sequence start at row 8. wait "3" means the game shows that frame for the period of 3 cycles. "attack" - this is when attack action is performed. "sound footman-attack" - this is where sound is being played.

the "wait" command is not only about animations, it affects actual attack speed, unit speed etc. For example, you may put a delay before the attack, or after the attack - the unit will be able to withdraw or attack again only after that delay.

Back to footman's animations. We missed another part of the code the previously mentioned code refers to:

local FootmanStill = UnitStill
local FootmanMove = {"unbreakable begin","frame 5", "move 3", "wait 2", "frame 10", "move 3", "wait 1",
"frame 10", "move 3", "wait 2", "frame 15", "move 2", "wait 1",
"frame 15", "move 3", "wait 1", "frame 20", "move 2", "wait 1",
"frame 20", "move 3", "wait 2", "frame 25", "move 3", "wait 1",
"frame 25", "move 3", "wait 2", "frame 30", "move 2", "wait 1",
"frame 30", "move 3", "wait 1", "frame 5", "move 2", "unbreakable end", "wait 1",}
local FootmanDeath = {"unbreakable begin", "frame 60", "wait 3", "frame 65", "wait 3", "frame 65", "wait 100",
"frame 65", "unbreakable end", "wait 1",}

FootmanStill refers to unitstill - you may research what that is if you want.

Footmandeath is only interesting because frame 65 stays for 100 frame - that's the dead body lying after death animation is played. Make that 10000 and it will stay there.

The secret lies in FootmanMove. Not only does it specify animation frames, but it also declares, how far the unit moves after each frame of animation. For one anim cycle the unit has to move 1 tile away. One tile = 32 pixels. If you sum up the values of all "move" commands, you get 32. Otherwise the unit will not move properly.

Now you know enough to try make your own animations based on existing ones.

Let's get back to the basic code of our "footman".

DrawLevel = 40,

This is about layers. If two units have the same drawlevel, the unit which is lower will be drawn above the unit which is higher on the screen. Like, we hve a tower below an other unit. The spire will be drawn above the unit, which is correct. But if we declare the unit's drawlevel=41, the unit will be drawn above the spire, meaning it sorta flies. All fliers have the higher drawlevel.

What's next...

TileSize = {1, 1}, BoxSize = {60, 60},

Tilesize is how much place on map the unit occupies. 1,1 is 32x32. 2,2 is 64x64.

Boxsize is the size of selection square AND the area around the unit's center, clicking on which results in selecting the unit - that's pretty important.

ComputerReactionRange = 6,
Pers />Speed = ...

- do nothing.

Basic damage is reduced by armor, then piercing damage is added anyway..

Missile = "missile-none",

What missile from missiles.lua the unit uses to deliver damage.

Demand = 1,

Eats this much food.

Corpse = "unit-human-dead-body",

When death anim ends, the unit is replaced with this corpse unit found in scripts\units.lua

Sounds = {
"selected", "footman-selected",
"acknowledge", "peasant-acknowledge",
"ready", "footman-ready",
"help", "human_bad",
"dead", "human_bad"} } )

ok the three last sounds are new. Listed in sound.lua Look at human_bad:

MakeSound("human_bad",
{"human/basic_voices/help/1.wav",
"human/basic_voices/help/2.wav",
"human/basic_voices/help/3.wav",
"human/basic_voices/help/5.wav",
"human/basic_voices/help/4.wav"})

That sure is intuitive - you can manage your very own sounds this way. The sounds have to be saved as a 22 khz mono .wav.

A note on files: they're originally archived, mine are not. So, if there's "1.wav.gz" in a folder, you may unrar the 1.wav to the same destination, and delete the .gz file.

On further info on specific params, try to google them, like "wargus CanTargetLand "

Here's one useful search result: Stratagus.com

Thank you for your attention, I hope this helps create more pony stuff :)

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: