// ---------------------------------------------------------
// ABILITY LEVEL UP SYSTEM
// CREATED BY -KOBAS- ON REQUEST
// VERSION 2.0
// ---------------------------------------------------------
function ItemSystemSetup takes nothing returns nothing
local integer ItemId
set udg_KSHash = InitHashtable()
set ItemId = 'I000' //FOR ITEM -> 'I000'
call SaveInteger(udg_KSHash, ItemId, 0, 0 ) //Required Agility
call SaveInteger(udg_KSHash, ItemId, 1, 40 ) //Required Intelligence
call SaveInteger(udg_KSHash, ItemId, 2, 0 ) //Required Strength
call SaveInteger(udg_KSHash, ItemId, 3, 0 ) //Required Level
call SaveInteger(udg_KSHash, ItemId, 4, 10 ) //Ability Max Level
call SaveInteger(udg_KSHash, ItemId, 5, 0 ) //Item Gold Cost
call SaveInteger(udg_KSHash, ItemId, 6, 2 ) //Item Lumber Cost
call SaveInteger(udg_KSHash, ItemId, 7, 'A000') //Ability Id
set ItemId = 'I001' //FOR ITEM -> 'I001'
call SaveInteger(udg_KSHash, ItemId, 0, 0 ) //Required Agility
call SaveInteger(udg_KSHash, ItemId, 1, 0 ) //Required Intelligence
call SaveInteger(udg_KSHash, ItemId, 2, 40 ) //Required Strength
call SaveInteger(udg_KSHash, ItemId, 3, 0 ) //Required Level
call SaveInteger(udg_KSHash, ItemId, 4, 10 ) //Ability Max Level
call SaveInteger(udg_KSHash, ItemId, 5, 3 ) //Item Gold Cost
call SaveInteger(udg_KSHash, ItemId, 6, 0 ) //Item Lumber Cost
call SaveInteger(udg_KSHash, ItemId, 7, 'A001') //Ability Id
// ---------------------------------------------------------
// HERE YOU CAN EDIT MSG DISPLAYED TO PLAYER
// ---------------------------------------------------------
call SaveStr(udg_KSHash, 0, 0, "Hero ability is already max level") //MSG Shown when unit has already ability level set to max
call SaveStr(udg_KSHash, 0, 1, "Hero stats are low") //MSG Shown when unit don't have required stats
call SaveStr(udg_KSHash, 0, 2, "Hero level is low") //MSG Shown when unit don't have required level
// ---------------------------------------------------------
// HERE YOU CAN EDIT SPECIAL EFFECTS DISPLAYED TO PLAYERS
// ---------------------------------------------------------
call SaveStr(udg_KSHash, 1, 0, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl") //Special Effect path: Learn ability
call SaveStr(udg_KSHash, 1, 1, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl") //Special Effect path: level up ability
call SaveStr(udg_KSHash, 1, 2, "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl") //Special Effect path: Error
// ---------------------------------------------------------
endfunction
function ItemSystemCleanUp takes integer id, integer i returns nothing
call SetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER, ( GetPlayerState( GetTriggerPlayer() ,PLAYER_STATE_RESOURCE_LUMBER) + LoadInteger(udg_KSHash, id, 6) ) ) // We add lumber back to player
call SetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState( GetTriggerPlayer() ,PLAYER_STATE_RESOURCE_GOLD) + LoadInteger(udg_KSHash, id, 5) ) ) // We add gold back to player
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, LoadStr(udg_KSHash, 0, i))
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KSHash, 1, 2),GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit())))
endfunction
function ItemSystem takes nothing returns nothing
local integer ItemId = GetItemTypeId(GetManipulatedItem())
local unit u = GetTriggerUnit()
// ---------------------------------------------------------
// NO NEED TO BE CHANGED
// ---------------------------------------------------------
if GetHeroLevel(u) >= LoadInteger(udg_KSHash, ItemId, 3) then
if GetHeroAgi(u, false) >= LoadInteger(udg_KSHash, ItemId, 0) and GetHeroInt(u, false) >= LoadInteger(udg_KSHash, ItemId, 1) and GetHeroStr(u, false) >= LoadInteger(udg_KSHash, ItemId, 2) then
if GetUnitAbilityLevel(u, LoadInteger(udg_KSHash, ItemId, 7)) == 0 then
call UnitAddAbility(u, LoadInteger(udg_KSHash, ItemId, 7))
call UnitMakeAbilityPermanent(u,true, LoadInteger(udg_KSHash, ItemId, 7))
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KSHash, 1, 0),GetUnitX(u),GetUnitY(u)))
elseif GetUnitAbilityLevel(u, LoadInteger(udg_KSHash, ItemId, 7)) == LoadInteger(udg_KSHash, ItemId, 4) then
call ItemSystemCleanUp(ItemId, 0)
else
call IncUnitAbilityLevel(u, LoadInteger(udg_KSHash, ItemId, 7))
call DestroyEffect(AddSpecialEffect(LoadStr(udg_KSHash, 1, 1),GetUnitX(u),GetUnitY(u)))
endif
else
call ItemSystemCleanUp(ItemId, 1)
endif
else
call ItemSystemCleanUp(ItemId, 2)
endif
call SetWidgetLife(GetManipulatedItem(),0.406)
call RemoveItem(GetManipulatedItem())
set u = null
endfunction
// ---------------------------------------------------------
// BJ BELOW WILL TRIGGER THIS FOR ANY PLAYER SO NO NEED FOR
// CORRECTIONS, OFC EDIT IT IN CASE YOU USE THIS FOR 1 PLAYER
// EXAMPLE FOR PLAYER RED:
// TriggerRegisterPlayerUnitEvent(gg_trg_Kobas_System, player(0), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
// ---------------------------------------------------------
function InitTrig_Kobas_System takes nothing returns nothing
set gg_trg_Kobas_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Kobas_System, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Kobas_System, function ItemSystem )
call ItemSystemSetup()
endfunction