HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Footman to Footman Hero?

09-13-2006, 10:29 PM#1
CrashLemon
Hi there, I made a trigger for a map I'm working on. The only problem is that the way I code my trigger, it will take forever. Here are the explanations:

I'm making a trigger that when you click on a footman, it turn this one into a footman hero (I made the footman hero in the object editor), when you click on a Peasant, it turn this one into a Peasant hero, when you click on a Rifleman, it turn this on into a Rifleman Hero, etc...

How could I make this trigger so I could do, A unit is clicked, transform the unit in (Clicked Unit names)+(Suffix: Hero) so it automaticaly change the unit and give it to the clicking player without triggering all this:
Trigger:
Collapse Events
Player - Player 2 (Blue) Selects a unit
Collapse Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Collapse Actions
Set Blue_Clicked_Unit = (Triggering Unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of Blue_Clicked_Unit) Equal to Peasant
Collapse Then - Actions
Unit - Change ownership of Blue_Clicked_Unit to Player 2 (Blue) and Change color
Unit - Replace Blue_Clicked_Unit with a Peasant (Hero) using The new unit's max life and mana
Set Blue_Clicked_Unit = (Last replaced unit)
Collapse Else - Actions
Do nothing

//Same thing but for the Footman
Collapse
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of Blue_Clicked_Unit) Equal to Footman
Collapse Then - Actions
Unit - Change ownership of Blue_Clicked_Unit to Player 2 (Blue) and Change color
Unit - Replace Blue_Clicked_Unit with a Footman (Hero) using The new unit's max life and mana
Set Blue_Clicked_Unit = (Last replaced unit)
Collapse Else - Actions
Do nothing

// Etc....
09-14-2006, 04:02 PM#2
oNdizZ
You could create a new global variable of the type unit-type and make it an array.
start with setting all your regular units into it and then (ill assume you have 10 heros) set the hero units (in the same order as you did with the regular ones, ie: if you started with a peasant youll set slot nr 11 to the peasant hero).

then.. oh right, you could need a new variable of the integer type.

use the same event and condition as your current trigger.
add the first action line aswell
after that, do a regular integer a loop
with an if/then/else in it:

Trigger:
if (Unit-type of Blue_Clicked_Unit) Equal to your_unit-type_var[Integer A]) then
set your_integer_variable = Integer A
else
endif

after that use:

Trigger:
Unit - Replace Blue_Clicked_Unit with a your_unit-type_var[your_integer_var+10] using The new unit's relative life and mana


(sloppy i know, didnt feel like opening up WE)

hope you understood the main concept :)
09-14-2006, 05:55 PM#3
Anitarf
Selection events are terrible, they happen with a delay.
09-15-2006, 01:32 AM#4
CrashLemon
Quote:
Originally Posted by Anitarf
Selection events are terrible, they happen with a delay.

Not when I play... Probably because I'm hosting?