• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Replacing units

Status
Not open for further replies.
Level 6
Joined
Jan 29, 2010
Messages
213
[SOLVED]


Hi all, I have some kind of problem with changing units when I drop Item(Gun(Bow))

[trigger.]Drop Gun:
  • Gun drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item level of (Item being manipulated)) Equal to 1
        • Then - Actions
          • Set Item[2] = 0
          • For each (Integer ItemSlot[2]) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item level of (Item carried by (Hero manipulating item) in slot ItemSlot[2])) Equal to 1
                • Then - Actions
                  • Set Item[2] = (Item[2] + 1)
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Item[2] Equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Str|r lnk
                      • (Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Int|r lnk
                      • (Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Agi|r lnk
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item being manipulated)) Equal to Simple Bow
                    • Then - Actions
                      • If ((Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Str|r lnk) then do (Unit - Replace (Hero manipulating item) with a Gladiator |cffffcc00Str|r using The old unit's relative life and mana) else do (Do nothing)
                      • If ((Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Agi|r lnk) then do (Unit - Replace (Hero manipulating item) with a Gladiator |cffffcc00Agi|r using The old unit's relative life and mana) else do (Do nothing)
                      • If ((Unit-type of (Hero manipulating item)) Equal to Gladiator |cffffcc00Int|r lnk) then do (Unit - Replace (Hero manipulating item) with a Gladiator |cffffcc00Int|r using The old unit's relative life and mana) else do (Do nothing)
                      • For each (Integer A) from 1 to 6, do (Actions)
                        • Loop - Actions
                          • Hero - Give (Item carried by (Hero manipulating item) in slot (Integer A)) to (Last replaced unit)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
        • Else - Actions

I tested all trigger with game display text, and so the result is:

---at start---
Item[2]=0
---Picked up item---
Item[2]=1
---Dropped item---
Item[2]=1

------------------
So the problem is in event (unit loses an item(It works only when unit picks up the item, but not when he drops him))

What kind of even I have to use to get this trigger working correctly, like he has to?


There's map if u want to test it:
http://www.hiveworkshop.com/forums/pastebin_data/0v71nu/_files/test.w3x
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
If you read the replace unit function definition you will see that all it does is remove the given unit and make a new unit of the specified type and set many of its properties to that of the unit that was removed.

As such, all references to the unit which you "replaced" will return null cause the unit was removed (no longer exists).
 
Level 6
Joined
Jan 29, 2010
Messages
213
If you read the replace unit function definition you will see that all it does is remove the given unit and make a new unit of the specified type and set many of its properties to that of the unit that was removed.

As such, all references to the unit which you "replaced" will return null cause the unit was removed (no longer exists).

That isn't a real problem :/
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here you go:


  • unit acquires an item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off unit loses an item <gen>
      • Set boolean = False
      • Custom script: if IsUnitSelected(GetTriggerUnit() , GetTriggerPlayer()) then
      • Set boolean = True
      • Custom script: endif
      • If ((Unit-type of (Triggering unit)) Equal to Mountain King) then do (Unit - Replace (Triggering unit) with a Paladin using The old unit's relative life and mana) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • boolean Equal to True
        • Then - Actions
          • Selection - Add (Last replaced unit) to selection for (Triggering player)
        • Else - Actions
      • Trigger - Turn on (This trigger)
      • Trigger - Turn on unit loses an item <gen>
  • unit loses an item
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • Trigger - Turn off unit acquires an item <gen>
      • Trigger - Turn off (This trigger)
      • Set boolean = False
      • Custom script: if IsUnitSelected(GetTriggerUnit() , GetTriggerPlayer()) then
      • Set boolean = True
      • Custom script: endif
      • If ((Unit-type of (Triggering unit)) Equal to Paladin) then do (Unit - Replace (Triggering unit) with a Mountain King using The old unit's relative life and mana) else do (Do nothing)
      • Hero - Drop (Item carried by (Last replaced unit) of type (Item-type of (Item being manipulated))) from (Last replaced unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • boolean Equal to True
        • Then - Actions
          • Selection - Add (Last replaced unit) to selection for (Triggering player)
        • Else - Actions
      • Trigger - Turn on (This trigger)
      • Trigger - Turn on unit acquires an item <gen>
 

Attachments

  • test(3).w3x
    17.4 KB · Views: 73
Level 6
Joined
Jan 29, 2010
Messages
213
Here you go:


  • unit acquires an item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off unit loses an item <gen>
      • Set boolean = False
      • Custom script: if IsUnitSelected(GetTriggerUnit() , GetTriggerPlayer()) then
      • Set boolean = True
      • Custom script: endif
      • If ((Unit-type of (Triggering unit)) Equal to Mountain King) then do (Unit - Replace (Triggering unit) with a Paladin using The old unit's relative life and mana) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • boolean Equal to True
        • Then - Actions
          • Selection - Add (Last replaced unit) to selection for (Triggering player)
        • Else - Actions
      • Trigger - Turn on (This trigger)
      • Trigger - Turn on unit loses an item <gen>
  • unit loses an item
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • Trigger - Turn off unit acquires an item <gen>
      • Trigger - Turn off (This trigger)
      • Set boolean = False
      • Custom script: if IsUnitSelected(GetTriggerUnit() , GetTriggerPlayer()) then
      • Set boolean = True
      • Custom script: endif
      • If ((Unit-type of (Triggering unit)) Equal to Paladin) then do (Unit - Replace (Triggering unit) with a Mountain King using The old unit's relative life and mana) else do (Do nothing)
      • Hero - Drop (Item carried by (Last replaced unit) of type (Item-type of (Item being manipulated))) from (Last replaced unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • boolean Equal to True
        • Then - Actions
          • Selection - Add (Last replaced unit) to selection for (Triggering player)
        • Else - Actions
      • Trigger - Turn on (This trigger)
      • Trigger - Turn on unit acquires an item <gen>

Working perfect! thenks :)
 
Status
Not open for further replies.
Top