• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Problems with my weapon system...

Status
Not open for further replies.
Level 2
Joined
Oct 13, 2010
Messages
9
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 :cwink:) 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! ^^ :cmad:) 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 ^^:cgrin: )... 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:
  • 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>
(The stack items trigger adds the charges of the same type of item, like ammo :croll:)
Again, I know that I'm bad at this... I'd appreciate any help!
Thanks!
/Zowjos
 
Level 13
Joined
Apr 15, 2008
Messages
1,063
Maybe you could try a completely different approach, change the unit with Chaos ability or permanent morph.
I am not sure about chaos, but morph should definetely work for heroes. The problem with morph is that you would need an ability for each unit combination, while for chaos you only need one ability for each resulting unit.
Chaos: Just set the new unit type, and add this ability to the unit that should change.
Morph: for each old->new combnation, create an ability (setting the original unit type to "base unit" and the new unit type in "alternate unit"). Also, select the "permanent" option and set times to 0.
Then, when the unit should change, add according ability and order the unit to use it.
 
Level 11
Joined
Sep 12, 2008
Messages
657
hmm, if you got jass new gen pack,
i can give you a system i made..
it basicly remakes a hero, saving all hes info, etc.
and allows you to save up to 6 abilities.
tell me if you need it ^^ (it would save you alot of trouble making many weapons)
 
Level 2
Joined
Oct 13, 2010
Messages
9
The chaos ability, wow, didn't even think about that. Tried it out, and well, it works perfectly! Cooldowns and everything are still there, items don't change place in the inventory either!

My only question though; is there absolutely no downside with using the chaos ability? No leaks, nothing? (I don't know, just seems too easy :crazz:) Also, does the unit keep the chaos ability? Do you have to remove it?

Anyway, thanks for the replies, it's much easier to work upon the map now. :csmile:
 
Level 2
Joined
Oct 13, 2010
Messages
9
Yea me too. I'm trying all kinds of things for the moment just to make sure that it really is working.
 
Level 2
Joined
Oct 20, 2010
Messages
7
There is a pitfall to using chaos.

Gaining the same chaos ability twice in a row (e.g. transforming a unit into the unit type it already is) tends to behave oddly. An exponential increase in damage values is the main symptom.

So long as nobody can equip two guns at once, this shouldn't be a problem.
 
Level 4
Joined
Oct 19, 2010
Messages
71
I'm fairly inexperienced, but I'll take a crack at this anyway.

1) If it's possible for multiple triggers to be running at the same time, perhaps your unit variable is being reset by another trigger.

2) If what I mentioned in #1 is happening, that would cause the problem in #2. However, I think it more likely that the game is forgetting which unit is the last created unit, or another unit is recognized as that unit. You could try setting a variable to the last created unit in this trigger. To get a better picture of what is happening, each time the loop runs, you could have it write integer A above the last created unit.

3) This is the question where I can offer the most helpful info. I like your solution, but I noticed an unit action that would be more elegant:

  • Actions
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • Hero - Drop the item from slot (Integer A) of (Triggering unit)
        • Hero - Give (Last dropped item) to (Last created unit)
        • Unit - Order (Last created unit) to move (Last dropped item) to inventory slot (Integer A)
 
Status
Not open for further replies.
Top