- Joined
- Feb 26, 2005
- Messages
- 210
I'm trying a bit of an experiment for a map I am making. Instead of regenerating health and mana; I want heroes to require the use of healing items. So that a hero will not have to keep running back to shops to stay in the fight I want these items to generate in the hero's inventory periodically. The greater the Strength/Intelligence the faster the item generation.
I've already eliminated regeneration through advanced settings; the hard part is implementing the rest of the system. It will require JASS loops to be efficient. Here is the code so far:
This code will give permanent item reproduction but is severely flawed. The loop needs to reset upon the hero's death, the timing of the loop needs to be Strength based, and I need a way for a simultaneous mana pot loop.
I've already eliminated regeneration through advanced settings; the hard part is implementing the rest of the system. It will require JASS loops to be efficient. Here is the code so far:
JASS:
function Trig_Item_Reproduction_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetSoldUnit(), UNIT_TYPE_HERO) == true ) ) then
return false
endif
return true
endfunction
function Trig_Item_Reproduction_Actions takes nothing returns nothing
local unit u = GetSoldUnit()
loop
call TriggerSleepAction( 15.00 )
if GetUnitState(u, UNIT_STATE_LIFE) > 0 and UnitInventorySizeBJ(u) > UnitInventoryCount(u) then
call UnitAddItemByIdSwapped( 'pghe', u )
endif
endloop
endfunction
//===========================================================================
function InitTrig_Item_Reproduction takes nothing returns nothing
set gg_trg_Item_Reproduction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Reproduction, EVENT_PLAYER_UNIT_SELL )
call TriggerAddCondition( gg_trg_Item_Reproduction, Condition( function Trig_Item_Reproduction_Conditions ) )
call TriggerAddAction( gg_trg_Item_Reproduction, function Trig_Item_Reproduction_Actions )
endfunction