• 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.

[Trigger] Item Pick Up Increases Ability Level

Status
Not open for further replies.
Level 8
Joined
Jun 13, 2010
Messages
344
Hi

I am making an ability called Combat Skill. Certain items, when carried, have to increase the level of the ability. So when you pick it up, it increases in level and when you lose it, you decrease in level.

Fails:
It works when I pick the item up and it counts for both items to a total level of 3, since you have level 1 as a standard.
However, when you lose the items 1 by 1, the first drop makes the level 3. The second drop makes the level go to 2 and stay there. So now you actually have level 2, without carrying any item.
What seems to be the issue? I am lost.


So far I've done this:


  • Combat Skill Increase
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Backpack
    • Actions
      • Set CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] = 1
      • Set ItemCounter_Item = (Item being manipulated)
      • Set ItemCounter_PickUpUnit = (Triggering unit)
      • Set ItemCounter_Inventory = (Size of inventory for ItemCounter_PickUpUnit)
      • For each (Integer ItemCounter_Loop) from 1 to ItemCounter_Inventory, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Scrapped Boots (PA)
                  • (Item-type of (Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop)) Equal to Henchman Bow (MH)
            • Then - Actions
              • Set CombatSkill[(Player number of (Owner of A_Unit))] = (CombatSkill[(Player number of (Owner of A_Unit))] + 1)
            • Else - Actions
      • Game - Display to (All players) the text: (String(CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))]))
      • -------- PASSIVE CHECK --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Cunning (Passive) for ItemCounter_PickUpUnit) Equal to 1
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] Greater than or equal to 12
            • Then - Actions
              • Unit - Set level of Combat Skill for ItemCounter_PickUpUnit to 12
            • Else - Actions
              • Unit - Set level of Combat Skill for ItemCounter_PickUpUnit to CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] Greater than or equal to 10
            • Then - Actions
              • Unit - Set level of Combat Skill for ItemCounter_PickUpUnit to 10
            • Else - Actions
              • Unit - Set level of Combat Skill for ItemCounter_PickUpUnit to CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))]
Thanks for reading!

Edit:
I guess I found the issue and fixed it. It seems it counts the item within the integer before it actually drops the item.
So I seperated the trigger into 2, 1 for acquires item and 1 for loses item. In the loses item I made the array integer -1 after calculating the inventory..
  • Set CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] = (CombatSkill[(Player number of (Owner of ItemCounter_PickUpUnit))] - 1)
Just wish I wouldn't have to use such a slacking half-way-method and just being able to have 1 trigger for this...
 
Last edited:
you can do that in one trigger, just use GetHandleId(GetTriggerEventId())
  • Custom script: if GetHandleId(GetTriggerEventId()) == 48 then // EVENT "item droped"
  • your actions to item dropped
  • Custom script: elseif GetHandleId(GetTriggerEventId()) == 49 then // EVENT "item picked up"
  • your actions for item picked up
  • Custom script: endif
and yes, upon "unit loses and item" event this dropped item is still counted in inventory when you looking for items in loop, simple solution is adding condition:
ItemCounter_Item not equal to Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Might be better to have them as two triggers. Unless you can process the events exactly the same, eg chat message events for many players, then it is almost always better to separate into multiple triggers to avoid the decision logic overhead and improve cohesion.
 
Last edited:
Level 8
Joined
Jun 13, 2010
Messages
344
and yes, upon "unit loses and item" event this dropped item is still counted in inventory when you looking for items in loop, simple solution is adding condition:
ItemCounter_Item not equal to Item carried by ItemCounter_PickUpUnit in slot ItemCounter_Loop

Oh ye why didn't i think of that. So simple..

And to Dr Super Good, yes I guess you are right by that.
 
Status
Not open for further replies.
Top