Hello.
First of all I need to say I'm not a good jass user, I just started learning it so please don't flame me of doing something at a very weird way.
This is the problem:
I'm making an Equipment System which allows you to equip items in a spellbook. For this I gave every unit some abilities (agi16, agi8, agi4..etc) to improve their stat points when they equip an item.
I made my first few moves in Jass, and thoud I was done with the first part of the system now.. but now I tested it.
When my hero clicks the item to equip it (it has a spell based on Fan of Knives) the trigger doesn't run. I made a test trigger with the right event and a game message when it goes off, and this worked. So I'm not using the wrong event.
Can someone look through it (alot of work I think) and tell me what I'm doing wrong?
This is the Initialization Trigger to set the item data (how much strength an item gives per example)
This is the EquipItem Trigger. This should start running when a unit Uses an item, but it aint running atm.
First of all I need to say I'm not a good jass user, I just started learning it so please don't flame me of doing something at a very weird way.
This is the problem:
I'm making an Equipment System which allows you to equip items in a spellbook. For this I gave every unit some abilities (agi16, agi8, agi4..etc) to improve their stat points when they equip an item.
I made my first few moves in Jass, and thoud I was done with the first part of the system now.. but now I tested it.
When my hero clicks the item to equip it (it has a spell based on Fan of Knives) the trigger doesn't run. I made a test trigger with the right event and a game message when it goes off, and this worked. So I'm not using the wrong event.
Can someone look through it (alot of work I think) and tell me what I'm doing wrong?
This is the Initialization Trigger to set the item data (how much strength an item gives per example)
JASS:
function Trig_ItemInit_Actions takes nothing returns nothing
///////////////////ItemBonusses/////////////////////////////
local integer i = 1
local integer t = 0
set i = 1
loop
exitwhen i > 4 ////EDIT the 4 to the maxitems////
set t = t + 1
set udg_ItemType[t] = 'I000'
set udg_ItemIntelligence[t] = 4
set udg_ItemStrength[t] = 1
set udg_ItemAgility[t] = 2
set udg_ItemArmor[t] = 3
set i = i + 1
endloop
set udg_agi[1] = 'A01Z'
set udg_agi[16] = 'A020'
set udg_agi[2] = 'A021'
set udg_agi[4] = 'A022'
set udg_agi[8] = 'A023'
set udg_int[1] = 'A024'
set udg_int[16] = 'A025'
set udg_int[2] = 'A026'
set udg_int[4] = 'A027'
set udg_int[8] = 'A028'
set udg_str[1] = 'A029'
set udg_str[16] = 'A02A'
set udg_str[2] = 'A02B'
set udg_str[4] = 'A02C'
set udg_str[8] = 'A02D'
set udg_arm[1] = 'A02E'
set udg_arm[2] = 'A02F'
set udg_arm[4] = 'A02G'
set udg_arm[8] = 'A02H'
set udg_dam[1] = 'A02I'
set udg_dam[128] = 'A02J'
set udg_dam[16] = 'A02K'
set udg_dam[2] = 'A02L'
set udg_dam[32] = 'A02M'
set udg_dam[4] = 'A02N'
set udg_dam[64] = 'A02O'
set udg_dam[8] = 'A02P'
endfunction
//===========================================================================
function InitTrig_ItemInit takes nothing returns nothing
set gg_trg_ItemInit = CreateTrigger( )
call TriggerAddAction( gg_trg_ItemInit, function Trig_ItemInit_Actions )
endfunction
This is the EquipItem Trigger. This should start running when a unit Uses an item, but it aint running atm.
JASS:
function Trig_ItemEquip_Conditions takes nothing returns boolean
if (not (GetItemType(GetManipulatedItem()) == ITEM_TYPE_PERMANENT)) then
return false
endif
return true
endfunction
function Trig_ItemEquip_Actions takes nothing returns nothing
local integer i = 0
local integer in = 0
local unit u = GetTriggerUnit()
local integer t = 0
local integer x = 0
set i = 1
loop
exitwhen i > 4 ////EDIT the 4 to the maxitems////
if udg_ItemType[i] == GetItemTypeId(GetManipulatedItem()) then
set i = in
else
set i = i+1
endif
endloop
///////This is where it adds stats.. Not an important part to read, and I think I'm doing it pretty weird, but whatever.. I think it works.../////
set x = udg_ItemAgility[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_agi[16], u, GetUnitAbilityLevelSwapped(udg_agi[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_agi[8], u, GetUnitAbilityLevelSwapped(udg_agi[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_agi[4], u, GetUnitAbilityLevelSwapped(udg_agi[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_agi[2], u, GetUnitAbilityLevelSwapped(udg_agi[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_agi[1], u, GetUnitAbilityLevelSwapped(udg_agi[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))
set x = udg_ItemIntelligence[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_int[16], u, GetUnitAbilityLevelSwapped(udg_int[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_int[8], u, GetUnitAbilityLevelSwapped(udg_int[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_int[4], u, GetUnitAbilityLevelSwapped(udg_int[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_int[2], u, GetUnitAbilityLevelSwapped(udg_int[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_int[1], u, GetUnitAbilityLevelSwapped(udg_int[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))
set x = udg_ItemStrength[in]
set t = ModuloInteger(x, 16)
call SetUnitAbilityLevelSwapped(udg_str[16], u, GetUnitAbilityLevelSwapped(udg_str[16], u) + t)
set x = x - (16*ModuloInteger(x, 16))
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_str[8], u, GetUnitAbilityLevelSwapped(udg_str[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_str[4], u, GetUnitAbilityLevelSwapped(udg_str[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_str[2], u, GetUnitAbilityLevelSwapped(udg_str[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_str[1], u, GetUnitAbilityLevelSwapped(udg_str[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))
set x = udg_ItemArmor[in]
set t = ModuloInteger(x, 8)
call SetUnitAbilityLevelSwapped(udg_arm[8], u, GetUnitAbilityLevelSwapped(udg_arm[8], u) +t)
set x = x - (8*ModuloInteger(x, 8))
set t = ModuloInteger(x, 4)
call SetUnitAbilityLevelSwapped(udg_arm[4], u, GetUnitAbilityLevelSwapped(udg_arm[4], u) +t)
set x = x - (4*ModuloInteger(x, 4))
set t = ModuloInteger(x, 2)
call SetUnitAbilityLevelSwapped(udg_arm[2], u, GetUnitAbilityLevelSwapped(udg_arm[2], u) +t)
set x = x - (2*ModuloInteger(x, 2))
set t = ModuloInteger(x, 1)
call SetUnitAbilityLevelSwapped(udg_arm[1], u, GetUnitAbilityLevelSwapped(udg_arm[1], u) +t)
set x = x - (1*ModuloInteger(x, 1))
endfunction
//===========================================================================
function InitTrig_ItemEquip takes nothing returns nothing
set gg_trg_ItemEquip = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ItemEquip, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddCondition( gg_trg_ItemEquip, Condition( function Trig_ItemEquip_Conditions ) )
call TriggerAddAction( gg_trg_ItemEquip, function Trig_ItemEquip_Actions )
endfunction