• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Stat detection for item

Status
Not open for further replies.
Level 5
Joined
Jun 15, 2016
Messages
111
How to make some sort of detection system, (which I think will use custom script but idk how) that makes it so that when you pick up an item, it checks your stats. For example, this item needs 15 strength to carry, and you only have 14. How will you make it not pick it up(or drop upon carrying?)
 
Level 12
Joined
May 22, 2015
Messages
1,051
You would need to use a trigger. Something like:
  • Item Check
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • Item type of (Item being manipulated) equal to (mySpecialItem)
    • (Strength of (Triggering Unit) including bonuses) Less than 15
  • Actions
    • Item - Create 1 (Item type of (Item being manipulated)) at (Position of (Triggering unit))
    • Item - Remove (Item being manipulated) from the game
The actions are sloppy because I don't remember how to force an item onto the ground. This would work but could cause other issues if you are keeping track of the specific item for other reasons. The trigger above also has a point leak when it creates a new item.

Another thing to watch out for is that items might add stats. I don't remember if those stats would be applied by the time this trigger runs, but if you are checking if they have enough strength, and the item adds some strength, it might let the hero carry it even if they shouldn't be able to.
 
Level 5
Joined
Jun 15, 2016
Messages
111
You would need to use a trigger. Something like:
  • Item Check
  • Events
    • Unit - A unit acquires an item
  • Conditions
    • Item type of (Item being manipulated) equal to (mySpecialItem)
    • (Strength of (Triggering Unit) including bonuses) Less than 15
  • Actions
    • Item - Create 1 (Item type of (Item being manipulated)) at (Position of (Triggering unit))
    • Item - Remove (Item being manipulated) from the game
The actions are sloppy because I don't remember how to force an item onto the ground. This would work but could cause other issues if you are keeping track of the specific item for other reasons. The trigger above also has a point leak when it creates a new item.

Another thing to watch out for is that items might add stats. I don't remember if those stats would be applied by the time this trigger runs, but if you are checking if they have enough strength, and the item adds some strength, it might let the hero carry it even if they shouldn't be able to.
Thanks a bunch, I think ill just "Drop item for Hero" action.
 
Status
Not open for further replies.
Top