function item_is_in_pool takes nothing returns boolean
if(GetItemTypeId(GetManipulatedItem())=='I06B')then
return true
endif
endfunction
function set_item_player takes returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
call SetItemPlayer(I,GetPlayerId(GetOwningPlayer(U))
set u=null
set i=null
endfunction
function trigger_item_pickup takes nothing returns nothing
set t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
This is my first trigger and I have no clue why its not working
I've been thinking about that Blizzard Function too but it seems did not work for me, therefore I created a system Item Bound (Signature) - however it's in GUI.
Wait, what you're trying to do exactly ?
And what's the "not working" part ?
Specify.
I've been thinking about that Blizzard Function too but it seems did not work for me, therefore I created a system Item Bound (Signature) - however it's in GUI.
Wait, what you're trying to do exactly ?
And what's the "not working" part ?
Specify.
I got a unit that drops a item but this item being drop belongs to that player .. now if this unit picks up that item and that item is say 'I909' it should change the itemowner to the guy who picked it up
I'm very new to jass too but here would be my take on it:
JASS:
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
call SetItemPlayer(i, GetOwningPlayer(u), true)
// true changes item color, but I don't get why item color would change
// fixed the trigger, but this here is likely not work like defskull said
set u=null
set i=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
Assuming the trigger name is "item pickup"
Edit: woops, here it is.
Edit2: nvm, u have some wrong functions, 1 min, gotta fix mines too
Edit3: tested, trigger works, Item ownership doesn't. I have an item ownership code in gui in one of my maps, 1 min.
I'm very new to jass too but here would be my take on it:
JASS:
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
call SetItemPlayer(I,GetPlayerId(GetOwningPlayer(U))
set u=null
set i=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
Assuming the trigger name is "item pickup"
Edit: woops, here it is.
Edit2: nvm, u have some wrong functions, 1 min, gotta fix mines too
I don't know? I just started Jass like yesterday.
It's like that by standard conversion.
Only that init function needs it if it is necessary.
If you want items bound by ownership, one minute, working something.
I don't know? I just started Jass like yesterday.
It's like that by standard conversion.
Only that init function needs it if it is necessary.
If you want items bound by ownership, one minute, working something.
Well, this is my second jass script I ever wrote. Sort of. Not really, since ¾ of it is yours.
Fun stuff. Liking it more than GUI already, damn why did I stick with GUI for 6 years
(and refused to learn hashtables + timers, all I know is arrays lmao).
JASS:
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
/*************************************************************************************
replace the above line with
return GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
if you want all items bounded except for items of purchasable class
or something like
return GetItemTypeId(GetManipulatedItem()) == 'xxxx' or GetItemTypeId(GetManipulatedItem()) == 'xxxx'
if you want to bound only 2 item types, etc
*************************************************************************************/
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
local force f=GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit()))
if (GetItemUserData(i) == 0) then
call SetItemUserData(i, GetConvertedPlayerId(GetOwningPlayer(u)))
endif
if (GetItemUserData(i) != GetConvertedPlayerId(GetOwningPlayer(u))) then
call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit())
call DisplayTextToForce(f, "This item belongs to " + GetPlayerName(ConvertedPlayer(GetItemUserData(i))))
endif
set u=null
set i=null
set f=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
Trigger name: item pickup
What it does: items bound by player, gives message of who owner is if other player tries to pick.
EDIT: I did this by setting Item Custom Value to Player # of manipulator. Just thought you'd need to know in case you ever want to edit it.
Well, this is my second jass script I ever wrote. Sort of. Not really, since ¾ of it is yours.
Fun stuff. Liking it more than GUI already, damn why did I stick with GUI for 6 years
(and refused to learn hashtables + timers, all I know is arrays lmao).
JASS:
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
/*************************************************************************************
replace the above line with
return GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
if you want all items bounded except for items of purchasable class
or something like
return GetItemTypeId(GetManipulatedItem()) == 'xxxx' or GetItemTypeId(GetManipulatedItem()) == 'xxxx'
if you want to bound only 2 item types, etc
*************************************************************************************/
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
local force f=GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit()))
if (GetItemUserData(i) == 0) then
call SetItemUserData(i, GetConvertedPlayerId(GetOwningPlayer(u)))
endif
if (GetItemUserData(i) != GetConvertedPlayerId(GetOwningPlayer(u))) then
call UnitRemoveItemSwapped( GetManipulatedItem(), GetTriggerUnit())
call DisplayTextToForce(f, "This item belongs to " + GetPlayerName(ConvertedPlayer(GetItemUserData(i))))
endif
set u=null
set i=null
set f=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
Trigger name: item pickup
What it does: items bound by player, gives message of who owner is if other player tries to pick.
EDIT: I did this by setting Item Custom Value to Player # of manipulator. Just thought you'd need to know in case you ever want to edit it.
function item_is_in_pool takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I06B'
/*************************************************************************************
replace the above line with
return GetItemType(GetManipulatedItem()) != ITEM_TYPE_PURCHASABLE
if you want all items bounded except for items of purchasable class
or something like
return GetItemTypeId(GetManipulatedItem()) == 'xxxx' or GetItemTypeId(GetManipulatedItem()) == 'xxxx'
if you want to bound only 2 item types, etc
*************************************************************************************/
endfunction
function set_item_player takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
if GetItemUserData(i) == 0 then
call SetItemUserData(i, GetPlayerId(GetOwningPlayer(u))+1)
endif
if GetItemUserData(i) != GetPlayerId(GetOwningPlayer(u))+1 then
call UnitRemoveItem(u, GetManipulatedItem())
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 5, "This item belongs to " + GetPlayerName(Player(GetItemUserData(i))))
endif
set u=null
set i=null
endfunction
function InitTrig_item_pickup takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(t,Condition(function item_is_in_pool))
call TriggerAddAction(t,function set_item_player)
set t=null
endfunction
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.