HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Item ability help (Preventing use within an area)

02-02-2006, 01:36 PM#1
Erdrik
I have a 'safe zone' within my map in which any hero entering becomes invunerable, and sets aquisition range to 0. Also non hero units are forcably ordered away from this area. I even set up triggers that detect when a hero within this area casts an ability, If they do I pause the unit order it to stop then unpause it. I also added a bit of text to inform the player that they cannot use spells within the area. It works fine except with items.

When using an item like 'potion of healing' the healing effect is cast but the item charge is not used. I want to remove the players ability to use ANY item within this area so that Players cannot exploit this and use limitless charged items.
ie: standing on the edge of the safe area and using an infernal stone to limitlessly cast infernals into the play area.

I have tried:
___
1) Giving all hero 2 inventory abilities. the default, and another that has 'Data - Can Use Items' set to false. the locked inventory ability is disabled immidiatly upon the player selecting their hero. When they enter the safe area the locked ability is enabled then the default disabled. When they leave the safe area the default ability is enabled then the locked disabled.
Everything worked when entering the safe zone, I could tell the hero still had the item as I could clearly see the buff, but its inventory displayed as empty.
But when the hero left the safe zone, the item gets dropped when switching back to normal inventory..

2) A seperate trigger that detects item usage. except casting is detected first and the trigger that detects item usage never gets called.
___

If anyone out there has any ideas or clues, or simply sees something im missing(or wishes to see the triggers) please let me know.
02-02-2006, 01:44 PM#2
Whitehorn
Can you not pause, stop, unpause when they use an item also?
02-02-2006, 01:49 PM#3
Erdrik
The trigger already detects when they are casting a spell and then does 'pause, stop, unpause'. As I stated with my second attempt, The ability detecting trigger is called before the Item use trigger. Which means that if the 'pause, stop, unpause' method i was using was going to work it would be already. Unless you have another way to initiating the 'pause, stop, unpause' method sooner?
02-02-2006, 01:55 PM#4
Whitehorn
I thought using another trigger to catch 'manipulates an item'.
02-02-2006, 02:08 PM#5
Vexorian
Uses an item is less robust than detecting the spell used by the item. Problem was that uses an item didn't work well with non-consumable items
02-02-2006, 02:09 PM#6
Erdrik
Quote:
Originally Posted by Erdrik

2) A seperate trigger that detects item usage. except casting is detected first and the trigger that detects item usage never gets called.


I have already tried that. The problem is that The other trigger, that detects abilities being cast is called first and the item use trigger isn't being called. I have text displayed at the begining of both triggers, and only the ability detection trigger's text is displayed.

EDIT: errr this post is directed at Whitehorn.
02-02-2006, 02:15 PM#7
Vexorian
You need to detect the order to use the item actually.

That requires JASS since they are just orderids not orderstrings.

If you want I can tell you a trigger that uses JASS and does that.

But you can also just remove the items from the heroes and then give them back later.
02-02-2006, 02:20 PM#8
Erdrik
Would the order ID be for using items in general or specific items/ item types?

I would like to see the trigger either way tho. Its always a good idea to study new info. I learned like 5 new things coming to these forums.
02-02-2006, 02:44 PM#9
Vexorian
2 ways

First one requires an integer variable called orderslot:
Trigger:
Untitled Trigger 001
Collapse Events
Unit - A unit Is issued an order targeting an object
Unit - A unit Is issued an order targeting a point
Unit - A unit Is issued an order with no target
Conditions
Collapse Actions
Custom script: set udg_orderslot = GetIssuedOrderId() - 852007
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
orderslot less than or equal to 6
orderslot greater than or equal to 1
Collapse Then - Actions
-------- a player ordered a unit to use an item in slot orderslot of (triggering unit) --------
Else - Actions

The second way instantly gets the item itself, but you need this function at the custom script section:

Collapse JASS:
function GetIssuedOrderItem takes nothing returns item
    if not (GetIssuedOrderId() >= 852008) and (GetIssuedOrderId() <= 852013) then
        return null
    endif
    return(UnitItemInSlot(GetTriggerUnit(), (GetIssuedOrderId()-852008)))
endfunction

Then you need a item variable called orderitem :

Trigger:
Untitled Trigger 001
Collapse Events
Unit - A unit Is issued an order targeting an object
Unit - A unit Is issued an order targeting a point
Unit - A unit Is issued an order with no target
Conditions
Collapse Actions
Custom script: set udg_orderitem = GetIssuedOrderItem()
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
orderitem not equal to No item
Collapse Then - Actions
-------- a player ordered a unit to use the item orderitem --------
Else - Actions
02-02-2006, 02:48 PM#10
Erdrik
YAY! That will most definetly work.

Thank you much!
02-02-2006, 03:10 PM#11
Erdrik
How would the udg_orderitem variable look if it were an array? and one that took an integer from the player number of the owner of the ordered unit?
Quote:
set udg_orderitem[Player number of (Owner of (Ordered Unit))] = GetIssuedOrderItem() ??

EDIT: Sry, about the double post btw :P
02-02-2006, 03:11 PM#12
Blade.dk
Collapse JASS:
set udg_orderitem[GetPlayerId(GetOwningPlayer(GetOrderedUnit()))+1] = GetIssuedOrderItem()
02-02-2006, 03:13 PM#13
Erdrik
lol k Thnx

EDIT: nm :P

EDIT2:err I get a error for the custom script now : Expected a name

Quote:
set udg_orderitem[GetPlayerId(GetOwningPlayer(GetOrderedUnit()))+1] = GetIssuedOrderItem()

...?
02-02-2006, 03:22 PM#14
SortOf
wouldnt charging the Hero Inventory to a six slot Normal inventory work just as well?
02-02-2006, 03:25 PM#15
Vexorian
1) are you adding the GetIssuedOrderItem() function?
2) did you add the orderitem variable and set it as array?


I don't really understand the reason you needed to make it an array though