Name | Type | is_array | initial_value |
Ability_Loop | abilcode | Yes | |
Ability_Loop_Max | integer | No | |
AI_Allies_Count | integer | Yes | |
AI_Ancient_Clash | boolean | No | |
AI_Building_Mid | unit | Yes | |
AI_Building_Top | unit | Yes | |
AI_Custom_01 | integer | Yes | |
AI_Custom_02 | integer | Yes | |
AI_Custom_03 | integer | Yes | |
AI_Custom_04 | integer | Yes | |
AI_End_Game | boolean | No | |
AI_Fight_Time | boolean | No | |
AI_Fire_Flag | unit | Yes | |
AI_Frost_Flag | unit | Yes | |
AI_Go_Bot | boolean | Yes | |
AI_Go_Mid | boolean | Yes | |
AI_Go_Top | boolean | Yes | |
AI_Guard_Index | integer | No | |
AI_Hero | unit | Yes | |
AI_Hero_Count | integer | No | |
AI_ITEM_REGION | rect | No | |
AI_Level | integer | No | |
AI_Loop | integer | No | |
AI_MINE_End | boolean | No | |
AI_MINE_Index | integer | No | |
AI_MINE_MUI | integer | No | |
AI_MINE_Unit | unit | Yes | |
AI_Player_Count | integer | No | |
AI_Player_Number | integer | No | |
AI_Player_Total | integer | No | |
AI_Push_Target | unit | Yes | |
AI_Push_Timer | timer | No | |
AI_Region_Base | rect | Yes | |
AI_Regroup_Order | boolean | Yes | |
AI_Skill_01 | abilcode | Yes | |
AI_Skill_02 | abilcode | Yes | |
AI_Skill_03 | abilcode | Yes | |
AI_Skill_04 | abilcode | Yes | |
AI_State_Chasing | boolean | Yes | |
AI_State_Healing | boolean | Yes | |
AI_State_MINE | boolean | No | |
AI_State_Push | boolean | No | |
AI_Target_Hero | unit | Yes | |
AI_Teleport_Group | group | No | |
AI_TempInt | integer | No | |
AI_TempInt_Custom | integer | No | |
AI_TempPlayer | player | No | |
AI_TempUnit | unit | No | |
AI_Tower_Guard | unit | Yes | |
AI_Tower_Target | unit | Yes | |
AI_Turn_On | boolean | No | |
AI_Type_Carry | boolean | Yes | |
AI_Type_Support | boolean | Yes | |
AI_Type_Tanker | boolean | Yes | |
ATC_Attack_Count | integer | Yes | |
ATC_Attack_Max | integer | Yes | |
ATC_Buff | buffcode | Yes | |
ATC_Caster | unit | Yes | |
ATC_Loop | integer | No | |
ATC_MUI | integer | No | |
ATC_Player | player | Yes | |
ATC_Spell_Level | integer | Yes | |
ATC_Text_Float | texttag | Yes | |
ATC_Text_Value | integer | Yes | |
ATC_Trigger_Effect | trigger | Yes | |
BR_AS_Bonus | abilcode | Yes | |
BR_Hero | unit | No | |
BR_Level | integer | No | |
BR_Life | real | Yes | |
CB_Caster | unit | No | |
CB_Distance | real | No | |
CB_Dummy | unit | No | |
CB_Loop_Point | location | No | |
CB_Marker | unit | No | |
CB_Marker_Point | location | No | |
CB_Max_Radius | real | No | |
CF_Bounce_Radius | real | Yes | |
CF_Caster | unit | Yes | |
CF_Index | integer | No | |
CF_Jump | integer | Yes | |
CF_Loop | integer | No | |
CF_Missle | unit | Yes | |
CF_MUI | integer | No | |
CF_Player | player | Yes | |
CF_Point_Loop | location | Yes | |
CF_Speed | real | Yes | |
CF_Spell_Effect | abilcode | Yes | |
CF_Spell_Level | integer | Yes | |
CF_Target | unit | Yes | |
CF_Trigger_Effect | trigger | Yes | |
Chat_String | string | No | |
Circle_DisassembleUnit | location | Yes | |
CleanedItem | item | Yes | |
Creep_Unit | unit | No | |
CS_Ability | abilcode | Yes | |
CS_Caster | unit | Yes | |
CS_Caster_Point | location | No | |
CS_Duration | real | Yes | |
CS_Effect_Attached | effect | Yes | |
CS_Effect_While_Channel | boolean | Yes | |
CS_Interval | real | Yes | |
CS_Loop | integer | No | |
CS_MUI | integer | No | |
CS_Player | player | Yes | |
CS_Spell_Level | integer | Yes | |
CS_Stop | boolean | Yes | |
CS_Target | unit | Yes | |
CS_Target_Point | location | No | |
CS_Trigger_Effect | trigger | Yes | |
CSA_Caster | unit | No | |
CSA_Caster_Mana | real | No | |
CSA_Damaged_Group | group | No | |
CSA_Int | integer | No | |
CSA_Timer | timer | No | |
DS_Attached_Effect | effect | Yes | |
DS_Caster | unit | Yes | |
DS_Caster_Point | location | No | |
DS_Countdown_Unit | unit | Yes | |
DS_Damage_Value | real | Yes | |
DS_Duration | real | No | |
DS_Effect_String | string | Yes | |
DS_Loop | integer | No | |
DS_MUI | integer | No | |
DS_Player | player | Yes | |
DS_Spell_Level | integer | Yes | |
DS_Target_Unit | unit | Yes | |
DS_Trigger_Effect | trigger | Yes | |
Dummy_Creep | unit | No | |
Floating_Text | texttag | No | |
FR_Angle | real | Yes | |
FR_Angle_Offset | real | Yes | |
FR_Back | boolean | Yes | |
FR_Ball | unit | Yes | |
FR_Caster | unit | Yes | |
FR_Current_Distance | real | Yes | |
FR_Exception_Group | group | No | |
FR_Exception_Group_BF | group | No | |
FR_Exception_Group_HR | group | No | |
FR_Index | integer | No | |
FR_Loop | integer | No | |
FR_Max_Distance | real | Yes | |
FR_Move_Offset | real | Yes | |
FR_MUI | integer | No | |
FR_Player | player | Yes | |
FR_Point_Loop | location | Yes | |
FR_Spell_Effect | abilcode | Yes | |
FR_Spell_Level | integer | Yes | |
FR_Trigger_Effect | trigger | Yes | |
Game_AntiWater_Radius | real | No | |
Game_Boss | timer | No | |
Game_Boss_Arthas | unit | No | |
Game_Boss_Has_Died | boolean | No | |
Game_Boss_Kiljaeden | unit | No | |
Game_Boss_TW | timerdialog | No | |
Game_Camera_Locker | unit | No | |
Game_Circle | unit | Yes | |
Game_Creep_Spawn | timer | No | |
Game_CreepUpgrade_Timer | timer | No | |
Game_Doubloons_Fire | integer | No | |
Game_Doubloons_Ice | integer | No | |
Game_Get_LocalPlayer | player | No | |
Game_Siege_Count | integer | No | |
Get_Local_Player | player | No | |
Hero_Can_LevelUp | boolean | Yes | |
Hero_Deaths_Count | integer | Yes | |
Hero_Dying | unit | No | |
Hero_Icon | string | Yes | |
Hero_Killer | unit | No | |
Hero_Kills_Count | integer | Yes | |
Hero_Main_Player | unit | Yes | |
Hero_Main_Target | unit | Yes | |
Hero_Preloaded | boolean | Yes | |
Integer | integer | No | |
Integer_Loop | integer | No | |
Item_CanBeDisassemble | boolean | Yes | |
Item_Check | integer | No | |
Item_Count | integer | No | |
Item_CustomValue | integer | No | |
Item_DisassembleAbility | abilcode | No | |
Item_DisassembleEffect | string | No | |
Item_DisassemblePoint | location | Yes | |
Item_Effect | string | No | |
Item_EnableOS | boolean | No | |
Item_Fake | itemcode | Yes | |
Item_LoopA | integer | No | |
Item_LoopB | integer | No | |
Item_LoopC | integer | No | |
Item_Mat1 | itemcode | Yes | |
Item_Mat1Amount | integer | Yes | |
Item_Mat2 | itemcode | Yes | |
Item_Mat2Amount | integer | Yes | |
Item_Mat3 | itemcode | Yes | |
Item_Mat3Amount | integer | Yes | |
Item_Mat4 | itemcode | Yes | |
Item_Mat4Amount | integer | Yes | |
Item_Mat5 | itemcode | Yes | |
Item_Mat5Amount | integer | Yes | |
Item_MatMax | integer | Yes | |
Item_Max | integer | No | |
Item_Owner | player | Yes | |
Item_OwneredItem | item | Yes | |
Item_OwnershipException | group | No | |
Item_Point | location | Yes | |
Item_Real | itemcode | Yes | |
Item_RecipeMax | integer | No | |
Item_Result | itemcode | Yes | |
ItemCleanupFlag | boolean | No | |
ItemCleanupTimer | timer | No | |
ItemsToClean | integer | No | |
JD_Angle | real | Yes | |
JD_Animations | string | Yes | |
JD_Attached_Effect | effect | Yes | |
JD_Custom_Int | integer | Yes | |
JD_Damage_Boolean | boolean | Yes | |
JD_Distances | real | Yes | |
JD_Effect | string | Yes | |
JD_Group | group | No | |
JD_HighSettings | real | Yes | |
JD_In_Jump_Group | group | No | |
JD_JumpHigh | real | Yes | |
JD_MUI | integer | Yes | |
JD_Player | player | Yes | |
JD_ReachedDistance | real | Yes | |
JD_RealTimer | real | Yes | |
JD_Side_Trigger | trigger | Yes | |
JD_SpeedUnits | real | Yes | |
JD_Spell_Level | integer | Yes | |
JD_TempPoint | location | Yes | |
JD_TreesDestroy | boolean | Yes | |
JD_Unit | unit | Yes | |
JDA_Animation | string | No | |
JDA_AnimationSpeed | real | No | |
JDA_Collision | boolean | No | |
JDA_Custom_Int | integer | No | |
JDA_Damage_Boolean | boolean | No | |
JDA_Damage_Trigger | trigger | No | |
JDA_Damage_Value | real | No | |
JDA_DestroyTrees_Dash | boolean | No | |
JDA_JumpHigh_Distance | real | No | |
JDA_Player | player | No | |
JDA_SpecialEffect | string | No | |
JDA_Speed | real | No | |
JDA_Spell_Level | integer | No | |
JDA_TargetPoint | location | No | |
JDA_Unit | unit | No | |
KB_Angle | real | Yes | |
KB_Casters | unit | Yes | |
KB_CountBuffs | integer | No | |
KB_DestroyTrees | boolean | Yes | |
KB_EffectCounter | integer | Yes | |
KB_EffectCounter2 | integer | Yes | |
KB_Effects_1 | string | Yes | |
KB_Effects_2 | string | Yes | |
KB_GeneralIntegers | integervar | Yes | |
KB_KnockbackedUnits | group | No | |
KB_Levels | integer | Yes | |
KB_MaxDistance | real | Yes | |
KB_ReachedDistance | real | Yes | |
KB_ReducedReal | real | No | |
KB_ReduceSpeedReal | real | Yes | |
KB_SpecificSpeed | real | Yes | |
KB_StartPositions | location | Yes | |
KB_TempPoint | location | Yes | |
KB_TempReal | real | No | |
KB_TotalKnockUnits | integer | No | |
KB_Units | unit | Yes | |
KBA_Caster | unit | No | |
KBA_DestroyTrees | boolean | No | |
KBA_DistancePerLevel | real | No | |
KBA_Level | integer | No | |
KBA_SpecialEffects | string | Yes | |
KBA_Speed | real | No | |
KBA_StartingPosition | location | No | |
KBA_TargetUnit | unit | No | |
Kill_Points | integer | Yes | |
Lich_King | unit | No | |
Lign | integer | No | |
Loop | integervar | No | |
MERC_Boss_Clock | timer | No | |
MERC_Clock | timer | No | |
MERC_Count | integer | Yes | |
MERC_Max_Large | integer | No | |
MERC_Max_Medium | integer | No | |
MERC_Region | rect | Yes | |
MERC_Type | unitcode | Yes | |
MINE_Boss | unit | No | |
MINE_Countdown | timer | No | |
MINE_Countdown_TW | timerdialog | No | |
MINE_Region | rect | Yes | |
Multiboard01 | multiboard | No | |
NS_Exception_Group_FB | group | Yes | |
NS_Exception_Group_IG | group | Yes | |
NS_Exception_Group_WN | group | Yes | |
OR_Vitality_Level | integer | No | |
PDD_allocatedAttacks | integer | No | |
PDD_allocCounter | integer | No | |
PDD_amount | real | No | |
PDD_ATTACK_TYPE_UNIVERSAL | attacktype | No | |
PDD_BRACERS_SPELL_DMG_RED | real | No | |
PDD_CODE | integer | No | |
PDD_DAMAGE_TYPE_DETECTOR | integer | No | |
PDD_damageEvent | trigger | No | |
PDD_damageEventTrigger | real | No | |
PDD_damageHandler | trigger | No | |
PDD_damageType | integer | No | |
PDD_ETHEREAL_DAMAGE_FACTOR | real | No | |
PDD_h | hashtable | No | |
PDD_PHYSICAL | integer | No | |
PDD_pureAmount | real | No | |
PDD_runAllocatedAttacks | trigger | No | |
PDD_SET_MAX_LIFE | integer | No | |
PDD_source | unit | No | |
PDD_SPELL | integer | No | |
PDD_SPELL_DMG_REDUCTION_ITEM | integer | No | |
PDD_SPELL_RESIST_AUTO_DETECT | boolean | No | |
PDD_target | unit | No | |
PDD_totalAllocs | integer | No | |
PDD_TRIGGER_CLEANUP_PERIOD | real | No | |
PDD_UNIT_MIN_LIFE | real | No | |
Player_Already_Picked | boolean | Yes | |
Player_Color | string | Yes | |
Player_Group | force | No | |
Player_Name_Color | string | Yes | |
Player_Number | integer | No | |
PS_Item | item | No | |
PS_Unit | unit | No | |
Random_Data | integer | Yes | |
Random_Hero | integer | No | |
Random_Hero_Type | unitcode | Yes | |
Random_Loop | integer | No | |
Random_Total | integer | No | |
Result | itemcode | Yes | |
RF_Exception_Group | group | No | |
RV_Hero | unit | Yes | |
RV_Number | integer | No | |
RV_Tombstone | unit | Yes | |
Sample_Group | group | No | |
Sample_Point | location | No | |
SC_Real | real | No | |
SFS_Did_Get_Spell | boolean | Yes | |
SFS_Item | itemcode | Yes | |
SFS_Main_Hero_Spell | abilcode | Yes | |
SFS_Max_Stock | integer | No | |
SFS_Spell_Level | integer | Yes | |
SFS_Spell_Used | abilcode | Yes | |
Shop_Ability | abilcode | Yes | |
Shop_Type | unitcode | Yes | |
Sound_Effect | sound | Yes | |
Special_Effect | effect | No | |
SpecialEffect_String | string | No | |
Spell_AMG | integer | No | |
Spell_AMG_Max | integer | No | |
Spell_Caster | unit | No | |
Spell_Caster_Point | location | No | |
Spell_Dummy | unit | No | |
Spell_Dummy_Ability | abilcode | No | |
Spell_Dummy_Loop | unit | Yes | |
Spell_GNW | integer | No | |
Spell_GNW_Max | integer | No | |
Spell_Level | integer | No | |
Spell_Lowest_HP | real | No | |
Spell_Lowest_HP_Unit | unit | No | |
Spell_Point_Loop | location | Yes | |
Spell_SA_Damage | integer | No | |
Spell_Target | unit | No | |
Spell_Target_Point | location | No | |
Spell_UnitGroup | group | No | |
SR_Angle | real | Yes | |
SR_Caster | unit | Yes | |
SR_Caster_Point | location | No | |
SR_Damage_Value | real | Yes | |
SR_DistanceTraveled | real | Yes | |
SR_Effect | string | Yes | |
SR_Effect_Attached | effect | Yes | |
SR_Effect_Interval | integer | Yes | |
SR_Effect_String | string | Yes | |
SR_Exception_Group | group | No | |
SR_Exception_Group_BR | group | No | |
SR_Exception_Group_FR | group | No | |
SR_Exception_Group_IS | group | No | |
SR_Exception_Group_KS | group | No | |
SR_Exception_Group_LM | group | No | |
SR_Exception_Group_SL | group | No | |
SR_Exception_Group_WA | group | No | |
SR_Exception_Group_WS | group | No | |
SR_Loop | integer | No | |
SR_Marker | unit | Yes | |
SR_MaxDistance | real | Yes | |
SR_MUI | integer | No | |
SR_Player | player | Yes | |
SR_Player_Number | integer | Yes | |
SR_Side_Trigger | trigger | Yes | |
SR_Slided_Unit | unit | Yes | |
SR_Speed | real | Yes | |
SR_Spell_Level | integer | Yes | |
SR_Target_Group | group | No | |
SR_Target_Point | location | No | |
Start_Point_Navy | location | No | |
Tauren_Hp | integer | No | |
Temp_Item | item | Yes | |
Temp_Item_Type | itemcode | Yes | |
Temp_String | string | Yes | |
Temp_Tech | techcode | Yes | |
Temp_Unit_Int | unit | Yes | |
Temp_Unit_Type | unitcode | Yes | |
TempAbility | abilcode | No | |
TempBoolean | boolean | No | |
TempBuff | buffcode | No | |
TempGroup | group | No | |
TempGroup_02 | group | No | |
TempInt | integer | No | |
TempItem | item | No | |
TempPlayer | player | No | |
TempPoint | location | No | |
TempPoint_Loop | location | Yes | |
TempReal | real | No | |
TempReal_01 | real | No | |
TempRegion | rect | Yes | |
TempUnit | unit | No | |
Triggering_Player | player | No | |
TW_Caster | unit | Yes | |
TW_Caster_Point | location | Yes | |
TW_Current_High | real | Yes | |
TW_Damage_Value | real | Yes | |
TW_Effect | string | Yes | |
TW_Effect_Interval | integer | Yes | |
TW_Exception_Group | group | No | |
TW_Flying_Value | real | Yes | |
TW_Go_Up | boolean | Yes | |
TW_Interval | real | Yes | |
TW_Loop | integer | No | |
TW_Max_High | real | Yes | |
TW_MUI | integer | No | |
TW_Player | player | Yes | |
TW_Speed | real | Yes | |
TW_Spell_Level | integer | Yes | |
TW_Target_Unit | unit | Yes | |
TW_Trigger_Effect | trigger | Yes | |
Unit_Attacked | unit | No | |
Unit_Attacked_Point | location | No | |
Unit_Attacking | unit | No | |
Unit_Attacking_Point | location | No | |
VC_Angle | real | Yes | |
VC_Caster | unit | Yes | |
VC_Effect | string | Yes | |
VC_Effect_Interval | real | Yes | |
VC_Exception_Group | group | No | |
VC_Group | group | Yes | |
VC_Index | integer | No | |
VC_Interval | real | Yes | |
VC_Loop | integer | No | |
VC_MUI | integer | No | |
VC_Remain_Time | real | Yes | |
VC_Slide_Point | location | Yes | |
VC_Speed | real | No | |
VC_Target_Unit | unit | Yes | |
VC_Vacuum_Point | location | Yes | |
Weather_Effect | weathereffect | No | |
Wisp_Player | unit | Yes |
//TESH.scrollpos=72
//TESH.alwaysfold=0
library KillingSpree initializer Init
//===============================================================
// Killing Spree system
// killing streak and combo count !
//---------------------------------------------------------------
// Requires
// - JassNewGen
//
// How to Import
// - just create a trigger named KillingSpree
// - convert it to custom text
// - replace the whole text with this one
//===============================================================
globals
private constant real ComboTime = 20. //20 seconds between combo
private constant real ComboDisplayTime = 1. //the time delay before display combo
endglobals
//==========================
globals
private integer array StreakCount
private integer array ComboCount
private string array tj_PlayerColor
private integer array ComboTimeCount
private boolean FirstBlood = false
endglobals
private function PolledWaitV takes real duration returns nothing
local timer t
local real timeRemaining
if (duration > 0) then
set t = CreateTimer()
call TimerStart(t, duration, false, null)
loop
set timeRemaining = TimerGetRemaining(t)
exitwhen timeRemaining <= 0
// If we have a bit of time left, skip past 10% of the remaining
// duration instead of checking every interval, to minimize the
// polling on long waits.
if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * timeRemaining)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(t)
set t = null
endif
endfunction
private function GetStreakName takes integer str returns string
if str == 3 then
return "|cff14cc00Killing Spree|r"
endif
if str == 4 then
return "|c00540081Dominating|r"
endif
if str == 5 then
return "|cffff0080Mega Kill|r"
endif
if str == 6 then
return "|c00FEBA0EUnstoppable|r"
endif
if str == 7 then
return "|c004E2A04Wicked Sick|r"
endif
if str == 8 then
return "|c007EBFF1Monster Kill|r"
endif
if str == 9 then
return "|c00FF0303Godlike|r"
endif
if str >= 10 then
return "|cffff8c00Beyond Godlike|r"
endif
return "GetStreakName"
endfunction
private function ComboTimer takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 11
if ComboTimeCount[i] > 0 then
set ComboTimeCount[i] = ComboTimeCount[i] - 1
endif
if ComboTimeCount[i] == 0 then
set ComboCount[i] = 0
set ComboTimeCount[i] = -1
endif
set i = i + 1
endloop
endfunction
private function HeroDiesCond takes nothing returns boolean
return IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true
endfunction
private function PlayerRedCond takes nothing returns boolean
return GetOwningPlayer(GetKillingUnitBJ()) != Player(0)
endfunction
private function PlayerGreenCond takes nothing returns boolean
return GetOwningPlayer(GetKillingUnitBJ()) != Player(6)
endfunction
private function PlayerNTCond takes nothing returns boolean
return GetOwningPlayer(GetKillingUnitBJ()) != Player(PLAYER_NEUTRAL_AGGRESSIVE)
endfunction
private function HeroKillCheckCombo takes integer pkid, integer pdid returns nothing
local integer streak = StreakCount[pkid] + 1
local integer combo = ComboCount[pkid] + 1
local player pk = Player(pkid)
set StreakCount[pkid] = streak
set ComboCount[pkid] = combo
//--
set ComboTimeCount[pkid] = R2I(ComboTime * 4) //because the duration of the timer is 0.25, the combotime should be multiplied by 4 ( 1 / 0.25 = 4 )
//--
//--- Check streak ---
if streak == 3 then
//killing spree
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is on a |cff14cc00Killing Spree|r" )
call PlaySoundBJ( gg_snd_06_KillingSpree )
elseif streak == 4 then
//dominating
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is |c00540081Dominating|r" )
call PlaySoundBJ( gg_snd_07_Dominating )
elseif streak == 5 then
//mega kill
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r has a |cffff0080Mega Kill|r" )
call PlaySoundBJ( gg_snd_08_MegaKill )
elseif streak == 6 then
//wicked sick
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is |c00FEBA0EUnstoppable|r" )
call PlaySoundBJ( gg_snd_09_Unstoppable )
elseif streak == 7 then
//unstoppable
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is |c004E2A04Wicked Sick|r" )
call PlaySoundBJ( gg_snd_10_WickedSick )
elseif streak == 8 then
//monster kill
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r has a |c007EBFF1Monster Kill|r" )
call PlaySoundBJ( gg_snd_11_MonsterKill )
elseif streak == 9 then
//godlike
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is |c00FF0303Godlike !!!|r" )
call PlaySoundBJ( gg_snd_12_Godlike )
elseif streak >= 10 then
//beyond godlike
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is |cffff8c00Beyond Godlike|r, someone kill them !!!" )
call PlaySoundBJ( gg_snd_13_Holyshit )
endif
call PolledWaitV( ComboDisplayTime )
//--- Check combo ---
if combo == 2 then
//double kill
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r got a |cff0000e1Double Kill|r" )
call PlaySoundBJ( gg_snd_02_DoubleKill )
elseif combo == 3 then
//triple kill
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r got a |cff14cc00Triple Kill|r" )
call PlaySoundBJ( gg_snd_03_TripleKill )
elseif combo == 4 then
//ultra kill
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r got a |cff009bb7Ultra Kill|r" )
call PlaySoundBJ( gg_snd_04_UltraKill )
elseif combo >= 5 then
//unbelievable
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[pkid]+GetPlayerName(pk)+"|r is on a |c00FF0303RAMPAGE|r")
call PlaySoundBJ( gg_snd_05_Rampage )
endif
set pk = null
endfunction
private function HeroDies takes nothing returns nothing
local unit k = GetKillingUnit()
local unit u = GetTriggerUnit()
local player p1 = GetOwningPlayer(u)
local player p2
local integer id1 = GetPlayerId(p1)
local integer id2
local integer streak = StreakCount[id1]
if k != null then
set p2 = GetOwningPlayer(k)
set id2 = GetPlayerId(p2)
if StreakCount[id1] >= 3 then
//call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[id2]+GetPlayerName(p2)+"|r has ended "+tj_PlayerColor[id1]+GetPlayerName(p1)+"|r's "+GetStreakName(StreakCount[id1])+" streak")
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[id1]+GetPlayerName(p1)+"|r's "+GetStreakName(StreakCount[id1])+" streak has been ended")
else
call DoNothing( )
endif
if not FirstBlood then
call DoNothing( )
//set FirstBlood = true
//call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,tj_PlayerColor[id2]+GetPlayerName(p2)+"|r just draw |c00FF0303First Blood|r for 200 gold" )
//give gold
//call PlaySoundBJ( gg_snd_01_FirstBlood )
endif
call HeroKillCheckCombo( id2, id1 )
endif
set StreakCount[id1] = 0
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction( t, function HeroDies )
call TriggerAddCondition( t, Condition( function HeroDiesCond ) )
call TriggerAddCondition( t, Condition( function PlayerRedCond ) )
call TriggerAddCondition( t, Condition( function PlayerGreenCond ) )
call TriggerAddCondition( t, Condition( function PlayerNTCond ) )
call TimerStart( CreateTimer() , 0.25, true, function ComboTimer )
set i = 0
loop
exitwhen i > 11
set StreakCount[i] = 0
set ComboCount[i] = 0
set ComboTimeCount[i] = -1
set i = i + 1
endloop
set tj_PlayerColor[0] = "|c00FF0303"
set tj_PlayerColor[1] = "|c000042FF"
set tj_PlayerColor[2] = "|c001CE6B9"
set tj_PlayerColor[3] = "|c00540081"
set tj_PlayerColor[4] = "|c00FFFC01"
set tj_PlayerColor[5] = "|c00FEBA0E"
set tj_PlayerColor[6] = "|c0020C000"
set tj_PlayerColor[7] = "|c00E55BB0"
set tj_PlayerColor[8] = "|c00959697"
set tj_PlayerColor[9] = "|c007EBFF1"
set tj_PlayerColor[10] = "|c00106246"
set tj_PlayerColor[11] = "|c004E2A04"
endfunction
endlibrary
//TESH.scrollpos=56
//TESH.alwaysfold=0
function Trig_Preload_Loop_Actions takes nothing returns nothing
// -----------------------PRELOAD ITEMS-----------------------
// -----------------------PRELOAD ABILITY-----------------------
//01
call PreloadAbility('A01T')
//02
call PreloadAbility('A037')
//03
call PreloadAbility('A0BO')
//04
call PreloadAbility('A0BQ')
//05
call PreloadAbility('Arav')
//06
call PreloadAbility('A07V')
//07
call PreloadAbility('A0CX')
//08
call PreloadAbility('A0EF')
//09
call PreloadAbility('A0EE')
//10
call PreloadAbility('A07N')
//11
call PreloadAbility('A0BZ')
//12
call PreloadAbility('A0EN')
//13
call PreloadAbility('A061')
//14
call PreloadAbility('A041')
//15
call PreloadAbility('A02G')
//16 Shop Level 1 - 02
call PreloadAbility('A0FS')
//17 Shop Level 3 - 02
call PreloadAbility('A0FU')
//18 Shop Level 5 - 02
call PreloadAbility('A0FV')
//19 Shop Level 9 - 02
call PreloadAbility('A0EQ')
//20 Orb of Lighting
call PreloadAbility('A0BY')
//21 Thunder Guard
call PreloadAbility('A0C5')
//22 Flare of Sight
call PreloadAbility('A01U')
//23 Battle Hammer Stun
call PreloadAbility('A09K')
//24 Eruption - Stun - BOSS
call PreloadAbility('A01P')
//25 Cooldown - Cargo Hold
call PreloadAbility('Sch2')
//26 ATTACK COUNT SYSTEM
call PreloadAbility('A0CP')
//--------------------------------------
//01 SFS - Blink
call PreloadAbility('A0C4')
//02 SFS - Ensnare
call PreloadAbility('A0CA')
//03 SFS - Reveal
call PreloadAbility('A01X')
//04 SFS - Silence
call PreloadAbility('A01Y')
//--------------------------------------
//01 Cooldown Ice Blade
call PreloadAbility('A0H4')
//02 Cooldown Battle Hammer
call PreloadAbility('A0H5')
//03 Cooldown Thunder Guard
call PreloadAbility('A0H6')
//04 Call for Home
call PreloadAbility('A088')
//05 Cooldown Lighting Items
call PreloadAbility('A095')
endfunction
//===========================================================================
function InitTrig_Preload_Loop takes nothing returns nothing
set gg_trg_Preload_Loop = CreateTrigger( )
call TriggerAddAction( gg_trg_Preload_Loop, function Trig_Preload_Loop_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
////////////////////////////////////////////////////////////////////////////////////
//
// Physical Damage Detection Engine GUI v 1.3.0.0
// ----------------------------------------------
// By looking_for_help aka eey
//
// This system is able to detect, modify and deal damage. It can differentiate
// between physical and spell damage, as well as block, reduce or increase the
// applied damage to a desired value. You can also allocate damage events from
// running damage events.
//
// This is the GUI version of the system, meaning that you can use this with the
// standard editor and basically without any knowledge of JASS.
//
////////////////////////////////////////////////////////////////////////////////////
//
// Implementation
// --------------
// 1. Create all variables that this system uses (compare the variable editor).
// You don't have to set them to specific values, they get initialized
// automatically by the system so just create them.
// 2. Copy this trigger to your map. You can then add damage handlers by using
// the event "value of real variable becomes equal to 1" with the variable
// udg_PDD_damageEventTrigger. Compare the OnDamage trigger for an example usage.
// 3. Copy the two custom abilities to your map and make sure they have the
// correct ID. You can specify the ID in the function InitGlobalVariables
// above.
// 4. Go to the locust swarm ability and invert its damage return portion
// from (default) 0.75 to -0.75.
// 5. Remove the spell damage reduction ability from the spell damage reduction
// items you use (runed bracers). You can configure the resistance of this
// item in the InitGlobalVariables function, modifying the global variable
// udg_PDD_BRACERS_SPELL_DMG_RED.
//
////////////////////////////////////////////////////////////////////////////////////
//
// Important Notes
// ---------------
// 1. Life Drain does not work with this system, so you should use a triggered
// version of this spell if you want to use it.
// 2. Same for Finger of Death, if you want to use this spell bug free with this
// system, you should use a triggered version of it.
// 3. If you use damage modifiers by setting the damage amount variable, you have
// to use GetUnitLife, GetUnitMaxLife and SetUnitLife instead of GetWidgetLife,
// GetUnitState for UNIT_STATE_MAX_LIFE and SetWidgetLife in your whole map to
// ensure there occure no bugs.
// 4. The boolean udg_PDD_SPELL_RESIST_AUTO_DETECT is only neccessary set to true
// if you want to use a customized damage table with spell damage resistance
// above 100%. If this is not the case, it should be set to false, as the
// system is faster then and still works correct.
// 5. As already mentioned you can't use the spell reduction ability when using this
// system (runed bracers and elunes grace). If you want to use them, you can
// trigger them by using the damage modifiers. Runed bracers is already considered
// in this system, so you don't have to code it.
//
////////////////////////////////////////////////////////////////////////////////////
//
// System API
// ----------
// real damageEventTrigger
// - Use the event "value of real variable becomes equal to 1" to detect a damage
// event. In this event you can use the following API. Compare the OnDamage
// trigger for an example usage.
//
// unit target
// - In this global unit variable, the damaged unit is saved. Don't write any-
// thing into this variable, use it as readonly.
//
// unit source
// - In this global unit variable, the damage source is saved. Don't write any-
// thing into this variable, use it as readonly.
//
// real amount
// - In this global real variable, the amount of damage is saved. This amount
// can be modified by simply setting it to the desired amount that should be
// applied to the target. Set the amount to 0.0 to block the damage completly.
// Negative values will result in heal.
//
// integer damageType
// - In this global integer variable, the damage type of the current damage is
// saved. Use it to differentiate between physical, spell and code damage. The
// variable can takes the values PHYSICAL == 0, SPELL == 1 and CODE == 2. Don't
// write anything into this variable, use it as readonly.
//
// function GetUnitLife takes unit u returns real
// - Use this function instead of the GetWidgetLife native. It ensures that you
// get the correct health value, even when damage modifiers are applied. If
// you don't use damage modifiers at all, you don't need this function.
//
// function GetUnitMaxLife takes unit u returns real
// - Use this function instead of the GetUnitState(u, UNIT_STATE_MAX_LIFE) native.
// It will return the correct value, even when damage modifiers are applied. If
// you don't use damage modifiers at all, you don't need this function.
//
// function SetUnitLife takes unit u, real newLife returns nothing
// - Use this function instead of the SetWidgetLife(u, newLife) native if you use
// damage modifiers in your map. Same rules as for the GetUnitMaxLife and the
// GetUnitMaxLife functions.
//
// function UnitDamageTargetEx takes unit localSource, unit localTarget, real localAmount, boolean attack, boolean ranged, attacktype localAttackType, damagetype localDamageType, weapontype localWeaponType returns boolean
// - Use this function to deal damage from a running damage event. It works exactly
// the same as the native UnitDamageTarget but is recursion safe so that you can
// realize damage reflection for example with this. Don't ever use this function
// outside of an onDamage event.
//
// function AddDamageHandler takes code damageHandler returns nothing
// - Allows you to add a damage handler function to the system. This is not
// required for GUI users, only for vanilla JASS users. GUI users should
// use the real variable damageEventTrigger to add damage handlers to this
// system as explained above.
//
// function RemoveDamageHandler takes code damageHandler returns nothing
// - Allows you to remove a damage handler function from the system dynamic-
// ally. If you added the same handler function multiple times to the sys-
// tem, this function will remove all of these equal functions. This is not
// required for GUI users, only for vanilla JASS users.
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Configurable globals
//////////////////////////////////////////////////////////////////////////////////
function InitGlobalVariables takes nothing returns nothing
// Put here the correct ability IDs
set udg_PDD_DAMAGE_TYPE_DETECTOR = 'A0AT'
set udg_PDD_SET_MAX_LIFE = 'A0AU'
// Here you can configure some stuff, read the documentation for further info
set udg_PDD_SPELL_DMG_REDUCTION_ITEM = 'brac'
set udg_PDD_SPELL_RESIST_AUTO_DETECT = false
set udg_PDD_ETHEREAL_DAMAGE_FACTOR = 1.66
set udg_PDD_BRACERS_SPELL_DMG_RED = 0.33
set udg_PDD_TRIGGER_CLEANUP_PERIOD = 10.0
endfunction
//////////////////////////////////////////////////////////////////////////////////
// End of configurable globals
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// User functions
//////////////////////////////////////////////////////////////////////////////////
function AddDamageHandler takes code func returns nothing
local integer id = GetHandleId(Condition(func))
local integer index = 0
// Loop to manage equal damage handlers
loop
exitwhen ( LoadTriggerConditionHandle(udg_PDD_h, id, index) == null )
set index = index + 1
endloop
// Store the desired damage handler function
call SaveTriggerConditionHandle(udg_PDD_h, id, index, TriggerAddCondition(udg_PDD_damageHandler, Filter(func)))
endfunction
function RemoveDamageHandler takes code func returns nothing
local integer id = GetHandleId(Condition(func))
local integer index = 0
// Loop through all equal damage handlers
loop
exitwhen ( LoadTriggerConditionHandle(udg_PDD_h, id, index) == null )
call TriggerRemoveCondition(udg_PDD_damageHandler, LoadTriggerConditionHandle(udg_PDD_h, id, index))
set index = index + 1
endloop
// Clean things up
call FlushChildHashtable(udg_PDD_h, id)
endfunction
function GetUnitLife takes unit u returns real
local boolean duringModification
local integer uId = GetHandleId(u)
local real health
local real storedHealth = LoadReal(udg_PDD_h, uId, 2)
local real storedDamage = LoadReal(udg_PDD_h, uId, 1)
// Check if the unit is being rescued from damage
set duringModification = GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0
if duringModification then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
endif
// Get the correct health value of the unit
if storedHealth != 0.0 then
set health = storedHealth - storedDamage
else
set health = GetWidgetLife(u) - storedDamage
endif
// Restore the rescue ability and return
if duringModification then
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
endif
return health
endfunction
function GetUnitMaxLife takes unit u returns real
local real maxHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
set maxHealth = GetUnitState(u, UNIT_STATE_MAX_LIFE)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
return maxHealth
endif
// If the unit isn't being rescued, use the standard native
return GetUnitState(u, UNIT_STATE_MAX_LIFE)
endfunction
function SetUnitLife takes unit u, real newLife returns nothing
local integer targetId
local integer oldTimerId
local real oldHealth
// Check if the unit is being rescued from damage
if GetUnitAbilityLevel(u, udg_PDD_SET_MAX_LIFE) > 0 then
call UnitRemoveAbility(u, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(u, newLife)
call UnitAddAbility(u, udg_PDD_SET_MAX_LIFE)
// Get the unit specific timer information
set targetId = GetHandleId(u)
set oldHealth = LoadReal(udg_PDD_h, targetId, 0)
// Update the unit specific timer information
if oldHealth != 0.0 then
set oldTimerId = LoadInteger(udg_PDD_h, targetId, 3)
call SaveReal(udg_PDD_h, targetId, 2, newLife)
call SaveReal(udg_PDD_h, targetId, 0, newLife)
call SaveReal(udg_PDD_h, oldTimerId, 4, newLife)
endif
return
endif
// If the unit isn't being rescued, use the standard native
call SetWidgetLife(u, newLife)
endfunction
function UnitDamageTargetEx takes unit localSource, unit localTarget, real localAmount, boolean attack, boolean ranged, attacktype localAttackType, damagetype localDamageType, weapontype localWeaponType returns boolean
// Avoid infinite loop due to recursion
if udg_PDD_damageType == udg_PDD_CODE then
return false
endif
// Avoid allocating attacks on units that are about to be killed
if ( localTarget == udg_PDD_target and GetUnitLife(localTarget) - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE ) then
return false
endif
// Store all damage parameters determined by the user
set udg_PDD_allocatedAttacks = udg_PDD_allocatedAttacks + 1
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 0, localSource)
call SaveUnitHandle(udg_PDD_h, udg_PDD_allocatedAttacks, 1, localTarget)
call SaveReal(udg_PDD_h, udg_PDD_allocatedAttacks, 2, localAmount)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 3, attack)
call SaveBoolean(udg_PDD_h, udg_PDD_allocatedAttacks, 4, ranged)
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 5, GetHandleId(localAttackType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 6, GetHandleId(localDamageType))
call SaveInteger(udg_PDD_h, udg_PDD_allocatedAttacks, 7, GetHandleId(localWeaponType))
// Return true if the damage was allocated
return true
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Sub functions
////////////////////////////////////////////////////////////////////////////////////
function DealFixDamage takes unit source, unit target, real pureAmount returns nothing
local real MAX_DAMAGE = 1000000.0
local real beforeHitpoints
local real newHitpoints
// Ensure the amount is positive
if pureAmount < 0 then
set pureAmount = -pureAmount
endif
// Save the targets hitpoints
set beforeHitpoints = GetWidgetLife(target)
set newHitpoints = beforeHitpoints - pureAmount
// Apply the desired, fixed amount
if newHitpoints >= udg_PDD_UNIT_MIN_LIFE then
call SetUnitState(target, UNIT_STATE_LIFE, newHitpoints)
else
if ( IsUnitType(target, UNIT_TYPE_ETHEREAL) == false ) then
call SetWidgetLife(target, 1.0)
call UnitDamageTarget(source, target, MAX_DAMAGE, true, false, udg_PDD_ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_UNIVERSAL, null)
call SetWidgetLife(target, 0.0)
else
call UnitRemoveAbility(target, udg_PDD_DAMAGE_TYPE_DETECTOR)
call SetWidgetLife(target, 1.0)
call UnitDamageTarget(source, target, MAX_DAMAGE, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
call SetWidgetLife(target, 0.0)
endif
endif
endfunction
function GetUnitSpellResistance takes unit u returns real
local real originalHP
local real beforeHP
local real afterHP
local real resistance
local real DUMMY_DAMAGE = 100
local real DUMMY_FACTOR = 0.01
// Deal spell damage in order to get the units resistance
call UnitRemoveAbility(udg_PDD_target, udg_PDD_DAMAGE_TYPE_DETECTOR)
set originalHP = GetWidgetLife(udg_PDD_target)
call UnitAddAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, 20000.0)
set beforeHP = GetWidgetLife(udg_PDD_target)
call DisableTrigger(udg_PDD_damageEvent)
call UnitDamageTarget(udg_PDD_source, udg_PDD_target, DUMMY_DAMAGE, true, false, null, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(udg_PDD_damageEvent)
set afterHP = GetWidgetLife(udg_PDD_target)
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, originalHP)
call UnitAddAbility(udg_PDD_target, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(udg_PDD_target, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
// Calculate this resistance
set resistance = DUMMY_FACTOR*(beforeHP - afterHP)
// If the resistance was greater than 100%, return it
if resistance > 1.0 then
return resistance
else
return 1.0
endif
endfunction
function UnitHasItemOfType takes unit u, integer itemId returns integer
local integer index = 0
local item indexItem
// Check if the target has a spell damage reducing item
loop
set indexItem = UnitItemInSlot(u, index)
if ( indexItem != null ) and ( GetItemTypeId(indexItem) == itemId ) then
set indexItem = null
return index + 1
endif
set index = index + 1
exitwhen index >= bj_MAX_INVENTORY
endloop
set indexItem = null
return 0
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Damage Engine
////////////////////////////////////////////////////////////////////////////////////
function AfterDamage takes nothing returns nothing
local timer time = GetExpiredTimer()
local integer id = GetHandleId(time)
local unit localSource = LoadUnitHandle(udg_PDD_h, id, 0)
local unit localTarget = LoadUnitHandle(udg_PDD_h, id, 1)
local real pureAmount = LoadReal(udg_PDD_h, id, 2)
local real amount = LoadReal(udg_PDD_h, id, 3)
local real originalHealth = LoadReal(udg_PDD_h, id, 4)
// If the damage was modified, restore units health
if originalHealth != 0.0 then
call UnitRemoveAbility(localTarget, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(localTarget, originalHealth)
endif
// Apply the desired amount of damage
if amount > 0.0 then
call DisableTrigger(udg_PDD_damageEvent)
call DealFixDamage(localSource, localTarget, amount)
call EnableTrigger(udg_PDD_damageEvent)
else
call SetWidgetLife(localTarget, originalHealth - amount)
endif
// Clean things up
call FlushChildHashtable(udg_PDD_h, id)
call FlushChildHashtable(udg_PDD_h, GetHandleId(localTarget))
call DestroyTimer(time)
set time = null
set localSource = null
set localTarget = null
endfunction
function DamageEngine takes nothing returns nothing
local timer time
local integer id
local real health
local real rawAmount
local real originalHealth
local integer targetId
local integer oldTimerId
local real oldHealth
local real oldOriginalHealth
local real oldAmount
set rawAmount = GetEventDamage()
if rawAmount == 0.0 then
return
endif
set udg_PDD_source = GetEventDamageSource()
set udg_PDD_target = GetTriggerUnit()
// Determine the damage type
if rawAmount > 0.0 then
if udg_PDD_damageType != udg_PDD_CODE then
set udg_PDD_damageType = udg_PDD_PHYSICAL
endif
set udg_PDD_amount = rawAmount
else
if udg_PDD_damageType != udg_PDD_CODE then
set udg_PDD_damageType = udg_PDD_SPELL
endif
set udg_PDD_amount = -rawAmount
endif
// Register spell reduction above 100%
if udg_PDD_SPELL_RESIST_AUTO_DETECT then
set udg_PDD_amount = GetUnitSpellResistance(udg_PDD_target)*udg_PDD_amount
else
if ( IsUnitType(udg_PDD_target, UNIT_TYPE_ETHEREAL) and IsUnitEnemy(udg_PDD_target, GetOwningPlayer(udg_PDD_source)) and rawAmount < 0.0 ) then
set udg_PDD_amount = udg_PDD_ETHEREAL_DAMAGE_FACTOR*udg_PDD_amount
endif
endif
// Register spell damage reducing items like runed bracers
if ( IsUnitType(udg_PDD_target, UNIT_TYPE_HERO) and UnitHasItemOfType(udg_PDD_target, udg_PDD_SPELL_DMG_REDUCTION_ITEM) > 0 ) and rawAmount < 0.0 then
set udg_PDD_amount = (1 - udg_PDD_BRACERS_SPELL_DMG_RED)*udg_PDD_amount
endif
// Save health and damage variables
if udg_PDD_damageType != udg_PDD_CODE then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
endif
set udg_PDD_pureAmount = udg_PDD_amount
set originalHealth = GetWidgetLife(udg_PDD_target)
set oldTimerId = 0
// Call damage handlers
set udg_PDD_damageEventTrigger = 0.0
set udg_PDD_damageEventTrigger = 1.0
set udg_PDD_damageEventTrigger = 0.0
// If the damage was modified, apply the rescue ability
if udg_PDD_amount != udg_PDD_pureAmount then
call UnitAddAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, GetWidgetLife(udg_PDD_target) + udg_PDD_pureAmount)
endif
// Check if a previous timer didn't yet expire
set targetId = GetHandleId(udg_PDD_target)
set oldHealth = LoadReal(udg_PDD_h, targetId, 0)
// If this is the case, update the timer information
if oldHealth != 0.0 then
set oldTimerId = LoadInteger(udg_PDD_h, targetId, 3)
set oldOriginalHealth = LoadReal(udg_PDD_h, targetId, 2)
set oldAmount = LoadReal(udg_PDD_h, targetId, 1)
set originalHealth = oldOriginalHealth - oldAmount
call SaveReal(udg_PDD_h, oldTimerId, 4, oldOriginalHealth)
endif
// Call after damage event if damage was spell, modified, code or parallel
if ( rawAmount < 0.0 or udg_PDD_pureAmount != udg_PDD_amount or oldTimerId != 0 or udg_PDD_allocatedAttacks > 0 ) then
set time = CreateTimer()
set id = GetHandleId(time)
// Save handles for after damage event
call SaveUnitHandle(udg_PDD_h, id, 0, udg_PDD_source)
call SaveUnitHandle(udg_PDD_h, id, 1, udg_PDD_target)
call SaveReal(udg_PDD_h, id, 2, udg_PDD_pureAmount)
call SaveReal(udg_PDD_h, id, 3, udg_PDD_amount)
call SaveReal(udg_PDD_h, id, 4, originalHealth)
// Save this extra to manage parallel damage instances
call SaveReal(udg_PDD_h, targetId, 0, GetWidgetLife(udg_PDD_target))
call SaveReal(udg_PDD_h, targetId, 1, udg_PDD_amount)
call SaveReal(udg_PDD_h, targetId, 2, originalHealth)
call SaveInteger(udg_PDD_h, targetId, 3, id)
// Avoid healing of negative spell damage
if rawAmount < 0.0 then
call DisableTrigger(udg_PDD_damageEvent)
call DealFixDamage(udg_PDD_source, udg_PDD_target, -rawAmount)
if ( originalHealth - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE ) then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call DealFixDamage(udg_PDD_source, udg_PDD_target, udg_PDD_amount)
endif
call EnableTrigger(udg_PDD_damageEvent)
endif
// Guarantee unit exploding
if originalHealth - udg_PDD_amount < udg_PDD_UNIT_MIN_LIFE then
if rawAmount > 0.0 then
call UnitRemoveAbility(udg_PDD_target, udg_PDD_SET_MAX_LIFE)
call SetWidgetLife(udg_PDD_target, udg_PDD_UNIT_MIN_LIFE)
endif
endif
// Start the after damage event
call TimerStart(time, 0.0, false, function AfterDamage)
endif
// Handle allocated attacks from UnitDamageTargetEx
if udg_PDD_totalAllocs == 0 then
set udg_PDD_totalAllocs = udg_PDD_allocatedAttacks
endif
if udg_PDD_allocatedAttacks > 0 then
set udg_PDD_allocatedAttacks = udg_PDD_allocatedAttacks - 1
set udg_PDD_allocCounter = udg_PDD_allocCounter + 1
call TriggerEvaluate(udg_PDD_runAllocatedAttacks)
endif
// Reset all required variables
set udg_PDD_damageType = -1
set udg_PDD_totalAllocs = 0
set udg_PDD_allocCounter = -1
endfunction
////////////////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////////////////
function RestoreTriggers takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
// Re-register units that are alive
if GetUnitTypeId(enumUnit) != 0 then
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, enumUnit, EVENT_UNIT_DAMAGED)
endif
set enumUnit = null
endfunction
function ClearMemory_Actions takes nothing returns nothing
local group g = CreateGroup()
local code c = function DamageEngine
// Reset the damage event
call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
call ResetTrigger(udg_PDD_damageEvent)
call DestroyTrigger(udg_PDD_damageEvent)
set udg_PDD_damageEvent = null
// Rebuild it then
set udg_PDD_damageEvent = CreateTrigger()
call TriggerAddCondition(udg_PDD_damageEvent, Filter(c))
call ForGroup(g, function RestoreTriggers)
// Clean things up
call DestroyGroup(g)
set g = null
set c = null
endfunction
function MapInit takes nothing returns nothing
local unit enumUnit = GetEnumUnit()
// Register units on map initialization
call UnitAddAbility(enumUnit, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(enumUnit, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, enumUnit, EVENT_UNIT_DAMAGED)
set enumUnit = null
endfunction
function UnitEntersMap takes nothing returns nothing
local unit triggerUnit = GetTriggerUnit()
// Register units that enter the map
if ( GetUnitAbilityLevel(triggerUnit, udg_PDD_DAMAGE_TYPE_DETECTOR) < 1 ) then
call UnitAddAbility(triggerUnit, udg_PDD_DAMAGE_TYPE_DETECTOR)
call UnitMakeAbilityPermanent(triggerUnit, true, udg_PDD_DAMAGE_TYPE_DETECTOR)
call TriggerRegisterUnitEvent(udg_PDD_damageEvent, triggerUnit, EVENT_UNIT_DAMAGED)
endif
set triggerUnit = null
endfunction
function RunAllocatedAttacks takes nothing returns nothing
local integer localAllocAttacks = udg_PDD_allocatedAttacks + 1
// Calculate the correct sequence of allocated attacks
set localAllocAttacks = localAllocAttacks - udg_PDD_totalAllocs + 1 + 2*udg_PDD_allocCounter
// Deal code damage if the unit isn't exploding
set udg_PDD_damageType = udg_PDD_CODE
if GetUnitLife(LoadUnitHandle(udg_PDD_h, localAllocAttacks, 1)) >= udg_PDD_UNIT_MIN_LIFE then
call UnitDamageTarget(LoadUnitHandle(udg_PDD_h, localAllocAttacks, 0), LoadUnitHandle(udg_PDD_h, localAllocAttacks, 1), LoadReal(udg_PDD_h, localAllocAttacks, 2), LoadBoolean(udg_PDD_h, localAllocAttacks, 3), LoadBoolean(udg_PDD_h, localAllocAttacks, 4), ConvertAttackType(LoadInteger(udg_PDD_h, localAllocAttacks, 5)), ConvertDamageType(LoadInteger(udg_PDD_h, localAllocAttacks, 6)), ConvertWeaponType(LoadInteger(udg_PDD_h, localAllocAttacks, 7)))
else
call FlushChildHashtable(udg_PDD_h, localAllocAttacks - 1)
endif
// Clean things up
call FlushChildHashtable(udg_PDD_h, localAllocAttacks)
endfunction
function InitTrig_DamageEvent takes nothing returns nothing
local group g = CreateGroup()
local region r = CreateRegion()
local trigger UnitEnters = CreateTrigger()
local trigger ClearMemory = CreateTrigger()
local code cDamageEngine = function DamageEngine
local code cUnitEnters = function UnitEntersMap
local code cClearMemory = function ClearMemory_Actions
local code cRunAllocatedAttacks = function RunAllocatedAttacks
// Initialize global variables
set udg_PDD_h = InitHashtable()
set udg_PDD_damageEvent = CreateTrigger()
set udg_PDD_damageHandler = CreateTrigger()
set udg_PDD_damageType = -1
set udg_PDD_allocatedAttacks = 0
set udg_PDD_runAllocatedAttacks = CreateTrigger()
// Initialize global configurable constants
call InitGlobalVariables()
// Initialize global fixed constants
set udg_PDD_PHYSICAL = 0
set udg_PDD_SPELL = 1
set udg_PDD_CODE = 2
set udg_PDD_UNIT_MIN_LIFE = 0.406
set udg_PDD_ATTACK_TYPE_UNIVERSAL = ConvertAttackType(7)
set udg_PDD_totalAllocs = 0
set udg_PDD_allocCounter = -1
set udg_PDD_damageEventTrigger = 0.0
// Register units on map initialization
call TriggerRegisterVariableEvent(udg_PDD_damageHandler, "udg_PDD_damageEventTrigger", EQUAL, 1.0)
call TriggerAddCondition(udg_PDD_damageEvent, Filter(cDamageEngine))
call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
call ForGroup(g, function MapInit)
// Register units that enter the map
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(UnitEnters, r, null)
call TriggerAddCondition(UnitEnters, Filter(cUnitEnters))
// Register trigger for allocated attacks
call TriggerAddCondition(udg_PDD_runAllocatedAttacks, Filter(cRunAllocatedAttacks))
// Clear memory leaks
call TriggerRegisterTimerEvent(ClearMemory, udg_PDD_TRIGGER_CLEANUP_PERIOD, true)
call TriggerAddCondition(ClearMemory, Filter(cClearMemory))
// Clean things up
call DestroyGroup(g)
set UnitEnters = null
set ClearMemory = null
set cDamageEngine = null
set cUnitEnters = null
set cClearMemory = null
set cRunAllocatedAttacks = null
set g = null
set r = null
endfunction
//TESH.scrollpos=16
//TESH.alwaysfold=0
//*****************************************************************************\\
//! Paladon presents !\\
//* Telekinesis *
//* vJass *
//*******************************************************************************
// Notes: *
// This is my second Jass / vJass spell. *
// This spell is dedicated to all the participants of the *
// 18th Spells & Systems Mini Contest. *
// *
// Requirements: *
// *
// JassNewGenPack *
// A target area based spell *
// To import this spell, just copy the 'Telekinesis vJass' trigger into your *
// very own map and adjust the following values in the 'Settings'. *
//!*******************************SETTINGS************************************!\\
scope Telekinesis initializer GetStarted
globals
private constant integer SpellID = 'A0B4' // Returns the rawcode of the spell. To get a spell's rawcode, press Ctrl+D in the Object Editor.
private constant real SpellAoEStart = 270.0 // Returns the initial area in which the enemied units are affected by this spell.
private constant real SpellAoEIncreasement = 30.0 // Returns the increasement per level of the previous area.
private constant real MinHeightStart = 150.0 // Returns the initial minimal reachable height.
private constant real MinHeightIncreasement = 100.0 // Returns the increasement of the minimal reachable height per level.
private constant real MaxHeightStart = 250.0 // Returns the initial maximal reachable height.
private constant real MaxHeightIncreasement = 100.0 // Returns the increasement of the maximal reachable height per level.
private constant real Speed = 1.45 // Returns the time in seconds in which the affected units are in the air.
private constant real SpeedVariationPerc = 0.20 // Returns the percentage of the variation between each unit's lifting speed. Default is 0.20 which means 20% variation.
private constant string LiftSFX = "Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl" // Returns the path of the special effect displayed periodically at the chest of the lifted targets.
private constant real LiftSFXTimer = 0.30 // Returns the interval in seconds in which the previous effect is displayed.
private constant string StartSFX = "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl" // Returns the path of the special effect displayed at the targets upon casting this spell.
private constant string ImpactSFX = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" // Returns the path of the special effect displayed upon impact on earth.
private constant real HDmgInPercStart = 0.35 // Returns the percentage of the height dealt in damage. Default is 0.08 for 8% height dealt in damage to the lifted unit upon impact.
private constant real HDmgInPercIncreasement = 0.05 // Returns increasement per level of the previous value. Default is 0.02 for 2% increasement per level.
private constant real ImpactDmgStart = 60.0 // Returns the direct damage dealt to the target upon impact.
private constant real ImpactDmgIncreasement = 20.0 // Returns increasement per level of the previous value.
private constant attacktype AttackType = ATTACK_TYPE_NORMAL // Returns the attack type in which the damage is dealt. There's actually no need to adjust this value.
private constant damagetype DamageType = DAMAGE_TYPE_NORMAL // Returns the damage type in which the damage is dealt. There's actually no need to adjust this value.
private constant weapontype WeaponType = WEAPON_TYPE_ROCK_HEAVY_BASH // Returns the weapon type with which the damage is dealt. There's actually no need to adjust this value, replace it with 'null' to remove the corresponding sound.
private constant boolean Pause = true // Returns whether the flying unit should be paused.
endglobals
//********************************END OF THE SETTINGS**************************
//**Do not modify anything below this line unless you know what you are doing**
//*****************************************************************************
globals // Declaring the global variables.
private group Fgroup = CreateGroup()
private group FlyG = CreateGroup()
private boolexpr filter = null
private integer i = 0
private unit tempU
private player tempP
endglobals
//! General functions used
private function GetFilter takes nothing returns boolean // Filters the targetable units.
return GetWidgetLife(GetFilterUnit()) > 0 and IsUnitEnemy(GetFilterUnit(),tempP) and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false
endfunction
private function TeleCondition takes nothing returns boolean // Checks the SpellID in order to trigger this spell, and no other, upon casting.
return GetSpellAbilityId() == SpellID
endfunction
//! The spell itself
private struct Spell // Declaring the struct variables.
unit c
unit t
real int
real maxH
real LsfxT
real speed
integer l
static Spell array indx
static integer counter = 0
static timer time = CreateTimer()
static method TeleLift takes nothing returns nothing // Lifting the targets and handleing all the impact stuff.
local real x
local real y
local Spell d
set i = 0
loop
exitwhen i >= Spell.counter
set d = Spell.indx[i]
if d.int < 180 then
set d.int = d.int + d.speed
set d.LsfxT = d.LsfxT + 0.01
call SetUnitFlyHeight(d.t,(Sin(d.int*bj_DEGTORAD)*d.maxH)+GetUnitDefaultFlyHeight(d.t),0)
if d.LsfxT >= LiftSFXTimer then
call DestroyEffect(AddSpecialEffectTarget(LiftSFX,d.t,"chest"))
set d.LsfxT = 0
endif
else
set tempP = GetOwningPlayer(d.c)
set x = GetUnitX(d.t)
set y = GetUnitY(d.t)
call GroupRemoveUnit (FlyG,d.t)
call DestroyEffect(AddSpecialEffect(ImpactSFX,x,y))
call UnitDamageTarget(d.c,d.t,(d.maxH*(HDmgInPercStart+(d.l-1)*HDmgInPercIncreasement))+(ImpactDmgStart+(d.l-1)*ImpactDmgIncreasement),true,true,AttackType,DamageType,WeaponType)
if Pause == true then
call PauseUnit(d.t,false)
endif
call SetUnitFlyHeight(d.t,GetUnitDefaultFlyHeight(d.t),0)
set d.c = null
set d.t = null
call d.destroy()
set Spell.counter = Spell.counter - 1
set Spell.indx[i] = d.indx[Spell.counter]
set i = i - 1
if Spell.counter == 0 then
call PauseTimer(Spell.time)
endif
endif
set i = i + 1
endloop
set i = 0
endmethod
static method GetValues takes unit c, unit t, integer l returns nothing // Applies the spell values into the struct system.
local Spell d = Spell.allocate()
set d.c = c
set d.t = t
set d.l = l
set d.int = 0
set d.LsfxT = 0
set d.maxH = GetRandomReal(MinHeightStart+(l-1)*MinHeightIncreasement,MaxHeightStart+(l-1)*MaxHeightIncreasement)
set d.speed = 1.8/GetRandomReal(Speed*(1+SpeedVariationPerc),Speed*(1-SpeedVariationPerc))
if Spell.counter == 0 then
call TimerStart(Spell.time,0.01,true, function Spell.TeleLift)
endif
set Spell.indx[Spell.counter] = d
set Spell.counter = Spell.counter + 1
endmethod
endstruct
//! Casting the spell
private function TeleInput takes nothing returns nothing // Gets and initializes the storage of all the spell values.
local unit caster = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(caster,SpellID)
local location loc = GetSpellTargetLoc()
set tempP = GetOwningPlayer(caster)
call GroupEnumUnitsInRange(Fgroup,GetLocationX(loc),GetLocationY(loc),SpellAoEStart+SpellAoEIncreasement*(level-1),filter)
loop
set tempU = FirstOfGroup(Fgroup)
exitwhen tempU == null
if IsUnitInGroup (tempU,FlyG) == false then
call Spell.GetValues(caster,tempU,GetUnitAbilityLevel(caster,SpellID))
call GroupAddUnit (FlyG,tempU)
call UnitAddAbility(tempU,'Amrf')
call UnitRemoveAbility(tempU,'Amrf')
call DestroyEffect(AddSpecialEffect(StartSFX,GetUnitX(tempU),GetUnitY(tempU)))
if Pause == true then
call PauseUnit(tempU,true)
endif
endif
call GroupRemoveUnit(Fgroup,tempU)
endloop
call RemoveLocation(loc)
set loc = null
set caster = null
endfunction
//! Preloading and setting
private function GetStarted takes nothing returns nothing // Preloads effects, adds actions and conditions to the spell's trigger.
local trigger TeleTrig = CreateTrigger()
set filter = Condition(function GetFilter)
loop
call TriggerRegisterPlayerUnitEvent(TeleTrig, Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
set i = 0
call TriggerAddCondition(TeleTrig, Condition(function TeleCondition))
call TriggerAddAction(TeleTrig, function TeleInput)
call Preload(LiftSFX)
call Preload(StartSFX)
call Preload(ImpactSFX)
call PreloadStart()
endfunction
endscope