Hey guys! Well, I got some problems with one of my triggers in my zombie-map. The map (well, don’t want to give a complete description of it but I guess I could give a short one to show you what it's supposed to be like
) is meant to be based upon basic ideas/tricks/triggers in order to make it as easy as possible for me to complete, since I only posses basic (I been working on random projects in map editor for like... one and a half year and I'm still bad! ^^
) knowledge of how to create triggers, because map editor is very time-consuming, and so on…
Anyway, what isn’t working is probably the key trigger in this map (of course haha). It is the trigger that replaces the unit that uses a weapon with another unit, which in turn has the right range and so on for the appropriate weapon. Err... like this:
Melee unit -> Uses rifle -> Is replaced with a ranged unit.
But there are several problems with it; it's probably not the best way to do it (it's probably a terrible way of doing it ^^
)... These are the problems:
1. The unit manipulating the item isn’t removed in the process unless I move the “Remove - Unit” action closer to the “set variable - Triggering_Unit ” action. (Which I find really weird) What’s the problem? Do I reset the variable at some point during the trigger? (except in the end of it of course...)
2. The “Triggering_unit” (the unit that is being removed) doesn’t give all his items to the created unit.
3. Also, continuing on the same part of the actions whom I talked about above, the items in the “replaced” units backpack automatically rearrange themselves in the receiving units backpack. For example, you place your gun in the 6th slot and use its ability. When your unit is replaced, the gun will “jump” to the first slot. Is there any way to fix this? (I'm thinking of something like, giving him an item if he doesn't have any item in the item slot, then removing all items of that type.)
And... the triggers:
)
Again, I know that I'm bad at this... I'd appreciate any help!
Thanks!
/Zowjos


Anyway, what isn’t working is probably the key trigger in this map (of course haha). It is the trigger that replaces the unit that uses a weapon with another unit, which in turn has the right range and so on for the appropriate weapon. Err... like this:
Melee unit -> Uses rifle -> Is replaced with a ranged unit.
But there are several problems with it; it's probably not the best way to do it (it's probably a terrible way of doing it ^^

1. The unit manipulating the item isn’t removed in the process unless I move the “Remove - Unit” action closer to the “set variable - Triggering_Unit ” action. (Which I find really weird) What’s the problem? Do I reset the variable at some point during the trigger? (except in the end of it of course...)
2. The “Triggering_unit” (the unit that is being removed) doesn’t give all his items to the created unit.
3. Also, continuing on the same part of the actions whom I talked about above, the items in the “replaced” units backpack automatically rearrange themselves in the receiving units backpack. For example, you place your gun in the 6th slot and use its ability. When your unit is replaced, the gun will “jump” to the first slot. Is there any way to fix this? (I'm thinking of something like, giving him an item if he doesn't have any item in the item slot, then removing all items of that type.)
And... the triggers:
-
Uses rifle MK11
-
Events
-
Unit - A unit Uses an item
-
-
Conditions
-
(Item-type of (Item being manipulated)) Equal to Standard Mk X-11 Rifle
-
-
Actions
-
Trigger - Turn off Stack items <gen>
-
Set Triggering_unit = (Triggering unit)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Unit-type of Triggering_unit) Not equal to Armed civilian (Rapid Fire)
-
-
Then - Actions
-
--------
-
-------- Variables --------
-
-------- -(some variables are further down)- --------
-
Set Loc_1 = (Position of Triggering_unit)
-
Set Xp_of_Hero = (Hero experience of Triggering_unit)
-
Set HP_Amount = (Integer((Life of Triggering_unit)))
-
Set Mana_Amount = (Integer((Mana of Triggering_unit)))
-
-------- - --------
-
-------- (1) - Create a dummy and move the last created unit there when the replaced unit "dies". --------
-
Unit - Create 1 Dummy for (Owner of Triggering_unit) at Loc_1 facing (Facing of Triggering_unit) degrees
-
Set Dummy_Unit = (Last created unit)
-
Set Loc_2 = (Position of Dummy_Unit)
-
Unit - Add a 0.50 second Generic expiration timer to Dummy_Unit
-
-------- - --------
-
-------- Also set the unit's level to that of the "replaced" unit. --------
-
Unit - Create 1 Armed civilian (Rapid Fire) for (Owner of Triggering_unit) at Loc_1 facing (Facing of Triggering_unit) degrees
-
Hero - Set (Last created unit) experience to Xp_of_Hero, Hide level-up graphics
-
-------- - --------
-
-------- Its important to set the life of the new rifleman efter he has leveled up, or else he will benefit from his previously gained strength --------
-
Unit - Set mana of (Last created unit) to (Real(Mana_Amount))
-
Unit - Set life of (Last created unit) to (Real(HP_Amount))
-
-------- - --------
-
-------- - --------
-
-------- Drop items --------
-
For each (Integer A) from 1 to (Size of inventory for Triggering_unit), do (Actions)
-
Loop - Actions
-
Hero - Drop the item from slot (Integer A) of Triggering_unit
-
Hero - Give (Last dropped item) to (Last created unit)
-
-
-
-------- - --------
-
-------- -------------->((SPELL ADD) ->Q) If unit has Fend off then... --------
-
Set Spell_Level = (Level of Fend off for Triggering_unit)
-
-------- - --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Spell_Level Not equal to 0
-
-
Then - Actions
-
Hero - Learn skill for (Last created unit): Fend off
-
Unit - Set level of Fend off for (Last created unit) to Spell_Level
-
-
Else - Actions
-
-
Set Spell_Level = 0
-
-------- - --------
-
-------- -------------->((SPELL ADD) ->W) If unit has "That one!" then... --------
-
Set Spell_Level = (Level of That one! for Triggering_unit)
-
-------- - --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Spell_Level Not equal to 0
-
-
Then - Actions
-
Hero - Learn skill for (Last created unit): That one!
-
Unit - Set level of That one! for (Last created unit) to Spell_Level
-
-
Else - Actions
-
-
Set Spell_Level = 0
-
-------- - --------
-
-------- -------------->((SPELL ADD) ->E) If unit has Heal then... --------
-
Set Spell_Level = (Level of Heal for Triggering_unit)
-
-------- - --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Spell_Level Not equal to 0
-
-
Then - Actions
-
Hero - Learn skill for (Last created unit): Heal
-
Unit - Set level of Heal for (Last created unit) to Spell_Level
-
-
Else - Actions
-
-
Set Spell_Level = 0
-
-------- - --------
-
-------- -------------->((SPELL ADD) ->R) If unit has rapid fire then... --------
-
Set Spell_Level = (Level of Focus for Triggering_unit)
-
-------- - --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Spell_Level Not equal to 0
-
-
Then - Actions
-
Hero - Learn skill for (Last created unit): Focus
-
Unit - Set level of Focus for (Last created unit) to Spell_Level
-
-
Else - Actions
-
-
Set Spell_Level = 0
-
-------- - --------
-
-------- - Clean-up - --------
-
-------- - --------
-
-------- Add selection --------
-
Selection - Add (Last created unit) to selection for (Owner of (Last created unit))
-
-------- - --------
-
Unit - Remove Triggering_unit from the game
-
-------- - --------
-
-------- Unit group -->Add unit to the Unit group of all friendly heroes. Remove the former unit. --------
-
Unit Group - Remove Triggering_unit from Unit_Group_Good_Guys
-
Unit Group - Add (Last created unit) to Unit_Group_Good_Guys
-
-------- - --------
-
-------- (1) - Move last created unit to postition of "Triggering_unit" --------
-
Unit - Move (Last created unit) instantly to Loc_2, facing Default building facing degrees
-
-------- - --------
-
Set HP_Amount = 0
-
Set Mana_Amount = 0
-
Set Xp_of_Hero = 0
-
Set Dummy_Unit = No unit
-
Set Triggering_unit = No unit
-
Custom script: call RemoveLocation(udg_Loc_1)
-
Custom script: call RemoveLocation(udg_Loc_2)
-
-------- - --------
-
-
Else - Actions
-
-------- The "else" actions are basically the same as the "then" actions, they just replace the 'rifle' unit with the 'melee' unit. --------
-
-------- - --------
-
-
-
Trigger - Turn on Stack items <gen>
-
-

Again, I know that I'm bad at this... I'd appreciate any help!
Thanks!
/Zowjos