library Damage initializer InitDamageFunction
// Sorry for my bad english, i'm only studying it ^^
globals
hashtable hash = InitHashtable() // hashtable
boolean Player_Name_Cond = false // if you'll change "false" on "true" it will active boolean on the player name which gives the damage, so only you will can to give damage
// you can change the name in the function: Player_Name_Condition
integer Spell_Book = 'A003' // spellbook id ( from 0 to million)
integer Spell_Book2 = 'A00D' // spellbook id ( from 0 to - million )
integer Spell_1 = 'A00C' // spell id from 0 to 9
integer Spell_2 = 'A001' // spell id from 0 to 90
integer Spell_3 = 'A002' // spell id from 0 to 900
integer Spell_4 = 'A004' // spell id from 0 to 9000
integer Spell_5 = 'A005' // spell id from 0 to 90000
integer Spell_6 = 'A006' // spell id from 0 to million
integer Spell_7 = 'A000' // spell id from - 1 to - 9
integer Spell_8 = 'A00B' // spell id from - 10 to - 90
integer Spell_9 = 'A00A' // spell id from - 100 to - 900
integer Spell_10 = 'A009' // spell id from - 1000 to - 9000
integer Spell_11 = 'A008' // spell id from - 10000 to - 90000
integer Spell_12 = 'A007' // spell id from - 100000 to - milliom
endglobals
private function IsUnitWithSkill takes unit a returns boolean
return GetUnitAbilityLevel(a, Spell_Book) > 0
endfunction
public function Add_Damage takes real str, unit a returns nothing
local string e
local integer lenght
local integer array spellLevel
if str >= -1000000 and str <= 1000000 then
if not IsUnitWithSkill(a) then
call UnitAddAbility(a, Spell_Book)
call UnitAddAbility(a, Spell_Book2)
endif
set e = I2S(R2I(str))
set lenght = StringLength(e)
if str >= 0 then
if lenght == 1 then
set spellLevel[1] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 2 then
set spellLevel[1] = S2I(SubString(e, 1, 2)) + 1
set spellLevel[2] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 3 then
set spellLevel[1] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[2] = S2I(SubString(e, 1, 2)) + 1
set spellLevel[3] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 4 then
set spellLevel[1] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[2] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[3] = S2I(SubString(e, 1, 2)) + 1
set spellLevel[4] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 5 then
set spellLevel[1] = S2I(SubString(e, 4, 5)) + 1
set spellLevel[2] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[3] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[4] = S2I(SubString(e, 1, 2)) + 1
set spellLevel[5] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 6 then
set spellLevel[1] = S2I(SubString(e, 5, 6)) + 1
set spellLevel[2] = S2I(SubString(e, 4, 5)) + 1
set spellLevel[3] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[4] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[5] = S2I(SubString(e, 1, 2)) + 1
set spellLevel[6] = S2I(SubString(e, 0, 1)) + 1
else
if lenght == 7 then
set spellLevel[6] = S2I(SubString(e, 0, 1)) + 10
endif
endif
endif
endif
endif
endif
endif
call SetUnitAbilityLevel(a, Spell_1, spellLevel[1])
call SetUnitAbilityLevel(a, Spell_2, spellLevel[2])
call SetUnitAbilityLevel(a, Spell_3, spellLevel[3])
call SetUnitAbilityLevel(a, Spell_4, spellLevel[4])
call SetUnitAbilityLevel(a, Spell_5, spellLevel[5])
call SetUnitAbilityLevel(a, Spell_6, spellLevel[6])
call SetUnitAbilityLevel(a, Spell_7, 0)
call SetUnitAbilityLevel(a, Spell_8, 0)
call SetUnitAbilityLevel(a, Spell_9, 0)
call SetUnitAbilityLevel(a, Spell_10, 0)
call SetUnitAbilityLevel(a, Spell_11, 0)
call SetUnitAbilityLevel(a, Spell_12, 0)
else
set lenght = lenght - 1
if lenght == 1 then
set spellLevel[1] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 2 then
set spellLevel[1] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[2] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 3 then
set spellLevel[1] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[2] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[3] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 4 then
set spellLevel[1] = S2I(SubString(e, 4, 5)) + 1
set spellLevel[2] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[3] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[4] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 5 then
set spellLevel[1] = S2I(SubString(e, 5, 6)) + 1
set spellLevel[2] = S2I(SubString(e, 4, 5)) + 1
set spellLevel[3] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[4] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[5] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 6 then
set spellLevel[1] = S2I(SubString(e, 6, 7)) + 1
set spellLevel[2] = S2I(SubString(e, 5, 6)) + 1
set spellLevel[3] = S2I(SubString(e, 4, 5)) + 1
set spellLevel[4] = S2I(SubString(e, 3, 4)) + 1
set spellLevel[5] = S2I(SubString(e, 2, 3)) + 1
set spellLevel[6] = S2I(SubString(e, 1, 2)) + 1
else
if lenght == 7 then
set spellLevel[6] = S2I(SubString(e, 1, 2)) + 10
endif
endif
endif
endif
endif
endif
endif
call SetUnitAbilityLevel(a, Spell_1, 0)
call SetUnitAbilityLevel(a, Spell_2, 0)
call SetUnitAbilityLevel(a, Spell_3, 0)
call SetUnitAbilityLevel(a, Spell_4, 0)
call SetUnitAbilityLevel(a, Spell_5, 0)
call SetUnitAbilityLevel(a, Spell_6, 0)
call SetUnitAbilityLevel(a, Spell_7, spellLevel[1])
call SetUnitAbilityLevel(a, Spell_8, spellLevel[2])
call SetUnitAbilityLevel(a, Spell_9, spellLevel[3])
call SetUnitAbilityLevel(a, Spell_10, spellLevel[4])
call SetUnitAbilityLevel(a, Spell_11, spellLevel[5])
call SetUnitAbilityLevel(a, Spell_12, spellLevel[6])
endif
if str > 0 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", a, "origin"))
else
if str < 0 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", a, "origin"))
else
if str == 0 then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", a, "origin"))
endif
endif
endif
set a = null
else
call DisplayTextToPlayer(GetOwningPlayer(a), 0, 0, "You can give damage only from -million to million" )
endif
endfunction
private function Trig_String_Actions takes nothing returns nothing
local unit a = LoadUnitHandle(hash, GetPlayerId(GetTriggerPlayer()), StringHash("target"))
call Add_Damage(S2R(SubString(GetEventPlayerChatString(), 3, 11)), a)
set a = null
// you can change "S2R(SubString(GetEventPlayerChatString(),3,11))" on your own any real variable (from -mill to +mill) and it'll
// be given to unit, also you can change unit a on your unit (for skill maybe))
endfunction
private function Trig_Pick_Actions takes nothing returns nothing
call FlushChildHashtable(hash, GetPlayerId(GetTriggerPlayer())) // flush hash
call SaveUnitHandle(hash, GetPlayerId(GetTriggerPlayer()), StringHash("target"), GetTriggerUnit()) // save picked unit in handle
endfunction
private function Trig_String_Conditions takes nothing returns boolean
return StringCase(SubString(GetEventPlayerChatString(), 0, 2), false) == "-d" //check on stringcase
endfunction
private function Player_Name_Condition takes nothing returns boolean
return GetPlayerName(GetTriggerPlayer()) == "Your name" // Change your player name here
endfunction
private function InitDamageFunction takes nothing returns nothing
local unit a
local integer i = 0
local trigger Pick = CreateTrigger()
local trigger String = CreateTrigger()
if Player_Name_Cond then
call TriggerAddCondition( String, Condition(function Player_Name_Condition))
endif
call TriggerAddCondition( String, Condition( function Trig_String_Conditions ) )
call TriggerAddAction( String, function Trig_String_Actions )
set a = CreateUnit(Player(14), 'hfoo', 0, 0, 0)
call UnitAddAbility(a, Spell_1)
call UnitAddAbility(a, Spell_2)
call UnitAddAbility(a, Spell_3)
call UnitAddAbility(a, Spell_4)
call UnitAddAbility(a, Spell_5)
call UnitAddAbility(a, Spell_6)
call UnitAddAbility(a, Spell_Book)
call UnitAddAbility(a, Spell_Book2)
call RemoveUnit(a)
set a = null
loop
exitwhen i > 11
call TriggerRegisterPlayerChatEvent( String, Player(i), "-", false )
call TriggerRegisterPlayerUnitEvent(Pick, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
call SetPlayerAbilityAvailable( Player( i ), Spell_Book, false )
call SetPlayerAbilityAvailable( Player( i ), Spell_Book2, false )
set i = i + 1
endloop
call TriggerAddAction( Pick, function Trig_Pick_Actions )
endfunction
endlibrary