• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Make so Hero cant hand off Item to other unit

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
I need to make it so I cant use 1 unit to hand an item to another unit.

(it cant use - unit acquires and item event - because if the unit gets the item the game will crash. I am trying to figure a way to use order targeting an object event to stop it before the item can enter the inventory of the other unit.
 

sentrywiz

S

sentrywiz

I need to make it so I cant use 1 unit to hand an item to another unit.

(it cant use - unit acquires and item event - because if the unit gets the item the game will crash. I am trying to figure a way to use order targeting an object event to stop it before the item can enter the inventory of the other unit.

a simple solution is: edit the hero (inventory) ability so that heroes aren't able to drop items OR just make the items unable to be dropped. this will limit your map, but its a solution. otherwise i'm not sure how would you stop a unit from "trading" an item to another unit unless you can differentiate between "trading" items and buying / finding them on the ground etc.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Unit acquires an item

-> if LoadInteger(hashtTable, itemHandleId, 0) == 0 then
->> SaveInteger(hashTable, itemHandleId, 0, TriggerUnitHandleId)
-> else
->> if LoadInteger(hashtTable, itemHandleId, 0) != TriggerUnitHandleId then
->>> drop item
->> endif
-> endif

EDIT: This would prevent a unit picking up an item that is dropped on the ground by another unit. I guess you don't want that.

Alright. Another idea.

Unit loses an item -> save true for the item. Start a timer with 0.00 second expiration time. If a unit acquires an item before the item expires, and the item has true stored, then the item has been transferred from a unit to another.
 
Level 13
Joined
Mar 24, 2010
Messages
950
Unit acquires an item

Unit loses an item -> save true for the item. Start a timer with 0.00 second expiration time. If a unit acquires an item before the item expires, and the item has true stored, then the item has been transferred from a unit to another.

good idea, but main problem is how to prevent it after that fact. Like i know how to make it so they cant pick it up off the ground or buy from a store, that's all set. But what do i use to stop the item transfer from inventory to inventory.. hmm and the main problem is we just dont have the Event to stop this from happening i think.

The only option is to use targeting an object, so triggering unit issuing an order to give an item from some slot # to another unit.. I should be able to figure this out i've made a perfect item bag before. *i'll come back to this soon*
 
Level 8
Joined
Dec 10, 2006
Messages
67
Isn't an undroppable item, once in a given unit's inventory, pretty much impossible to remove by any method other than expending its charges or a direct trigger action? What I'm wondering about is under what circumstances are units trading items when they're not supposed to be. There's a chance there's a workaround solution.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
good idea, but main problem is how to prevent it after that fact. Like i know how to make it so they cant pick it up off the ground or buy from a store, that's all set. But what do i use to stop the item transfer from inventory to inventory.. hmm and the main problem is we just dont have the Event to stop this from happening i think.

Use the method I posted and then force the unit to drop the item and give it back to the original unit.
 
Level 13
Joined
Mar 24, 2010
Messages
950
Isn't an undroppable item, once in a given unit's inventory, pretty much impossible to remove by any method other than expending its charges or a direct trigger action? What I'm wondering about is under what circumstances are units trading items when they're not supposed to be. There's a chance there's a workaround solution.

the item is fine to trade between heros or set down on the ground, i just dont want a hero given a certain item to a unit that can also use items like a hero would. it glitches out so i made it so that unit cant buy the item and cant pick the item up. but i need to not allow it to be given the item from a hero.

I tried a test map Maker but didnt work it out yet..
 
Level 5
Joined
Jan 17, 2014
Messages
131
the item is fine to trade between heros or set down on the ground, i just dont want a hero given a certain item to a unit that can also use items like a hero would. it glitches out so i made it so that unit cant buy the item and cant pick the item up. but i need to not allow it to be given the item from a hero.

I tried a test map Maker but didnt work it out yet..

Wait, are we talking about an item that is automatically used on pick up? If not, then make an inventory ability or use the Units inventory ability and a trigger:

  • Trigger
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Level of "Your Inventory Ability" for (Triggering unit)) Equal to 1
    • Actions
      • Hero - Drop (Item being manipulated) from (Triggering unit)
 
Level 8
Joined
Dec 10, 2006
Messages
67
Is this an automatically used item that adjusts a hero attribute such as strength, agility, inteligence, XP, level, or skill points? Giving such an item to a non-hero with the ability to use items seems to always cause an immediate crash. I've experienced this before. Even dropping said item immediately after acquiring it might not be enough to stop this. If this is what's going on, you might be going about this all wrong. Here's a possible way to handle this. Take the modifying ability away from the item. This should allow non-heros to have it in inventory. Add a trigger that makes whatever adjustment the item was supposed to make via trigger action if and only if a hero acquires this item. If the adjustment is only supposed to be in effect while the hero has the item, a trigger that reverses the effect upon loss of item would have to be implemented as well.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • LoseItem
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Trigger - Turn on AcquiteItem <gen>
      • Trigger - Turn on IsItemReceived <gen>
      • Set units[i] = (Triggering unit)
      • Set itAr[i] = (Item being manipulated)
      • Set i = (i + 1)
  • AcquiteItem
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer i1) from 0 to (i - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item being manipulated) Equal to itAr[i1]
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off LoseItem <gen>
              • Hero - Give (Item being manipulated) to units[i1]
              • Trigger - Turn on (This trigger)
              • Trigger - Turn on LoseItem <gen>
              • Skip remaining actions
            • Else - Actions
  • IsItemReceived
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off AcquiteItem <gen>
      • Set i = 0
      • Set itAr[0] = No item
 
Level 13
Joined
Mar 24, 2010
Messages
950
Is this an automatically used item that adjusts a hero attribute such as strength, agility, inteligence, XP, level, or skill points? Giving such an item to a non-hero with the ability to use items seems to always cause an immediate crash. I've experienced this before. Even dropping said item immediately after acquiring it might not be enough to stop this. If this is what's going on, you might be going about this all wrong. Here's a possible way to handle this. Take the modifying ability away from the item. This should allow non-heros to have it in inventory. Add a trigger that makes whatever adjustment the item was supposed to make via trigger action if and only if a hero acquires this item. If the adjustment is only supposed to be in effect while the hero has the item, a trigger that reverses the effect upon loss of item would have to be implemented as well.

This is an item using engineering abilities to affect hero abilities like wardens shadow strike for example. It takes the hero's ability and when this item is held by that hero it enhances its power essentially changing the spell out with a stronger one. I know all about the exp and tome items making the game crash but this situation isnt that. Its not used when acquired, its not a usable item at all, its passive basically.

When one of these items with the engineering ability to affect a hero spell is obtained by this unit type with a inventory capable of using items the game crashes. I need this unit to not be able to pick up this item, buy it from a store or have a hero place it in the units inventory.
The last one of those 3 is the only problem im having atm.


Maker: i'll try that trigger out but do you think that willl fire off fast enough before the item actually goes in the units inventory to make the game crash?
 
Level 8
Joined
Dec 10, 2006
Messages
67
Non-hero units are incapable of having hero abilities so trying to affect them in a non-hero might have the same result as attempting affect hero attributes which is what I think these engineering abilities are doing. Some items can have an effect just by being in the inventory. Take a look at the item in the Object Editor. There should be a field titled Use Automatically When Acquired or something like that. I don't think this is the same as Actively Used. If the Automatic Use field is TRUE, these engineering abilities are probably attempting to modify hero abilities just by the item being in inventory. This, I believe, could be what is causing the crashes.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Maker: i'll try that trigger out but do you think that willl fire off fast enough before the item actually goes in the units inventory to make the game crash?

I have to say I didn't read your original post closely enough for some reason or I forgot what it exactly said when I started triggering the system.

The item does indeed go briefly to the inventory of the other unit.

You could try attaching the ability to the item with triggers, and not in object editor.

Unit acquires an item of type x, if unit is a hero or some other condition then add ability. Otherwise do not add ability and give item back.
 
Status
Not open for further replies.
Top