Moderator
M
Moderator
22:15, 10th Oct 2012
Magtheridon96: Approved.
Magtheridon96: Approved.
function AddCSS takes integer ii, integer si returns nothing
call SaveInteger(udg_CSS_Hash, 1, ii, si)
call SaveInteger(udg_CSS_Hash, 1, si, ii)
endfunction
function SetCSSTypeB takes integer ii, boolean b returns nothing
call SaveBoolean(udg_CSS_Hash, 0, ii, b)
endfunction
function SetCSSClassB takes integer ii, boolean b returns nothing
call SaveBoolean(udg_CSS_Hash, 8, ii, b)
endfunction
function SetCSSType takes integer ii, integer i returns nothing
call SaveInteger(udg_CSS_Hash, 2, ii, i)
endfunction
function SetCSSCost takes integer ii, integer i returns nothing
call SaveInteger(udg_CSS_Hash, 3, ii, i)
endfunction
function SetCSSMaxLevel takes integer ii, integer i returns nothing
call SaveInteger(udg_CSS_Hash, 4, ii, i)
endfunction
function SetCSSClass takes integer ii, integer i returns nothing
call SaveInteger(udg_CSS_Hash, 5, ii, i)
endfunction
function SetCSSReqLevel takes integer ii, integer i returns nothing
call SaveInteger(udg_CSS_Hash, 6, ii, i)
endfunction
function SetCSSPoint takes unit u, integer p returns nothing
call SaveInteger(udg_CSS_Hash, 7, GetHandleId(u), p)
endfunction
function AddCSSPoint takes unit u, integer p returns nothing
call SaveInteger(udg_CSS_Hash, 7, GetHandleId(u), LoadInteger(udg_CSS_Hash, 7, GetHandleId(u)) + p)
endfunction
function GetCSSSpell takes integer ii returns integer si
return LoadInteger(udg_CSS_Hash, 1, ii)
endfunction
function GetCSSItem takes integer si returns integer ii
return LoadInteger(udg_CSS_Hash, 1, si)
endfunction
function GetCSSType takes integer ii returns integer i
return LoadInteger(udg_CSS_Hash, 2, ii)
endfunction
function GetCSSCost takes integer ii returns integer i
return LoadInteger(udg_CSS_Hash, 3, ii)
endfunction
function GetCSSMaxLevel takes integer ii returns integer i
return LoadInteger(udg_CSS_Hash, 4, ii)
endfunction
function GetCSSClass takes integer ii returns integer i
return LoadInteger(udg_CSS_Hash, 5, ii)
endfunction
function GetCSSReqLevel takes integer ii returns integer i
return LoadInteger(udg_CSS_Hash, 6, ii)
endfunction
function GetCSSPoint takes unit u returns integer i
return LoadInteger(udg_CSS_Hash, 7, GetHandleId(u))
endfunction
function GetCSSClassB takes integer ii returns boolean b
return LoadBoolean(udg_CSS_Hash, 8, ii)
endfunction
function GetCSSTypeB takes integer ii returns boolean b
return LoadBoolean(udg_CSS_Hash, 0, ii)
endfunction
function GetCSSUnitS takes unit u, integer i returns integer si
return LoadInteger(udg_CSS_Hash, GetHandleId(u), i)
endfunction
CSS Initialization

Events


Map initialization

Conditions

Actions


Custom script: set udg_CSS_Hash = InitHashtable()


-------- ----------- --------


Custom script: call SetCSSClass('Hpal', 1)


Custom script: call SetCSSClass('Hamg', 2)


-------- ----------- --------


Custom script: call AddCSS('I000', 'AHav')


Custom script: call SetCSSType('I000', 2)


Custom script: call SetCSSCost('I000', 2)


Custom script: call SetCSSMaxLevel('I000', 1)


Custom script: call SetCSSClass('I000', 1)


Custom script: call SetCSSClassB('I000', true)


Custom script: call SetCSSTypeB('I000', true)


-------- ----------- --------


Custom script: call AddCSS('I001', 'ANab')


Custom script: call SetCSSType('I001', 1)


Custom script: call SetCSSCost('I001', 1)


Custom script: call SetCSSMaxLevel('I001', 3)


Custom script: call SetCSSClass('I001', 2)


Custom script: call SetCSSClassB('I001', true)


Custom script: call SetCSSTypeB('I001', true)


-------- ----------- --------


Custom script: call AddCSS('I002', 'AHbz')


Custom script: call SetCSSTypeB('I001', true)


Custom script: call SetCSSType('I002', 1)


Custom script: call SetCSSCost('I002', 1)


Custom script: call SetCSSMaxLevel('I002', 3)


Custom script: call SetCSSClassB('I001', false)


-------- ----------- --------


Custom script: call AddCSS('I003', 'AOhx')


Custom script: call SetCSSCost('I003', 1)


Custom script: call SetCSSMaxLevel('I003', 3)


Custom script: call SetCSSClass('I003', 1)


Custom script: call SetCSSClassB('I000', true)


Custom script: call SetCSSTypeB('I003', false)


-------- ----------- --------


Custom script: call AddCSS('I004', 'AOmi')


Custom script: call SetCSSType('I004', 1)


Custom script: call SetCSSCost('I004', 1)


Custom script: call SetCSSMaxLevel('I004', 3)


Custom script: call SetCSSClass('I004', 2)


Custom script: call SetCSSClassB('I004', true)


Custom script: call SetCSSTypeB('I004', true)
CSS Check

Events


Unit - A unit Acquires an item

Conditions


(Item-class of (Item being manipulated)) Equal to Powerup

Actions


Set TempItem = (Item being manipulated)


Set TempItemType = (Item-type of TempItem)


Set TempUnit = (Triggering unit)


Set TempUnitType = (Unit-type of TempUnit)


Custom script: set udg_TempAbility = GetCSSSpell(udg_TempItemType)


Set TempInt = (Level of TempAbility for TempUnit)


-------- - --------


Custom script: if (udg_TempAbility > 0) and (not GetCSSClassB(udg_TempItemType) or GetCSSClass(udg_TempItemType) == GetCSSClass(udg_TempUnitType)) then


-------- - --------


Custom script: if not GetCSSTypeB(udg_TempItemType) or (GetCSSUnitS(udg_TempUnit, GetCSSType(udg_TempItemType)) == 0) or (GetCSSUnitS(udg_TempUnit, GetCSSType(udg_TempItemType)) == udg_TempAbility) then


-------- - --------


Custom script: if (GetCSSCost(udg_TempItemType) <= GetCSSPoint(udg_TempUnit)) then


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




TempInt Equal to 0



Then - Actions




Custom script: if GetCSSReqLevel(udg_TempItemType) > GetUnitLevel(udg_TempUnit) then




Custom script: call BJDebugMsg("Your hero requires " + I2S(GetCSSReqLevel) + "to learn this skill!!!")




Custom script: else




Custom script: call UnitAddAbility(udg_TempUnit, udg_TempAbility)




Custom script: call SaveInteger(udg_CSS_Hash, 7,GetHandleId(udg_TempUnit), GetCSSPoint(udg_TempUnit) - GetCSSCost(udg_TempItemType))




Custom script: call SaveInteger(udg_CSS_Hash,GetHandleId(udg_TempUnit), GetCSSType(udg_TempItemType), udg_TempAbility)




Custom script: endif



Else - Actions




Custom script: if udg_TempInt < GetCSSMaxLevel(udg_TempItemType) then




Unit - Increase level of TempAbility for TempUnit




Custom script: call SaveInteger(udg_CSS_Hash, 7,GetHandleId(udg_TempUnit), GetCSSPoint(udg_TempUnit) - GetCSSCost(udg_TempItemType))




Custom script: else




Custom script: call BJDebugMsg("This skill has been already max level !!! " )




Custom script: endif


Custom script: else


Custom script: call BJDebugMsg("Not enought skill point !!! " )


Custom script: endif


-------- - --------


Custom script: else


Custom script: call BJDebugMsg("You have had this spell type already!!! " )


Custom script: endif


-------- - --------


Custom script: else


Custom script: call BJDebugMsg("Your class can't learn this skill !!! " )


Custom script: endif


-------- - --------