- Joined
- Aug 19, 2015
- Messages
- 68
Hi guys,
My map has been very stable recently and when i added this trigger, it crashed pretty fast so i think this was the reason.
What's wrong with this code?
In JASS, the trigger looks like this:
I looked up UnitHasItemOfTypeBJ
http://wiki.thehelper.net/wc3/jass/Blizzard.j/UnitHasItemOfTypeBJ
and GetInventoryIndexOfItemTypeBJ
http://wiki.thehelper.net/wc3/jass/Blizzard.j/GetInventoryIndexOfItemTypeBJ
Thanks.
My map has been very stable recently and when i added this trigger, it crashed pretty fast so i think this was the reason.
What's wrong with this code?
-
Bonus Gold Item
-
Events
-
Unit - A unit Dies
-
-
Conditions
-
((Killing unit) has an item of type Anatomic map) Equal to True
-
-
Actions
-
Player - Add 3 to (Owner of (Killing unit)) Current gold
-
-
In JASS, the trigger looks like this:
JASS:
function Trig_Untitled_Trigger_001_Copy_Conditions takes nothing returns boolean
if ( not ( UnitHasItemOfTypeBJ(GetKillingUnitBJ(), 'I000') == true ) ) then
return false
endif
return true
endfunction
function Trig_Untitled_Trigger_001_Copy_Actions takes nothing returns nothing
call AdjustPlayerStateBJ( 3, GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001_Copy takes nothing returns nothing
set gg_trg_Untitled_Trigger_001_Copy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001_Copy, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Untitled_Trigger_001_Copy, Condition( function Trig_Untitled_Trigger_001_Copy_Conditions ) )
call TriggerAddAction( gg_trg_Untitled_Trigger_001_Copy, function Trig_Untitled_Trigger_001_Copy_Actions )
endfunction
I looked up UnitHasItemOfTypeBJ
http://wiki.thehelper.net/wc3/jass/Blizzard.j/UnitHasItemOfTypeBJ
JASS:
function UnitHasItemOfTypeBJ takes unit whichUnit, integer itemId returns boolean
return GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) > 0
endfunction
and GetInventoryIndexOfItemTypeBJ
http://wiki.thehelper.net/wc3/jass/Blizzard.j/GetInventoryIndexOfItemTypeBJ
JASS:
function GetInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer
local integer index
local item indexItem
set index = 0
loop
set indexItem = UnitItemInSlot(whichUnit, index)
if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
return index + 1
endif
set index = index + 1
exitwhen index >= bj_MAX_INVENTORY
endloop
return 0
endfunction
Thanks.