exge
New Member
- Reaction score
- 15
here is my code, pls help.. the items dropped cant be picked up
Code:
function Trig_attack_mob_Conditions takes nothing returns boolean
//return GetOwningPlayer(GetAttackedUnitBJ()) == Player(PLAYER_NEUTRAL_AGGRESSIVE)
return true
endfunction
function Trig_attack_mob_Actions takes nothing returns nothing
local unit mob = GetAttackedUnitBJ()
local unit atk = GetAttacker()
local player atkplayer = GetOwningPlayer(atk)
if GetUnitUserData(mob) == null then
call SetUnitUserData( mob, GetConvertedPlayerId(atkplayer))
else
call DoNothing()
endif
set mob = null
set atk = null
set atkplayer = null
endfunction
//===========================================================================
function InitTrig_attack_mob takes nothing returns nothing
set gg_trg_attack_mob = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_attack_mob, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_attack_mob, Condition( function Trig_attack_mob_Conditions ) )
call TriggerAddAction( gg_trg_attack_mob, function Trig_attack_mob_Actions )
endfunction
Code:
function Trig_mob_die_Actions takes nothing returns nothing
local unit deadmob = GetDyingUnit()
local unit killunit = GetKillingUnit()
local player killer = GetOwningPlayer(killunit)
local location deadmobloc = GetUnitLoc(deadmob)
call dropitem('rag1',deadmob,100)
if GetUnitUserData(deadmob) == GetConvertedPlayerId(killer) then
//===Unit matches
call AddHeroXPSwapped( ( 500 / GetHeroLevel(killunit) + 250), killunit, true )
else
//===NOT matching
call AddHeroXPSwapped( -( 500 / GetHeroLevel(killunit) + 250), killunit, true )
endif
set deadmob = null
set killunit = null
set killer = null
call RemoveLocation(deadmobloc)
endfunction
//===========================================================================
function InitTrig_mob_die takes nothing returns nothing
set gg_trg_mob_die = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_mob_die, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_mob_die, function Trig_mob_die_Actions )
endfunction
Code:
function Trig_aq_item_Actions takes nothing returns nothing
local unit aqitemunit = GetManipulatingUnit()
local item dropped = GetManipulatedItem()
if GetItemUserData(dropped) == (GetUnitUserData(aqitemunit)) then
call DoNothing()
else
call UnitRemoveItemSwapped(dropped, aqitemunit)
endif
endfunction
//===========================================================================
function InitTrig_aq_item takes nothing returns nothing
set gg_trg_aq_item = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_aq_item, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_aq_item, function Trig_aq_item_Actions )
endfunction
Code:
function dropitem takes integer itemid, unit deadmob, integer chance returns nothing
if GetRandomInt(1, 100) <= chance then
call CreateItemLoc(itemid, GetUnitLoc(deadmob))
call SetItemUserData(GetLastCreatedItem(), GetUnitUserData(deadmob))
endif
//call DisplayTextToForce(GetPlayersAll(), I2S(GetUnitUserData(deadmob)))
endfunction