- Reaction score
- 91
I have a script that is supposed to issue usage of a specific item at some point of the game. Because there are a lot of items that I use based on instant, unit or point cast, I used a simplified method and just call the 3 natives instead of checking whether the item should be casted on units/points/instantaneously or not.
Say this is a part of my script that issues that item casting. Everything works perfectly except for unit targeting... This event is supposed to trigger when a spell is cast and if the specific item targets units, it should target a unit. The problem is that the item was never used on the target even though I had no other mistakes in my code. After some toying around I rearranged the order of casting and found out that this time it works flawlessly.
So, can anybody explain to me why the first method does not work for unit targeting while the second works for everything?
Even though in the first method FAIL is never displayed, it does not cast the item!
JASS:
// This code is executed in a loop so I use an O(n) search in an array for item types. "crap" is an item variable, don't get confused... ^^
// ITEM[a] is my integer array containing all item types.
set crap = GetItemOfTypeFromUnitBJ(this.cast, ITEM[a])
if not UnitUseItemPoint(this.cast, crap, this.tx, this.ty) then
if not UnitUseItem(this.cast, crap) then
// should work?
if not UnitUseItemTarget(this.cast, crap, this.targ) then
call BJDebugMsg("FAIL ?!?!?!?")
endif
endif
endif
Say this is a part of my script that issues that item casting. Everything works perfectly except for unit targeting... This event is supposed to trigger when a spell is cast and if the specific item targets units, it should target a unit. The problem is that the item was never used on the target even though I had no other mistakes in my code. After some toying around I rearranged the order of casting and found out that this time it works flawlessly.
JASS:
// This code is executed in a loop so I use an O(n) search in an array for item types. "crap" is an item variable, don't get confused... ^^
set crap = GetItemOfTypeFromUnitBJ(this.cast, ITEM[a])
if not UnitUseItemPoint(this.cast, crap, this.tx, this.ty) then
if not UnitUseItemTarget(this.cast, crap, this.targ) then
if not UnitUseItem(this.cast, crap) then
call BJDebugMsg("FAIL ?!?!?!?")
endif
endif
endif
So, can anybody explain to me why the first method does not work for unit targeting while the second works for everything?
Even though in the first method FAIL is never displayed, it does not cast the item!