-
Are you planning to upload your awesome map to Hive? Please review the rules here.Dismiss Notice
-
Dismiss Notice
Awaken what lies in the heart of your swarm. The 17th Techtree Contest has arrived!
-
Dismiss Notice
The Hive Workshop is launching its first HD modelling contest. How HD should it be?
-
Dismiss Notice
Check out the Staff Job Openings thread.
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.
Trigger Viewer






























































































































































































































































































































































































































































































//TESH.scrollpos=0 //TESH.alwaysfold=0
Name | Type | Is Array | Initial Value |
//TESH.scrollpos=234
//TESH.alwaysfold=0
//! import "luajass.Aeon_of_War.j"
//! textmacro LUA_FILE_HEADER
//! i do
//! i local FILENAME = "Aeon_of_War"
//! i function getfilename()
//! i return FILENAME
//! i end
//! i local PATH_LUA_p = "grimext\\luadir"
//! i local PATH_JASS_p = PATH_LUA_p .. "\\" .. FILENAME .. "_dir"
//! i local PATH_LUA = PATH_LUA_p .. "\\"
//! i local PATH_JASS = PATH_JASS_p .. "\\"
//! i local JASS_HUB = "jass\\luajass." .. FILENAME .. ".j"
//! i local olddofile = dofile
//! i local oldrequire = require
//! i local oldloadfile = loadfile
//! i function dofile(name)
//! i oldrequire("luadir\\" .. name)
//! i end
//! i function require(name)
//! i dofile(name)
//! i end
//! i function loadfile(name)
//! i dofile(name)
//! i end
//! i local function getluapath(name)
//! i return (PATH_LUA .. name .. ".lua")
//! i end
//! i local function getjasspath(name)
//! i return (PATH_JASS .. name .. ".luajass.j")
//! i end
//! i local function getjassimport(name)
//! i return ("\/\/! import \"..\\" .. getjasspath(name) .. "\"")
//! i end
//! i local function del(name)
//! i os.remove(name)
//! i end
//! i local function read(path)
//! i local file = io.open(path, "r")
//! i code = nil
//! i if (file ~= nil) then
//! i code = file:read("*all")
//! i file:close()
//! i end
//! i return code
//! i end
//! i local function write(path, code)
//! i file = io.open(path, "w")
//! i file:write(code)
//! i file:close()
//! i end
//! i local function import(name)
//! i local code = read(JASS_HUB)
//! i local line = getjassimport(name) .. "\n"
//! i local s,k = code:find(line)
//! i if (s == nil) then
//! i write(JASS_HUB, code .. line)
//! i end
//! i end
//! i function readlua(name)
//! i return read(getluapath(name))
//! i end
//! i function writelua(name, code)
//! i write(getluapath(name), code)
//! i end
//! i function readjass(name)
//! i return read(getjasspath(name))
//! i end
//! i function writejass(name, code)
//! i write(getjasspath(name), code)
//! i import(name)
//! i end
//! i function deletelua(name)
//! i del(getluapath(name))
//! i end
//! i function deletejass(name)
//! i del(getjasspath(name))
//! i local line = getjassimport(name) .. "\n"
//! i local code = read(JASS_HUB)
//! i local s,k = code:find(line)
//! i if (s ~= nil) then
//! i write(JASS_HUB, code:sub(1,s-1) .. code:sub(k+1))
//! i end
//! i end
//! i end
//! endtextmacro
library BasicFunctions requires AutoIndex
function Legal_Hero_Check takes unit u returns boolean
if ( GetUnitTypeId(u) == WARRIOR_ID ) then
return true
endif
if ( GetUnitTypeId(u) == PRIEST_ID ) then
return true
endif
if ( GetUnitTypeId(u) == MAGE_ID ) then
return true
endif
if ( GetUnitTypeId(u) == DRUID_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ROGUE_ID ) then
return true
endif
if ( GetUnitTypeId(u) == HUNTER_ID ) then
return true
endif
if ( GetUnitTypeId(u) == NECRO_ID ) then
return true
endif
if ( GetUnitTypeId(u) == PALADIN_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ENT_ID ) then
return true
endif
// Horde
if ( GetUnitTypeId(u) == WARRIOR_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == PRIEST_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == MAGE_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == DRUID_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == ROGUE_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == HUNTER_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == NECRO_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == SHAMAN_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ENT_ID2 ) then
return true
endif
return false
endfunction
function Chance takes real r returns boolean
if GetRandomReal(1,100) <= r then
return true
endif
return false
endfunction
function IsTeam1 takes unit u returns boolean
return IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true
endfunction
function Game_Message takes string Message returns nothing
call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 15.00, EVENT + Message )
endfunction
function Debug_Message takes string Message returns nothing
if DEBUG_MODE then
call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 15.00, DEBUG + Message )
endif
endfunction
function AI_Only_Check_Callback takes nothing returns nothing
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_USER then
// Team 1
if IsPlayerAlly(GetEnumPlayer(), Player(1)) == true then
set AI_Only_Team1 = false
// Team 2
else
set AI_Only_Team2 = false
endif
endif
endfunction
function AI_Only_Check takes nothing returns nothing
set AI_Only = false
// Team 1
set AI_Only_Team1 = true
call ForForce(Players_Team1, function AI_Only_Check_Callback)
// Team 2
set AI_Only_Team2 = true
call ForForce(Players_Team2, function AI_Only_Check_Callback)
if AI_Only_Team1 == true or AI_Only_Team2 == true then
set AI_Only = true
endif
endfunction
function Order_Unit_Move_To_Direct_WP takes unit u, integer i returns nothing
call IssuePointOrderLoc( u, "move", Waypoint_Array[i] )
endfunction
function Order_Unit_To_Next_WP takes unit u returns nothing
local integer i = waypoint_table[GetUnitId(u)]
if i != 0 then
call IssuePointOrderLoc( u, "attack", Waypoint_Array[i] )
endif
endfunction
function Order_Unit_To_Next_WP_Delay takes unit u returns nothing
local integer i = waypoint_table[GetUnitId(u)]
call TriggerSleepAction( 1.00 )
call IssuePointOrderLoc( u, "attack", Waypoint_Array[i] )
endfunction
function UnitUsesWP takes unit u returns boolean
return IsPlayerInForce(GetOwningPlayer(u), AI_Players) and waypoint_table[GetUnitId(u)] > 0 and waypoint_table[GetUnitId(u)] < 60
endfunction
function CreateTagOnUnit takes unit TargetUnit, string Text returns nothing
local integer id = GetPlayerId(GetOwningPlayer(TargetUnit))
local texttag t = CreateTextTag()
set Text = "|c00" + PlayerColors[id] + Text + "|r"
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.0184)
call SetTextTagPos(t, GetUnitX(TargetUnit), GetUnitY(TargetUnit), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
set t = null
endfunction
function CreateDamageTag takes unit source, unit target, real value, boolean isCrit, boolean isHealing returns nothing
local texttag t
local string s
local real life = GetUnitState(target, UNIT_STATE_LIFE)
local real max_life = GetUnitState(target, UNIT_STATE_MAX_LIFE)
local player PlayerSource = GetOwningPlayer(source)
local player PlayerTarget = GetOwningPlayer(target)
// Let's only display damage/healing if it's not 0
if ( not ( value == 0 ) ) then
set t = CreateTextTag()
if value < 0 then
set value = -value
endif
set s = I2S(R2I(value))
call SetTextTagVisibility(t, false)
// crit?
if isCrit then
call SetTextTagText(t, s+"!", CRIT_TAG_SIZE)
if not isHealing then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodFootman.mdl", target, "origin"))
endif
// normal
else
call SetTextTagText(t, s, TAG_SIZE) // 0.0184
endif
// Healing
if isHealing then
if PlayerTarget == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
call SetTextTagColor(t, 178, 233, 142, 255)
if life >= max_life then
call SetTextTagText(t, "", TAG_SIZE)
endif
// Damage
else
call SetTextTagColor(t, 200, 0, 30, 255)
endif
call SetTextTagPos(t, GetUnitX(target), GetUnitY(target), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
if PlayerSource == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
endif
set t = null
set PlayerSource = null
set PlayerTarget = null
endfunction
function Get_Number_Of_Players takes integer team returns integer
local integer number
// Team 1
if team == 1 then
set number = NumberOfPlayersTeam1
// Team 2
elseif team == 2 then
set number = NumberOfPlayersTeam2
// All players
else
set number = NumberOfPlayers
endif
return number
endfunction
function Init_Players_AI_Callback takes nothing returns nothing
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
set AI_Active = true
// Team 1
if IsPlayerAlly(GetEnumPlayer(), Player(1)) == true then
call ForceAddPlayer( AI_Players_Team1, GetEnumPlayer() )
call ForceAddPlayer( AI_Players, GetEnumPlayer() )
// Team 2
else
call ForceAddPlayer( AI_Players_Team2, GetEnumPlayer() )
call ForceAddPlayer( AI_Players, GetEnumPlayer() )
endif
endif
endfunction
function Init_Players takes nothing returns nothing
local integer id
// Init Colors first
// Team 1 and Team 2
set PlayerColors[0] = "FF0202"
set PlayerColors[1] = "0041FF"
// User Players
set PlayerColors[2] = "1BE5B8"
set PlayerColors[3] = "530080"
set PlayerColors[4] = "FFFC00"
set PlayerColors[5] = "FE890D"
set PlayerColors[6] = "1FBF00"
set PlayerColors[7] = "E45AAF"
set PlayerColors[8] = "949596"
set PlayerColors[9] = "7DBEF1"
set PlayerColors[10] = "0F6145"
set PlayerColors[11] = "4D2903"
// Other Players
set PlayerColors[GetPlayerId(Player(PLAYER_NEUTRAL_AGGRESSIVE))] = "DA4949"
set PlayerColors[GetPlayerId(Player(bj_PLAYER_NEUTRAL_VICTIM))] = "B6B6B6"
set PlayerColors[GetPlayerId(Player(bj_PLAYER_NEUTRAL_EXTRA))] = "B6B6B6"
set PlayerColors[GetPlayerId(Player(PLAYER_NEUTRAL_PASSIVE))] = "94D598"
// Player Names
set PlayerNames[2] = "|cff" + PlayerColors[2] + GetPlayerName(Player(2)) + "|r"
set PlayerNames[3] = "|cff" + PlayerColors[3] + GetPlayerName(Player(3)) + "|r"
set PlayerNames[4] = "|cff" + PlayerColors[4] + GetPlayerName(Player(4)) + "|r"
set PlayerNames[5] = "|cff" + PlayerColors[5] + GetPlayerName(Player(5)) + "|r"
set PlayerNames[6] = "|cff" + PlayerColors[6] + GetPlayerName(Player(6)) + "|r"
set PlayerNames[7] = "|cff" + PlayerColors[7] + GetPlayerName(Player(7)) + "|r"
set PlayerNames[8] = "|cff" + PlayerColors[8] + GetPlayerName(Player(8)) + "|r"
set PlayerNames[9] = "|cff" + PlayerColors[9] + GetPlayerName(Player(9)) + "|r"
set PlayerNames[10] = "|cff" + PlayerColors[10] + GetPlayerName(Player(10)) + "|r"
set PlayerNames[11] = "|cff" + PlayerColors[11] + GetPlayerName(Player(11)) + "|r"
// Init all players
set id = 2
loop
exitwhen id > 11
if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players, Player(id) )
set NumberOfPlayers = NumberOfPlayers + 1
endif
set id = id + 1
endloop
// Init Team 1
if GetPlayerSlotState(Player(2)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(2) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(6)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(6) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(8)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(8) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(9)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(9) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(10)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(10) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
// Init Team 2
if GetPlayerSlotState(Player(3)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(3) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(4)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(4) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(5)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(5) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(7)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(7) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(11)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(11) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
// Init AI players
call ForceAddPlayer ( AI_Players, Player(0) )
call ForceAddPlayer ( AI_Players, Player(1) )
call ForceAddPlayer ( AI_Players, Player(PLAYER_NEUTRAL_AGGRESSIVE) )
call ForForce( Players_Team1, function Init_Players_AI_Callback)
call ForForce( Players_Team2, function Init_Players_AI_Callback)
endfunction
function IsUnitTeam1 takes unit u returns boolean
if IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true then
set u = null
return true
endif
set u = null
return false
endfunction
function IsUnitTeam2 takes unit u returns boolean
if IsPlayerAlly(GetOwningPlayer(u), Player(0)) == true then
set u = null
return true
endif
set u = null
return false
endfunction
function Team_Message takes integer teamid, string message returns nothing
local real positionX = 0
local real positionY = 0
local real duration = 10
// Team 1
if teamid == 1 then
call DisplayTimedTextToPlayer(Player(1), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(2), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(6), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(8), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(9), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(10), positionX, positionY, duration, message)
// Team 2
elseif teamid == 2 then
call DisplayTimedTextToPlayer(Player(0), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(3), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(4), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(5), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(7), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(11), positionX, positionY, duration, message)
else
call DisplayTimedTextToPlayer(Player(0), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(1), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(2), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(3), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(4), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(5), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(6), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(7), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(8), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(9), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(10), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(11), positionX, positionY, duration, message)
endif
endfunction
function IncScoreDamage takes integer id, real d returns nothing
set Score_Damage[id] = Score_Damage[id] + d
endfunction
function IncScoreHealing takes integer id, real d returns nothing
set Score_Healing[id] = Score_Healing[id] + d
endfunction
function GetOnePlayerId takes nothing returns integer
local integer i
local integer id
set i = 2
loop
exitwhen i > 11
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestLevelId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Levels[i] > Score_Levels[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestKillsId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Kills[i] > Score_Kills[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestPvPId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_PvP[i] > Score_PvP[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetLowestDeathsId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Deaths[i] < Score_Deaths[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetMostDamageId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Damage[i] > Score_Damage[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetMostHealingId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Healing[i] > Score_Healing[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
private function ScorePlayersCallback takes nothing returns nothing
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(57, 2700), 1024 )
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(-5808, 7793), 1024 )
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(-2312, 4384), 1024 )
call CameraSetupApplyForPlayer( true, ScoreCam, GetEnumPlayer(), 0 )
endfunction
private function ScoreDefeatCallback takes nothing returns nothing
call CustomDefeatBJ( GetEnumPlayer(), "The enemy team has defeated you!" )
endfunction
private function ScoreVictoryCallback takes nothing returns nothing
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endfunction
function ShowScores takes integer WinningTeam returns nothing
local real duration = SCORE_DURATION
local integer i = GetRandomInt(0,30)
if i > 20 then
set ScoreCam = gg_cam_Camera_003
elseif i > 10 then
set ScoreCam = gg_cam_Camera_002
else
set ScoreCam = gg_cam_Camera_001
endif
call EnableUserControl(false)
call PauseAllUnitsBJ( true )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\PH1.mp3" )
call TriggerSleepAction(2.0)
call PlaySoundBJ(Sound_Score)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 3, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
// call TriggerSleepAction(3)
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
if WinningTeam == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " |cff2377D5TEAM 1|r WINS!")
elseif WinningTeam == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " |cffF32222TEAM 2|r WINS!")
endif
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call TriggerSleepAction(7)
call DisableTrigger( gg_trg_Camera )
call ForForce(bj_FORCE_ALL_PLAYERS, function ScorePlayersCallback)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 8, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, "|cffDCDCDCThanks for playing |r"+TITLE+" "+VERSION)
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, "|cffDCDCDCPlease feel free to report any feedback on this map at|r |cffFFA358hiveworkshop.com|r")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffFFDD8DHighest Level|r "+"|cffDCDCDC["+I2S(Score_Levels[GetHighestLevelId()])+"] : |r"+PlayerNames[GetHighestLevelId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffFF974AMost PvP|r "+"|cffDCDCDC["+I2S(Score_PvP[GetHighestPvPId()])+"] : |r"+PlayerNames[GetHighestPvPId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffD60505Most Kills|r "+"|cffDCDCDC["+I2S(Score_Kills[GetHighestKillsId()])+"] : |r"+PlayerNames[GetHighestKillsId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cff7A7878Least Deaths|r "+"|cffDCDCDC["+I2S(Score_Deaths[GetLowestDeathsId()])+"] : |r"+PlayerNames[GetLowestDeathsId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call TriggerSleepAction(duration)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 2, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction(2)
if WinningTeam == 1 then
call ForForce(Players_Team1, function ScoreVictoryCallback)
call ForForce(Players_Team2, function ScoreDefeatCallback)
elseif WinningTeam == 2 then
call ForForce(Players_Team1, function ScoreDefeatCallback)
call ForForce(Players_Team2, function ScoreVictoryCallback)
endif
endfunction
endlibrary
//TESH.alwaysfold=0
//! import "luajass.Aeon_of_War.j"
//! textmacro LUA_FILE_HEADER
//! i do
//! i local FILENAME = "Aeon_of_War"
//! i function getfilename()
//! i return FILENAME
//! i end
//! i local PATH_LUA_p = "grimext\\luadir"
//! i local PATH_JASS_p = PATH_LUA_p .. "\\" .. FILENAME .. "_dir"
//! i local PATH_LUA = PATH_LUA_p .. "\\"
//! i local PATH_JASS = PATH_JASS_p .. "\\"
//! i local JASS_HUB = "jass\\luajass." .. FILENAME .. ".j"
//! i local olddofile = dofile
//! i local oldrequire = require
//! i local oldloadfile = loadfile
//! i function dofile(name)
//! i oldrequire("luadir\\" .. name)
//! i end
//! i function require(name)
//! i dofile(name)
//! i end
//! i function loadfile(name)
//! i dofile(name)
//! i end
//! i local function getluapath(name)
//! i return (PATH_LUA .. name .. ".lua")
//! i end
//! i local function getjasspath(name)
//! i return (PATH_JASS .. name .. ".luajass.j")
//! i end
//! i local function getjassimport(name)
//! i return ("\/\/! import \"..\\" .. getjasspath(name) .. "\"")
//! i end
//! i local function del(name)
//! i os.remove(name)
//! i end
//! i local function read(path)
//! i local file = io.open(path, "r")
//! i code = nil
//! i if (file ~= nil) then
//! i code = file:read("*all")
//! i file:close()
//! i end
//! i return code
//! i end
//! i local function write(path, code)
//! i file = io.open(path, "w")
//! i file:write(code)
//! i file:close()
//! i end
//! i local function import(name)
//! i local code = read(JASS_HUB)
//! i local line = getjassimport(name) .. "\n"
//! i local s,k = code:find(line)
//! i if (s == nil) then
//! i write(JASS_HUB, code .. line)
//! i end
//! i end
//! i function readlua(name)
//! i return read(getluapath(name))
//! i end
//! i function writelua(name, code)
//! i write(getluapath(name), code)
//! i end
//! i function readjass(name)
//! i return read(getjasspath(name))
//! i end
//! i function writejass(name, code)
//! i write(getjasspath(name), code)
//! i import(name)
//! i end
//! i function deletelua(name)
//! i del(getluapath(name))
//! i end
//! i function deletejass(name)
//! i del(getjasspath(name))
//! i local line = getjassimport(name) .. "\n"
//! i local code = read(JASS_HUB)
//! i local s,k = code:find(line)
//! i if (s ~= nil) then
//! i write(JASS_HUB, code:sub(1,s-1) .. code:sub(k+1))
//! i end
//! i end
//! i end
//! endtextmacro
library BasicFunctions requires AutoIndex
function Legal_Hero_Check takes unit u returns boolean
if ( GetUnitTypeId(u) == WARRIOR_ID ) then
return true
endif
if ( GetUnitTypeId(u) == PRIEST_ID ) then
return true
endif
if ( GetUnitTypeId(u) == MAGE_ID ) then
return true
endif
if ( GetUnitTypeId(u) == DRUID_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ROGUE_ID ) then
return true
endif
if ( GetUnitTypeId(u) == HUNTER_ID ) then
return true
endif
if ( GetUnitTypeId(u) == NECRO_ID ) then
return true
endif
if ( GetUnitTypeId(u) == PALADIN_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ENT_ID ) then
return true
endif
// Horde
if ( GetUnitTypeId(u) == WARRIOR_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == PRIEST_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == MAGE_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == DRUID_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == ROGUE_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == HUNTER_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == NECRO_ID2 ) then
return true
endif
if ( GetUnitTypeId(u) == SHAMAN_ID ) then
return true
endif
if ( GetUnitTypeId(u) == ENT_ID2 ) then
return true
endif
return false
endfunction
function Chance takes real r returns boolean
if GetRandomReal(1,100) <= r then
return true
endif
return false
endfunction
function IsTeam1 takes unit u returns boolean
return IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true
endfunction
function Game_Message takes string Message returns nothing
call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 15.00, EVENT + Message )
endfunction
function Debug_Message takes string Message returns nothing
if DEBUG_MODE then
call DisplayTimedTextToPlayer( GetLocalPlayer(), 0, 0, 15.00, DEBUG + Message )
endif
endfunction
function AI_Only_Check_Callback takes nothing returns nothing
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_USER then
// Team 1
if IsPlayerAlly(GetEnumPlayer(), Player(1)) == true then
set AI_Only_Team1 = false
// Team 2
else
set AI_Only_Team2 = false
endif
endif
endfunction
function AI_Only_Check takes nothing returns nothing
set AI_Only = false
// Team 1
set AI_Only_Team1 = true
call ForForce(Players_Team1, function AI_Only_Check_Callback)
// Team 2
set AI_Only_Team2 = true
call ForForce(Players_Team2, function AI_Only_Check_Callback)
if AI_Only_Team1 == true or AI_Only_Team2 == true then
set AI_Only = true
endif
endfunction
function Order_Unit_Move_To_Direct_WP takes unit u, integer i returns nothing
call IssuePointOrderLoc( u, "move", Waypoint_Array[i] )
endfunction
function Order_Unit_To_Next_WP takes unit u returns nothing
local integer i = waypoint_table[GetUnitId(u)]
if i != 0 then
call IssuePointOrderLoc( u, "attack", Waypoint_Array[i] )
endif
endfunction
function Order_Unit_To_Next_WP_Delay takes unit u returns nothing
local integer i = waypoint_table[GetUnitId(u)]
call TriggerSleepAction( 1.00 )
call IssuePointOrderLoc( u, "attack", Waypoint_Array[i] )
endfunction
function UnitUsesWP takes unit u returns boolean
return IsPlayerInForce(GetOwningPlayer(u), AI_Players) and waypoint_table[GetUnitId(u)] > 0 and waypoint_table[GetUnitId(u)] < 60
endfunction
function CreateTagOnUnit takes unit TargetUnit, string Text returns nothing
local integer id = GetPlayerId(GetOwningPlayer(TargetUnit))
local texttag t = CreateTextTag()
set Text = "|c00" + PlayerColors[id] + Text + "|r"
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.0184)
call SetTextTagPos(t, GetUnitX(TargetUnit), GetUnitY(TargetUnit), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
set t = null
endfunction
function CreateDamageTag takes unit source, unit target, real value, boolean isCrit, boolean isHealing returns nothing
local texttag t
local string s
local real life = GetUnitState(target, UNIT_STATE_LIFE)
local real max_life = GetUnitState(target, UNIT_STATE_MAX_LIFE)
local player PlayerSource = GetOwningPlayer(source)
local player PlayerTarget = GetOwningPlayer(target)
// Let's only display damage/healing if it's not 0
if ( not ( value == 0 ) ) then
set t = CreateTextTag()
if value < 0 then
set value = -value
endif
set s = I2S(R2I(value))
call SetTextTagVisibility(t, false)
// crit?
if isCrit then
call SetTextTagText(t, s+"!", CRIT_TAG_SIZE)
if not isHealing then
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\HumanBloodFootman.mdl", target, "origin"))
endif
// normal
else
call SetTextTagText(t, s, TAG_SIZE) // 0.0184
endif
// Healing
if isHealing then
if PlayerTarget == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
call SetTextTagColor(t, 178, 233, 142, 255)
if life >= max_life then
call SetTextTagText(t, "", TAG_SIZE)
endif
// Damage
else
call SetTextTagColor(t, 200, 0, 30, 255)
endif
call SetTextTagPos(t, GetUnitX(target), GetUnitY(target), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagFadepoint(t, 2)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
if PlayerSource == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
endif
set t = null
set PlayerSource = null
set PlayerTarget = null
endfunction
function Get_Number_Of_Players takes integer team returns integer
local integer number
// Team 1
if team == 1 then
set number = NumberOfPlayersTeam1
// Team 2
elseif team == 2 then
set number = NumberOfPlayersTeam2
// All players
else
set number = NumberOfPlayers
endif
return number
endfunction
function Init_Players_AI_Callback takes nothing returns nothing
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
set AI_Active = true
// Team 1
if IsPlayerAlly(GetEnumPlayer(), Player(1)) == true then
call ForceAddPlayer( AI_Players_Team1, GetEnumPlayer() )
call ForceAddPlayer( AI_Players, GetEnumPlayer() )
// Team 2
else
call ForceAddPlayer( AI_Players_Team2, GetEnumPlayer() )
call ForceAddPlayer( AI_Players, GetEnumPlayer() )
endif
endif
endfunction
function Init_Players takes nothing returns nothing
local integer id
// Init Colors first
// Team 1 and Team 2
set PlayerColors[0] = "FF0202"
set PlayerColors[1] = "0041FF"
// User Players
set PlayerColors[2] = "1BE5B8"
set PlayerColors[3] = "530080"
set PlayerColors[4] = "FFFC00"
set PlayerColors[5] = "FE890D"
set PlayerColors[6] = "1FBF00"
set PlayerColors[7] = "E45AAF"
set PlayerColors[8] = "949596"
set PlayerColors[9] = "7DBEF1"
set PlayerColors[10] = "0F6145"
set PlayerColors[11] = "4D2903"
// Other Players
set PlayerColors[GetPlayerId(Player(PLAYER_NEUTRAL_AGGRESSIVE))] = "DA4949"
set PlayerColors[GetPlayerId(Player(bj_PLAYER_NEUTRAL_VICTIM))] = "B6B6B6"
set PlayerColors[GetPlayerId(Player(bj_PLAYER_NEUTRAL_EXTRA))] = "B6B6B6"
set PlayerColors[GetPlayerId(Player(PLAYER_NEUTRAL_PASSIVE))] = "94D598"
// Player Names
set PlayerNames[2] = "|cff" + PlayerColors[2] + GetPlayerName(Player(2)) + "|r"
set PlayerNames[3] = "|cff" + PlayerColors[3] + GetPlayerName(Player(3)) + "|r"
set PlayerNames[4] = "|cff" + PlayerColors[4] + GetPlayerName(Player(4)) + "|r"
set PlayerNames[5] = "|cff" + PlayerColors[5] + GetPlayerName(Player(5)) + "|r"
set PlayerNames[6] = "|cff" + PlayerColors[6] + GetPlayerName(Player(6)) + "|r"
set PlayerNames[7] = "|cff" + PlayerColors[7] + GetPlayerName(Player(7)) + "|r"
set PlayerNames[8] = "|cff" + PlayerColors[8] + GetPlayerName(Player(8)) + "|r"
set PlayerNames[9] = "|cff" + PlayerColors[9] + GetPlayerName(Player(9)) + "|r"
set PlayerNames[10] = "|cff" + PlayerColors[10] + GetPlayerName(Player(10)) + "|r"
set PlayerNames[11] = "|cff" + PlayerColors[11] + GetPlayerName(Player(11)) + "|r"
// Init all players
set id = 2
loop
exitwhen id > 11
if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players, Player(id) )
set NumberOfPlayers = NumberOfPlayers + 1
endif
set id = id + 1
endloop
// Init Team 1
if GetPlayerSlotState(Player(2)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(2) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(6)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(6) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(8)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(8) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(9)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(9) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
if GetPlayerSlotState(Player(10)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team1, Player(10) )
set NumberOfPlayersTeam1 = NumberOfPlayersTeam1 + 1
endif
// Init Team 2
if GetPlayerSlotState(Player(3)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(3) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(4)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(4) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(5)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(5) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(7)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(7) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
if GetPlayerSlotState(Player(11)) == PLAYER_SLOT_STATE_PLAYING then
call ForceAddPlayer( Players_Team2, Player(11) )
set NumberOfPlayersTeam2 = NumberOfPlayersTeam2 + 1
endif
// Init AI players
call ForceAddPlayer ( AI_Players, Player(0) )
call ForceAddPlayer ( AI_Players, Player(1) )
call ForceAddPlayer ( AI_Players, Player(PLAYER_NEUTRAL_AGGRESSIVE) )
call ForForce( Players_Team1, function Init_Players_AI_Callback)
call ForForce( Players_Team2, function Init_Players_AI_Callback)
endfunction
function IsUnitTeam1 takes unit u returns boolean
if IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true then
set u = null
return true
endif
set u = null
return false
endfunction
function IsUnitTeam2 takes unit u returns boolean
if IsPlayerAlly(GetOwningPlayer(u), Player(0)) == true then
set u = null
return true
endif
set u = null
return false
endfunction
function Team_Message takes integer teamid, string message returns nothing
local real positionX = 0
local real positionY = 0
local real duration = 10
// Team 1
if teamid == 1 then
call DisplayTimedTextToPlayer(Player(1), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(2), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(6), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(8), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(9), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(10), positionX, positionY, duration, message)
// Team 2
elseif teamid == 2 then
call DisplayTimedTextToPlayer(Player(0), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(3), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(4), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(5), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(7), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(11), positionX, positionY, duration, message)
else
call DisplayTimedTextToPlayer(Player(0), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(1), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(2), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(3), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(4), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(5), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(6), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(7), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(8), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(9), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(10), positionX, positionY, duration, message)
call DisplayTimedTextToPlayer(Player(11), positionX, positionY, duration, message)
endif
endfunction
function IncScoreDamage takes integer id, real d returns nothing
set Score_Damage[id] = Score_Damage[id] + d
endfunction
function IncScoreHealing takes integer id, real d returns nothing
set Score_Healing[id] = Score_Healing[id] + d
endfunction
function GetOnePlayerId takes nothing returns integer
local integer i
local integer id
set i = 2
loop
exitwhen i > 11
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestLevelId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Levels[i] > Score_Levels[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestKillsId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Kills[i] > Score_Kills[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetHighestPvPId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_PvP[i] > Score_PvP[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetLowestDeathsId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Deaths[i] < Score_Deaths[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetMostDamageId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Damage[i] > Score_Damage[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
function GetMostHealingId takes nothing returns integer
local integer i
local integer id = GetOnePlayerId()
set i = 2
loop
exitwhen i > 11
if Score_Healing[i] > Score_Healing[id] and GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
set id = i
endif
set i = i + 1
endloop
return id
endfunction
private function ScorePlayersCallback takes nothing returns nothing
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(57, 2700), 1024 )
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(-5808, 7793), 1024 )
call CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(-2312, 4384), 1024 )
call CameraSetupApplyForPlayer( true, ScoreCam, GetEnumPlayer(), 0 )
endfunction
private function ScoreDefeatCallback takes nothing returns nothing
call CustomDefeatBJ( GetEnumPlayer(), "The enemy team has defeated you!" )
endfunction
private function ScoreVictoryCallback takes nothing returns nothing
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endfunction
function ShowScores takes integer WinningTeam returns nothing
local real duration = SCORE_DURATION
local integer i = GetRandomInt(0,30)
if i > 20 then
set ScoreCam = gg_cam_Camera_003
elseif i > 10 then
set ScoreCam = gg_cam_Camera_002
else
set ScoreCam = gg_cam_Camera_001
endif
call EnableUserControl(false)
call PauseAllUnitsBJ( true )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\PH1.mp3" )
call TriggerSleepAction(2.0)
call PlaySoundBJ(Sound_Score)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 3, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
// call TriggerSleepAction(3)
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
if WinningTeam == 1 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " |cff2377D5TEAM 1|r WINS!")
elseif WinningTeam == 2 then
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " |cffF32222TEAM 2|r WINS!")
endif
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration, " ")
call TriggerSleepAction(7)
call DisableTrigger( gg_trg_Camera )
call ForForce(bj_FORCE_ALL_PLAYERS, function ScorePlayersCallback)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 8, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, "|cffDCDCDCThanks for playing |r"+TITLE+" "+VERSION)
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, "|cffDCDCDCPlease feel free to report any feedback on this map at|r |cffFFA358hiveworkshop.com|r")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffFFDD8DHighest Level|r "+"|cffDCDCDC["+I2S(Score_Levels[GetHighestLevelId()])+"] : |r"+PlayerNames[GetHighestLevelId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffFF974AMost PvP|r "+"|cffDCDCDC["+I2S(Score_PvP[GetHighestPvPId()])+"] : |r"+PlayerNames[GetHighestPvPId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cffD60505Most Kills|r "+"|cffDCDCDC["+I2S(Score_Kills[GetHighestKillsId()])+"] : |r"+PlayerNames[GetHighestKillsId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " |cff7A7878Least Deaths|r "+"|cffDCDCDC["+I2S(Score_Deaths[GetLowestDeathsId()])+"] : |r"+PlayerNames[GetLowestDeathsId()])
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, duration*2, " ")
call TriggerSleepAction(duration)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 2, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction(2)
if WinningTeam == 1 then
call ForForce(Players_Team1, function ScoreVictoryCallback)
call ForForce(Players_Team2, function ScoreDefeatCallback)
elseif WinningTeam == 2 then
call ForForce(Players_Team1, function ScoreDefeatCallback)
call ForForce(Players_Team2, function ScoreVictoryCallback)
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
globals
// Map information
constant string TITLE = "|c0054e37cA|c004bd679e|c0043ca77o|c003abd75n |c002aa471o|c0021986ef |c00107f6aW|c00087268a|c00006666r|r"
constant string VERSION = "|cffF7D599v1.03|r"
constant string AUTHOR = "|cff616161by MoCo|r"
// constant boolean DEBUG_RUN = true
constant real CAMERA_RANGE = 640 // 720 // Z offset of game camera
constant integer UNIT_CAP = 100 // currently unused
constant integer START_GOLD = 0
constant integer START_HONOR = 3
constant string SKY_MODEL = "Environment\\Sky\\FelwoodSky\\FelwoodSky.mdl"
// Tags
constant string DEBUG = "|cffEA34DFDebug-Info:|r "
constant string EVENT = "|cffF7A647Game Event:|r "
constant string HINT = "|cff34A3EAHint:|r "
constant string UPGRADE = "|cff9AFDACTeam Upgrade Notice:|r "
constant string TEAM1 = "|cff2377D5Team 1|r "
constant string TEAM2 = "|cffF32222Team 2|r "
constant integer MAX_PLAYERS = 11
constant real TAG_SIZE = 0.02 // // 0.0184
constant real CRIT_TAG_SIZE = 0.03
constant integer INCOME = 20
constant real GENERIC_ASSIST_RANGE = 512
constant real HONOR_RANGE = 800
constant real SCORE_DURATION = 20
unit array Heroes[1]
fogmodifier array Fogs[1]
integer array Score_Kills[1]
integer array Score_PvP[1]
integer array Score_Deaths[1]
integer array Score_Levels[1]
real array Score_Damage[1]
real array Score_Healing[1]
camerasetup ScoreCam
// Various stuff
location array Waypoint_Array[1]
location Spawn_Team1
location Spawn_Team2
unit Base_Team1 = gg_unit_htow_0033
unit Base_Team2 = gg_unit_ogre_0055
sound Sound_General
sound Sound_2
sound Sound_Score
integer Order_Stop
unit Raccoon_Team1
unit Raccoon_Team2
unit Raccoon_Neutral
unit Tavern
unit Tavern_Team1
unit Tavern_Team2
// Player Stuff
force Players = CreateForce()
force Players_Team1 = CreateForce()
force Players_Team2 = CreateForce()
force AI_Players = CreateForce()
force AI_Players_Team1 = CreateForce()
force AI_Players_Team2 = CreateForce()
integer NumberOfPlayers = 0
integer NumberOfPlayersTeam1 = 0
integer NumberOfPlayersTeam2 = 0
boolean AI_Only = false
boolean AI_Only_Team1 = false
boolean AI_Only_Team2 = false
string array PlayerColors[1]
string array PlayerNames[1]
boolean AI_Active = false
unit Shrine1
unit Shrine2
unit array Dragons[1]
// Groups
group AI_Safes_Team1 = CreateGroup()
group AI_Safes_Team2 = CreateGroup()
// Various stuff
unit array Safes[1]
unit array Inactive_Heroes[1]
unit array AI_Safes[1]
unit array AI_Workers[1]
integer array Druid_Str_Mod[1]
// sounds
sound Sound_Bear
sound Sound_Wolf
sound Sound_Falcon
sound Sound_Arrow
endglobals
//TESH.alwaysfold=0
globals
// Map information
constant string TITLE = "|c0054e37cA|c004bd679e|c0043ca77o|c003abd75n |c002aa471o|c0021986ef |c00107f6aW|c00087268a|c00006666r|r"
constant string VERSION = "|cffF7D599v1.03|r"
constant string AUTHOR = "|cff616161by MoCo|r"
// constant boolean DEBUG_RUN = true
constant real CAMERA_RANGE = 640 // 720 // Z offset of game camera
constant integer UNIT_CAP = 100 // currently unused
constant integer START_GOLD = 0
constant integer START_HONOR = 3
constant string SKY_MODEL = "Environment\\Sky\\FelwoodSky\\FelwoodSky.mdl"
// Tags
constant string DEBUG = "|cffEA34DFDebug-Info:|r "
constant string EVENT = "|cffF7A647Game Event:|r "
constant string HINT = "|cff34A3EAHint:|r "
constant string UPGRADE = "|cff9AFDACTeam Upgrade Notice:|r "
constant string TEAM1 = "|cff2377D5Team 1|r "
constant string TEAM2 = "|cffF32222Team 2|r "
constant integer MAX_PLAYERS = 11
constant real TAG_SIZE = 0.02 // // 0.0184
constant real CRIT_TAG_SIZE = 0.03
constant integer INCOME = 20
constant real GENERIC_ASSIST_RANGE = 512
constant real HONOR_RANGE = 800
constant real SCORE_DURATION = 20
unit array Heroes[1]
fogmodifier array Fogs[1]
integer array Score_Kills[1]
integer array Score_PvP[1]
integer array Score_Deaths[1]
integer array Score_Levels[1]
real array Score_Damage[1]
real array Score_Healing[1]
camerasetup ScoreCam
// Various stuff
location array Waypoint_Array[1]
location Spawn_Team1
location Spawn_Team2
unit Base_Team1 = gg_unit_htow_0033
unit Base_Team2 = gg_unit_ogre_0055
sound Sound_General
sound Sound_2
sound Sound_Score
integer Order_Stop
unit Raccoon_Team1
unit Raccoon_Team2
unit Raccoon_Neutral
unit Tavern
unit Tavern_Team1
unit Tavern_Team2
// Player Stuff
force Players = CreateForce()
force Players_Team1 = CreateForce()
force Players_Team2 = CreateForce()
force AI_Players = CreateForce()
force AI_Players_Team1 = CreateForce()
force AI_Players_Team2 = CreateForce()
integer NumberOfPlayers = 0
integer NumberOfPlayersTeam1 = 0
integer NumberOfPlayersTeam2 = 0
boolean AI_Only = false
boolean AI_Only_Team1 = false
boolean AI_Only_Team2 = false
string array PlayerColors[1]
string array PlayerNames[1]
boolean AI_Active = false
unit Shrine1
unit Shrine2
unit array Dragons[1]
// Groups
group AI_Safes_Team1 = CreateGroup()
group AI_Safes_Team2 = CreateGroup()
// Various stuff
unit array Safes[1]
unit array Inactive_Heroes[1]
unit array AI_Safes[1]
unit array AI_Workers[1]
integer array Druid_Str_Mod[1]
// sounds
sound Sound_Bear
sound Sound_Wolf
sound Sound_Falcon
sound Sound_Arrow
endglobals
//TESH.scrollpos=3
//TESH.alwaysfold=0
scope GameInit initializer Init
function Trig_Game_Init_Visibility_Callback takes nothing returns nothing
set bj_lastCreatedFogModifier = CreateFogModifierRect(GetEnumPlayer(), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false)
call FogModifierStart(bj_lastCreatedFogModifier)
endfunction
function Trig_Game_Init_Selectors_Callback takes nothing returns nothing
local integer id = GetPlayerId(GetEnumPlayer())
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set Hero_Selectors[id] = CreateUnitAtLoc(GetEnumPlayer(), 'e006', GetUnitLoc(Tavern_Team1), bj_UNIT_FACING)
else
set Hero_Selectors[id] = CreateUnitAtLoc(GetEnumPlayer(), 'e006', GetUnitLoc(Tavern_Team2), bj_UNIT_FACING)
endif
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_GOLD, START_GOLD )
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER, START_HONOR )
endfunction
function Select_Tavern_Callback takes nothing returns nothing
local unit tavern
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set tavern = Tavern_Team1
else
set tavern = Tavern_Team2
endif
call ClearSelectionForPlayer( GetEnumPlayer() )
call SelectUnitForPlayerSingle(tavern, GetEnumPlayer())
call PanCameraToTimedForPlayer(GetEnumPlayer(), GetUnitX(tavern), GetUnitY(tavern), 0)
call DestroyFogModifier(Fogs[GetPlayerId(GetEnumPlayer())])
if GetLocalPlayer() == GetEnumPlayer() then
call SetCameraTargetController(tavern, 0, 0, false)
endif
set tavern = null
endfunction
private function PlayersCallback takes nothing returns nothing
call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetEnumPlayer(), 0 )
set Fogs[GetPlayerId(GetEnumPlayer())] = CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(57, 2700), 1024 )
endfunction
function Init_Game takes nothing returns nothing
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call EnableUserControl(false)
// Adjust minimap
call EnableMinimapFilterButtons( false, false )
call SetAllyColorFilterState( 0 )
call SetCreepCampFilterState( false )
call SetSkyModel( SKY_MODEL )
// call MeleeStartingHeroLimit() Does not work
// Init units and regions
call TriggerExecute( gg_trg_Init_Units_and_Regions )
// Init Player stuff
call Init_Players()
call AI_Only_Check() // make sure to init players before
call ForForce(Players, function PlayersCallback)
// Creeps are too strong
call SetPlayerHandicap(Player(PLAYER_NEUTRAL_AGGRESSIVE), 0.5)
call SetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_GIVES_BOUNTY, 0)
// OrderStop
set Order_Stop = GetUnitCurrentOrder(gg_unit_ngsp_0152)
// Set Master Sound (used for different stuff)
call Preload( "Sound\\Interface\\ArrangedTeamInvitation.wav" )
set Sound_General = CreateSound("Sound\\Interface\\ArrangedTeamInvitation.wav", false, false, true, 12700, 12700, "")
call Preload( "Sound\\Interface\\GameFound.wav" )
set Sound_Score = CreateSound("Sound\\Interface\\GameFound.wav", false, false, true, 12700, 12700, "")
call Preload( "Sound\\Interface\\SecretFound.wav" )
set Sound_2 = CreateSound("Sound\\Interface\\SecretFound.wav", false, false, true, 12700, 12700, "")
call Preload( "Abilities\\Weapons\\Arrow\\ArrowAttack1.wav" )
set Sound_Arrow = CreateSound("Abilities\\Weapons\\Arrow\\ArrowAttack1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Creeps\\GrizzlyBear\\GrizzlyBearReady1.wav" )
set Sound_Bear = CreateSound("Units\\Creeps\\GrizzlyBear\\GrizzlyBearReady1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Orc\\Spiritwolf\\SpiritWolfBirth1.wav" )
set Sound_Wolf = CreateSound("Units\\Orc\\Spiritwolf\\SpiritWolfBirth1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Creeps\\WarEagle\\HawkReady1.wav" )
set Sound_Falcon = CreateSound("Units\\Creeps\\WarEagle\\HawkReady1.wav", false, true, true, 12700, 12700, "")
// Create Hero Selectors
call ForForce(Players, function Trig_Game_Init_Selectors_Callback)
call TriggerSleepAction( 0.1 )
call PlayThematicMusic("Sound\\Music\\mp3Music\\OrcTheme.mp3")
if DEBUG_MODE then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 1, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
else
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 3.00, " " + TITLE + " " + AUTHOR)
call TriggerSleepAction( 1.00 )
// -------------------- Start Fade -----------------------------------
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 2, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction( 3.00 )
endif
// -------------------- Game Startup -----------------------------------
// call CinematicModeBJ( false, GetPlayersAll() )
call StartSound(Sound_2)
call ResetToGameCamera(0)
call EnableTrigger( gg_trg_Camera )
call EnableUserControl(true)
//call TriggerSleepAction( 0.01 )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction( 0.5 )
call ForForce(Players, function Select_Tavern_Callback)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 1, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call DisplayTimedTextToForce( Players, 10, "You may type |cffFFA358help|r for a list of useful commands" )
call DisplayTimedTextToForce( Players, 10, " " )
// If Debug Mode, show whole map
if DEBUG_MODE then
call ForForce(bj_FORCE_ALL_PLAYERS, function Trig_Game_Init_Visibility_Callback)
endif
// Let's spawn AI heroes now
call TriggerSleepAction( 3.00 )
call Spawn_AI_Heroes()
endfunction
//===========================================================================
function Init takes nothing returns nothing
set gg_trg_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Initialization, function Init_Game )
endfunction
endscope
//TESH.alwaysfold=0
scope GameInit initializer Init
function Trig_Game_Init_Visibility_Callback takes nothing returns nothing
set bj_lastCreatedFogModifier = CreateFogModifierRect(GetEnumPlayer(), FOG_OF_WAR_VISIBLE, bj_mapInitialPlayableArea, true, false)
call FogModifierStart(bj_lastCreatedFogModifier)
endfunction
function Trig_Game_Init_Selectors_Callback takes nothing returns nothing
local integer id = GetPlayerId(GetEnumPlayer())
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set Hero_Selectors[id] = CreateUnitAtLoc(GetEnumPlayer(), 'e006', GetUnitLoc(Tavern_Team1), bj_UNIT_FACING)
else
set Hero_Selectors[id] = CreateUnitAtLoc(GetEnumPlayer(), 'e006', GetUnitLoc(Tavern_Team2), bj_UNIT_FACING)
endif
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_GOLD, START_GOLD )
call SetPlayerState( Player(id), PLAYER_STATE_RESOURCE_LUMBER, START_HONOR )
endfunction
function Select_Tavern_Callback takes nothing returns nothing
local unit tavern
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set tavern = Tavern_Team1
else
set tavern = Tavern_Team2
endif
call ClearSelectionForPlayer( GetEnumPlayer() )
call SelectUnitForPlayerSingle(tavern, GetEnumPlayer())
call PanCameraToTimedForPlayer(GetEnumPlayer(), GetUnitX(tavern), GetUnitY(tavern), 0)
call DestroyFogModifier(Fogs[GetPlayerId(GetEnumPlayer())])
if GetLocalPlayer() == GetEnumPlayer() then
call SetCameraTargetController(tavern, 0, 0, false)
endif
set tavern = null
endfunction
private function PlayersCallback takes nothing returns nothing
call CameraSetupApplyForPlayer( true, gg_cam_Camera_001, GetEnumPlayer(), 0 )
set Fogs[GetPlayerId(GetEnumPlayer())] = CreateFogModifierRadiusLocBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, Location(57, 2700), 1024 )
endfunction
function Init_Game takes nothing returns nothing
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call EnableUserControl(false)
// Adjust minimap
call EnableMinimapFilterButtons( false, false )
call SetAllyColorFilterState( 0 )
call SetCreepCampFilterState( false )
call SetSkyModel( SKY_MODEL )
// call MeleeStartingHeroLimit() Does not work
// Init units and regions
call TriggerExecute( gg_trg_Init_Units_and_Regions )
// Init Player stuff
call Init_Players()
call AI_Only_Check() // make sure to init players before
call ForForce(Players, function PlayersCallback)
// Creeps are too strong
call SetPlayerHandicap(Player(PLAYER_NEUTRAL_AGGRESSIVE), 0.5)
call SetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_GIVES_BOUNTY, 0)
// OrderStop
set Order_Stop = GetUnitCurrentOrder(gg_unit_ngsp_0152)
// Set Master Sound (used for different stuff)
call Preload( "Sound\\Interface\\ArrangedTeamInvitation.wav" )
set Sound_General = CreateSound("Sound\\Interface\\ArrangedTeamInvitation.wav", false, false, true, 12700, 12700, "")
call Preload( "Sound\\Interface\\GameFound.wav" )
set Sound_Score = CreateSound("Sound\\Interface\\GameFound.wav", false, false, true, 12700, 12700, "")
call Preload( "Sound\\Interface\\SecretFound.wav" )
set Sound_2 = CreateSound("Sound\\Interface\\SecretFound.wav", false, false, true, 12700, 12700, "")
call Preload( "Abilities\\Weapons\\Arrow\\ArrowAttack1.wav" )
set Sound_Arrow = CreateSound("Abilities\\Weapons\\Arrow\\ArrowAttack1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Creeps\\GrizzlyBear\\GrizzlyBearReady1.wav" )
set Sound_Bear = CreateSound("Units\\Creeps\\GrizzlyBear\\GrizzlyBearReady1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Orc\\Spiritwolf\\SpiritWolfBirth1.wav" )
set Sound_Wolf = CreateSound("Units\\Orc\\Spiritwolf\\SpiritWolfBirth1.wav", false, true, true, 12700, 12700, "")
call Preload( "Units\\Creeps\\WarEagle\\HawkReady1.wav" )
set Sound_Falcon = CreateSound("Units\\Creeps\\WarEagle\\HawkReady1.wav", false, true, true, 12700, 12700, "")
// Create Hero Selectors
call ForForce(Players, function Trig_Game_Init_Selectors_Callback)
call TriggerSleepAction( 0.1 )
call PlayThematicMusic("Sound\\Music\\mp3Music\\OrcTheme.mp3")
if DEBUG_MODE then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 1, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
else
call DisplayTimedTextToForce( bj_FORCE_ALL_PLAYERS, 3.00, " " + TITLE + " " + AUTHOR)
call TriggerSleepAction( 1.00 )
// -------------------- Start Fade -----------------------------------
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 2, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction( 3.00 )
endif
// -------------------- Game Startup -----------------------------------
// call CinematicModeBJ( false, GetPlayersAll() )
call StartSound(Sound_2)
call ResetToGameCamera(0)
call EnableTrigger( gg_trg_Camera )
call EnableUserControl(true)
//call TriggerSleepAction( 0.01 )
call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call TriggerSleepAction( 0.5 )
call ForForce(Players, function Select_Tavern_Callback)
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 1, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0 )
call DisplayTimedTextToForce( Players, 10, "You may type |cffFFA358help|r for a list of useful commands" )
call DisplayTimedTextToForce( Players, 10, " " )
// If Debug Mode, show whole map
if DEBUG_MODE then
call ForForce(bj_FORCE_ALL_PLAYERS, function Trig_Game_Init_Visibility_Callback)
endif
// Let's spawn AI heroes now
call TriggerSleepAction( 3.00 )
call Spawn_AI_Heroes()
endfunction
//===========================================================================
function Init takes nothing returns nothing
set gg_trg_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Initialization, function Init_Game )
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Camera_Actions takes nothing returns nothing
call SetCameraField(CAMERA_FIELD_ZOFFSET, CAMERA_RANGE, 0)
endfunction
//===========================================================================
function InitTrig_Camera takes nothing returns nothing
set gg_trg_Camera = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Camera, 0.01, true)
call TriggerAddAction( gg_trg_Camera, function Trig_Camera_Actions )
endfunction
//TESH.alwaysfold=0
function Trig_Camera_Actions takes nothing returns nothing
call SetCameraField(CAMERA_FIELD_ZOFFSET, CAMERA_RANGE, 0)
endfunction
//===========================================================================
function InitTrig_Camera takes nothing returns nothing
set gg_trg_Camera = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Camera, 0.01, true)
call TriggerAddAction( gg_trg_Camera, function Trig_Camera_Actions )
endfunction
//TESH.scrollpos=51
//TESH.alwaysfold=0
function Trig_Init_Safes_Create_Tag takes unit u returns nothing
local texttag t = CreateTextTag()
local string s = PlayerNames[GetPlayerId(GetOwningPlayer(u))]
call SetTextTagText(t, s, 0.02)
call SetTextTagPos(t, GetUnitX(u), GetUnitY(u), 0.00)
call SetTextTagVisibility(t, true)
call SetTextTagPermanent(t, true)
set t = null
endfunction
function Trig_Init_Units_Actions takes nothing returns nothing
local integer id
local unit u
set Tavern_Team1 = gg_unit_ntav_0085
set Tavern_Team2 = gg_unit_n009_0002
set Base_Team1 = gg_unit_htow_0033
set Base_Team2 = gg_unit_ogre_0055
set Shrine1 = gg_unit_nbse_0013
set Shrine2 = gg_unit_nbse_0014
set Spawn_Team1 = Location(GetRectCenterX(gg_rct_SpawnTeam1M), GetRectCenterY(gg_rct_SpawnTeam1M))
set Spawn_Team2 = Location(GetRectCenterX(gg_rct_SpawnTeam2M), GetRectCenterY(gg_rct_SpawnTeam2M))
// Init The Raccoon of Wisdom - he makes you drunk
set Raccoon_Neutral = gg_unit_n00M_0071
// Bosses
// Init the annoying safes..
// Team 1
set Safes[2] = gg_unit_h001_0126
set Safes[6] = gg_unit_h001_0129
set Safes[8] = gg_unit_h001_0130
set Safes[9] = gg_unit_h001_0131
set Safes[10] = gg_unit_h001_0132
// Team 2
set Safes[3] = gg_unit_h00A_0024
set Safes[4] = gg_unit_h00A_0053
set Safes[5] = gg_unit_h00A_0057
set Safes[7] = gg_unit_h00A_0059
set Safes[11] = gg_unit_h00A_0067
set id = 2
loop
exitwhen id > 11
if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
call Trig_Init_Safes_Create_Tag(Safes[id])
call SetUnitUseFood(Safes[id], false)
if IsPlayerAlly(Player(id), Player(1)) then
set u = CreateUnitAtLoc(Player(id), 'hpea', GetUnitLoc(Safes[id]), bj_UNIT_FACING)
else
set u = CreateUnitAtLoc(Player(id), 'opeo', GetUnitLoc(Safes[id]), bj_UNIT_FACING)
endif
if GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER then
if IsPlayerAlly(Player(id), Player(1)) then
call GroupAddUnit( AI_Safes_Team1, Safes[id] )
else
call GroupAddUnit( AI_Safes_Team2, Safes[id] )
endif
set AI_Workers[id] = u
set AI_Safes[id] = Safes[id]
endif
else
call RemoveUnit( Safes[id] )
endif
set id = id + 1
endloop
set u = null
endfunction
//===========================================================================
function InitTrig_Init_Units_and_Regions takes nothing returns nothing
set gg_trg_Init_Units_and_Regions = CreateTrigger( )
call TriggerAddAction( gg_trg_Init_Units_and_Regions, function Trig_Init_Units_Actions )
endfunction
//TESH.alwaysfold=0
function Trig_Init_Safes_Create_Tag takes unit u returns nothing
local texttag t = CreateTextTag()
local string s = PlayerNames[GetPlayerId(GetOwningPlayer(u))]
call SetTextTagText(t, s, 0.02)
call SetTextTagPos(t, GetUnitX(u), GetUnitY(u), 0.00)
call SetTextTagVisibility(t, true)
call SetTextTagPermanent(t, true)
set t = null
endfunction
function Trig_Init_Units_Actions takes nothing returns nothing
local integer id
local unit u
set Tavern_Team1 = gg_unit_ntav_0085
set Tavern_Team2 = gg_unit_n009_0002
set Base_Team1 = gg_unit_htow_0033
set Base_Team2 = gg_unit_ogre_0055
set Shrine1 = gg_unit_nbse_0013
set Shrine2 = gg_unit_nbse_0014
set Spawn_Team1 = Location(GetRectCenterX(gg_rct_SpawnTeam1M), GetRectCenterY(gg_rct_SpawnTeam1M))
set Spawn_Team2 = Location(GetRectCenterX(gg_rct_SpawnTeam2M), GetRectCenterY(gg_rct_SpawnTeam2M))
// Init The Raccoon of Wisdom - he makes you drunk
set Raccoon_Neutral = gg_unit_n00M_0071
// Bosses
// Init the annoying safes..
// Team 1
set Safes[2] = gg_unit_h001_0126
set Safes[6] = gg_unit_h001_0129
set Safes[8] = gg_unit_h001_0130
set Safes[9] = gg_unit_h001_0131
set Safes[10] = gg_unit_h001_0132
// Team 2
set Safes[3] = gg_unit_h00A_0024
set Safes[4] = gg_unit_h00A_0053
set Safes[5] = gg_unit_h00A_0057
set Safes[7] = gg_unit_h00A_0059
set Safes[11] = gg_unit_h00A_0067
set id = 2
loop
exitwhen id > 11
if GetPlayerSlotState(Player(id)) == PLAYER_SLOT_STATE_PLAYING then
call Trig_Init_Safes_Create_Tag(Safes[id])
call SetUnitUseFood(Safes[id], false)
if IsPlayerAlly(Player(id), Player(1)) then
set u = CreateUnitAtLoc(Player(id), 'hpea', GetUnitLoc(Safes[id]), bj_UNIT_FACING)
else
set u = CreateUnitAtLoc(Player(id), 'opeo', GetUnitLoc(Safes[id]), bj_UNIT_FACING)
endif
if GetPlayerController(Player(id)) == MAP_CONTROL_COMPUTER then
if IsPlayerAlly(Player(id), Player(1)) then
call GroupAddUnit( AI_Safes_Team1, Safes[id] )
else
call GroupAddUnit( AI_Safes_Team2, Safes[id] )
endif
set AI_Workers[id] = u
set AI_Safes[id] = Safes[id]
endif
else
call RemoveUnit( Safes[id] )
endif
set id = id + 1
endloop
set u = null
endfunction
//===========================================================================
function InitTrig_Init_Units_and_Regions takes nothing returns nothing
set gg_trg_Init_Units_and_Regions = CreateTrigger( )
call TriggerAddAction( gg_trg_Init_Units_and_Regions, function Trig_Init_Units_Actions )
endfunction








































//TESH.scrollpos=0
//TESH.alwaysfold=0
scope Merchants initializer Init
private function Actions takes nothing returns nothing
local effect e
// Let's add some exclamation marks to all merchants
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_ngsp_0152, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_ngsp_0149, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_e00C_0045, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_e00B_0075, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_n002_0061, "overhead")
set e = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Merchants initializer Init
private function Actions takes nothing returns nothing
local effect e
// Let's add some exclamation marks to all merchants
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_ngsp_0152, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_ngsp_0149, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_e00C_0045, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_e00B_0075, "overhead")
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", gg_unit_n002_0061, "overhead")
set e = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=747
//TESH.alwaysfold=0
library HeroSystem initializer Init requires TimerUtils, BasicFunctions
globals
constant real HERO_DEAD_TIME = 30 // Respawn time for heroes
constant real BASIC_CRIT_CHANCE = 10.0 // 3.0
constant real CRIT_PER_ATTRIBUTE = 0.2
constant real CRIT_FACTOR = 2.0
constant integer HONOR_CAP = 20 // Number of small actions to be done to gain +1 honor
// Heroes Team 1
constant integer WARRIOR_ID = 'O003'
constant integer PRIEST_ID = 'H005'
constant integer MAGE_ID = 'H003'
constant integer DRUID_ID = 'E002'
constant integer DRUIDB_ID = 'E004'
constant integer ROGUE_ID = 'E003'
constant integer HUNTER_ID = 'H004'
constant integer NECRO_ID = 'H00F'
constant integer ENT_ID = 'O002'
constant integer ENTR_ID = 'O00G'
constant integer PALADIN_ID = 'H006'
// Heroes Team 2
constant integer WARRIOR_ID2 = 'O009'
constant integer PRIEST_ID2 = 'O00A'
constant integer MAGE_ID2 = 'H00B'
constant integer DRUID_ID2 = 'E007'
constant integer DRUIDB_ID2 = 'E009'
constant integer ROGUE_ID2 = 'E000'
constant integer HUNTER_ID2 = 'H00C'
constant integer NECRO_ID2 = 'H00G'
constant integer ENT_ID2 = 'O00F'
constant integer SHAMAN_ID = 'O001'
// unit array Heroes[1]
boolean array Players_Selected[1]
timer array Resurrection_Timers[1]
timerdialog array Resurrection_Timer_Windows[1]
string array Kill_Comments[1]
unit array Hero_Selectors[1]
unit array Avatars[1]
group Hero_Group = CreateGroup()
group Dead_Heroes = CreateGroup()
group AI_Heroes = CreateGroup()
group AI_Heroes_Team1 = CreateGroup()
group AI_Heroes_Team2 = CreateGroup()
group Strength_Heroes = CreateGroup()
group Agility_Heroes = CreateGroup()
group Intelligence_Heroes = CreateGroup()
group Melee_Heroes = CreateGroup()
group Ranged_Heroes = CreateGroup()
// pets & summons
unit array Water_Elementals[1]
unit array Pets_Bears[1]
unit array Pets_Wolfs[1]
unit array Pets_Falcons[1]
unit array Pets[1]
unit array UnholySpirits[1]
integer HonorPlayerId
integer Honor1
integer Honor2
integer array HonorStack[1]
endglobals
function IsHero takes unit u returns boolean
return IsUnitInGroup(u, Hero_Group)
endfunction
function IsAIHero takes unit u returns boolean
return IsHero(u) and GetPlayerController(GetOwningPlayer(u)) == MAP_CONTROL_COMPUTER
endfunction
function IsStrHero takes unit u returns boolean
return IsUnitInGroup(u, Strength_Heroes)
endfunction
function IsAgiHero takes unit u returns boolean
return IsUnitInGroup(u, Agility_Heroes)
endfunction
function IsIntHero takes unit u returns boolean
return IsUnitInGroup(u, Intelligence_Heroes)
endfunction
function GetRandomHeroID takes integer team returns integer
local integer i
local integer HeroID
if team == 1 then
set HeroID = WARRIOR_ID
set i = GetRandomInt(10,100)
// call Debug_Message("Random Int: "+I2S(i))
if i >= 10 then
set HeroID = WARRIOR_ID
endif
if i >= 20 then
set HeroID = MAGE_ID
endif
if i >= 30 then
set HeroID = PRIEST_ID
endif
if i >= 40 then
set HeroID = DRUID_ID
endif
if i >= 50 then
set HeroID = ROGUE_ID
endif
if i >= 60 then
set HeroID = HUNTER_ID
endif
if i >= 70 then
set HeroID = NECRO_ID
endif
if i >= 80 then
set HeroID = PALADIN_ID
endif
if i >= 90 then
set HeroID = ENT_ID
endif
elseif team == 2 then
set HeroID = WARRIOR_ID2
set i = GetRandomInt(10,100)
if i >= 10 then
set HeroID = WARRIOR_ID2
endif
if i >= 20 then
set HeroID = MAGE_ID2
endif
if i >= 30 then
set HeroID = PRIEST_ID2
endif
if i >= 40 then
set HeroID = DRUID_ID2
endif
if i >= 50 then
set HeroID = ROGUE_ID2
endif
if i >= 60 then
set HeroID = HUNTER_ID2
endif
if i >= 70 then
set HeroID = NECRO_ID2
endif
if i >= 80 then
set HeroID = SHAMAN_ID
endif
if i >= 90 then
set HeroID = ENT_ID2
endif
endif
return HeroID
endfunction
private function ComputerBuysItems takes unit u returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
local integer honor = GetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER)
// Str Hero
if IsStrHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I01M') then
call UnitAddItemByIdSwapped( 'I01M', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=9 and not UnitHasItemOfTypeBJ(u, 'I00Q') then
call UnitAddItemByIdSwapped( 'I00Q', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-9)
endif
// Agi Hero
elseif IsAgiHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I01M') then
call UnitAddItemByIdSwapped( 'I01M', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I011') then
call UnitAddItemByIdSwapped( 'I011', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Int Hero
elseif IsIntHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I018') then
call UnitAddItemByIdSwapped( 'I018', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I003') then
call UnitAddItemByIdSwapped( 'I003', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
endif
endfunction
function GetRandomStartWP takes unit u returns integer
local integer i = GetRandomInt(11,40)
local integer j = 0
if IsPlayerAlly(GetOwningPlayer(u), Player(1)) then
if i > 10 then
set j = 1
endif
if i > 20 then
set j = 11
endif
if i > 30 then
set j = 21
endif
else
if i > 10 then
set j = 7
endif
if i > 20 then
set j = 17
endif
if i > 30 then
set j = 27
endif
endif
return j
endfunction
function Revive_Hero takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
local unit shrine
local unit u = Heroes[id]
local integer i
// Team stuff
if ( ( IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true ) ) then
set shrine = Shrine1
else
set shrine = Shrine2
endif
call SetUnitUseFood(Safes[id], false)
// Revive Hero at Shrine
call ReviveHero( u, GetUnitX(shrine), GetUnitY(shrine), true )
call PanCameraToTimedLocForPlayer( Player(id), GetUnitLoc(shrine), 0 )
call ClearSelectionForPlayer(Player(id))
call SelectUnitAddForPlayer( u, Player(id))
call GroupRemoveUnit(Dead_Heroes, u )
call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
call TimerDialogDisplay(Resurrection_Timer_Windows[id], false)
// call ReleaseTimer(Resurrection_Timers[id])
// Roots debug
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u) )
// Druid Debug for Bear Form
if Druid_Str_Mod[id] > 0 then
call SetHeroStr(u, GetHeroStr(u, false) - Druid_Str_Mod[id], true)
set Druid_Str_Mod[id] = 0
endif
// Necro
if Avatars[id] != null then
call KillUnit(Avatars[id])
endif
// AI Hero?
if IsAIHero(u) then
call ComputerBuysItems(u)
set i = GetRandomStartWP(u)
// call Debug_Message("Send AI Hero on Way " + GetUnitName(u) + " to point: "+I2S(i))
set waypoint_table[GetUnitId(u)] = i
call Order_Unit_To_Next_WP(u)
endif
set u = null
set shrine = null
endfunction
private function Init_Kill_Comments takes nothing returns nothing
// Init PvP Comments
set Kill_Comments[1] = "Got one!"
set Kill_Comments[2] = "And stay down!"
set Kill_Comments[3] = "Too easy.."
set Kill_Comments[4] = "Starts getting fun!"
set Kill_Comments[5] = "Take it easy!"
set Kill_Comments[6] = "Don't worry be happy!"
set Kill_Comments[7] = "Anyone seen that kill?"
set Kill_Comments[8] = "Bang!"
set Kill_Comments[9] = "Good fight anyway!"
set Kill_Comments[10] = "Nice try!"
set Kill_Comments[11] = "Got ya!"
set Kill_Comments[12] = "Terminated!"
set Kill_Comments[13] = "Fragged!"
set Kill_Comments[14] = "You face the dirt!"
set Kill_Comments[15] = "Got one!"
endfunction
function Add_Honor takes integer id, integer honorPoints returns nothing
local texttag t = CreateTextTag()
local string s = "|cffFFAE5F+" +I2S(honorPoints) + " Honor!|r"
local player PlayerTarget = Player(id)
if id >= 2 and id <= 11 then
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER)+honorPoints)
call SetTextTagColor(t, 178, 233, 142, 255)
call SetTextTagText(t, s, 0.0184)
call SetTextTagPos(t, GetUnitX(Heroes[id]), GetUnitY(Heroes[id]), 0.00)
call SetTextTagVelocity(t, 0, 0.05)
call SetTextTagVisibility(t, false)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
if PlayerTarget == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
endif
set t = null
set PlayerTarget = null
endfunction
private function HonorCallback takes nothing returns nothing
call Add_Honor(GetPlayerId(GetOwningPlayer(GetEnumUnit())), Honor2)
endfunction
private function HonorConditionsTeam1 takes nothing returns boolean
return IsHero(GetFilterUnit()) and IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), Player(1)) and GetPlayerId(GetOwningPlayer(GetFilterUnit())) != HonorPlayerId
endfunction
private function HonorConditionsTeam2 takes nothing returns boolean
return IsHero(GetFilterUnit()) and IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), Player(0)) and GetPlayerId(GetOwningPlayer(GetFilterUnit())) != HonorPlayerId
endfunction
function IncHonorStack takes integer id, integer i returns nothing
set HonorStack[id] = HonorStack[id] + i
if HonorStack[id] >= HONOR_CAP then
set HonorStack[id] = 0
call Add_Honor(id, 1)
endif
endfunction
function AddHonorArea takes real x, real y, integer team, integer id, integer a1, integer a2 returns nothing
local group targets = NewGroup()
set HonorPlayerId = id
set Honor1 = a1
set Honor2 = a2
call Add_Honor(id, Honor1)
// Get targets
if team == 1 then
call GroupEnumUnitsInRange(targets, x, y, HONOR_RANGE, Condition(function HonorConditionsTeam1))
elseif team == 2 then
call GroupEnumUnitsInRange(targets, x, y, HONOR_RANGE, Condition(function HonorConditionsTeam2))
endif
call ForGroup( targets, function HonorCallback )
call ReleaseGroup(targets)
set targets = null
endfunction
private function Conditions_A_Hero_Dies takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function A_Hero_Dies takes nothing returns nothing
local unit u = GetDyingUnit()
local unit k = GetKillingUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
local integer id2 = GetPlayerId(GetOwningPlayer(k))
call DisplayTextToPlayer( Player(id), 0, 0, "|cffFF2323You died!|r Your Hero is revived in |cffFFA358" + I2S(R2I(HERO_DEAD_TIME)) + "|r seconds." )
call GroupAddUnit(Dead_Heroes, u )
if IsPlayerAlly(Player(id), Player(0)) then
call AddHonorArea(GetUnitX(u), GetUnitY(u), 1, id2, 1, 1)
elseif IsPlayerAlly(Player(id), Player(1)) then
call AddHonorArea(GetUnitX(u), GetUnitY(u), 2, id2, 1, 1)
endif
call SetUnitUseFood(Safes[id], true)
call UnitRemoveItem(u, gg_item_I00H_0097)
// Death Timer
call SetTimerData(Resurrection_Timers[id], id)
call TimerStart(Resurrection_Timers[id], HERO_DEAD_TIME, false, function Revive_Hero)
// Window
set Resurrection_Timer_Windows[id] = CreateTimerDialog(Resurrection_Timers[id])
call TimerDialogSetTitle(Resurrection_Timer_Windows[id], PlayerNames[id])
call TimerDialogDisplayForPlayerBJ(true, Resurrection_Timer_Windows[id], Player(id))
// If Mage, kill water elemental too
if Water_Elementals[id] != null then
call KillUnit(Water_Elementals[id])
endif
// If Hunter, kill Pet too
if Pets[id] != null then
call KillUnit(Pets[id])
endif
// If Necro, kill Unholy Summon
if UnholySpirits[id] != null then
call KillUnit(UnholySpirits[id])
endif
// If Dragon companion, kill it too
if Dragons[id] != null then
call KillUnit(Dragons[id])
endif
set u = null
set k = null
endfunction
private function Conditions_Hero_Kills_Hero takes nothing returns boolean
return IsHero(GetDyingUnit()) == true and IsPlayerInForce(GetOwningPlayer(GetKillingUnit()), Players) == true and IsPlayerEnemy(GetOwningPlayer(GetKillingUnit()), GetOwningPlayer(GetDyingUnit())) == true and not IsUnitType(GetKillingUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function Hero_Kills_Hero takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
local integer i = GetRandomInt(1, 15)
// +1 Honor Point
//call Add_Honor(id, 1)
//if IsPlayerAlly(Player(id), Player(1)) then
// call AddHonorArea(GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()), 1, id, 1, 1)
//elseif IsPlayerAlly(Player(id), Player(0)) then
// call AddHonorArea(GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()), 2, id, 1, 1)
//endif
// Random PvP comment
call CreateTagOnUnit(Heroes[id], Kill_Comments[i])
endfunction
function Repick takes integer id returns nothing
local force team
local unit tavern
local integer i
// Hero has to be alive and not inactive due to special spells
if GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and Inactive_Heroes[id] == null then
if ( IsPlayerAlly(Player(id), Player(1)) == true ) then
set tavern = Tavern_Team1
set team = Players_Team1
else
set tavern = Tavern_Team2
set team = Players_Team2
endif
// Message
call DisplayTimedTextToForce(team, 10, PlayerNames[id] + " is picking a new hero!")
// drop items
set i = 0
loop
exitwhen i > 5
// if GetItemTypeId(UnitItemInSlot(Heroes[id], i)) == 'stel' then
// call RemoveItem(UnitItemInSlot(Heroes[id], i))
// else
call UnitRemoveItem(Heroes[id], UnitItemInSlot(Heroes[id], i))
// endif
set i = i + 1
endloop
call GroupRemoveUnit(Hero_Group, Heroes[id])
call GroupRemoveUnit(Strength_Heroes, Heroes[id])
call GroupRemoveUnit(Agility_Heroes, Heroes[id])
call GroupRemoveUnit(Intelligence_Heroes, Heroes[id])
call GroupRemoveUnit(Melee_Heroes, Heroes[id])
call GroupRemoveUnit(Ranged_Heroes, Heroes[id])
call RemoveUnit(Heroes[id])
set Heroes[id] = null
if Water_Elementals[id] != null then
call RemoveUnit(Water_Elementals[id])
set Water_Elementals[id] = null
endif
if Pets[id] != null then
call RemoveUnit(Pets[id])
set Pets[id] = null
endif
if Pets_Bears[id] != null then
call RemoveUnit(Pets_Bears[id])
set Pets_Bears[id] = null
endif
if Pets_Wolfs[id] != null then
call RemoveUnit(Pets_Wolfs[id])
set Pets_Wolfs[id] = null
endif
if Pets_Falcons[id] != null then
call RemoveUnit(Pets_Falcons[id])
set Pets_Falcons[id] = null
endif
if UnholySpirits[id] != null then
call RemoveUnit(UnholySpirits[id])
set UnholySpirits[id] = null
endif
if Dragons[id] != null then
call RemoveUnit(Dragons[id])
set Dragons[id] = null
endif
// Mark player as selected
set Players_Selected[id] = false
// Create hero selector
set Hero_Selectors[id] = CreateUnit(Player(id), 'e006' , GetUnitX(tavern), GetUnitY(tavern), bj_UNIT_FACING)
call ClearSelectionForPlayer(Player(id))
call StartSoundForPlayerBJ(Player(id),Sound_2)
call SelectUnitForPlayerSingle(tavern, Player(id))
call PanCameraToForPlayer(Player(id), GetUnitX(tavern), GetUnitY(tavern))
call SetCameraPositionForPlayer(Player(id), GetUnitX(tavern), GetUnitY(tavern))
if not DEBUG_MODE then
if GetLocalPlayer() == Player(id) then
call SetCameraTargetController(tavern, 0, 0, false)
endif
endif
else
call DisplayTimedTextToPlayer(Player(id), 0, 0, 10, "Your hero has to be |cffFFA358alive|r to use this function!")
endif
set tavern = null
set team = null
endfunction
private function Spawn_AI_Heroes_Callback takes nothing returns nothing
local unit u = null
local integer i
local integer HeroID
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set HeroID = GetRandomHeroID(1)
else
set HeroID = GetRandomHeroID(2)
endif
endif
set u = CreateUnit(GetEnumPlayer(), HeroID, GetUnitX(Shrine1), GetUnitY(Shrine1), bj_UNIT_FACING)
set u = null
endfunction
function Spawn_AI_Heroes takes nothing returns nothing
call ForForce( Players, function Spawn_AI_Heroes_Callback )
endfunction
private function Conditions_Hero_Init takes nothing returns boolean
// Player has to be unselected, Unit has to be hero, unit has to be lagal
return Players_Selected[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] == false and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true and Legal_Hero_Check(GetTriggerUnit()) == true
endfunction
private function Hero_Init takes nothing returns nothing
local unit Hero = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local unit shrine
local force = team
// Mark player as selected
set Players_Selected[id] = true
set Heroes[id] = Hero
call GroupAddUnit( Hero_Group, Hero )
// If AI Hero, then..
if IsAIHero(Hero) then
call GroupAddUnit( AI_Heroes, Hero )
endif
// Class specific stuff
// --------------------
// Warrior
if ( GetUnitTypeId(Hero) == WARRIOR_ID or GetUnitTypeId(Hero) == WARRIOR_ID2 ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
// Give Shield
if GetUnitTypeId(Hero) == WARRIOR_ID2 then
call AddSpecialEffectTarget("RoundShieldL.mdl", Hero, "left")
endif
endif
// Priest
if ( GetUnitTypeId(Hero) == PRIEST_ID or GetUnitTypeId(Hero) == PRIEST_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Mage
if ( GetUnitTypeId(Hero) == MAGE_ID or GetUnitTypeId(Hero) == MAGE_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Druid
if ( GetUnitTypeId(Hero) == DRUID_ID or GetUnitTypeId(Hero) == DRUID_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Paladin
if ( GetUnitTypeId(Hero) == PALADIN_ID ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Rogue
if ( GetUnitTypeId(Hero) == ROGUE_ID or GetUnitTypeId(Hero) == ROGUE_ID2 ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Hunter
if ( GetUnitTypeId(Hero) == HUNTER_ID or GetUnitTypeId(Hero) == HUNTER_ID2 ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Necromancer
if ( GetUnitTypeId(Hero) == NECRO_ID or GetUnitTypeId(Hero) == NECRO_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Shaman
if ( GetUnitTypeId(Hero) == SHAMAN_ID ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Ancient Protector
if ( GetUnitTypeId(Hero) == ENT_ID or GetUnitTypeId(Hero) == ENT_ID2 ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Remove Hero Selector
call RemoveUnit( Hero_Selectors[id] )
// Move Hero to Shrine
if ( IsPlayerAlly(GetOwningPlayer(Hero), Player(1)) == true ) then
set shrine = Shrine1
set team = Players_Team1
else
set shrine = Shrine2
set team = Players_Team2
endif
call ResetToGameCameraForPlayer(Player(id), 0)
call StartSoundForPlayerBJ(Player(id), Sound_General)
// call DisplayTimedTextToPlayer(Player(id),0,0,10, "Hero selected: "+GetUnitName(Hero))
call DisplayTimedTextToForce(team, 10, PlayerNames[id] + " has chosen the "+GetUnitName(Hero) )
call ClearSelectionForPlayer(Player(id))
call SelectUnitForPlayerSingle(Hero, Player(id))
call SetUnitPositionLoc( Hero, GetUnitLoc(shrine) )
call PanCameraToTimedForPlayer(Player(id), GetUnitX(shrine), GetUnitY(shrine), 0)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Awaken\\Awaken.mdl", Hero, "origin"))
if DEBUG_MODE then
call UnitAddItemByIdSwapped( 'stel', Hero )
endif
// If AI Hero, then go to next waypoint
if IsAIHero(Hero) then
set waypoint_table[GetUnitId(Hero)] = GetRandomStartWP(Hero)
call Order_Unit_To_Next_WP( Hero )
endif
// Ent animation debug
if ( GetUnitTypeId(Hero) == ENT_ID or GetUnitTypeId(Hero) == ENT_ID2 ) then
call SetUnitAnimationByIndex(Hero, 0)
endif
set Hero = null
set shrine = null
set team = null
endfunction
private function Conditions_Pick_Flag takes nothing returns boolean
return IsAIHero(GetTriggerUnit())
endfunction
private function Pick_Flag takes nothing returns nothing
call IssueTargetOrder( GetTriggerUnit(), "smart", gg_item_I00H_0097 )
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local integer i
local trigger trg = CreateTrigger( )
call Init_Kill_Comments()
// Init Heroes
call TriggerRegisterEnterRectSimple( trg, GetPlayableMapRect() )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Init ) )
call TriggerAddAction( trg, function Hero_Init )
// A Hero dies
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_A_Hero_Dies ) )
call TriggerAddAction( trg, function A_Hero_Dies )
// Hero kills Hero (PvP)
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg , EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg , Condition( function Conditions_Hero_Kills_Hero ) )
call TriggerAddAction( trg , function Hero_Kills_Hero )
// Pick up Flag
set trg = CreateTrigger( )
call TriggerRegisterEnterRectSimple( trg, Rect( GetItemX(gg_item_I00H_0097) - 512, GetItemY(gg_item_I00H_0097) - 512, GetItemX(gg_item_I00H_0097) + 512, GetItemY(gg_item_I00H_0097) + 512 ) )
call TriggerAddCondition( trg , Condition( function Conditions_Pick_Flag ) )
call TriggerAddAction( trg , function Pick_Flag )
// Init Resurrection Timers & Selection stuff
set i = 0
loop
exitwhen i > MAX_PLAYERS
set Resurrection_Timers[i] = NewTimer()
set Players_Selected[i] = false
set Resurrection_Timer_Windows[i] = CreateTimerDialog(Resurrection_Timers[i])
call TimerDialogSetTitle(Resurrection_Timer_Windows[i], PlayerNames[i])
call TimerDialogDisplay(Resurrection_Timer_Windows[i], false)
set i = i + 1
endloop
set trg = null
endfunction
endlibrary
//TESH.alwaysfold=0
library HeroSystem initializer Init requires TimerUtils, BasicFunctions
globals
constant real HERO_DEAD_TIME = 30 // Respawn time for heroes
constant real BASIC_CRIT_CHANCE = 10.0 // 3.0
constant real CRIT_PER_ATTRIBUTE = 0.2
constant real CRIT_FACTOR = 2.0
constant integer HONOR_CAP = 20 // Number of small actions to be done to gain +1 honor
// Heroes Team 1
constant integer WARRIOR_ID = 'O003'
constant integer PRIEST_ID = 'H005'
constant integer MAGE_ID = 'H003'
constant integer DRUID_ID = 'E002'
constant integer DRUIDB_ID = 'E004'
constant integer ROGUE_ID = 'E003'
constant integer HUNTER_ID = 'H004'
constant integer NECRO_ID = 'H00F'
constant integer ENT_ID = 'O002'
constant integer ENTR_ID = 'O00G'
constant integer PALADIN_ID = 'H006'
// Heroes Team 2
constant integer WARRIOR_ID2 = 'O009'
constant integer PRIEST_ID2 = 'O00A'
constant integer MAGE_ID2 = 'H00B'
constant integer DRUID_ID2 = 'E007'
constant integer DRUIDB_ID2 = 'E009'
constant integer ROGUE_ID2 = 'E000'
constant integer HUNTER_ID2 = 'H00C'
constant integer NECRO_ID2 = 'H00G'
constant integer ENT_ID2 = 'O00F'
constant integer SHAMAN_ID = 'O001'
// unit array Heroes[1]
boolean array Players_Selected[1]
timer array Resurrection_Timers[1]
timerdialog array Resurrection_Timer_Windows[1]
string array Kill_Comments[1]
unit array Hero_Selectors[1]
unit array Avatars[1]
group Hero_Group = CreateGroup()
group Dead_Heroes = CreateGroup()
group AI_Heroes = CreateGroup()
group AI_Heroes_Team1 = CreateGroup()
group AI_Heroes_Team2 = CreateGroup()
group Strength_Heroes = CreateGroup()
group Agility_Heroes = CreateGroup()
group Intelligence_Heroes = CreateGroup()
group Melee_Heroes = CreateGroup()
group Ranged_Heroes = CreateGroup()
// pets & summons
unit array Water_Elementals[1]
unit array Pets_Bears[1]
unit array Pets_Wolfs[1]
unit array Pets_Falcons[1]
unit array Pets[1]
unit array UnholySpirits[1]
integer HonorPlayerId
integer Honor1
integer Honor2
integer array HonorStack[1]
endglobals
function IsHero takes unit u returns boolean
return IsUnitInGroup(u, Hero_Group)
endfunction
function IsAIHero takes unit u returns boolean
return IsHero(u) and GetPlayerController(GetOwningPlayer(u)) == MAP_CONTROL_COMPUTER
endfunction
function IsStrHero takes unit u returns boolean
return IsUnitInGroup(u, Strength_Heroes)
endfunction
function IsAgiHero takes unit u returns boolean
return IsUnitInGroup(u, Agility_Heroes)
endfunction
function IsIntHero takes unit u returns boolean
return IsUnitInGroup(u, Intelligence_Heroes)
endfunction
function GetRandomHeroID takes integer team returns integer
local integer i
local integer HeroID
if team == 1 then
set HeroID = WARRIOR_ID
set i = GetRandomInt(10,100)
// call Debug_Message("Random Int: "+I2S(i))
if i >= 10 then
set HeroID = WARRIOR_ID
endif
if i >= 20 then
set HeroID = MAGE_ID
endif
if i >= 30 then
set HeroID = PRIEST_ID
endif
if i >= 40 then
set HeroID = DRUID_ID
endif
if i >= 50 then
set HeroID = ROGUE_ID
endif
if i >= 60 then
set HeroID = HUNTER_ID
endif
if i >= 70 then
set HeroID = NECRO_ID
endif
if i >= 80 then
set HeroID = PALADIN_ID
endif
if i >= 90 then
set HeroID = ENT_ID
endif
elseif team == 2 then
set HeroID = WARRIOR_ID2
set i = GetRandomInt(10,100)
if i >= 10 then
set HeroID = WARRIOR_ID2
endif
if i >= 20 then
set HeroID = MAGE_ID2
endif
if i >= 30 then
set HeroID = PRIEST_ID2
endif
if i >= 40 then
set HeroID = DRUID_ID2
endif
if i >= 50 then
set HeroID = ROGUE_ID2
endif
if i >= 60 then
set HeroID = HUNTER_ID2
endif
if i >= 70 then
set HeroID = NECRO_ID2
endif
if i >= 80 then
set HeroID = SHAMAN_ID
endif
if i >= 90 then
set HeroID = ENT_ID2
endif
endif
return HeroID
endfunction
private function ComputerBuysItems takes unit u returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
local integer honor = GetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER)
// Str Hero
if IsStrHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I01M') then
call UnitAddItemByIdSwapped( 'I01M', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=9 and not UnitHasItemOfTypeBJ(u, 'I00Q') then
call UnitAddItemByIdSwapped( 'I00Q', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-9)
endif
// Agi Hero
elseif IsAgiHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I01M') then
call UnitAddItemByIdSwapped( 'I01M', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I011') then
call UnitAddItemByIdSwapped( 'I011', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Int Hero
elseif IsIntHero(u) then
// Buy Weapon
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I018') then
call UnitAddItemByIdSwapped( 'I018', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
// Buy Armor
if honor >=7 and not UnitHasItemOfTypeBJ(u, 'I003') then
call UnitAddItemByIdSwapped( 'I003', u )
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, honor-7)
endif
endif
endfunction
function GetRandomStartWP takes unit u returns integer
local integer i = GetRandomInt(11,40)
local integer j = 0
if IsPlayerAlly(GetOwningPlayer(u), Player(1)) then
if i > 10 then
set j = 1
endif
if i > 20 then
set j = 11
endif
if i > 30 then
set j = 21
endif
else
if i > 10 then
set j = 7
endif
if i > 20 then
set j = 17
endif
if i > 30 then
set j = 27
endif
endif
return j
endfunction
function Revive_Hero takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
local unit shrine
local unit u = Heroes[id]
local integer i
// Team stuff
if ( ( IsPlayerAlly(GetOwningPlayer(u), Player(1)) == true ) ) then
set shrine = Shrine1
else
set shrine = Shrine2
endif
call SetUnitUseFood(Safes[id], false)
// Revive Hero at Shrine
call ReviveHero( u, GetUnitX(shrine), GetUnitY(shrine), true )
call PanCameraToTimedLocForPlayer( Player(id), GetUnitLoc(shrine), 0 )
call ClearSelectionForPlayer(Player(id))
call SelectUnitAddForPlayer( u, Player(id))
call GroupRemoveUnit(Dead_Heroes, u )
call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
call TimerDialogDisplay(Resurrection_Timer_Windows[id], false)
// call ReleaseTimer(Resurrection_Timers[id])
// Roots debug
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u) )
// Druid Debug for Bear Form
if Druid_Str_Mod[id] > 0 then
call SetHeroStr(u, GetHeroStr(u, false) - Druid_Str_Mod[id], true)
set Druid_Str_Mod[id] = 0
endif
// Necro
if Avatars[id] != null then
call KillUnit(Avatars[id])
endif
// AI Hero?
if IsAIHero(u) then
call ComputerBuysItems(u)
set i = GetRandomStartWP(u)
// call Debug_Message("Send AI Hero on Way " + GetUnitName(u) + " to point: "+I2S(i))
set waypoint_table[GetUnitId(u)] = i
call Order_Unit_To_Next_WP(u)
endif
set u = null
set shrine = null
endfunction
private function Init_Kill_Comments takes nothing returns nothing
// Init PvP Comments
set Kill_Comments[1] = "Got one!"
set Kill_Comments[2] = "And stay down!"
set Kill_Comments[3] = "Too easy.."
set Kill_Comments[4] = "Starts getting fun!"
set Kill_Comments[5] = "Take it easy!"
set Kill_Comments[6] = "Don't worry be happy!"
set Kill_Comments[7] = "Anyone seen that kill?"
set Kill_Comments[8] = "Bang!"
set Kill_Comments[9] = "Good fight anyway!"
set Kill_Comments[10] = "Nice try!"
set Kill_Comments[11] = "Got ya!"
set Kill_Comments[12] = "Terminated!"
set Kill_Comments[13] = "Fragged!"
set Kill_Comments[14] = "You face the dirt!"
set Kill_Comments[15] = "Got one!"
endfunction
function Add_Honor takes integer id, integer honorPoints returns nothing
local texttag t = CreateTextTag()
local string s = "|cffFFAE5F+" +I2S(honorPoints) + " Honor!|r"
local player PlayerTarget = Player(id)
if id >= 2 and id <= 11 then
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(Player(id), PLAYER_STATE_RESOURCE_LUMBER)+honorPoints)
call SetTextTagColor(t, 178, 233, 142, 255)
call SetTextTagText(t, s, 0.0184)
call SetTextTagPos(t, GetUnitX(Heroes[id]), GetUnitY(Heroes[id]), 0.00)
call SetTextTagVelocity(t, 0, 0.05)
call SetTextTagVisibility(t, false)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
if PlayerTarget == GetLocalPlayer() then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetTextTagVisibility(t, true)
endif
endif
set t = null
set PlayerTarget = null
endfunction
private function HonorCallback takes nothing returns nothing
call Add_Honor(GetPlayerId(GetOwningPlayer(GetEnumUnit())), Honor2)
endfunction
private function HonorConditionsTeam1 takes nothing returns boolean
return IsHero(GetFilterUnit()) and IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), Player(1)) and GetPlayerId(GetOwningPlayer(GetFilterUnit())) != HonorPlayerId
endfunction
private function HonorConditionsTeam2 takes nothing returns boolean
return IsHero(GetFilterUnit()) and IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), Player(0)) and GetPlayerId(GetOwningPlayer(GetFilterUnit())) != HonorPlayerId
endfunction
function IncHonorStack takes integer id, integer i returns nothing
set HonorStack[id] = HonorStack[id] + i
if HonorStack[id] >= HONOR_CAP then
set HonorStack[id] = 0
call Add_Honor(id, 1)
endif
endfunction
function AddHonorArea takes real x, real y, integer team, integer id, integer a1, integer a2 returns nothing
local group targets = NewGroup()
set HonorPlayerId = id
set Honor1 = a1
set Honor2 = a2
call Add_Honor(id, Honor1)
// Get targets
if team == 1 then
call GroupEnumUnitsInRange(targets, x, y, HONOR_RANGE, Condition(function HonorConditionsTeam1))
elseif team == 2 then
call GroupEnumUnitsInRange(targets, x, y, HONOR_RANGE, Condition(function HonorConditionsTeam2))
endif
call ForGroup( targets, function HonorCallback )
call ReleaseGroup(targets)
set targets = null
endfunction
private function Conditions_A_Hero_Dies takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function A_Hero_Dies takes nothing returns nothing
local unit u = GetDyingUnit()
local unit k = GetKillingUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
local integer id2 = GetPlayerId(GetOwningPlayer(k))
call DisplayTextToPlayer( Player(id), 0, 0, "|cffFF2323You died!|r Your Hero is revived in |cffFFA358" + I2S(R2I(HERO_DEAD_TIME)) + "|r seconds." )
call GroupAddUnit(Dead_Heroes, u )
if IsPlayerAlly(Player(id), Player(0)) then
call AddHonorArea(GetUnitX(u), GetUnitY(u), 1, id2, 1, 1)
elseif IsPlayerAlly(Player(id), Player(1)) then
call AddHonorArea(GetUnitX(u), GetUnitY(u), 2, id2, 1, 1)
endif
call SetUnitUseFood(Safes[id], true)
call UnitRemoveItem(u, gg_item_I00H_0097)
// Death Timer
call SetTimerData(Resurrection_Timers[id], id)
call TimerStart(Resurrection_Timers[id], HERO_DEAD_TIME, false, function Revive_Hero)
// Window
set Resurrection_Timer_Windows[id] = CreateTimerDialog(Resurrection_Timers[id])
call TimerDialogSetTitle(Resurrection_Timer_Windows[id], PlayerNames[id])
call TimerDialogDisplayForPlayerBJ(true, Resurrection_Timer_Windows[id], Player(id))
// If Mage, kill water elemental too
if Water_Elementals[id] != null then
call KillUnit(Water_Elementals[id])
endif
// If Hunter, kill Pet too
if Pets[id] != null then
call KillUnit(Pets[id])
endif
// If Necro, kill Unholy Summon
if UnholySpirits[id] != null then
call KillUnit(UnholySpirits[id])
endif
// If Dragon companion, kill it too
if Dragons[id] != null then
call KillUnit(Dragons[id])
endif
set u = null
set k = null
endfunction
private function Conditions_Hero_Kills_Hero takes nothing returns boolean
return IsHero(GetDyingUnit()) == true and IsPlayerInForce(GetOwningPlayer(GetKillingUnit()), Players) == true and IsPlayerEnemy(GetOwningPlayer(GetKillingUnit()), GetOwningPlayer(GetDyingUnit())) == true and not IsUnitType(GetKillingUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function Hero_Kills_Hero takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
local integer i = GetRandomInt(1, 15)
// +1 Honor Point
//call Add_Honor(id, 1)
//if IsPlayerAlly(Player(id), Player(1)) then
// call AddHonorArea(GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()), 1, id, 1, 1)
//elseif IsPlayerAlly(Player(id), Player(0)) then
// call AddHonorArea(GetUnitX(GetDyingUnit()), GetUnitY(GetDyingUnit()), 2, id, 1, 1)
//endif
// Random PvP comment
call CreateTagOnUnit(Heroes[id], Kill_Comments[i])
endfunction
function Repick takes integer id returns nothing
local force team
local unit tavern
local integer i
// Hero has to be alive and not inactive due to special spells
if GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and Inactive_Heroes[id] == null then
if ( IsPlayerAlly(Player(id), Player(1)) == true ) then
set tavern = Tavern_Team1
set team = Players_Team1
else
set tavern = Tavern_Team2
set team = Players_Team2
endif
// Message
call DisplayTimedTextToForce(team, 10, PlayerNames[id] + " is picking a new hero!")
// drop items
set i = 0
loop
exitwhen i > 5
// if GetItemTypeId(UnitItemInSlot(Heroes[id], i)) == 'stel' then
// call RemoveItem(UnitItemInSlot(Heroes[id], i))
// else
call UnitRemoveItem(Heroes[id], UnitItemInSlot(Heroes[id], i))
// endif
set i = i + 1
endloop
call GroupRemoveUnit(Hero_Group, Heroes[id])
call GroupRemoveUnit(Strength_Heroes, Heroes[id])
call GroupRemoveUnit(Agility_Heroes, Heroes[id])
call GroupRemoveUnit(Intelligence_Heroes, Heroes[id])
call GroupRemoveUnit(Melee_Heroes, Heroes[id])
call GroupRemoveUnit(Ranged_Heroes, Heroes[id])
call RemoveUnit(Heroes[id])
set Heroes[id] = null
if Water_Elementals[id] != null then
call RemoveUnit(Water_Elementals[id])
set Water_Elementals[id] = null
endif
if Pets[id] != null then
call RemoveUnit(Pets[id])
set Pets[id] = null
endif
if Pets_Bears[id] != null then
call RemoveUnit(Pets_Bears[id])
set Pets_Bears[id] = null
endif
if Pets_Wolfs[id] != null then
call RemoveUnit(Pets_Wolfs[id])
set Pets_Wolfs[id] = null
endif
if Pets_Falcons[id] != null then
call RemoveUnit(Pets_Falcons[id])
set Pets_Falcons[id] = null
endif
if UnholySpirits[id] != null then
call RemoveUnit(UnholySpirits[id])
set UnholySpirits[id] = null
endif
if Dragons[id] != null then
call RemoveUnit(Dragons[id])
set Dragons[id] = null
endif
// Mark player as selected
set Players_Selected[id] = false
// Create hero selector
set Hero_Selectors[id] = CreateUnit(Player(id), 'e006' , GetUnitX(tavern), GetUnitY(tavern), bj_UNIT_FACING)
call ClearSelectionForPlayer(Player(id))
call StartSoundForPlayerBJ(Player(id),Sound_2)
call SelectUnitForPlayerSingle(tavern, Player(id))
call PanCameraToForPlayer(Player(id), GetUnitX(tavern), GetUnitY(tavern))
call SetCameraPositionForPlayer(Player(id), GetUnitX(tavern), GetUnitY(tavern))
if not DEBUG_MODE then
if GetLocalPlayer() == Player(id) then
call SetCameraTargetController(tavern, 0, 0, false)
endif
endif
else
call DisplayTimedTextToPlayer(Player(id), 0, 0, 10, "Your hero has to be |cffFFA358alive|r to use this function!")
endif
set tavern = null
set team = null
endfunction
private function Spawn_AI_Heroes_Callback takes nothing returns nothing
local unit u = null
local integer i
local integer HeroID
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
if IsPlayerAlly(GetEnumPlayer(), Player(1)) then
set HeroID = GetRandomHeroID(1)
else
set HeroID = GetRandomHeroID(2)
endif
endif
set u = CreateUnit(GetEnumPlayer(), HeroID, GetUnitX(Shrine1), GetUnitY(Shrine1), bj_UNIT_FACING)
set u = null
endfunction
function Spawn_AI_Heroes takes nothing returns nothing
call ForForce( Players, function Spawn_AI_Heroes_Callback )
endfunction
private function Conditions_Hero_Init takes nothing returns boolean
// Player has to be unselected, Unit has to be hero, unit has to be lagal
return Players_Selected[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] == false and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true and Legal_Hero_Check(GetTriggerUnit()) == true
endfunction
private function Hero_Init takes nothing returns nothing
local unit Hero = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local unit shrine
local force = team
// Mark player as selected
set Players_Selected[id] = true
set Heroes[id] = Hero
call GroupAddUnit( Hero_Group, Hero )
// If AI Hero, then..
if IsAIHero(Hero) then
call GroupAddUnit( AI_Heroes, Hero )
endif
// Class specific stuff
// --------------------
// Warrior
if ( GetUnitTypeId(Hero) == WARRIOR_ID or GetUnitTypeId(Hero) == WARRIOR_ID2 ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
// Give Shield
if GetUnitTypeId(Hero) == WARRIOR_ID2 then
call AddSpecialEffectTarget("RoundShieldL.mdl", Hero, "left")
endif
endif
// Priest
if ( GetUnitTypeId(Hero) == PRIEST_ID or GetUnitTypeId(Hero) == PRIEST_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Mage
if ( GetUnitTypeId(Hero) == MAGE_ID or GetUnitTypeId(Hero) == MAGE_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Druid
if ( GetUnitTypeId(Hero) == DRUID_ID or GetUnitTypeId(Hero) == DRUID_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Paladin
if ( GetUnitTypeId(Hero) == PALADIN_ID ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Rogue
if ( GetUnitTypeId(Hero) == ROGUE_ID or GetUnitTypeId(Hero) == ROGUE_ID2 ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Hunter
if ( GetUnitTypeId(Hero) == HUNTER_ID or GetUnitTypeId(Hero) == HUNTER_ID2 ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Necromancer
if ( GetUnitTypeId(Hero) == NECRO_ID or GetUnitTypeId(Hero) == NECRO_ID2 ) then
call GroupAddUnit( Intelligence_Heroes, Hero )
call GroupAddUnit( Ranged_Heroes, Hero )
endif
// Shaman
if ( GetUnitTypeId(Hero) == SHAMAN_ID ) then
call GroupAddUnit( Agility_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Ancient Protector
if ( GetUnitTypeId(Hero) == ENT_ID or GetUnitTypeId(Hero) == ENT_ID2 ) then
call GroupAddUnit( Strength_Heroes, Hero )
call GroupAddUnit( Melee_Heroes, Hero )
endif
// Remove Hero Selector
call RemoveUnit( Hero_Selectors[id] )
// Move Hero to Shrine
if ( IsPlayerAlly(GetOwningPlayer(Hero), Player(1)) == true ) then
set shrine = Shrine1
set team = Players_Team1
else
set shrine = Shrine2
set team = Players_Team2
endif
call ResetToGameCameraForPlayer(Player(id), 0)
call StartSoundForPlayerBJ(Player(id), Sound_General)
// call DisplayTimedTextToPlayer(Player(id),0,0,10, "Hero selected: "+GetUnitName(Hero))
call DisplayTimedTextToForce(team, 10, PlayerNames[id] + " has chosen the "+GetUnitName(Hero) )
call ClearSelectionForPlayer(Player(id))
call SelectUnitForPlayerSingle(Hero, Player(id))
call SetUnitPositionLoc( Hero, GetUnitLoc(shrine) )
call PanCameraToTimedForPlayer(Player(id), GetUnitX(shrine), GetUnitY(shrine), 0)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Awaken\\Awaken.mdl", Hero, "origin"))
if DEBUG_MODE then
call UnitAddItemByIdSwapped( 'stel', Hero )
endif
// If AI Hero, then go to next waypoint
if IsAIHero(Hero) then
set waypoint_table[GetUnitId(Hero)] = GetRandomStartWP(Hero)
call Order_Unit_To_Next_WP( Hero )
endif
// Ent animation debug
if ( GetUnitTypeId(Hero) == ENT_ID or GetUnitTypeId(Hero) == ENT_ID2 ) then
call SetUnitAnimationByIndex(Hero, 0)
endif
set Hero = null
set shrine = null
set team = null
endfunction
private function Conditions_Pick_Flag takes nothing returns boolean
return IsAIHero(GetTriggerUnit())
endfunction
private function Pick_Flag takes nothing returns nothing
call IssueTargetOrder( GetTriggerUnit(), "smart", gg_item_I00H_0097 )
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local integer i
local trigger trg = CreateTrigger( )
call Init_Kill_Comments()
// Init Heroes
call TriggerRegisterEnterRectSimple( trg, GetPlayableMapRect() )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Init ) )
call TriggerAddAction( trg, function Hero_Init )
// A Hero dies
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_A_Hero_Dies ) )
call TriggerAddAction( trg, function A_Hero_Dies )
// Hero kills Hero (PvP)
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg , EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg , Condition( function Conditions_Hero_Kills_Hero ) )
call TriggerAddAction( trg , function Hero_Kills_Hero )
// Pick up Flag
set trg = CreateTrigger( )
call TriggerRegisterEnterRectSimple( trg, Rect( GetItemX(gg_item_I00H_0097) - 512, GetItemY(gg_item_I00H_0097) - 512, GetItemX(gg_item_I00H_0097) + 512, GetItemY(gg_item_I00H_0097) + 512 ) )
call TriggerAddCondition( trg , Condition( function Conditions_Pick_Flag ) )
call TriggerAddAction( trg , function Pick_Flag )
// Init Resurrection Timers & Selection stuff
set i = 0
loop
exitwhen i > MAX_PLAYERS
set Resurrection_Timers[i] = NewTimer()
set Players_Selected[i] = false
set Resurrection_Timer_Windows[i] = CreateTimerDialog(Resurrection_Timers[i])
call TimerDialogSetTitle(Resurrection_Timer_Windows[i], PlayerNames[i])
call TimerDialogDisplay(Resurrection_Timer_Windows[i], false)
set i = i + 1
endloop
set trg = null
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope Events initializer Init
private function CommanderDeath takes nothing returns nothing
call Game_Message("The Alliance |cff046CB7High Commander|r has been slain!")
endfunction
private function WarchiefDeath takes nothing returns nothing
call Game_Message("The |cffFB2525Great Warchief|r has been slain!")
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterUnitEvent( trg, gg_unit_H00H_0062, EVENT_UNIT_DEATH )
call TriggerAddAction( trg, function CommanderDeath )
set trg = CreateTrigger( )
call TriggerRegisterUnitEvent( trg, gg_unit_O00D_0063, EVENT_UNIT_DEATH )
call TriggerAddAction( trg, function WarchiefDeath )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Events initializer Init
private function CommanderDeath takes nothing returns nothing
call Game_Message("The Alliance |cff046CB7High Commander|r has been slain!")
endfunction
private function WarchiefDeath takes nothing returns nothing
call Game_Message("The |cffFB2525Great Warchief|r has been slain!")
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterUnitEvent( trg, gg_unit_H00H_0062, EVENT_UNIT_DEATH )
call TriggerAddAction( trg, function CommanderDeath )
set trg = CreateTrigger( )
call TriggerRegisterUnitEvent( trg, gg_unit_O00D_0063, EVENT_UNIT_DEATH )
call TriggerAddAction( trg, function WarchiefDeath )
set trg = null
endfunction
endscope
//TESH.scrollpos=208
//TESH.alwaysfold=0
scope ScoreBoard initializer Init
globals
constant string SCORE_TITLE = TITLE + " " + VERSION // + " " + AUTHOR
private multiboard Score_Table // Don't use "= CreateMultiboard()"! else the game will crash
private integer array ScoreBoard_Positions[1]
// integer array Score_Kills[1]
// integer array Score_Hero_Kills[1]
// integer array Score_Deaths[1]
timer GameTime = CreateTimer()
integer GameTime_Minutes
integer GameTime_Seconds
private integer ClockRow
private integer TempInt
endglobals
private function Update_Callback takes nothing returns nothing
local multiboarditem field
local integer id = GetPlayerId(GetEnumPlayer())
// Name
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 0)
call MultiboardSetItemValue( field, " " + PlayerNames[id] )
// Level
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 1)
call MultiboardSetItemValue( field, " " + I2S(GetHeroLevel(Heroes[id])) )
set Score_Levels[id] = GetHeroLevel(Heroes[id])
// PvP
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 2)
call MultiboardSetItemValue( field, " " + I2S(Score_PvP[id]) )
// Kills
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 3)
call MultiboardSetItemValue( field, " " + I2S(Score_Kills[id]) )
// Deaths
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 4)
call MultiboardSetItemValue( field, I2S(Score_Deaths[id]) )
set field = null
endfunction
private function Update takes nothing returns nothing
call ForForce( Players, function Update_Callback )
endfunction
private function Conditions_Level_Up takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function Conditions_Hero_Kills takes nothing returns boolean
return IsPlayerInForce(GetOwningPlayer(GetKillingUnit()), Players) == true
endfunction
private function A_Hero_Kills takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
set Score_Kills[id] = Score_Kills[id] + 1
if IsHero(GetDyingUnit()) then
set Score_PvP[id] = Score_PvP[id] + 1
endif
call IncHonorStack(id, 2)
call Update()
endfunction
private function Conditions_Hero_Dies takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function A_Hero_Dies takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set Score_Deaths[id] = Score_Deaths[id] + 1
call Update()
endfunction
private function Set_Clock takes nothing returns nothing
local multiboarditem clockfield = null
set clockfield = MultiboardGetItem(Score_Table, ClockRow, 2)
set GameTime_Minutes = ( R2I(TimerGetElapsed(GameTime)) / 60 )
set GameTime_Seconds = ModuloInteger(R2I(TimerGetElapsed(GameTime)), 60)
if GameTime_Seconds >= 10 then
call MultiboardSetItemValue( clockfield, I2S(GameTime_Minutes) + ":" + I2S(GameTime_Seconds) )
else
call MultiboardSetItemValue( clockfield, I2S(GameTime_Minutes) + ":0" + I2S(GameTime_Seconds) )
endif
set clockfield = null
endfunction
private function Add_Players takes nothing returns nothing
local multiboarditem field = MultiboardGetItem(Score_Table, TempInt, 0)
local integer id = GetPlayerId(GetEnumPlayer())
set ScoreBoard_Positions[id] = TempInt
call MultiboardSetItemValue(field, " " + PlayerNames[id])
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 1)
call MultiboardSetItemValue( field, " 1" )
set TempInt = ( TempInt + 1 )
set field = null
endfunction
private function Init_Score_Board takes nothing returns nothing
local integer i
local integer j
local multiboarditem field = null
call TriggerSleepAction( 1.00 )
call TimerStart( GameTime, 999999.00, false, null )
// Now create the actual Multiboard
set Score_Table = CreateMultiboard()
call MultiboardSetRowCount(Score_Table, 6 + NumberOfPlayers )
call MultiboardSetColumnCount(Score_Table, 5)
call MultiboardSetTitleText(Score_Table, SCORE_TITLE)
call MultiboardDisplay(Score_Table, true)
// Adjust color and display style
set i = 0
loop
exitwhen ( i > MultiboardGetRowCount(Score_Table)-1 )
set j = 0
loop
exitwhen ( j > 4 )
set field = MultiboardGetItem(Score_Table, i, j)
call MultiboardSetItemStyle( field, true, false )
call MultiboardSetItemValueColor( field, 220, 220, 220, 255 )
set j = j + 1
endloop
set i = i + 1
endloop
// Adjust column width
set i = 0
loop
exitwhen ( i > MultiboardGetRowCount(Score_Table)-1 )
set field = MultiboardGetItem(Score_Table, i, 0)
call MultiboardSetItemWidth(field, 0.10)
set field = MultiboardGetItem(Score_Table, i, 1)
call MultiboardSetItemWidth(field, 0.03) // 0.01
set field = MultiboardGetItem(Score_Table, i, 2)
call MultiboardSetItemWidth(field, 0.03)
set field = MultiboardGetItem(Score_Table, i, 3)
call MultiboardSetItemWidth(field, 0.03)
set field = MultiboardGetItem(Score_Table, i, 4)
call MultiboardSetItemWidth(field, 0.01)
set i = i + 1
endloop
// Headline
set field = MultiboardGetItem(Score_Table, 0, 1)
call MultiboardSetItemValue( field, "|cffFFDD8DLv|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 2)
call MultiboardSetItemValue( field, "|cffFF974APvP|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 3)
call MultiboardSetItemValue( field, "|cffD60505Kills|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 4)
call MultiboardSetItemStyle( field, true, true )
call MultiboardSetItemIcon(field, "ReplaceableTextures\\CommandButtons\\BTNPunisher.blp")
// Team 1
set field = MultiboardGetItem(Score_Table, 1, 0)
call MultiboardSetItemValue( field, TEAM1 )
// Team 2
set field = MultiboardGetItem(Score_Table, 3 + NumberOfPlayersTeam1, 0)
call MultiboardSetItemValue( field, TEAM2 )
// Add Players Team 1
set TempInt = 2
call ForForce( Players_Team1, function Add_Players )
// Add Players Team 2
set TempInt = 4 + NumberOfPlayersTeam1
call ForForce( Players_Team2, function Add_Players )
// Game Time
set ClockRow = ( 5 + NumberOfPlayers )
set field = MultiboardGetItem(Score_Table, ClockRow, 0)
call MultiboardSetItemValueColor( field, 100, 100, 100, 255 )
call MultiboardSetItemValue( field, "Game Time:" )
set field = MultiboardGetItem(Score_Table, ClockRow, 2)
call MultiboardSetItemValueColor( field, 180, 180, 180, 255 )
call MultiboardSetItemValue( field, "0:00" )
call MultiboardDisplay( Score_Table, true )
// Update
call Update()
set field = null
endfunction
//===========================================================================
public function Init takes nothing returns nothing
// Init
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, false)
call TriggerAddAction( trg, function Init_Score_Board )
// Update Clock
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 1, true)
call TriggerAddAction(trg, function Set_Clock)
// Hero Dies
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Dies ) )
call TriggerAddAction( trg, function A_Hero_Dies )
// Hero Kills
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Kills ) )
call TriggerAddAction( trg, function A_Hero_Kills )
// Levelup
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_HERO_LEVEL )
call TriggerAddCondition( trg, Condition( function Conditions_Level_Up ) )
call TriggerAddAction( trg, function Update )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope ScoreBoard initializer Init
globals
constant string SCORE_TITLE = TITLE + " " + VERSION // + " " + AUTHOR
private multiboard Score_Table // Don't use "= CreateMultiboard()"! else the game will crash
private integer array ScoreBoard_Positions[1]
// integer array Score_Kills[1]
// integer array Score_Hero_Kills[1]
// integer array Score_Deaths[1]
timer GameTime = CreateTimer()
integer GameTime_Minutes
integer GameTime_Seconds
private integer ClockRow
private integer TempInt
endglobals
private function Update_Callback takes nothing returns nothing
local multiboarditem field
local integer id = GetPlayerId(GetEnumPlayer())
// Name
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 0)
call MultiboardSetItemValue( field, " " + PlayerNames[id] )
// Level
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 1)
call MultiboardSetItemValue( field, " " + I2S(GetHeroLevel(Heroes[id])) )
set Score_Levels[id] = GetHeroLevel(Heroes[id])
// PvP
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 2)
call MultiboardSetItemValue( field, " " + I2S(Score_PvP[id]) )
// Kills
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 3)
call MultiboardSetItemValue( field, " " + I2S(Score_Kills[id]) )
// Deaths
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 4)
call MultiboardSetItemValue( field, I2S(Score_Deaths[id]) )
set field = null
endfunction
private function Update takes nothing returns nothing
call ForForce( Players, function Update_Callback )
endfunction
private function Conditions_Level_Up takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function Conditions_Hero_Kills takes nothing returns boolean
return IsPlayerInForce(GetOwningPlayer(GetKillingUnit()), Players) == true
endfunction
private function A_Hero_Kills takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
set Score_Kills[id] = Score_Kills[id] + 1
if IsHero(GetDyingUnit()) then
set Score_PvP[id] = Score_PvP[id] + 1
endif
call IncHonorStack(id, 2)
call Update()
endfunction
private function Conditions_Hero_Dies takes nothing returns boolean
return IsHero(GetTriggerUnit())
endfunction
private function A_Hero_Dies takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
set Score_Deaths[id] = Score_Deaths[id] + 1
call Update()
endfunction
private function Set_Clock takes nothing returns nothing
local multiboarditem clockfield = null
set clockfield = MultiboardGetItem(Score_Table, ClockRow, 2)
set GameTime_Minutes = ( R2I(TimerGetElapsed(GameTime)) / 60 )
set GameTime_Seconds = ModuloInteger(R2I(TimerGetElapsed(GameTime)), 60)
if GameTime_Seconds >= 10 then
call MultiboardSetItemValue( clockfield, I2S(GameTime_Minutes) + ":" + I2S(GameTime_Seconds) )
else
call MultiboardSetItemValue( clockfield, I2S(GameTime_Minutes) + ":0" + I2S(GameTime_Seconds) )
endif
set clockfield = null
endfunction
private function Add_Players takes nothing returns nothing
local multiboarditem field = MultiboardGetItem(Score_Table, TempInt, 0)
local integer id = GetPlayerId(GetEnumPlayer())
set ScoreBoard_Positions[id] = TempInt
call MultiboardSetItemValue(field, " " + PlayerNames[id])
set field = MultiboardGetItem(Score_Table, ScoreBoard_Positions[id], 1)
call MultiboardSetItemValue( field, " 1" )
set TempInt = ( TempInt + 1 )
set field = null
endfunction
private function Init_Score_Board takes nothing returns nothing
local integer i
local integer j
local multiboarditem field = null
call TriggerSleepAction( 1.00 )
call TimerStart( GameTime, 999999.00, false, null )
// Now create the actual Multiboard
set Score_Table = CreateMultiboard()
call MultiboardSetRowCount(Score_Table, 6 + NumberOfPlayers )
call MultiboardSetColumnCount(Score_Table, 5)
call MultiboardSetTitleText(Score_Table, SCORE_TITLE)
call MultiboardDisplay(Score_Table, true)
// Adjust color and display style
set i = 0
loop
exitwhen ( i > MultiboardGetRowCount(Score_Table)-1 )
set j = 0
loop
exitwhen ( j > 4 )
set field = MultiboardGetItem(Score_Table, i, j)
call MultiboardSetItemStyle( field, true, false )
call MultiboardSetItemValueColor( field, 220, 220, 220, 255 )
set j = j + 1
endloop
set i = i + 1
endloop
// Adjust column width
set i = 0
loop
exitwhen ( i > MultiboardGetRowCount(Score_Table)-1 )
set field = MultiboardGetItem(Score_Table, i, 0)
call MultiboardSetItemWidth(field, 0.10)
set field = MultiboardGetItem(Score_Table, i, 1)
call MultiboardSetItemWidth(field, 0.03) // 0.01
set field = MultiboardGetItem(Score_Table, i, 2)
call MultiboardSetItemWidth(field, 0.03)
set field = MultiboardGetItem(Score_Table, i, 3)
call MultiboardSetItemWidth(field, 0.03)
set field = MultiboardGetItem(Score_Table, i, 4)
call MultiboardSetItemWidth(field, 0.01)
set i = i + 1
endloop
// Headline
set field = MultiboardGetItem(Score_Table, 0, 1)
call MultiboardSetItemValue( field, "|cffFFDD8DLv|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 2)
call MultiboardSetItemValue( field, "|cffFF974APvP|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 3)
call MultiboardSetItemValue( field, "|cffD60505Kills|r" )
call MultiboardSetItemValueColor( field, 255, 255, 255, 255 )
set field = MultiboardGetItem(Score_Table, 0, 4)
call MultiboardSetItemStyle( field, true, true )
call MultiboardSetItemIcon(field, "ReplaceableTextures\\CommandButtons\\BTNPunisher.blp")
// Team 1
set field = MultiboardGetItem(Score_Table, 1, 0)
call MultiboardSetItemValue( field, TEAM1 )
// Team 2
set field = MultiboardGetItem(Score_Table, 3 + NumberOfPlayersTeam1, 0)
call MultiboardSetItemValue( field, TEAM2 )
// Add Players Team 1
set TempInt = 2
call ForForce( Players_Team1, function Add_Players )
// Add Players Team 2
set TempInt = 4 + NumberOfPlayersTeam1
call ForForce( Players_Team2, function Add_Players )
// Game Time
set ClockRow = ( 5 + NumberOfPlayers )
set field = MultiboardGetItem(Score_Table, ClockRow, 0)
call MultiboardSetItemValueColor( field, 100, 100, 100, 255 )
call MultiboardSetItemValue( field, "Game Time:" )
set field = MultiboardGetItem(Score_Table, ClockRow, 2)
call MultiboardSetItemValueColor( field, 180, 180, 180, 255 )
call MultiboardSetItemValue( field, "0:00" )
call MultiboardDisplay( Score_Table, true )
// Update
call Update()
set field = null
endfunction
//===========================================================================
public function Init takes nothing returns nothing
// Init
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, false)
call TriggerAddAction( trg, function Init_Score_Board )
// Update Clock
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 1, true)
call TriggerAddAction(trg, function Set_Clock)
// Hero Dies
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Dies ) )
call TriggerAddAction( trg, function A_Hero_Dies )
// Hero Kills
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Hero_Kills ) )
call TriggerAddAction( trg, function A_Hero_Kills )
// Levelup
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_HERO_LEVEL )
call TriggerAddCondition( trg, Condition( function Conditions_Level_Up ) )
call TriggerAddAction( trg, function Update )
set trg = null
endfunction
endscope
//TESH.scrollpos=143
//TESH.alwaysfold=0
scope Troops initializer Init
globals
location Spawn_Team1L
location Spawn_Team1M
location Spawn_Team1R
location Spawn_Team2L
location Spawn_Team2M
location Spawn_Team2R
boolean Sorcerer1 = false
boolean Sorcerer2 = false
endglobals
private function ReActivator_Condition takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == false and UnitUsesWP(GetFilterUnit()) and GetUnitCurrentOrder(GetFilterUnit()) == Order_Stop and GetPlayerController(GetOwningPlayer(GetFilterUnit())) == MAP_CONTROL_COMPUTER// and CaptureSystem_Check_Unit(GetFilterUnit()) == false // change order "move" into the order you are giving the units on their way to the waypoints.
endfunction
private function ReActivator_Callback takes nothing returns nothing
call Order_Unit_To_Next_WP(GetEnumUnit())
endfunction
private function ReActivator takes nothing returns nothing
local group TempGroup = NewGroup()
call GroupEnumUnitsInRect(TempGroup, bj_mapInitialPlayableArea, Condition(function ReActivator_Condition)) // store the condition in a global if you have JNGP
call ForGroup( TempGroup, function ReActivator_Callback )
call ReleaseGroup( TempGroup )
set TempGroup = null
endfunction
private function Troops_Team1 takes integer FirstWP returns nothing
local unit CreatedUnit
// local integer FirstWP = 1
// Team 1
if ( GetUnitState(Base_Team1, UNIT_STATE_LIFE) > 0 ) then
// Archer
set CreatedUnit = CreateUnitAtLoc(Player(1), 'earc', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Footman
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hfoo', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Footman
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hfoo', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 2 Units
if ( Team1_Tier >= 2 ) then
// Priest / Mage
if Sorcerer1 == false then
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hmpr', Spawn_Team1, bj_UNIT_FACING)
set Sorcerer1 = true
else
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hsor', Spawn_Team1, bj_UNIT_FACING)
set Sorcerer1 = false
endif
call SetUnitState(CreatedUnit, UNIT_STATE_MANA, 150)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 3 Units
if ( Team1_Tier >= 3 ) then
// Knight
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hkni', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
endif
endif
endif
set CreatedUnit = null
endfunction
private function Troops_Team2 takes integer FirstWP returns nothing
local unit CreatedUnit
// Team 2
if ( GetUnitState(Base_Team2, UNIT_STATE_LIFE) > 0 ) then
// Archer
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ohun', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Grunt
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ogru', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Grunt
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ogru', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 2 Units
if ( Team2_Tier >= 2 ) then
// Priest / Mage
if Sorcerer2 == false then
set CreatedUnit = CreateUnitAtLoc(Player(0), 'odoc', Spawn_Team2, bj_UNIT_FACING)
set Sorcerer2 = true
else
set CreatedUnit = CreateUnitAtLoc(Player(0), 'oshm', Spawn_Team2, bj_UNIT_FACING)
set Sorcerer2 = false
endif
call SetUnitState(CreatedUnit, UNIT_STATE_MANA, 150)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 3 Units
if ( Team2_Tier >= 3 ) then
// Ogre
set CreatedUnit = CreateUnitAtLoc(Player(0), 'nogo', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
endif
endif
endif
set CreatedUnit = null
endfunction
private function Spawn_Troops takes nothing returns nothing
set Spawn_Team1 = Spawn_Team1L
set Spawn_Team2 = Spawn_Team2L
call Troops_Team1(21)
call Troops_Team2(27)
call TriggerSleepAction(10.0)
set Spawn_Team1 = Spawn_Team1M
set Spawn_Team2 = Spawn_Team2M
call Troops_Team1(1)
call Troops_Team2(7)
call TriggerSleepAction(10.0)
set Spawn_Team1 = Spawn_Team1R
set Spawn_Team2 = Spawn_Team2R
call Troops_Team1(11)
call Troops_Team2(17)
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 30.00, true)
call TriggerAddAction( trg, function Spawn_Troops )
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction(trg, function ReActivator)
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Spawn_Troops )
set Spawn_Team1L = Location(GetRectCenterX(gg_rct_SpawnTeam1L), GetRectCenterY(gg_rct_SpawnTeam1L))
set Spawn_Team1M = Location(GetRectCenterX(gg_rct_SpawnTeam1M), GetRectCenterY(gg_rct_SpawnTeam1M))
set Spawn_Team1R = Location(GetRectCenterX(gg_rct_SpawnTeam1R), GetRectCenterY(gg_rct_SpawnTeam1R))
set Spawn_Team2L = Location(GetRectCenterX(gg_rct_SpawnTeam2L), GetRectCenterY(gg_rct_SpawnTeam2L))
set Spawn_Team2M = Location(GetRectCenterX(gg_rct_SpawnTeam2M), GetRectCenterY(gg_rct_SpawnTeam2M))
set Spawn_Team2R = Location(GetRectCenterX(gg_rct_SpawnTeam2R), GetRectCenterY(gg_rct_SpawnTeam2R))
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Troops initializer Init
globals
location Spawn_Team1L
location Spawn_Team1M
location Spawn_Team1R
location Spawn_Team2L
location Spawn_Team2M
location Spawn_Team2R
boolean Sorcerer1 = false
boolean Sorcerer2 = false
endglobals
private function ReActivator_Condition takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == false and UnitUsesWP(GetFilterUnit()) and GetUnitCurrentOrder(GetFilterUnit()) == Order_Stop and GetPlayerController(GetOwningPlayer(GetFilterUnit())) == MAP_CONTROL_COMPUTER// and CaptureSystem_Check_Unit(GetFilterUnit()) == false // change order "move" into the order you are giving the units on their way to the waypoints.
endfunction
private function ReActivator_Callback takes nothing returns nothing
call Order_Unit_To_Next_WP(GetEnumUnit())
endfunction
private function ReActivator takes nothing returns nothing
local group TempGroup = NewGroup()
call GroupEnumUnitsInRect(TempGroup, bj_mapInitialPlayableArea, Condition(function ReActivator_Condition)) // store the condition in a global if you have JNGP
call ForGroup( TempGroup, function ReActivator_Callback )
call ReleaseGroup( TempGroup )
set TempGroup = null
endfunction
private function Troops_Team1 takes integer FirstWP returns nothing
local unit CreatedUnit
// local integer FirstWP = 1
// Team 1
if ( GetUnitState(Base_Team1, UNIT_STATE_LIFE) > 0 ) then
// Archer
set CreatedUnit = CreateUnitAtLoc(Player(1), 'earc', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Footman
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hfoo', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Footman
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hfoo', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 2 Units
if ( Team1_Tier >= 2 ) then
// Priest / Mage
if Sorcerer1 == false then
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hmpr', Spawn_Team1, bj_UNIT_FACING)
set Sorcerer1 = true
else
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hsor', Spawn_Team1, bj_UNIT_FACING)
set Sorcerer1 = false
endif
call SetUnitState(CreatedUnit, UNIT_STATE_MANA, 150)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 3 Units
if ( Team1_Tier >= 3 ) then
// Knight
set CreatedUnit = CreateUnitAtLoc(Player(1), 'hkni', Spawn_Team1, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
endif
endif
endif
set CreatedUnit = null
endfunction
private function Troops_Team2 takes integer FirstWP returns nothing
local unit CreatedUnit
// Team 2
if ( GetUnitState(Base_Team2, UNIT_STATE_LIFE) > 0 ) then
// Archer
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ohun', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Grunt
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ogru', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Grunt
set CreatedUnit = CreateUnitAtLoc(Player(0), 'ogru', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 2 Units
if ( Team2_Tier >= 2 ) then
// Priest / Mage
if Sorcerer2 == false then
set CreatedUnit = CreateUnitAtLoc(Player(0), 'odoc', Spawn_Team2, bj_UNIT_FACING)
set Sorcerer2 = true
else
set CreatedUnit = CreateUnitAtLoc(Player(0), 'oshm', Spawn_Team2, bj_UNIT_FACING)
set Sorcerer2 = false
endif
call SetUnitState(CreatedUnit, UNIT_STATE_MANA, 150)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
// Tier 3 Units
if ( Team2_Tier >= 3 ) then
// Ogre
set CreatedUnit = CreateUnitAtLoc(Player(0), 'nogo', Spawn_Team2, bj_UNIT_FACING)
set waypoint_table[GetUnitId(CreatedUnit)] = FirstWP
call Order_Unit_To_Next_WP( CreatedUnit )
endif
endif
endif
set CreatedUnit = null
endfunction
private function Spawn_Troops takes nothing returns nothing
set Spawn_Team1 = Spawn_Team1L
set Spawn_Team2 = Spawn_Team2L
call Troops_Team1(21)
call Troops_Team2(27)
call TriggerSleepAction(10.0)
set Spawn_Team1 = Spawn_Team1M
set Spawn_Team2 = Spawn_Team2M
call Troops_Team1(1)
call Troops_Team2(7)
call TriggerSleepAction(10.0)
set Spawn_Team1 = Spawn_Team1R
set Spawn_Team2 = Spawn_Team2R
call Troops_Team1(11)
call Troops_Team2(17)
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 30.00, true)
call TriggerAddAction( trg, function Spawn_Troops )
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction(trg, function ReActivator)
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Spawn_Troops )
set Spawn_Team1L = Location(GetRectCenterX(gg_rct_SpawnTeam1L), GetRectCenterY(gg_rct_SpawnTeam1L))
set Spawn_Team1M = Location(GetRectCenterX(gg_rct_SpawnTeam1M), GetRectCenterY(gg_rct_SpawnTeam1M))
set Spawn_Team1R = Location(GetRectCenterX(gg_rct_SpawnTeam1R), GetRectCenterY(gg_rct_SpawnTeam1R))
set Spawn_Team2L = Location(GetRectCenterX(gg_rct_SpawnTeam2L), GetRectCenterY(gg_rct_SpawnTeam2L))
set Spawn_Team2M = Location(GetRectCenterX(gg_rct_SpawnTeam2M), GetRectCenterY(gg_rct_SpawnTeam2M))
set Spawn_Team2R = Location(GetRectCenterX(gg_rct_SpawnTeam2R), GetRectCenterY(gg_rct_SpawnTeam2R))
set trg = null
endfunction
endscope
//TESH.scrollpos=33
//TESH.alwaysfold=0
scope CreepGate initializer Init
globals
location GateSpawn
endglobals
private function Creep_Conditions takes nothing returns boolean
return GetOwningPlayer(GetFilterUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endfunction
private function Spawn_Creeps takes nothing returns nothing
local unit u
local effect e
local group creeps = NewGroup()
call GroupEnumUnitsInRect(creeps, gg_rct_GateSpawn, Condition(function Creep_Conditions))
call Debug_Message("Try to spawn some creeps")
native GetRandomInt takes integer lowBound, integer highBound returns integer
if FirstOfGroup(creeps) == null then
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(1,2)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(2,3)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(3,6)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(5,7)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(8,10)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
endif
call ReleaseGroup(creeps)
set creeps = null
call DestroyEffect(e)
set e = null
set u = null
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 60.00, true)
call TriggerAddAction( trg, function Spawn_Creeps )
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Spawn_Creeps )
set GateSpawn = Location(GetRectCenterX(gg_rct_GateSpawn), GetRectCenterY(gg_rct_GateSpawn))
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope CreepGate initializer Init
globals
location GateSpawn
endglobals
private function Creep_Conditions takes nothing returns boolean
return GetOwningPlayer(GetFilterUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endfunction
private function Spawn_Creeps takes nothing returns nothing
local unit u
local effect e
local group creeps = NewGroup()
call GroupEnumUnitsInRect(creeps, gg_rct_GateSpawn, Condition(function Creep_Conditions))
call Debug_Message("Try to spawn some creeps")
native GetRandomInt takes integer lowBound, integer highBound returns integer
if FirstOfGroup(creeps) == null then
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(1,2)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(2,3)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(3,6)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(5,7)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(8,10)), GetRandomReal(GetRectMinX(gg_rct_GateSpawn), GetRectMaxX(gg_rct_GateSpawn)), GetRandomReal(GetRectMinY(gg_rct_GateSpawn), GetRectMaxY(gg_rct_GateSpawn)), bj_UNIT_FACING)
set e = AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", GetUnitX(u), GetUnitY(u))
call DestroyEffect(e)
endif
call ReleaseGroup(creeps)
set creeps = null
call DestroyEffect(e)
set e = null
set u = null
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 60.00, true)
call TriggerAddAction( trg, function Spawn_Creeps )
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 0.01, false)
call TriggerAddAction( trg, function Spawn_Creeps )
set GateSpawn = Location(GetRectCenterX(gg_rct_GateSpawn), GetRectCenterY(gg_rct_GateSpawn))
set trg = null
endfunction
endscope
//TESH.scrollpos=547
//TESH.alwaysfold=0
library Itemsystem initializer Init requires HeroSystem
globals
private equipment array Item_Array[1]
private Table ItemTab = 0
private real array ItemSystem_SpellDamageMods[1]
private real array ItemSystem_CritBoni[1]
private integer array ItemSystem_StrBoni[1]
private integer array ItemSystem_AgiBoni[1]
private integer array ItemSystem_IntBoni[1]
private integer ItemCount = 0 // don't touch this
private integer N = 0 // automatically stores the number of items, don't touch this!
endglobals
struct equipment
integer id
integer class // 1 = weapon, 2 = armor, 3 = boots, 4 = ring
boolean usableStr = true
boolean usableAgi = true
boolean usableInt = true
real spell_bonus = 0.0
real crit_bonus = 0.0
integer str_bonus = 0
integer agi_bonus = 0
integer int_bonus = 0
endstruct
function GetCritChance takes unit u returns real
local integer id = GetPlayerId(GetOwningPlayer(u))
local real crit = 0
if IsStrHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroStr(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
elseif IsAgiHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroAgi(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
elseif IsIntHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroInt(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
endif
return crit
endfunction
function Inc takes integer i returns integer
set i = i + 1
return i
endfunction
private function GetN takes integer id returns integer
return ItemTab[id] // probably much faster with table than the old code :)
endfunction
function IsSystemItem takes integer id returns boolean
if GetN(id) != 0 then
return true
endif
return false
endfunction
function GetStrBonus takes integer id returns integer
return ItemSystem_StrBoni[id]
endfunction
function GetAgiBonus takes integer id returns integer
return ItemSystem_AgiBoni[id]
endfunction
function GetIntBonus takes integer id returns integer
return ItemSystem_IntBoni[id]
endfunction
function GetSpellBonus takes integer id returns real
return ItemSystem_SpellDamageMods[id]
endfunction
function GetSpellMod takes integer id returns real
return 1 + ItemSystem_SpellDamageMods[id]
endfunction
function GetCritBonus takes integer id returns real
return ItemSystem_CritBoni[id]
endfunction
function IsStrItem takes integer id returns boolean
return Item_Array[GetN(id)].usableStr
endfunction
function IsAgiItem takes integer id returns boolean
return Item_Array[GetN(id)].usableAgi
endfunction
function IsIntItem takes integer id returns boolean
return Item_Array[GetN(id)].usableInt
endfunction
function IsWeapon takes integer id returns boolean
if Item_Array[GetN(id)].class == 1 then
return true
endif
return false
endfunction
function IsArmor takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 2 then
return true
endif
return false
endfunction
function IsBoots takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 3 then
return true
endif
return false
endfunction
function IsRing takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 4 then
return true
endif
return false
endfunction
function TwoOfSameClass takes integer id, unit Hero returns boolean
local integer i = 0
local integer j = 0
local integer help
local integer class
set id = GetN(id)
if id != 0 then
set class = Item_Array[id].class
loop
exitwhen i > 5
set help = GetItemTypeId(UnitItemInSlot(Hero, i))
if Item_Array[GetN(help)].class == class then
set j = j + 1
endif
set i = i + 1
endloop
if j > 1 then
return true
endif
endif
return false
endfunction
function Show_Stats takes integer id returns nothing
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
call DisplayTimedTextToPlayer(Player(id),0,0,10, "Hero stats of "+PlayerNames[id] + " ("+GetUnitName(Heroes[id]) + ") :")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff449EFBSpell/Ability power : |r |cffA7A7A7+" + R2S(GetSpellBonus(id)*100)+"%|r")
// call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cffCCF389Healing power : |r |cffA7A7A7+" + R2S(GetSpellBonus(id)*100)+"%|r")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff8977F6Crit chance : |r |cffA7A7A7" + R2S(GetCritChance(Heroes[id])) + "%|r")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cffE3231EStr : |r |cffA7A7A7+" + I2S(GetStrBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff76DD28Agi : |r |cffA7A7A7+" + I2S(GetAgiBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff3C5CACInt : |r |cffA7A7A7+" + I2S(GetIntBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
endfunction
private function SetMods takes integer id, integer player_id, boolean PickedUp returns nothing
local real life = GetUnitState(Heroes[player_id], UNIT_STATE_LIFE)
set id = GetN(id)
// call Debug_Message("Set Mods with item id: "+I2S(id))
// If aquired
if PickedUp then
set ItemSystem_SpellDamageMods[player_id] = ItemSystem_SpellDamageMods[player_id] + Item_Array[id].spell_bonus
// set ItemSystem_SpellHealingMods[player_id] = ItemSystem_SpellHealingMods[player_id] + Item_Array[id].spell_bonus + Item_Array[id].heal_bonus
set ItemSystem_CritBoni[player_id] = ItemSystem_CritBoni[player_id] + Item_Array[id].crit_bonus
call SetHeroStr( Heroes[player_id], GetHeroStr(Heroes[player_id],false) + Item_Array[id].str_bonus, true)
set ItemSystem_StrBoni[player_id] = ItemSystem_StrBoni[player_id] + Item_Array[id].str_bonus
call SetHeroAgi( Heroes[player_id], GetHeroAgi(Heroes[player_id],false) + Item_Array[id].agi_bonus, true)
set ItemSystem_AgiBoni[player_id] = ItemSystem_AgiBoni[player_id] + Item_Array[id].agi_bonus
call SetHeroInt( Heroes[player_id], GetHeroInt(Heroes[player_id],false) + Item_Array[id].int_bonus, true)
set ItemSystem_IntBoni[player_id] = ItemSystem_IntBoni[player_id] + Item_Array[id].int_bonus
// If dropped, remove multiplier
else
set ItemSystem_SpellDamageMods[player_id] = ItemSystem_SpellDamageMods[player_id] - Item_Array[id].spell_bonus
// set ItemSystem_SpellHealingMods[player_id] = ItemSystem_SpellHealingMods[player_id] - Item_Array[id].spell_bonus - Item_Array[id].heal_bonus
set ItemSystem_CritBoni[player_id] = ItemSystem_CritBoni[player_id] - Item_Array[id].crit_bonus
call SetHeroStr( Heroes[player_id], GetHeroStr(Heroes[player_id],false) - Item_Array[id].str_bonus, true)
set ItemSystem_StrBoni[player_id] = ItemSystem_StrBoni[player_id] - Item_Array[id].str_bonus
call SetHeroAgi( Heroes[player_id], GetHeroAgi(Heroes[player_id],false) - Item_Array[id].agi_bonus, true)
set ItemSystem_AgiBoni[player_id] = ItemSystem_AgiBoni[player_id] - Item_Array[id].agi_bonus
call SetHeroInt( Heroes[player_id], GetHeroInt(Heroes[player_id],false) - Item_Array[id].int_bonus, true)
set ItemSystem_IntBoni[player_id] = ItemSystem_IntBoni[player_id] - Item_Array[id].int_bonus
endif
call SetUnitState(Heroes[player_id], UNIT_STATE_LIFE, life)
endfunction
private function NewEquip takes nothing returns equipment
local equipment equi = equipment.create()
set equi.id = 0
set equi.class = 0
set equi.usableStr = true
set equi.usableAgi = true
set equi.usableInt = true
set equi.spell_bonus = 0.0
// set equi.heal_bonus = 0.0
set equi.crit_bonus = 0.0
set equi.str_bonus = 0
set equi.agi_bonus = 0
set equi.int_bonus = 0
return equi
endfunction
private function RegEquip takes equipment equi returns nothing
set ItemCount = ItemCount + 1
set ItemTab[equi.id] = ItemCount
set Item_Array[ItemCount] = equi
endfunction
private function Init_Items takes nothing returns nothing
local integer i
local equipment equi
set ItemTab = Table.create()
// Init Damage Mods
set i = 0
loop
exitwhen i > 11
set ItemSystem_SpellDamageMods[i] = 0.0
// set ItemSystem_SpellHealingMods[i] = 0.0
set ItemSystem_CritBoni[i] = 0.0
set i = i + 1
endloop
// WEAPONS
// ====================================
// Grandmaster's Sword
set equi = NewEquip()
set equi.id = 'I01M'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.15
set equi.crit_bonus = 3.0
call RegEquip(equi)
// Staff of Dominance
set equi = NewEquip()
set equi.id = 'I018'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.15
set equi.crit_bonus = 3.0
call RegEquip(equi)
// =============================================
// Blade of the Hellwinds
set equi = NewEquip()
set equi.id = 'I00B'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.25
set equi.crit_bonus = 5.0
call RegEquip(equi)
// Staff of the Nether Realms
set equi = NewEquip()
set equi.id = 'I008'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.25
set equi.crit_bonus = 5.0
call RegEquip(equi)
// The Bone Crusher
set equi = NewEquip()
set equi.id = 'I015'
set equi.class = 1
set equi.usableAgi = false
set equi.usableInt = false
set equi.spell_bonus = 0.1
call RegEquip(equi)
// The Blood Drinker
set equi = NewEquip()
set equi.id = 'I01A'
set equi.class = 1
set equi.spell_bonus = 0.1
call RegEquip(equi)
// Staff of the Cobra
set equi = NewEquip()
set equi.id = 'I01D'
set equi.class = 1
set equi.spell_bonus = 0.2
set equi.crit_bonus = 3.0
set equi.str_bonus = 5
set equi.agi_bonus = 5
set equi.int_bonus = 5
call RegEquip(equi)
// Blade of the Underworld
set equi = NewEquip()
set equi.id = 'I00K'
set equi.class = 1
set equi.spell_bonus = 0.15
call RegEquip(equi)
// The Crippler
set equi = NewEquip()
set equi.id = 'I00M'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.1
set equi.crit_bonus = 3.0
call RegEquip(equi)
// Thunderstorm
set equi = NewEquip()
set equi.id = 'I01H'
set equi.class = 1
set equi.usableInt = false
call RegEquip(equi)
// Destroyer of Worlds
set equi = NewEquip()
set equi.id = 'I01B'
set equi.class = 1
set equi.usableAgi = false
set equi.usableInt = false
set equi.crit_bonus = 6.0
set equi.spell_bonus = 0.3
call RegEquip(equi)
// Hattori Hanzo Blade
set equi = NewEquip()
set equi.id = 'I019'
set equi.class = 1
set equi.usableInt = false
set equi.crit_bonus = 10.0
call RegEquip(equi)
// Staff of the Elder Gods
set equi = NewEquip()
set equi.id = 'I00D'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.3
set equi.crit_bonus = 6.0
call RegEquip(equi)
// ARMOR
// ====================================
// Sorcerer's Robes
set equi = NewEquip()
set equi.id = 'I00T'
set equi.class = 2
set equi.str_bonus = 2
set equi.int_bonus = 4
call RegEquip(equi)
// Shroud of the Warmage
set equi = NewEquip()
set equi.id = 'I003'
set equi.class = 2
set equi.str_bonus = 3
set equi.int_bonus = 3
call RegEquip(equi)
// Robes of the Dragonflame
set equi = NewEquip()
set equi.id = 'I00I'
set equi.class = 2
set equi.int_bonus = 6
call RegEquip(equi)
// Vestments of the Wanderer
set equi = NewEquip()
set equi.id = 'I011'
set equi.class = 2
set equi.usableInt = false
set equi.str_bonus = 3
set equi.agi_bonus = 3
set equi.int_bonus = 3
call RegEquip(equi)
// Chestguard of Tenacity
set equi = NewEquip()
set equi.id = 'I00Y'
set equi.class = 2
set equi.usableInt = false
set equi.str_bonus = 3
set equi.agi_bonus = 4
call RegEquip(equi)
// Shadowblood Armor
set equi = NewEquip()
set equi.id = 'I00W'
set equi.class = 2
set equi.usableInt = false
set equi.agi_bonus = 6
call RegEquip(equi)
// Cobaltsteel Armor
set equi = NewEquip()
set equi.id = 'I004'
set equi.class = 2
set equi.usableInt = false
set equi.usableAgi = false
set equi.str_bonus = 4
set equi.int_bonus = 4
call RegEquip(equi)
// Titan's Plate
set equi = NewEquip()
set equi.id = 'I00Q'
set equi.class = 2
set equi.usableInt = false
set equi.usableAgi = false
set equi.str_bonus = 6
call RegEquip(equi)
// ====================================
// BOOTS
// Boots of Speed
set equi = NewEquip()
set equi.id = 'I00S'
set equi.class = 3
call RegEquip(equi)
// Nightwind Boots
set equi = NewEquip()
set equi.id = 'I00F'
set equi.class = 3
call RegEquip(equi)
// ====================================
// RINGS
// Ring of Eagerness
set equi = NewEquip()
set equi.id = 'I01I'
set equi.class = 4
call RegEquip(equi)
// Ring of Balance
set equi = NewEquip()
set equi.id = 'I01J'
set equi.class = 4
set equi.str_bonus = 5
set equi.agi_bonus = 5
set equi.int_bonus = 5
call RegEquip(equi)
// Ring of Domination
set equi = NewEquip()
set equi.id = 'I00U'
set equi.class = 4
set equi.crit_bonus = 5.0
call RegEquip(equi)
// Ring of the Winds
set equi = NewEquip()
set equi.id = 'I01K'
set equi.class = 4
call RegEquip(equi)
// Ring of Protection
set equi = NewEquip()
set equi.id = 'I01L'
set equi.class = 4
call RegEquip(equi)
endfunction
private function Conditions_Item_Manipulate takes nothing returns boolean
return IsSystemItem( GetItemTypeId(GetManipulatedItem()) )
endfunction
private function Item_Manipulate takes nothing returns nothing
local integer player_id = GetPlayerId(GetOwningPlayer(GetManipulatingUnit()))
local integer item_id = GetItemTypeId(GetManipulatedItem())
local item Item = GetManipulatedItem()
local unit Hero = GetManipulatingUnit()
local boolean pickup = false
local boolean usable = true
// Pickup or drop?
if GetTriggerEventId() == EVENT_PLAYER_UNIT_PICKUP_ITEM then
set pickup = true
endif
if pickup then
// call Debug_Message("Item Class: "+
// Apply weapon specific modifications (This has to be called first, even if the weapon is dropped!)
call SetMods(item_id, player_id, true)
// Only one item of each class
if TwoOfSameClass(item_id, Hero) then
call DisplayTimedTextToPlayer(Player(player_id),0,0,5, "|cffF52828You can carry only one item of this type!|r")
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, " ")
call UnitRemoveItem(Hero, Item)
else
// Strength Weapons
if IsStrHero(Hero) and IsStrItem(item_id) == false then
set usable = false
endif
// Agility Weapons
if IsAgiHero(Hero) and IsAgiItem(item_id) == false then
set usable = false
endif
// Intelligence Weapons
if IsIntHero(Hero) and IsIntItem(item_id) == false then
set usable = false
endif
// Drop item if it's not usable
if usable == false then
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, "|cffF52828You cannot use this item!|r")
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, " ")
call UnitRemoveItem(Hero, Item)
else
// OK, if all these things before are passed, let's take the item as successfully picked up
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, "Picked up " + GetItemName(Item) )
call Show_Stats(player_id)
endif
endif
else
// Apply weapon specific modifications
call SetMods(item_id, player_id, false)
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, GetItemName(Item) + " dropped" )
// call Show_Stats(player_id)
endif
set Hero = null
set Item = null
endfunction
// ====================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
// Item Handling
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddCondition(trg, Condition(function Conditions_Item_Manipulate))
call TriggerAddAction( trg, function Item_Manipulate )
call Init_Items()
set trg = null
endfunction
endlibrary
//TESH.alwaysfold=0
library Itemsystem initializer Init requires HeroSystem
globals
private equipment array Item_Array[1]
private Table ItemTab = 0
private real array ItemSystem_SpellDamageMods[1]
private real array ItemSystem_CritBoni[1]
private integer array ItemSystem_StrBoni[1]
private integer array ItemSystem_AgiBoni[1]
private integer array ItemSystem_IntBoni[1]
private integer ItemCount = 0 // don't touch this
private integer N = 0 // automatically stores the number of items, don't touch this!
endglobals
struct equipment
integer id
integer class // 1 = weapon, 2 = armor, 3 = boots, 4 = ring
boolean usableStr = true
boolean usableAgi = true
boolean usableInt = true
real spell_bonus = 0.0
real crit_bonus = 0.0
integer str_bonus = 0
integer agi_bonus = 0
integer int_bonus = 0
endstruct
function GetCritChance takes unit u returns real
local integer id = GetPlayerId(GetOwningPlayer(u))
local real crit = 0
if IsStrHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroStr(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
elseif IsAgiHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroAgi(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
elseif IsIntHero(u) then
set crit = BASIC_CRIT_CHANCE + ItemSystem_CritBoni[id] + (GetHeroInt(Heroes[id], true) * CRIT_PER_ATTRIBUTE)
endif
return crit
endfunction
function Inc takes integer i returns integer
set i = i + 1
return i
endfunction
private function GetN takes integer id returns integer
return ItemTab[id] // probably much faster with table than the old code :)
endfunction
function IsSystemItem takes integer id returns boolean
if GetN(id) != 0 then
return true
endif
return false
endfunction
function GetStrBonus takes integer id returns integer
return ItemSystem_StrBoni[id]
endfunction
function GetAgiBonus takes integer id returns integer
return ItemSystem_AgiBoni[id]
endfunction
function GetIntBonus takes integer id returns integer
return ItemSystem_IntBoni[id]
endfunction
function GetSpellBonus takes integer id returns real
return ItemSystem_SpellDamageMods[id]
endfunction
function GetSpellMod takes integer id returns real
return 1 + ItemSystem_SpellDamageMods[id]
endfunction
function GetCritBonus takes integer id returns real
return ItemSystem_CritBoni[id]
endfunction
function IsStrItem takes integer id returns boolean
return Item_Array[GetN(id)].usableStr
endfunction
function IsAgiItem takes integer id returns boolean
return Item_Array[GetN(id)].usableAgi
endfunction
function IsIntItem takes integer id returns boolean
return Item_Array[GetN(id)].usableInt
endfunction
function IsWeapon takes integer id returns boolean
if Item_Array[GetN(id)].class == 1 then
return true
endif
return false
endfunction
function IsArmor takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 2 then
return true
endif
return false
endfunction
function IsBoots takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 3 then
return true
endif
return false
endfunction
function IsRing takes integer id returns boolean
set id = GetN(id)
if Item_Array[id].class == 4 then
return true
endif
return false
endfunction
function TwoOfSameClass takes integer id, unit Hero returns boolean
local integer i = 0
local integer j = 0
local integer help
local integer class
set id = GetN(id)
if id != 0 then
set class = Item_Array[id].class
loop
exitwhen i > 5
set help = GetItemTypeId(UnitItemInSlot(Hero, i))
if Item_Array[GetN(help)].class == class then
set j = j + 1
endif
set i = i + 1
endloop
if j > 1 then
return true
endif
endif
return false
endfunction
function Show_Stats takes integer id returns nothing
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
call DisplayTimedTextToPlayer(Player(id),0,0,10, "Hero stats of "+PlayerNames[id] + " ("+GetUnitName(Heroes[id]) + ") :")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff449EFBSpell/Ability power : |r |cffA7A7A7+" + R2S(GetSpellBonus(id)*100)+"%|r")
// call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cffCCF389Healing power : |r |cffA7A7A7+" + R2S(GetSpellBonus(id)*100)+"%|r")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff8977F6Crit chance : |r |cffA7A7A7" + R2S(GetCritChance(Heroes[id])) + "%|r")
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cffE3231EStr : |r |cffA7A7A7+" + I2S(GetStrBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff76DD28Agi : |r |cffA7A7A7+" + I2S(GetAgiBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " |cff3C5CACInt : |r |cffA7A7A7+" + I2S(GetIntBonus(id)))
call DisplayTimedTextToPlayer(Player(id),0,0,10, " ")
endfunction
private function SetMods takes integer id, integer player_id, boolean PickedUp returns nothing
local real life = GetUnitState(Heroes[player_id], UNIT_STATE_LIFE)
set id = GetN(id)
// call Debug_Message("Set Mods with item id: "+I2S(id))
// If aquired
if PickedUp then
set ItemSystem_SpellDamageMods[player_id] = ItemSystem_SpellDamageMods[player_id] + Item_Array[id].spell_bonus
// set ItemSystem_SpellHealingMods[player_id] = ItemSystem_SpellHealingMods[player_id] + Item_Array[id].spell_bonus + Item_Array[id].heal_bonus
set ItemSystem_CritBoni[player_id] = ItemSystem_CritBoni[player_id] + Item_Array[id].crit_bonus
call SetHeroStr( Heroes[player_id], GetHeroStr(Heroes[player_id],false) + Item_Array[id].str_bonus, true)
set ItemSystem_StrBoni[player_id] = ItemSystem_StrBoni[player_id] + Item_Array[id].str_bonus
call SetHeroAgi( Heroes[player_id], GetHeroAgi(Heroes[player_id],false) + Item_Array[id].agi_bonus, true)
set ItemSystem_AgiBoni[player_id] = ItemSystem_AgiBoni[player_id] + Item_Array[id].agi_bonus
call SetHeroInt( Heroes[player_id], GetHeroInt(Heroes[player_id],false) + Item_Array[id].int_bonus, true)
set ItemSystem_IntBoni[player_id] = ItemSystem_IntBoni[player_id] + Item_Array[id].int_bonus
// If dropped, remove multiplier
else
set ItemSystem_SpellDamageMods[player_id] = ItemSystem_SpellDamageMods[player_id] - Item_Array[id].spell_bonus
// set ItemSystem_SpellHealingMods[player_id] = ItemSystem_SpellHealingMods[player_id] - Item_Array[id].spell_bonus - Item_Array[id].heal_bonus
set ItemSystem_CritBoni[player_id] = ItemSystem_CritBoni[player_id] - Item_Array[id].crit_bonus
call SetHeroStr( Heroes[player_id], GetHeroStr(Heroes[player_id],false) - Item_Array[id].str_bonus, true)
set ItemSystem_StrBoni[player_id] = ItemSystem_StrBoni[player_id] - Item_Array[id].str_bonus
call SetHeroAgi( Heroes[player_id], GetHeroAgi(Heroes[player_id],false) - Item_Array[id].agi_bonus, true)
set ItemSystem_AgiBoni[player_id] = ItemSystem_AgiBoni[player_id] - Item_Array[id].agi_bonus
call SetHeroInt( Heroes[player_id], GetHeroInt(Heroes[player_id],false) - Item_Array[id].int_bonus, true)
set ItemSystem_IntBoni[player_id] = ItemSystem_IntBoni[player_id] - Item_Array[id].int_bonus
endif
call SetUnitState(Heroes[player_id], UNIT_STATE_LIFE, life)
endfunction
private function NewEquip takes nothing returns equipment
local equipment equi = equipment.create()
set equi.id = 0
set equi.class = 0
set equi.usableStr = true
set equi.usableAgi = true
set equi.usableInt = true
set equi.spell_bonus = 0.0
// set equi.heal_bonus = 0.0
set equi.crit_bonus = 0.0
set equi.str_bonus = 0
set equi.agi_bonus = 0
set equi.int_bonus = 0
return equi
endfunction
private function RegEquip takes equipment equi returns nothing
set ItemCount = ItemCount + 1
set ItemTab[equi.id] = ItemCount
set Item_Array[ItemCount] = equi
endfunction
private function Init_Items takes nothing returns nothing
local integer i
local equipment equi
set ItemTab = Table.create()
// Init Damage Mods
set i = 0
loop
exitwhen i > 11
set ItemSystem_SpellDamageMods[i] = 0.0
// set ItemSystem_SpellHealingMods[i] = 0.0
set ItemSystem_CritBoni[i] = 0.0
set i = i + 1
endloop
// WEAPONS
// ====================================
// Grandmaster's Sword
set equi = NewEquip()
set equi.id = 'I01M'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.15
set equi.crit_bonus = 3.0
call RegEquip(equi)
// Staff of Dominance
set equi = NewEquip()
set equi.id = 'I018'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.15
set equi.crit_bonus = 3.0
call RegEquip(equi)
// =============================================
// Blade of the Hellwinds
set equi = NewEquip()
set equi.id = 'I00B'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.25
set equi.crit_bonus = 5.0
call RegEquip(equi)
// Staff of the Nether Realms
set equi = NewEquip()
set equi.id = 'I008'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.25
set equi.crit_bonus = 5.0
call RegEquip(equi)
// The Bone Crusher
set equi = NewEquip()
set equi.id = 'I015'
set equi.class = 1
set equi.usableAgi = false
set equi.usableInt = false
set equi.spell_bonus = 0.1
call RegEquip(equi)
// The Blood Drinker
set equi = NewEquip()
set equi.id = 'I01A'
set equi.class = 1
set equi.spell_bonus = 0.1
call RegEquip(equi)
// Staff of the Cobra
set equi = NewEquip()
set equi.id = 'I01D'
set equi.class = 1
set equi.spell_bonus = 0.2
set equi.crit_bonus = 3.0
set equi.str_bonus = 5
set equi.agi_bonus = 5
set equi.int_bonus = 5
call RegEquip(equi)
// Blade of the Underworld
set equi = NewEquip()
set equi.id = 'I00K'
set equi.class = 1
set equi.spell_bonus = 0.15
call RegEquip(equi)
// The Crippler
set equi = NewEquip()
set equi.id = 'I00M'
set equi.class = 1
set equi.usableInt = false
set equi.spell_bonus = 0.1
set equi.crit_bonus = 3.0
call RegEquip(equi)
// Thunderstorm
set equi = NewEquip()
set equi.id = 'I01H'
set equi.class = 1
set equi.usableInt = false
call RegEquip(equi)
// Destroyer of Worlds
set equi = NewEquip()
set equi.id = 'I01B'
set equi.class = 1
set equi.usableAgi = false
set equi.usableInt = false
set equi.crit_bonus = 6.0
set equi.spell_bonus = 0.3
call RegEquip(equi)
// Hattori Hanzo Blade
set equi = NewEquip()
set equi.id = 'I019'
set equi.class = 1
set equi.usableInt = false
set equi.crit_bonus = 10.0
call RegEquip(equi)
// Staff of the Elder Gods
set equi = NewEquip()
set equi.id = 'I00D'
set equi.class = 1
set equi.usableStr = false
set equi.usableAgi = false
set equi.spell_bonus = 0.3
set equi.crit_bonus = 6.0
call RegEquip(equi)
// ARMOR
// ====================================
// Sorcerer's Robes
set equi = NewEquip()
set equi.id = 'I00T'
set equi.class = 2
set equi.str_bonus = 2
set equi.int_bonus = 4
call RegEquip(equi)
// Shroud of the Warmage
set equi = NewEquip()
set equi.id = 'I003'
set equi.class = 2
set equi.str_bonus = 3
set equi.int_bonus = 3
call RegEquip(equi)
// Robes of the Dragonflame
set equi = NewEquip()
set equi.id = 'I00I'
set equi.class = 2
set equi.int_bonus = 6
call RegEquip(equi)
// Vestments of the Wanderer
set equi = NewEquip()
set equi.id = 'I011'
set equi.class = 2
set equi.usableInt = false
set equi.str_bonus = 3
set equi.agi_bonus = 3
set equi.int_bonus = 3
call RegEquip(equi)
// Chestguard of Tenacity
set equi = NewEquip()
set equi.id = 'I00Y'
set equi.class = 2
set equi.usableInt = false
set equi.str_bonus = 3
set equi.agi_bonus = 4
call RegEquip(equi)
// Shadowblood Armor
set equi = NewEquip()
set equi.id = 'I00W'
set equi.class = 2
set equi.usableInt = false
set equi.agi_bonus = 6
call RegEquip(equi)
// Cobaltsteel Armor
set equi = NewEquip()
set equi.id = 'I004'
set equi.class = 2
set equi.usableInt = false
set equi.usableAgi = false
set equi.str_bonus = 4
set equi.int_bonus = 4
call RegEquip(equi)
// Titan's Plate
set equi = NewEquip()
set equi.id = 'I00Q'
set equi.class = 2
set equi.usableInt = false
set equi.usableAgi = false
set equi.str_bonus = 6
call RegEquip(equi)
// ====================================
// BOOTS
// Boots of Speed
set equi = NewEquip()
set equi.id = 'I00S'
set equi.class = 3
call RegEquip(equi)
// Nightwind Boots
set equi = NewEquip()
set equi.id = 'I00F'
set equi.class = 3
call RegEquip(equi)
// ====================================
// RINGS
// Ring of Eagerness
set equi = NewEquip()
set equi.id = 'I01I'
set equi.class = 4
call RegEquip(equi)
// Ring of Balance
set equi = NewEquip()
set equi.id = 'I01J'
set equi.class = 4
set equi.str_bonus = 5
set equi.agi_bonus = 5
set equi.int_bonus = 5
call RegEquip(equi)
// Ring of Domination
set equi = NewEquip()
set equi.id = 'I00U'
set equi.class = 4
set equi.crit_bonus = 5.0
call RegEquip(equi)
// Ring of the Winds
set equi = NewEquip()
set equi.id = 'I01K'
set equi.class = 4
call RegEquip(equi)
// Ring of Protection
set equi = NewEquip()
set equi.id = 'I01L'
set equi.class = 4
call RegEquip(equi)
endfunction
private function Conditions_Item_Manipulate takes nothing returns boolean
return IsSystemItem( GetItemTypeId(GetManipulatedItem()) )
endfunction
private function Item_Manipulate takes nothing returns nothing
local integer player_id = GetPlayerId(GetOwningPlayer(GetManipulatingUnit()))
local integer item_id = GetItemTypeId(GetManipulatedItem())
local item Item = GetManipulatedItem()
local unit Hero = GetManipulatingUnit()
local boolean pickup = false
local boolean usable = true
// Pickup or drop?
if GetTriggerEventId() == EVENT_PLAYER_UNIT_PICKUP_ITEM then
set pickup = true
endif
if pickup then
// call Debug_Message("Item Class: "+
// Apply weapon specific modifications (This has to be called first, even if the weapon is dropped!)
call SetMods(item_id, player_id, true)
// Only one item of each class
if TwoOfSameClass(item_id, Hero) then
call DisplayTimedTextToPlayer(Player(player_id),0,0,5, "|cffF52828You can carry only one item of this type!|r")
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, " ")
call UnitRemoveItem(Hero, Item)
else
// Strength Weapons
if IsStrHero(Hero) and IsStrItem(item_id) == false then
set usable = false
endif
// Agility Weapons
if IsAgiHero(Hero) and IsAgiItem(item_id) == false then
set usable = false
endif
// Intelligence Weapons
if IsIntHero(Hero) and IsIntItem(item_id) == false then
set usable = false
endif
// Drop item if it's not usable
if usable == false then
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, "|cffF52828You cannot use this item!|r")
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, " ")
call UnitRemoveItem(Hero, Item)
else
// OK, if all these things before are passed, let's take the item as successfully picked up
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, "Picked up " + GetItemName(Item) )
call Show_Stats(player_id)
endif
endif
else
// Apply weapon specific modifications
call SetMods(item_id, player_id, false)
call DisplayTimedTextToPlayer(Player(player_id), 0, 0, 10, GetItemName(Item) + " dropped" )
// call Show_Stats(player_id)
endif
set Hero = null
set Item = null
endfunction
// ====================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
// Item Handling
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddCondition(trg, Condition(function Conditions_Item_Manipulate))
call TriggerAddAction( trg, function Item_Manipulate )
call Init_Items()
set trg = null
endfunction
endlibrary
//TESH.scrollpos=377
//TESH.alwaysfold=0
library UpgradeSystem initializer Init requires HeroSystem
globals
// constant integer UPGRADE_TIME_TIER1
integer array Research_Array[1] // stores all upgrades available
integer Research_Count = 0 // This is the number of available upgrades
integer Team1_Tier = 1
integer Team2_Tier = 1
boolean Team1_TierUpgradeInProgress = false
boolean Team2_TierUpgradeInProgress = false
boolean Full_Upgrades_Team1 = false
boolean Full_Upgrades_Team2 = false
constant integer T2_COST = 2500
constant integer T3_COST = 5000
// integer Team_Gold
integer AI_Team_Gold
integer DecAmount = 0
// currently unused
unit array Towers_Team1[1]
unit array Towers_Team2[1]
rect array Tower_Points_Team1[1]
rect array Tower_Points_Team2[1]
endglobals
function Check_Upgrades takes integer id returns boolean
if ( not ( GetPlayerTechCount(Player(id), 'Rhme', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhar', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhpt', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhst', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Resm', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rema', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Reib', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhac', true) >= 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhse', true) >= 1 ) ) then
return false
endif
return true
endfunction
function Update_Upgrades_Status takes nothing returns nothing
// Team 1
if ( Check_Upgrades(1) ) then
set Full_Upgrades_Team1 = true
else
set Full_Upgrades_Team1 = false
endif
// Team 2
if ( Check_Upgrades(0) ) then
set Full_Upgrades_Team2 = true
else
set Full_Upgrades_Team2 = false
endif
endfunction
private function Finish_Research takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local string s
set s = ( UPGRADE + PlayerNames[id] + " just purchased a new Upgrade for your team!" )
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true ) then
// Set Tech Level for whole team
call SetPlayerTechResearched( Player(1), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(2), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(6), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(8), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(9), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(10), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
// Notice Message
call Team_Message(1, s)
// Team 2
else
// Set Tech Level for whole team
call SetPlayerTechResearched( Player(0), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(3), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(4), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(5), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(7), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(11), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
// Notice Message
call Team_Message(2, s)
endif
endfunction
private function AI_Buys_Upgrades takes nothing returns nothing
local integer i
local unit u
set i = GetRandomInt(1, Research_Count)
set u = GroupPickRandomUnit(AI_Safes_Team1)
call IssueImmediateOrderById( u, Research_Array[i] )
set i = GetRandomInt(1, Research_Count)
set u = GroupPickRandomUnit(AI_Safes_Team2)
call IssueImmediateOrderById( u, Research_Array[i] )
call Update_Upgrades_Status()
set u = null
if Full_Upgrades_Team1 and Full_Upgrades_Team2 then
call DisableTrigger( GetTriggeringTrigger() )
call DestroyTrigger( GetTriggeringTrigger() )
endif
endfunction
private function Conditions_Demolisher takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I00X'
endfunction
private function Demolisher takes nothing returns nothing
// Team 1
if IsUnitTeam1(GetManipulatingUnit()) then
call CreateUnitAtLoc( GetOwningPlayer(GetManipulatingUnit()), 'ocat', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
// Team 2
else
call CreateUnitAtLoc( GetOwningPlayer(GetManipulatingUnit()), 'ocat', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
endif
call TriggerSleepAction(0.02)
call RemoveItem( GetManipulatedItem() )
endfunction
private function Conditions_Dragon takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I00R' or GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
private function Dragon takes nothing returns nothing
local unit u
// Team 1
if IsUnitTeam1(GetManipulatingUnit()) then
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 1
call Order_Unit_To_Next_WP( u )
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 11
call Order_Unit_To_Next_WP( u )
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 21
call Order_Unit_To_Next_WP( u )
// Team 2
else
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 7
call Order_Unit_To_Next_WP( u )
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 17
call Order_Unit_To_Next_WP( u )
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 27
call Order_Unit_To_Next_WP( u )
endif
set u = null
call TriggerSleepAction(0.02)
call RemoveItem( GetManipulatedItem() )
endfunction
private function Conditions_Tier_Upgrade takes nothing returns boolean
// Keep / Stronghold
if ( GetItemTypeId(GetManipulatedItem()) == 'I010' ) or ( GetItemTypeId(GetManipulatedItem()) == 'I014' ) then
return true
endif
// Castle / Fortress
if ( GetItemTypeId(GetManipulatedItem()) == 'I00Z' ) or ( GetItemTypeId(GetManipulatedItem()) == 'I016' ) then
return true
endif
return false
endfunction
private function Tier_Upgrade_Start takes nothing returns nothing
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetManipulatingUnit()), Player(1)) == true ) then
if ( GetItemTypeId(GetManipulatedItem()) == 'I010' ) then
call IssueImmediateOrderById( Base_Team1, 'hkee' )
else
call IssueImmediateOrderById( Base_Team1, 'hcas' )
endif
// Team 2
else
// call Debug_Message("Team 2 Tier Upgrade start on "+ GetUnitName(Base_Team2))
if ( GetItemTypeId(GetManipulatedItem()) == 'I014' ) then
call IssueImmediateOrderById( Base_Team2, 'ostr' )
else
call IssueImmediateOrderById( Base_Team2, 'ofrt' )
endif
endif
endfunction
private function Conditions_Tier_Upgrade_Finish takes nothing returns boolean
// Keep / Stronghold
if ( GetUnitTypeId(GetTriggerUnit()) == 'hkee' ) or ( GetUnitTypeId(GetTriggerUnit()) == 'ostr' ) then
return true
endif
// Castle / Fortress
if ( GetUnitTypeId(GetTriggerUnit()) == 'hcas' ) or ( GetUnitTypeId(GetTriggerUnit()) == 'ofrt' )then
return true
endif
return false
endfunction
private function Tier_Upgrade_Finish takes nothing returns nothing
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit()) //+ 32
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true ) then
if ( GetUnitTypeId(GetTriggerUnit()) == 'hkee' ) then
call RemoveUnit(GetTriggerUnit())
set Base_Team1 = CreateUnit(Player(1), 'hkee', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM1 + "just upgraded to |cff9DD2F4Tier 2|r")
set Team1_Tier = 2
set Team1_TierUpgradeInProgress = false
call StartSound(Sound_General)
else
call RemoveUnit(GetTriggerUnit())
set Base_Team1 = CreateUnit(Player(1), 'hcas', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM1 + "just upgraded to |cffFF9751Tier 3|r")
set Team1_Tier = 3
set Team1_TierUpgradeInProgress = false
call StartSound(Sound_General)
endif
// Team 2
else
if ( GetUnitTypeId(GetTriggerUnit()) == 'ostr' ) then
call RemoveUnit(GetTriggerUnit())
set Base_Team2 = CreateUnit(Player(0), 'ostr', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM2 + "just upgraded to |cff9DD2F4Tier 2|r")
set Team2_Tier = 2
set Team2_TierUpgradeInProgress = false
call StartSound(Sound_General)
else
call RemoveUnit(GetTriggerUnit())
set Base_Team2 = CreateUnit(Player(0), 'ofrt', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM2 + "just upgraded to |cffFF9751Tier 3|r")
set Team2_Tier = 3
set Team2_TierUpgradeInProgress = false
call StartSound(Sound_General)
endif
endif
// call KillSoundWhenDone(soundHandle)
endfunction
private function Conditions_AI_Tier_Upgrades takes nothing returns boolean
return AI_Active and ( Team1_Tier < 3 or Team2_Tier < 3 )
endfunction
private function AI_Tier_Upgrades_Team1_Callback takes nothing returns nothing
local integer gold = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD)
local integer id = GetPlayerId(GetEnumPlayer())
local item it
local string s
if gold >= T2_COST and Team1_Tier < 2 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team1_TierUpgradeInProgress then
set it = CreateItem('I010', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T2_COST)
set Team1_TierUpgradeInProgress = true
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 2 upgrade!" )
call Team_Message(1, s)
endif
if gold >= T3_COST and Team1_Tier < 3 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team1_TierUpgradeInProgress then
set it = CreateItem('I00Z', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T3_COST)
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 3 upgrade!" )
set Team1_TierUpgradeInProgress = true
call Team_Message(1, s)
endif
set it = null
endfunction
private function AI_Tier_Upgrades_Team2_Callback takes nothing returns nothing
local integer gold = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD)
local integer id = GetPlayerId(GetEnumPlayer())
local item it
local string s
if gold >= T2_COST and Team2_Tier < 2 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team2_TierUpgradeInProgress then
set it = CreateItem('I014', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T2_COST)
set Team2_TierUpgradeInProgress = true
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 2 upgrade!" )
call Team_Message(2, s)
endif
if gold >= T3_COST and Team2_Tier < 3 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team2_TierUpgradeInProgress then
set it = CreateItem('I016', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T3_COST)
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 3 upgrade!" )
set Team2_TierUpgradeInProgress = true
call Team_Message(2, s)
endif
set it = null
endfunction
private function AI_Tier_Upgrades takes nothing returns nothing
// Team 1
if Team1_Tier < 3 then
call ForForce( AI_Players_Team1, function AI_Tier_Upgrades_Team1_Callback )
endif
// Team 2
if Team2_Tier < 3 then
call ForForce( AI_Players_Team2, function AI_Tier_Upgrades_Team2_Callback )
endif
endfunction
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
// Tier Upgrades
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Tier_Upgrade ) )
call TriggerAddAction( trg, function Tier_Upgrade_Start )
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_UPGRADE_FINISH )
call TriggerAddCondition( trg, Condition( function Conditions_Tier_Upgrade_Finish ) )
call TriggerAddAction( trg, function Tier_Upgrade_Finish )
// AI players buy Upgrades
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 20.00, true)
call TriggerAddAction( trg, function AI_Buys_Upgrades )
// AI Tier Upgrades
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 40.00, true)
call TriggerAddCondition( trg, Condition( function Conditions_AI_Tier_Upgrades ) )
call TriggerAddAction( trg, function AI_Tier_Upgrades )
// Finish Research
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_RESEARCH_FINISH )
call TriggerAddAction( trg, function Finish_Research )
// Demolisher
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Demolisher ) )
call TriggerAddAction( trg, function Demolisher )
// Dragon
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Dragon ) )
call TriggerAddAction( trg, function Dragon )
// Iron Forged Swords
set Research_Array[1] = 'Rhme'
// Iron Plating
set Research_Array[2] = 'Rhar'
// Priest Adept Training
set Research_Array[3] = 'Rhpt'
// Caster Adept Training
set Research_Array[4] = 'Rhst'
// Strength of the Moon (Archers)
set Research_Array[5] = 'Resm'
// Moon Armor
set Research_Array[6] = 'Rema'
// Improved Bows
set Research_Array[7] = 'Reib'
// Improved Masonary
set Research_Array[8] = 'Rhac'
// Magic Sentry
set Research_Array[9] = 'Rhse'
set Research_Count = 9
set trg = null
endfunction
endlibrary
//TESH.alwaysfold=0
library UpgradeSystem initializer Init requires HeroSystem
globals
// constant integer UPGRADE_TIME_TIER1
integer array Research_Array[1] // stores all upgrades available
integer Research_Count = 0 // This is the number of available upgrades
integer Team1_Tier = 1
integer Team2_Tier = 1
boolean Team1_TierUpgradeInProgress = false
boolean Team2_TierUpgradeInProgress = false
boolean Full_Upgrades_Team1 = false
boolean Full_Upgrades_Team2 = false
constant integer T2_COST = 2500
constant integer T3_COST = 5000
// integer Team_Gold
integer AI_Team_Gold
integer DecAmount = 0
// currently unused
unit array Towers_Team1[1]
unit array Towers_Team2[1]
rect array Tower_Points_Team1[1]
rect array Tower_Points_Team2[1]
endglobals
function Check_Upgrades takes integer id returns boolean
if ( not ( GetPlayerTechCount(Player(id), 'Rhme', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhar', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhpt', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhst', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Resm', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rema', true) == 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Reib', true) == 2 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhac', true) >= 3 ) ) then
return false
endif
if ( not ( GetPlayerTechCount(Player(id), 'Rhse', true) >= 1 ) ) then
return false
endif
return true
endfunction
function Update_Upgrades_Status takes nothing returns nothing
// Team 1
if ( Check_Upgrades(1) ) then
set Full_Upgrades_Team1 = true
else
set Full_Upgrades_Team1 = false
endif
// Team 2
if ( Check_Upgrades(0) ) then
set Full_Upgrades_Team2 = true
else
set Full_Upgrades_Team2 = false
endif
endfunction
private function Finish_Research takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local string s
set s = ( UPGRADE + PlayerNames[id] + " just purchased a new Upgrade for your team!" )
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true ) then
// Set Tech Level for whole team
call SetPlayerTechResearched( Player(1), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(2), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(6), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(8), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(9), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(10), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
// Notice Message
call Team_Message(1, s)
// Team 2
else
// Set Tech Level for whole team
call SetPlayerTechResearched( Player(0), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(3), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(4), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(5), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(7), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
call SetPlayerTechResearched( Player(11), GetResearched(), GetPlayerTechCount(GetOwningPlayer(GetTriggerUnit()), GetResearched(), true))
// Notice Message
call Team_Message(2, s)
endif
endfunction
private function AI_Buys_Upgrades takes nothing returns nothing
local integer i
local unit u
set i = GetRandomInt(1, Research_Count)
set u = GroupPickRandomUnit(AI_Safes_Team1)
call IssueImmediateOrderById( u, Research_Array[i] )
set i = GetRandomInt(1, Research_Count)
set u = GroupPickRandomUnit(AI_Safes_Team2)
call IssueImmediateOrderById( u, Research_Array[i] )
call Update_Upgrades_Status()
set u = null
if Full_Upgrades_Team1 and Full_Upgrades_Team2 then
call DisableTrigger( GetTriggeringTrigger() )
call DestroyTrigger( GetTriggeringTrigger() )
endif
endfunction
private function Conditions_Demolisher takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I00X'
endfunction
private function Demolisher takes nothing returns nothing
// Team 1
if IsUnitTeam1(GetManipulatingUnit()) then
call CreateUnitAtLoc( GetOwningPlayer(GetManipulatingUnit()), 'ocat', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
// Team 2
else
call CreateUnitAtLoc( GetOwningPlayer(GetManipulatingUnit()), 'ocat', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
endif
call TriggerSleepAction(0.02)
call RemoveItem( GetManipulatedItem() )
endfunction
private function Conditions_Dragon takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) == 'I00R' or GetItemTypeId(GetManipulatedItem()) == 'I012'
endfunction
private function Dragon takes nothing returns nothing
local unit u
// Team 1
if IsUnitTeam1(GetManipulatingUnit()) then
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 1
call Order_Unit_To_Next_WP( u )
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 11
call Order_Unit_To_Next_WP( u )
set u = CreateUnitAtLoc( Player(1), 'n00A', GetUnitLoc(Base_Team1), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 21
call Order_Unit_To_Next_WP( u )
// Team 2
else
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 7
call Order_Unit_To_Next_WP( u )
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 17
call Order_Unit_To_Next_WP( u )
call CreateUnitAtLoc( Player(0), 'n003', GetUnitLoc(Base_Team2), bj_UNIT_FACING )
set waypoint_table[GetUnitId(u)] = 27
call Order_Unit_To_Next_WP( u )
endif
set u = null
call TriggerSleepAction(0.02)
call RemoveItem( GetManipulatedItem() )
endfunction
private function Conditions_Tier_Upgrade takes nothing returns boolean
// Keep / Stronghold
if ( GetItemTypeId(GetManipulatedItem()) == 'I010' ) or ( GetItemTypeId(GetManipulatedItem()) == 'I014' ) then
return true
endif
// Castle / Fortress
if ( GetItemTypeId(GetManipulatedItem()) == 'I00Z' ) or ( GetItemTypeId(GetManipulatedItem()) == 'I016' ) then
return true
endif
return false
endfunction
private function Tier_Upgrade_Start takes nothing returns nothing
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetManipulatingUnit()), Player(1)) == true ) then
if ( GetItemTypeId(GetManipulatedItem()) == 'I010' ) then
call IssueImmediateOrderById( Base_Team1, 'hkee' )
else
call IssueImmediateOrderById( Base_Team1, 'hcas' )
endif
// Team 2
else
// call Debug_Message("Team 2 Tier Upgrade start on "+ GetUnitName(Base_Team2))
if ( GetItemTypeId(GetManipulatedItem()) == 'I014' ) then
call IssueImmediateOrderById( Base_Team2, 'ostr' )
else
call IssueImmediateOrderById( Base_Team2, 'ofrt' )
endif
endif
endfunction
private function Conditions_Tier_Upgrade_Finish takes nothing returns boolean
// Keep / Stronghold
if ( GetUnitTypeId(GetTriggerUnit()) == 'hkee' ) or ( GetUnitTypeId(GetTriggerUnit()) == 'ostr' ) then
return true
endif
// Castle / Fortress
if ( GetUnitTypeId(GetTriggerUnit()) == 'hcas' ) or ( GetUnitTypeId(GetTriggerUnit()) == 'ofrt' )then
return true
endif
return false
endfunction
private function Tier_Upgrade_Finish takes nothing returns nothing
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit()) //+ 32
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true ) then
if ( GetUnitTypeId(GetTriggerUnit()) == 'hkee' ) then
call RemoveUnit(GetTriggerUnit())
set Base_Team1 = CreateUnit(Player(1), 'hkee', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM1 + "just upgraded to |cff9DD2F4Tier 2|r")
set Team1_Tier = 2
set Team1_TierUpgradeInProgress = false
call StartSound(Sound_General)
else
call RemoveUnit(GetTriggerUnit())
set Base_Team1 = CreateUnit(Player(1), 'hcas', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM1 + "just upgraded to |cffFF9751Tier 3|r")
set Team1_Tier = 3
set Team1_TierUpgradeInProgress = false
call StartSound(Sound_General)
endif
// Team 2
else
if ( GetUnitTypeId(GetTriggerUnit()) == 'ostr' ) then
call RemoveUnit(GetTriggerUnit())
set Base_Team2 = CreateUnit(Player(0), 'ostr', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM2 + "just upgraded to |cff9DD2F4Tier 2|r")
set Team2_Tier = 2
set Team2_TierUpgradeInProgress = false
call StartSound(Sound_General)
else
call RemoveUnit(GetTriggerUnit())
set Base_Team2 = CreateUnit(Player(0), 'ofrt', x, y, bj_UNIT_FACING)
call Team_Message(0, TEAM2 + "just upgraded to |cffFF9751Tier 3|r")
set Team2_Tier = 3
set Team2_TierUpgradeInProgress = false
call StartSound(Sound_General)
endif
endif
// call KillSoundWhenDone(soundHandle)
endfunction
private function Conditions_AI_Tier_Upgrades takes nothing returns boolean
return AI_Active and ( Team1_Tier < 3 or Team2_Tier < 3 )
endfunction
private function AI_Tier_Upgrades_Team1_Callback takes nothing returns nothing
local integer gold = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD)
local integer id = GetPlayerId(GetEnumPlayer())
local item it
local string s
if gold >= T2_COST and Team1_Tier < 2 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team1_TierUpgradeInProgress then
set it = CreateItem('I010', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T2_COST)
set Team1_TierUpgradeInProgress = true
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 2 upgrade!" )
call Team_Message(1, s)
endif
if gold >= T3_COST and Team1_Tier < 3 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team1_TierUpgradeInProgress then
set it = CreateItem('I00Z', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T3_COST)
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 3 upgrade!" )
set Team1_TierUpgradeInProgress = true
call Team_Message(1, s)
endif
set it = null
endfunction
private function AI_Tier_Upgrades_Team2_Callback takes nothing returns nothing
local integer gold = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD)
local integer id = GetPlayerId(GetEnumPlayer())
local item it
local string s
if gold >= T2_COST and Team2_Tier < 2 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team2_TierUpgradeInProgress then
set it = CreateItem('I014', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T2_COST)
set Team2_TierUpgradeInProgress = true
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 2 upgrade!" )
call Team_Message(2, s)
endif
if gold >= T3_COST and Team2_Tier < 3 and GetUnitState(Heroes[id], UNIT_STATE_LIFE) > 0 and not Team2_TierUpgradeInProgress then
set it = CreateItem('I016', GetUnitX(Heroes[id]), GetUnitY(Heroes[id]))
call UnitAddItem(Heroes[id], it)
call SetPlayerState(Player(id), PLAYER_STATE_RESOURCE_GOLD, gold - T3_COST)
set s = ( UPGRADE + PlayerNames[id] + " just initiated the Tier 3 upgrade!" )
set Team2_TierUpgradeInProgress = true
call Team_Message(2, s)
endif
set it = null
endfunction
private function AI_Tier_Upgrades takes nothing returns nothing
// Team 1
if Team1_Tier < 3 then
call ForForce( AI_Players_Team1, function AI_Tier_Upgrades_Team1_Callback )
endif
// Team 2
if Team2_Tier < 3 then
call ForForce( AI_Players_Team2, function AI_Tier_Upgrades_Team2_Callback )
endif
endfunction
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
// Tier Upgrades
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Tier_Upgrade ) )
call TriggerAddAction( trg, function Tier_Upgrade_Start )
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_UPGRADE_FINISH )
call TriggerAddCondition( trg, Condition( function Conditions_Tier_Upgrade_Finish ) )
call TriggerAddAction( trg, function Tier_Upgrade_Finish )
// AI players buy Upgrades
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 20.00, true)
call TriggerAddAction( trg, function AI_Buys_Upgrades )
// AI Tier Upgrades
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg, 40.00, true)
call TriggerAddCondition( trg, Condition( function Conditions_AI_Tier_Upgrades ) )
call TriggerAddAction( trg, function AI_Tier_Upgrades )
// Finish Research
set trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_RESEARCH_FINISH )
call TriggerAddAction( trg, function Finish_Research )
// Demolisher
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Demolisher ) )
call TriggerAddAction( trg, function Demolisher )
// Dragon
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition( trg, Condition( function Conditions_Dragon ) )
call TriggerAddAction( trg, function Dragon )
// Iron Forged Swords
set Research_Array[1] = 'Rhme'
// Iron Plating
set Research_Array[2] = 'Rhar'
// Priest Adept Training
set Research_Array[3] = 'Rhpt'
// Caster Adept Training
set Research_Array[4] = 'Rhst'
// Strength of the Moon (Archers)
set Research_Array[5] = 'Resm'
// Moon Armor
set Research_Array[6] = 'Rema'
// Improved Bows
set Research_Array[7] = 'Reib'
// Improved Masonary
set Research_Array[8] = 'Rhac'
// Magic Sentry
set Research_Array[9] = 'Rhse'
set Research_Count = 9
set trg = null
endfunction
endlibrary
//TESH.scrollpos=15
//TESH.alwaysfold=0
scope PlayerLeavesGame initializer Init
private function Actions takes nothing returns nothing
local integer id = GetPlayerId(GetTriggerPlayer())
local unit u = Heroes[id]
call Game_Message("A player has left the game. AI will now take over control")
call SetPlayerController(GetTriggerPlayer(), MAP_CONTROL_COMPUTER)
call ForceAddPlayer( AI_Players, GetTriggerPlayer() )
set AI_Active = true
// Team 1
if ( IsPlayerAlly(GetTriggerPlayer(), Player(1)) == true ) then
call ForceAddPlayer( AI_Players_Team1, GetTriggerPlayer() )
call GroupAddUnit( AI_Heroes_Team1, u )
// Team 2
else
call ForceAddPlayer( AI_Players_Team2, GetTriggerPlayer() )
call GroupAddUnit( AI_Heroes_Team2, u )
endif
call GroupAddUnit( AI_Heroes, u )
// If AI Hero, then go to next waypoint
set waypoint_table[GetUnitId(u)] = 5
call Order_Unit_To_Next_WP( u )
set u = null
// Check, if we have an AI only team now
call AI_Only_Check()
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterPlayerEvent(trg, Player(2), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(3), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(4), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(5), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(6), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(7), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(8), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(9), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(10), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(11), EVENT_PLAYER_LEAVE)
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope PlayerLeavesGame initializer Init
private function Actions takes nothing returns nothing
local integer id = GetPlayerId(GetTriggerPlayer())
local unit u = Heroes[id]
call Game_Message("A player has left the game. AI will now take over control")
call SetPlayerController(GetTriggerPlayer(), MAP_CONTROL_COMPUTER)
call ForceAddPlayer( AI_Players, GetTriggerPlayer() )
set AI_Active = true
// Team 1
if ( IsPlayerAlly(GetTriggerPlayer(), Player(1)) == true ) then
call ForceAddPlayer( AI_Players_Team1, GetTriggerPlayer() )
call GroupAddUnit( AI_Heroes_Team1, u )
// Team 2
else
call ForceAddPlayer( AI_Players_Team2, GetTriggerPlayer() )
call GroupAddUnit( AI_Heroes_Team2, u )
endif
call GroupAddUnit( AI_Heroes, u )
// If AI Hero, then go to next waypoint
set waypoint_table[GetUnitId(u)] = 5
call Order_Unit_To_Next_WP( u )
set u = null
// Check, if we have an AI only team now
call AI_Only_Check()
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterPlayerEvent(trg, Player(2), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(3), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(4), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(5), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(6), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(7), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(8), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(9), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(10), EVENT_PLAYER_LEAVE)
call TriggerRegisterPlayerEvent(trg, Player(11), EVENT_PLAYER_LEAVE)
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=3
//TESH.alwaysfold=0
scope Victory initializer Init
private function Conditions takes nothing returns boolean
return ( GetDyingUnit() == Base_Team1 or GetDyingUnit() == Base_Team2 )
endfunction
private function Defeat_Callback takes nothing returns nothing
call CustomDefeatBJ( GetEnumPlayer(), "The enemy team has defeated you!" )
endfunction
private function Victory_Callback takes nothing returns nothing
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endfunction
private function Actions takes nothing returns nothing
// Team 1 wins
if GetDyingUnit() == Base_Team2 then
call ShowScores(1)
// call ForForce(Players_Team1, function Victory_Callback)
// call ForForce(Players_Team2, function Defeat_Callback)
endif
// Team 2 wins
if GetDyingUnit() == Base_Team1 then
call ShowScores(2)
// call ForForce(Players_Team1, function Defeat_Callback)
// call ForForce(Players_Team2, function Victory_Callback)
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions ) )
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Victory initializer Init
private function Conditions takes nothing returns boolean
return ( GetDyingUnit() == Base_Team1 or GetDyingUnit() == Base_Team2 )
endfunction
private function Defeat_Callback takes nothing returns nothing
call CustomDefeatBJ( GetEnumPlayer(), "The enemy team has defeated you!" )
endfunction
private function Victory_Callback takes nothing returns nothing
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endfunction
private function Actions takes nothing returns nothing
// Team 1 wins
if GetDyingUnit() == Base_Team2 then
call ShowScores(1)
// call ForForce(Players_Team1, function Victory_Callback)
// call ForForce(Players_Team2, function Defeat_Callback)
endif
// Team 2 wins
if GetDyingUnit() == Base_Team1 then
call ShowScores(2)
// call ForForce(Players_Team1, function Defeat_Callback)
// call ForForce(Players_Team2, function Victory_Callback)
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions ) )
call TriggerAddAction( trg, function Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=16
//TESH.alwaysfold=0
scope HonorSystem initializer Init
private function CreepConditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and GetUnitLevel(GetTriggerUnit()) >= 6
endfunction
private function CreepHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
local integer i = 1
if GetUnitLevel(GetTriggerUnit()) >= 9 then
set i = 2
endif
call Debug_Message("Creep Honor "+I2S(i))
if IsPlayerAlly( Player(id), Player(1)) then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 1, id, i, i)
elseif IsPlayerAlly( Player(id), Player(0)) then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 2, id, i, i)
endif
endfunction
private function BuildingConditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function BuildingHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
if IsPlayerAlly( GetOwningPlayer(GetTriggerUnit()), Player(0)) == true then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 1, id, 1, 1)
elseif IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 2, id, 1, 1)
endif
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function BuildingConditions ) )
call TriggerAddAction( trg, function BuildingHonor )
// Creeps
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function CreepConditions ) )
call TriggerAddAction( trg, function CreepHonor )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope HonorSystem initializer Init
private function CreepConditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) and GetUnitLevel(GetTriggerUnit()) >= 6
endfunction
private function CreepHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
local integer i = 1
if GetUnitLevel(GetTriggerUnit()) >= 9 then
set i = 2
endif
call Debug_Message("Creep Honor "+I2S(i))
if IsPlayerAlly( Player(id), Player(1)) then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 1, id, i, i)
elseif IsPlayerAlly( Player(id), Player(0)) then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 2, id, i, i)
endif
endfunction
private function BuildingConditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function BuildingHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetKillingUnit()))
if IsPlayerAlly( GetOwningPlayer(GetTriggerUnit()), Player(0)) == true then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 1, id, 1, 1)
elseif IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), Player(1)) == true then
call AddHonorArea(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 2, id, 1, 1)
endif
endfunction
//===========================================================================
public function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function BuildingConditions ) )
call TriggerAddAction( trg, function BuildingHonor )
// Creeps
set trg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function CreepConditions ) )
call TriggerAddAction( trg, function CreepHonor )
set trg = null
endfunction
endscope
//TESH.scrollpos=338
//TESH.alwaysfold=0
library CaptureSystem initializer Init requires HeroSystem
globals
private constant real CAP_TIME = 15.0
private constant integer CAP_TICKS = 15
constant integer CAP_INCOME = 15
private constant integer CAP_POINTS = 3
private constant real CAP_TICK_TIME = 0.75
integer array CaptureProgress[1]
boolean array CaptureInProgress[1]
unit array CaptureUnits[1]
timer array CaptureTimers[1]
unit array CaptureBuildings[1]
unit array CaptureFlags[1]
unit array CaptureCircles[1]
string array CaptureCaptions[1]
// timerdialog array CaptureTimerWindows[1]
sound CaptureSound
sound CaptureSound_Done
endglobals
function PointIsHostile takes integer i, unit u returns boolean
if GetOwningPlayer(CaptureBuildings[i]) == Player(PLAYER_NEUTRAL_PASSIVE) then
return true
endif
if IsPlayerEnemy(GetOwningPlayer(CaptureBuildings[i]), GetOwningPlayer(u)) then
return true
endif
return false
endfunction
private function CreateCaptions takes nothing returns nothing
// Floating Text
call CreateTextTagLocBJ( CaptureCaptions[1], GetUnitLoc(CaptureBuildings[1]), 0, 14, 100.00, 100.00, 100.00, 0 )
call CreateTextTagLocBJ( CaptureCaptions[2], GetUnitLoc(CaptureBuildings[2]), 0, 14, 100.00, 100.00, 100.00, 0 )
call CreateTextTagLocBJ( CaptureCaptions[3], GetUnitLoc(CaptureBuildings[3]), 0, 14, 100.00, 100.00, 100.00, 0 )
endfunction
private function Hero_Reactivator_Callback takes nothing returns nothing
if GetUnitCurrentOrder(GetEnumUnit()) == Order_Stop and GetEnumUnit() != CaptureUnits[1] and GetEnumUnit() != CaptureUnits[2] and GetEnumUnit() != CaptureUnits[3] then
call Order_Unit_To_Next_WP(GetEnumUnit())
endif
endfunction
private function Hero_Reactivator takes nothing returns nothing
call ForGroup( AI_Heroes, function Hero_Reactivator_Callback )
endfunction
private function Gold_Tag takes unit TargetUnit, string Text returns nothing
local texttag t = CreateTextTag()
local string value
set Text = "|c00FFE57F" + Text + "|r"
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.03)
call SetTextTagPos(t, GetUnitX(TargetUnit), GetUnitY(TargetUnit), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
set t = null
endfunction
private function CreateCaptureTag takes unit u, string Text returns nothing
// local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
local texttag t = CreateTextTag()
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.03)
call SetTextTagPos(t, GetUnitX(u), GetUnitY(u), 0.00)
call SetTextTagVelocity(t, 0, 0.1)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
endfunction
private function Income_Team1 takes integer i returns nothing
call SetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD) + i )
endfunction
private function Income_Team2 takes integer i returns nothing
call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD) + i )
endfunction
private function Income takes nothing returns nothing
local integer i
// Cycle through all points
set i = 1
loop
exitwhen i > CAP_POINTS
// call Debug_Message("Cap Building :"+I2S(i))
// Team 1
if ( GetOwningPlayer(CaptureBuildings[i]) == Player(1)) then
call Income_Team1(CAP_INCOME)
call Gold_Tag(CaptureBuildings[i], "+" + I2S(CAP_INCOME)) // NumberOfPlayersTeam1
endif
if ( GetOwningPlayer(CaptureBuildings[i]) == Player(0)) then
call Income_Team2(CAP_INCOME)
call Gold_Tag(CaptureBuildings[i], "+" + I2S(CAP_INCOME))
endif
set i = i + 1
endloop
// Give Gold for Bases
call Income_Team1(CAP_INCOME)
call Gold_Tag(Base_Team1, "+" + I2S(CAP_INCOME))
call Income_Team2(CAP_INCOME)
call Gold_Tag(Base_Team2, "+" + I2S(CAP_INCOME))
endfunction
function Capture_Abort takes integer i returns boolean
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
call CreateCaptureTag(CaptureUnits[i], "|c00F83232Capture aborted!|r" )
call ReleaseTimer(CaptureTimers[i])
set CaptureInProgress[i] = false
set CaptureProgress[i] = CAP_TICKS
set CaptureUnits[i] = null
call StartSoundForPlayerBJ(Player(id), CaptureSound)
return true
endfunction
private function Check_Unit takes unit u returns boolean
local integer id
set id = 1
loop
exitwhen id > CAP_POINTS
if ( u == CaptureUnits[id] ) then
set u = null
return true
endif
set id = id + 1
endloop
set u = null
return false
endfunction
private function Get_Waypoint_After_Capture takes unit u, integer id returns integer
local integer i = 0
// Tavern
if id == 1 then
set i = 4
endif
// Lumber Mill
if id == 2 then
set i = 14
endif
// Farm
if id == 3 then
set i = 24
endif
return i
endfunction
private function Assist_Conditions takes nothing returns boolean
return ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true )
endfunction
private function GiveHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetEnumUnit()))
call Add_Honor(id, 1)
endfunction
private function Capture_Success takes integer i returns nothing
local unit u = CaptureUnits[i]
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
local group allies = NewGroup()
// call ReleaseTimer(CaptureTimers[i])
call Debug_Message("Capture done "+I2S(i))
set CaptureInProgress[i] = false
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) then
call SetUnitOwner( CaptureBuildings[i], Player(1), true )
call SetUnitOwner( CaptureFlags[i], Player(1), true )
call AddHonorArea(GetUnitX(CaptureUnits[i]), GetUnitY(CaptureUnits[i]), 1, id, 1, 1)
else
call SetUnitOwner( CaptureBuildings[i], Player(0), true )
call SetUnitOwner( CaptureFlags[i], Player(0), true )
call AddHonorArea(GetUnitX(CaptureUnits[i]), GetUnitY(CaptureUnits[i]), 2, id, 1, 1)
endif
// +1 Honor Point
// call Add_Honor(id, 1)
// Get allies in range and give honor
call GroupEnumUnitsInRange(allies, GetUnitX(u), GetUnitY(u), GENERIC_ASSIST_RANGE, Condition(function Assist_Conditions))
call ForGroup( allies, function GiveHonor )
call CreateCaptureTag(u, "|c00BDF1A9Point captured!|r" )
// + XP
// call DES_MOCO_AddDirectXP(CaptureUnits[id], 75)
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) then
call Team_Message(1, TEAM1 + "captured the " + CaptureCaptions[i])
// Team 2
else
call Team_Message(2, TEAM2 + "captured the " + CaptureCaptions[i])
endif
// AI
if ( IsUnitInGroup(CaptureUnits[i], AI_Heroes) == true ) then
set waypoint_table[GetUnitId(CaptureUnits[i])] = Get_Waypoint_After_Capture(CaptureUnits[i], i)
call Order_Unit_To_Next_WP(CaptureUnits[i])
endif
call StartSound(CaptureSound_Done)
set CaptureUnits[i] = null
call ReleaseGroup(allies)
set allies = null
set u = null
endfunction
private function Capture_Callback takes nothing returns nothing
local integer i = GetTimerData(GetExpiredTimer())
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
if CaptureProgress[i] <= 0 then
call ReleaseTimer(GetExpiredTimer())
call Capture_Success(i)
else
call CreateCaptureTag(CaptureUnits[i], "|c00" + PlayerColors[id] + I2S(CaptureProgress[i]) + "|r" )
set CaptureProgress[i] = CaptureProgress[i] - 1
endif
endfunction
function Capture_AI takes integer i returns nothing
call TriggerSleepAction(.5)
// call IssuePointOrder( CaptureUnits[i], "patrol", GetUnitX(CaptureCircles[i])-16, GetUnitY(CaptureCircles[i])-16 )
// set waypoint_table[GetUnitId(CaptureUnits[i])] = 60+i
call IssueImmediateOrder( CaptureUnits[i], "holdposition" )
call Debug_Message("Capture AI: "+I2S(i)+" "+GetUnitName(CaptureUnits[i]))
endfunction
private function Capture_Start takes integer i, unit u returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
set CaptureInProgress[i] = true
set CaptureUnits[i] = u
set CaptureProgress[i] = CAP_TICKS
call CreateCaptureTag(u, "|c00FDD484Capture started!|r" )
// If Capture Unit is AI, then make it hold position
if ( IsUnitInGroup(u, AI_Heroes) == true ) then
call Capture_AI(i)
endif
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(0)) == true ) and ( GetOwningPlayer(CaptureBuildings[i]) == Player(1)) then
call Team_Message(1, "The |cffFF1C1Cenemy|r is capturing your points! (" + CaptureCaptions[i] + ")")
endif
// Team 2
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) and ( GetOwningPlayer(CaptureBuildings[i]) == Player(0)) then
call Team_Message(2, "The |cffFF1C1Cenemy|r is capturing your points! (" + CaptureCaptions[i] + ")")
endif
// Start timer
set CaptureTimers[i] = NewTimer()
call SetTimerData(CaptureTimers[i], i)
call TimerStart(CaptureTimers[i], CAP_TICK_TIME, true, function Capture_Callback)
call StartSoundForPlayerBJ(Player(id), CaptureSound)
endfunction
function Capture_Enter takes integer i returns boolean
// call Debug_Message("On enter "+I2S(i))
// Triggering unit has to be a hero
if IsHero(GetTriggerUnit()) == false then
return false
endif
// Only works if point neutral or hostile
if PointIsHostile(i, GetTriggerUnit()) == false then
return false
endif
if UnitHasBuff(GetTriggerUnit(), BUFF_TYPE_STEALTH) then
call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0,5,"|cffFF6A6AYou cannot capture while in stealth mode!|r")
return false
endif
// No capturing in progess
if ( CaptureInProgress[i] == false ) then
call Capture_Start(i,GetTriggerUnit())
endif
return true
endfunction
// =====================================================
private function Init takes nothing returns nothing
local integer i = 1
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction( trg, function Income )
// Hero Reactivator
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction(trg, function Hero_Reactivator)
// Init Capture Timers
set i = 1
loop
exitwhen i > CAP_POINTS
set CaptureTimers[i] = NewTimer()
set i = i + 1
endloop
// init Sound
call Preload( "Sound\\Interface\\QuestLog.wav" )
call Preload( "Sound\\Interface\\ArrangedTeamInvitation.wav" )
set CaptureSound = CreateSound("Sound\\Interface\\QuestLog.wav", false, false, true, 12700, 12700, "")
set CaptureSound_Done = CreateSound("Sound\\Interface\\ArrangedTeamInvitation.wav", false, false, true, 12700, 12700, "")
// Tavern
set CaptureCaptions[1] = "|cffCFEE93Tavern|r"
set CaptureBuildings[1] = gg_unit_n004_0021
set CaptureFlags[1] = gg_unit_h000_0011
set CaptureCircles[1] = gg_unit_ncp2_0003
// Lumber mill
set CaptureCaptions[2] = "|cffBBA48FLumber Mill|r"
set CaptureBuildings[2] = gg_unit_hlum_0037
set CaptureFlags[2] = gg_unit_h000_0019
set CaptureCircles[2] = gg_unit_ncp2_0020
// Farm
set CaptureCaptions[3] = "|cffFF9A40Farm|r"
set CaptureBuildings[3] = gg_unit_hhou_0015
set CaptureFlags[3] = gg_unit_h000_0016
set CaptureCircles[3] = gg_unit_ncp2_0001
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, false)
call TriggerAddAction( trg, function CreateCaptions )
set trg = null
endfunction
endlibrary
//TESH.alwaysfold=0
library CaptureSystem initializer Init requires HeroSystem
globals
private constant real CAP_TIME = 15.0
private constant integer CAP_TICKS = 15
constant integer CAP_INCOME = 15
private constant integer CAP_POINTS = 3
private constant real CAP_TICK_TIME = 0.75
integer array CaptureProgress[1]
boolean array CaptureInProgress[1]
unit array CaptureUnits[1]
timer array CaptureTimers[1]
unit array CaptureBuildings[1]
unit array CaptureFlags[1]
unit array CaptureCircles[1]
string array CaptureCaptions[1]
// timerdialog array CaptureTimerWindows[1]
sound CaptureSound
sound CaptureSound_Done
endglobals
function PointIsHostile takes integer i, unit u returns boolean
if GetOwningPlayer(CaptureBuildings[i]) == Player(PLAYER_NEUTRAL_PASSIVE) then
return true
endif
if IsPlayerEnemy(GetOwningPlayer(CaptureBuildings[i]), GetOwningPlayer(u)) then
return true
endif
return false
endfunction
private function CreateCaptions takes nothing returns nothing
// Floating Text
call CreateTextTagLocBJ( CaptureCaptions[1], GetUnitLoc(CaptureBuildings[1]), 0, 14, 100.00, 100.00, 100.00, 0 )
call CreateTextTagLocBJ( CaptureCaptions[2], GetUnitLoc(CaptureBuildings[2]), 0, 14, 100.00, 100.00, 100.00, 0 )
call CreateTextTagLocBJ( CaptureCaptions[3], GetUnitLoc(CaptureBuildings[3]), 0, 14, 100.00, 100.00, 100.00, 0 )
endfunction
private function Hero_Reactivator_Callback takes nothing returns nothing
if GetUnitCurrentOrder(GetEnumUnit()) == Order_Stop and GetEnumUnit() != CaptureUnits[1] and GetEnumUnit() != CaptureUnits[2] and GetEnumUnit() != CaptureUnits[3] then
call Order_Unit_To_Next_WP(GetEnumUnit())
endif
endfunction
private function Hero_Reactivator takes nothing returns nothing
call ForGroup( AI_Heroes, function Hero_Reactivator_Callback )
endfunction
private function Gold_Tag takes unit TargetUnit, string Text returns nothing
local texttag t = CreateTextTag()
local string value
set Text = "|c00FFE57F" + Text + "|r"
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.03)
call SetTextTagPos(t, GetUnitX(TargetUnit), GetUnitY(TargetUnit), 0.00)
call SetTextTagVelocity(t, 0, 0.03)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 4)
call SetTextTagPermanent(t, false)
set t = null
endfunction
private function CreateCaptureTag takes unit u, string Text returns nothing
// local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
local texttag t = CreateTextTag()
call SetTextTagColor(t, 182, 91, 234, 255)
call SetTextTagText(t, Text, 0.03)
call SetTextTagPos(t, GetUnitX(u), GetUnitY(u), 0.00)
call SetTextTagVelocity(t, 0, 0.1)
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 3)
call SetTextTagLifespan(t, 3)
call SetTextTagPermanent(t, false)
set t = null
endfunction
private function Income_Team1 takes integer i returns nothing
call SetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(6), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(8), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(10), PLAYER_STATE_RESOURCE_GOLD) + i )
endfunction
private function Income_Team2 takes integer i returns nothing
call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(3), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(4), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(5), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_GOLD) + i )
call SetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(11), PLAYER_STATE_RESOURCE_GOLD) + i )
endfunction
private function Income takes nothing returns nothing
local integer i
// Cycle through all points
set i = 1
loop
exitwhen i > CAP_POINTS
// call Debug_Message("Cap Building :"+I2S(i))
// Team 1
if ( GetOwningPlayer(CaptureBuildings[i]) == Player(1)) then
call Income_Team1(CAP_INCOME)
call Gold_Tag(CaptureBuildings[i], "+" + I2S(CAP_INCOME)) // NumberOfPlayersTeam1
endif
if ( GetOwningPlayer(CaptureBuildings[i]) == Player(0)) then
call Income_Team2(CAP_INCOME)
call Gold_Tag(CaptureBuildings[i], "+" + I2S(CAP_INCOME))
endif
set i = i + 1
endloop
// Give Gold for Bases
call Income_Team1(CAP_INCOME)
call Gold_Tag(Base_Team1, "+" + I2S(CAP_INCOME))
call Income_Team2(CAP_INCOME)
call Gold_Tag(Base_Team2, "+" + I2S(CAP_INCOME))
endfunction
function Capture_Abort takes integer i returns boolean
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
call CreateCaptureTag(CaptureUnits[i], "|c00F83232Capture aborted!|r" )
call ReleaseTimer(CaptureTimers[i])
set CaptureInProgress[i] = false
set CaptureProgress[i] = CAP_TICKS
set CaptureUnits[i] = null
call StartSoundForPlayerBJ(Player(id), CaptureSound)
return true
endfunction
private function Check_Unit takes unit u returns boolean
local integer id
set id = 1
loop
exitwhen id > CAP_POINTS
if ( u == CaptureUnits[id] ) then
set u = null
return true
endif
set id = id + 1
endloop
set u = null
return false
endfunction
private function Get_Waypoint_After_Capture takes unit u, integer id returns integer
local integer i = 0
// Tavern
if id == 1 then
set i = 4
endif
// Lumber Mill
if id == 2 then
set i = 14
endif
// Farm
if id == 3 then
set i = 24
endif
return i
endfunction
private function Assist_Conditions takes nothing returns boolean
return ( IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == true )
endfunction
private function GiveHonor takes nothing returns nothing
local integer id = GetPlayerId(GetOwningPlayer(GetEnumUnit()))
call Add_Honor(id, 1)
endfunction
private function Capture_Success takes integer i returns nothing
local unit u = CaptureUnits[i]
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
local group allies = NewGroup()
// call ReleaseTimer(CaptureTimers[i])
call Debug_Message("Capture done "+I2S(i))
set CaptureInProgress[i] = false
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) then
call SetUnitOwner( CaptureBuildings[i], Player(1), true )
call SetUnitOwner( CaptureFlags[i], Player(1), true )
call AddHonorArea(GetUnitX(CaptureUnits[i]), GetUnitY(CaptureUnits[i]), 1, id, 1, 1)
else
call SetUnitOwner( CaptureBuildings[i], Player(0), true )
call SetUnitOwner( CaptureFlags[i], Player(0), true )
call AddHonorArea(GetUnitX(CaptureUnits[i]), GetUnitY(CaptureUnits[i]), 2, id, 1, 1)
endif
// +1 Honor Point
// call Add_Honor(id, 1)
// Get allies in range and give honor
call GroupEnumUnitsInRange(allies, GetUnitX(u), GetUnitY(u), GENERIC_ASSIST_RANGE, Condition(function Assist_Conditions))
call ForGroup( allies, function GiveHonor )
call CreateCaptureTag(u, "|c00BDF1A9Point captured!|r" )
// + XP
// call DES_MOCO_AddDirectXP(CaptureUnits[id], 75)
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) then
call Team_Message(1, TEAM1 + "captured the " + CaptureCaptions[i])
// Team 2
else
call Team_Message(2, TEAM2 + "captured the " + CaptureCaptions[i])
endif
// AI
if ( IsUnitInGroup(CaptureUnits[i], AI_Heroes) == true ) then
set waypoint_table[GetUnitId(CaptureUnits[i])] = Get_Waypoint_After_Capture(CaptureUnits[i], i)
call Order_Unit_To_Next_WP(CaptureUnits[i])
endif
call StartSound(CaptureSound_Done)
set CaptureUnits[i] = null
call ReleaseGroup(allies)
set allies = null
set u = null
endfunction
private function Capture_Callback takes nothing returns nothing
local integer i = GetTimerData(GetExpiredTimer())
local integer id = GetPlayerId(GetOwningPlayer(CaptureUnits[i]))
if CaptureProgress[i] <= 0 then
call ReleaseTimer(GetExpiredTimer())
call Capture_Success(i)
else
call CreateCaptureTag(CaptureUnits[i], "|c00" + PlayerColors[id] + I2S(CaptureProgress[i]) + "|r" )
set CaptureProgress[i] = CaptureProgress[i] - 1
endif
endfunction
function Capture_AI takes integer i returns nothing
call TriggerSleepAction(.5)
// call IssuePointOrder( CaptureUnits[i], "patrol", GetUnitX(CaptureCircles[i])-16, GetUnitY(CaptureCircles[i])-16 )
// set waypoint_table[GetUnitId(CaptureUnits[i])] = 60+i
call IssueImmediateOrder( CaptureUnits[i], "holdposition" )
call Debug_Message("Capture AI: "+I2S(i)+" "+GetUnitName(CaptureUnits[i]))
endfunction
private function Capture_Start takes integer i, unit u returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
set CaptureInProgress[i] = true
set CaptureUnits[i] = u
set CaptureProgress[i] = CAP_TICKS
call CreateCaptureTag(u, "|c00FDD484Capture started!|r" )
// If Capture Unit is AI, then make it hold position
if ( IsUnitInGroup(u, AI_Heroes) == true ) then
call Capture_AI(i)
endif
// Team 1
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(0)) == true ) and ( GetOwningPlayer(CaptureBuildings[i]) == Player(1)) then
call Team_Message(1, "The |cffFF1C1Cenemy|r is capturing your points! (" + CaptureCaptions[i] + ")")
endif
// Team 2
if ( IsPlayerAlly(GetOwningPlayer(CaptureUnits[i]), Player(1)) == true ) and ( GetOwningPlayer(CaptureBuildings[i]) == Player(0)) then
call Team_Message(2, "The |cffFF1C1Cenemy|r is capturing your points! (" + CaptureCaptions[i] + ")")
endif
// Start timer
set CaptureTimers[i] = NewTimer()
call SetTimerData(CaptureTimers[i], i)
call TimerStart(CaptureTimers[i], CAP_TICK_TIME, true, function Capture_Callback)
call StartSoundForPlayerBJ(Player(id), CaptureSound)
endfunction
function Capture_Enter takes integer i returns boolean
// call Debug_Message("On enter "+I2S(i))
// Triggering unit has to be a hero
if IsHero(GetTriggerUnit()) == false then
return false
endif
// Only works if point neutral or hostile
if PointIsHostile(i, GetTriggerUnit()) == false then
return false
endif
if UnitHasBuff(GetTriggerUnit(), BUFF_TYPE_STEALTH) then
call DisplayTimedTextToPlayer(GetOwningPlayer(GetTriggerUnit()),0,0,5,"|cffFF6A6AYou cannot capture while in stealth mode!|r")
return false
endif
// No capturing in progess
if ( CaptureInProgress[i] == false ) then
call Capture_Start(i,GetTriggerUnit())
endif
return true
endfunction
// =====================================================
private function Init takes nothing returns nothing
local integer i = 1
local trigger trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction( trg, function Income )
// Hero Reactivator
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, true)
call TriggerAddAction(trg, function Hero_Reactivator)
// Init Capture Timers
set i = 1
loop
exitwhen i > CAP_POINTS
set CaptureTimers[i] = NewTimer()
set i = i + 1
endloop
// init Sound
call Preload( "Sound\\Interface\\QuestLog.wav" )
call Preload( "Sound\\Interface\\ArrangedTeamInvitation.wav" )
set CaptureSound = CreateSound("Sound\\Interface\\QuestLog.wav", false, false, true, 12700, 12700, "")
set CaptureSound_Done = CreateSound("Sound\\Interface\\ArrangedTeamInvitation.wav", false, false, true, 12700, 12700, "")
// Tavern
set CaptureCaptions[1] = "|cffCFEE93Tavern|r"
set CaptureBuildings[1] = gg_unit_n004_0021
set CaptureFlags[1] = gg_unit_h000_0011
set CaptureCircles[1] = gg_unit_ncp2_0003
// Lumber mill
set CaptureCaptions[2] = "|cffBBA48FLumber Mill|r"
set CaptureBuildings[2] = gg_unit_hlum_0037
set CaptureFlags[2] = gg_unit_h000_0019
set CaptureCircles[2] = gg_unit_ncp2_0020
// Farm
set CaptureCaptions[3] = "|cffFF9A40Farm|r"
set CaptureBuildings[3] = gg_unit_hhou_0015
set CaptureFlags[3] = gg_unit_h000_0016
set CaptureCircles[3] = gg_unit_ncp2_0001
set trg = CreateTrigger( )
call TriggerRegisterTimerEvent(trg, 5.00, false)
call TriggerAddAction( trg, function CreateCaptions )
set trg = null
endfunction
endlibrary
//TESH.scrollpos=36
//TESH.alwaysfold=0
scope Tavern initializer Init
globals
private constant integer ID = 1
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call Debug_Message("Tavern AI in range..")
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_Tavern )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_Tavern )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0003 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Tavern initializer Init
globals
private constant integer ID = 1
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call Debug_Message("Tavern AI in range..")
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_Tavern )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_Tavern )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0003 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=35
//TESH.alwaysfold=0
scope LumberMill initializer Init
globals
private constant integer ID = 2
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_LumberMill )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_LumberMill )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0020 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope LumberMill initializer Init
globals
private constant integer ID = 2
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_LumberMill )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_LumberMill )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0020 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=40
//TESH.alwaysfold=0
scope Farm initializer Init
globals
private constant integer ID = 3
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Conditions_Enter takes nothing returns boolean
return GetTriggerUnit() != CaptureUnits[ID]
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_Farm )
call TriggerAddCondition( trg, Condition( function Conditions_Enter ) )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_Farm )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0001 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.alwaysfold=0
scope Farm initializer Init
globals
private constant integer ID = 3
endglobals
private function Conditions_AI takes nothing returns boolean
// AI Hero
if not IsUnitInGroup(GetTriggerUnit(), AI_Heroes) == true then
return false
endif
// Building already taken?
if IsPlayerAlly(GetOwningPlayer(CaptureBuildings[ID]), GetOwningPlayer(GetTriggerUnit())) == true then
if ( not (GetOwningPlayer(CaptureBuildings[ID]) == Player(PLAYER_NEUTRAL_PASSIVE)) ) then
return false
endif
endif
return true
endfunction
private function AI_Actions takes nothing returns nothing
call IssuePointOrderLoc( GetTriggerUnit(), "move", GetUnitLoc(CaptureCircles[ID]) )
endfunction
private function Conditions_Break takes nothing returns boolean
if not (GetTriggerUnit() == CaptureUnits[ID] )then
return false
endif
if not ( CaptureInProgress[ID] ) then
return false
endif
return true
endfunction
private function Break takes nothing returns nothing
call Capture_Abort(ID)
endfunction
private function Conditions_Enter takes nothing returns boolean
return GetTriggerUnit() != CaptureUnits[ID]
endfunction
private function Enter takes nothing returns nothing
call Capture_Enter(ID)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger( )
// Enter
call TriggerRegisterEnterRectSimple( trg, gg_rct_Farm )
call TriggerAddCondition( trg, Condition( function Conditions_Enter ) )
call TriggerAddAction( trg, function Enter )
// Break
set trg = CreateTrigger()
call TriggerRegisterLeaveRectSimple( trg, gg_rct_Farm )
call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( trg, Condition( function Conditions_Break ) )
call TriggerAddAction( trg, function Break )
// AI
// set trg = CreateTrigger()
// call TriggerRegisterUnitInRangeSimple( trg, 2400.00, gg_unit_ncp2_0001 )
// call TriggerAddCondition( trg, Condition( function Conditions_AI ) )
// call TriggerAddAction( trg, function AI_Actions )
set trg = null
endfunction
endscope
//TESH.scrollpos=268
//TESH.alwaysfold=0
library SpellTable initializer Init requires TimerUtils
globals
private constant integer SPELL_MAX = 256
private integer Spell_Count = 0
spell array spells[1]
Table SpellTab
integer EFFECT_ID = 0
constant integer MAX_EFFECTS = 256
effect array EffectTable[1]
// Shared
constant real RANDOM_DAMAGE_MIN = 0.95
constant real RANDOM_DAMAGE_MAX = 1.05
constant real GENERIC_AOE_RANGE = 400.00
constant real GENERIC_DOT_INTERVAL = 1.3 // 1.2
constant real GENERIC_BUFF_DURATION = 20.00
constant real DISPEL_RADIUS = 256.00 // area dispel
// Warrior
constant real CHARGE_DAMAGE = 4.00
constant real SHIELD_SLAM_DAMAGE = 1.75
constant real SLAM_RANGE = 300.00
// Mage
constant real FROST_BOLT_DAMAGE = 3.00
constant real FREEZING_CHANCE = 30
constant real FREEZE_DURATION = 3.00
constant real FIRE_NOVA_DAMAGE = 2.25
constant real ICE_BARRIER_HEALTH = 8.00
constant real ICE_BARRIER_DURATION = 30.00
constant real SHEEP_DURATION = 5.00
// Druid
constant real MOON_FIRE_DAMAGE = 3.00
constant real REJUVENATION_HEALTH_PER_TICK = 1.0
constant real REJUVENATION_TICKS = 8.00
constant real MARKOFTHEWILD_HEALTH_BONUS = 10.00
constant real MARKOFTHEWILD_MANA_BONUS = 10.00
constant real MARKOFTHEWILD_ARMOR_BONUS = 1.00 // 0.20
constant real ROOTS_DAMAGE = 1.00
constant real ROOTS_TICKS = 3.00
constant real CLAW_STRIKE_DAMAGE = 3.00
constant real BASH_DAMAGE = 1.50
// Priest
constant real SHIELD_LIFE = 7.50
constant real SHIELD_DURATION = 30.00
constant real HOLY_NOVA_POWER = 2.50
constant real FEAR_TICKS = 5.00
constant real HEALING_TOUCH_POWER = 4.50
constant real MANA_BURN_DAMAGE = 2.00
constant real SHADOW_WORD_TICKS = 8.00
constant real SHADOW_WORD_DAMAGE = 0.75
constant real FEAR_MAX_TARGETS = 5
// Paladin
constant real HOLY_LIGHT_POWER = 5.00
constant real PURGE_POWER = 2.75
constant real PURGE_MOVEMENT_FACTOR = 0.50
constant real PURGE_DURATION = 3.00
constant real CALL_OF_JUSTICE_DAMAGE = 2.0
// Shaman
constant real EARTH_SHOCK_DAMAGE = 3.0
constant real HEALING_WAVE_POWER = 4.5
constant integer HEALING_WAVE_MAX_TARGETS = 4
constant real HEALING_WAVE_LOSS_FACTOR = 0.75
constant real FIRE_AND_ICE_FACTOR = 0.15
constant real FIRE_AND_ICE_DURATION = 30.00
constant real TOTEM_DURATION = 15.00
// Rogue
constant real FAN_OF_KNIVES_DAMAGE = 1.50
constant real DEADLY_STRIKE_DAMAGE = 2.00
constant real DEADLY_STRIKE_TICKS = 5.00
constant real DEADLY_STRIKE_TICK_FACTOR = 0.3 // tick damage is multiplied with this factor
constant real BACKSTAB_DAMAGE = 3.25
constant real STEALTH_DURATION = 30.00
// Hunter
constant real CRITICAL_SHOT_DAMAGE = 3.00
constant real CRITICAL_SHOT_TICKS = 3.00
constant real CRITICAL_SHOT_TICK_FACTOR = 0.30
constant real CRITICAL_SHOT_MOVEMENT_FACTOR = 0.7
constant real MULTI_SHOT_DAMAGE = 2.00
constant real MULTI_SHOT_RANGE = 200
// Necromancer
constant real SOUL_SHIELD_HEALTH = 5.00
constant real SOUL_SHIELD_DURATION = 30.00
constant real SOUL_SHIELD_HARVEST_PERCENT = 25.00
constant real VAMPIRIC_CURSE_TICKS = 7.00
constant real VAMPIRIC_CURSE_DAMAGE = 1.00
constant real VAMPIRIC_CURSE_HEALTH_FACTOR = 0.5
constant real DARK_CONSUMPTION_DAMAGE = 1.00
constant integer DARK_CONSUMPTION_TICKS = 5
constant real DARK_CONSUMPTION_RANGE = 200
// constant real BRUTAL_STRIKE_DAMAGE = 2.50
// constant real BRUTAL_STRIKE_TICKS = 3.00
// constant real BRUTAL_STRIKE_TICK_FACTOR = 0.3
constant real BEYOND_DEATH_DAMAGE = 2.00
constant real BEYOND_DEATH_DURATION = 15.00
// Ent
constant real ROCK_DAMAGE = 3.0
constant real BEAM_DAMAGE = 2.5
// Other
constant real FLAME_SHOCK_DAMAGE = 5.00
endglobals
struct spell
integer id = 0
unit caster = null
unit target = null
real x = 0
real y = 0
location loc = null
real damage = 0.0
boolean isCrit = false
real health = 0.0
real mana = 0.0
real armor = 0.0
real speed = 0.0
integer ticks = 0
integer effect_id = 0
method onDestroy takes nothing returns nothing
call RemoveLocation(.loc)
endmethod
endstruct
function GetSpellCaster takes integer id returns unit
return spells[id].caster
endfunction
function GetSpellTarget takes integer id returns unit
return spells[id].target
endfunction
function GetSpellDamage takes integer id returns real
return spells[id].damage
endfunction
function GetSpellLocation takes integer id returns location
return spells[id].loc
endfunction
function GetSpellHealth takes integer id returns real
return spells[id].health
endfunction
function GetSpellMana takes integer id returns real
return spells[id].mana
endfunction
function GetSpellCrit takes integer id returns boolean
return spells[id].isCrit
endfunction
function GetSpellTicks takes integer id returns integer
return spells[id].ticks
endfunction
function GetSpellEffectId takes integer id returns integer
return spells[id].effect_id
endfunction
function SetSpellEffectId takes integer id, integer value returns nothing
set spells[id].effect_id = value
endfunction
function GetRandomSpellMod takes nothing returns real
return GetRandomReal(RANDOM_DAMAGE_MIN, RANDOM_DAMAGE_MAX)
endfunction
function GetSpell takes integer id returns spell
return spells[id]
endfunction
function IncSpellTicks takes integer id returns nothing
set spells[id].ticks = spells[id].ticks + 1
endfunction
function ReleaseEffect takes integer id returns nothing
if EffectTable[id ] != null then
call DestroyEffect(EffectTable[id ])
set EffectTable[id ] = null
// call Debug_Message("Destroy Effect id "+I2S(id))
endif
endfunction
function SetMoveSpeed takes unit u returns nothing
local real normal_speed = GetUnitDefaultMoveSpeed(u)
call SetUnitMoveSpeed(u, normal_speed)
// Purge
if UnitHasBuff(u, BUFF_TYPE_PURGE) then
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u)*PURGE_MOVEMENT_FACTOR )
endif
// Critical Shot
if UnitHasBuff(u, BUFF_TYPE_CRITICAL_SHOT) then
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u)*CRITICAL_SHOT_MOVEMENT_FACTOR )
endif
// Roots
if UnitHasBuff(u, BUFF_TYPE_ROOTS) then
call SetUnitMoveSpeed(u, 0)
endif
// Frozen
if UnitHasBuff(u, BUFF_TYPE_FROZEN) then
call SetUnitMoveSpeed(u, 0)
endif
endfunction
private function RegisterEffectTimerCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
// call Debug_Message("Release Effect Timer Callback id "+I2S(id))
call ReleaseTimer(t)
call ReleaseEffect(id)
set t = null
endfunction
// Effects with timed life are automatically destroyed
function RegisterEffect takes effect e, real lifespan returns integer
local timer t
local integer id = EFFECT_ID
// If an old effect hasn't cleaned up -> destroy
if EffectTable[id] != null then
call DestroyEffect(EffectTable[id])
endif
// Store Effect and inc ID
set EffectTable[id] = e
if EFFECT_ID < MAX_EFFECTS - 1 then
set EFFECT_ID = EFFECT_ID + 1
else
set EFFECT_ID = 0
endif
// Timed life?
if lifespan > 0 then
set t = NewTimer()
call SetTimerData(t, id)
call TimerStart(t, lifespan, false, function RegisterEffectTimerCallback)
endif
// call Debug_Message("Effect registered, id: "+I2S(id))
set t = null
return id
endfunction
function ReleaseSpell takes integer id returns nothing
call spell.destroy(spells[id])
// call Debug_Message("Spell released: "+I2S(id))
endfunction
function RegisterSpell takes unit caster, unit target, location loc, real damage, boolean crit, real health, real mana, real armor, real speed, integer ticks, integer effect_id returns integer
local spell thisSpell = spell.create()
set thisSpell.id = Spell_Count // SetSpellId()
set thisSpell.caster = caster
set thisSpell.target = target
set thisSpell.loc = loc
set thisSpell.damage = damage
set thisSpell.isCrit = crit
set thisSpell.health = health
set thisSpell.mana = mana
set thisSpell.armor = armor
set thisSpell.speed = speed
set thisSpell.ticks = ticks
set thisSpell.effect_id = effect_id
if Spell_Count >= SPELL_MAX-1 then
set Spell_Count = 0
else
set Spell_Count = Spell_Count + 1
endif
set spells[thisSpell.id] = thisSpell
// call Debug_Message("Spell registered: "+I2S(thisSpell.id))
return thisSpell.id
endfunction
private function Init takes nothing returns nothing
set SpellTab = Table.create()
endfunction
endlibrary
//TESH.alwaysfold=0
library SpellTable initializer Init requires TimerUtils
globals
private constant integer SPELL_MAX = 256
private integer Spell_Count = 0
spell array spells[1]
Table SpellTab
integer EFFECT_ID = 0
constant integer MAX_EFFECTS = 256
effect array EffectTable[1]
// Shared
constant real RANDOM_DAMAGE_MIN = 0.95
constant real RANDOM_DAMAGE_MAX = 1.05
constant real GENERIC_AOE_RANGE = 400.00
constant real GENERIC_DOT_INTERVAL = 1.3 // 1.2
constant real GENERIC_BUFF_DURATION = 20.00
constant real DISPEL_RADIUS = 256.00 // area dispel
// Warrior
constant real CHARGE_DAMAGE = 4.00
constant real SHIELD_SLAM_DAMAGE = 1.75
constant real SLAM_RANGE = 300.00
// Mage
constant real FROST_BOLT_DAMAGE = 3.00
constant real FREEZING_CHANCE = 30
constant real FREEZE_DURATION = 3.00
constant real FIRE_NOVA_DAMAGE = 2.25
constant real ICE_BARRIER_HEALTH = 8.00
constant real ICE_BARRIER_DURATION = 30.00
constant real SHEEP_DURATION = 5.00
// Druid
constant real MOON_FIRE_DAMAGE = 3.00
constant real REJUVENATION_HEALTH_PER_TICK = 1.0
constant real REJUVENATION_TICKS = 8.00
constant real MARKOFTHEWILD_HEALTH_BONUS = 10.00
constant real MARKOFTHEWILD_MANA_BONUS = 10.00
constant real MARKOFTHEWILD_ARMOR_BONUS = 1.00 // 0.20
constant real ROOTS_DAMAGE = 1.00
constant real ROOTS_TICKS = 3.00
constant real CLAW_STRIKE_DAMAGE = 3.00
constant real BASH_DAMAGE = 1.50
// Priest
constant real SHIELD_LIFE = 7.50
constant real SHIELD_DURATION = 30.00
constant real HOLY_NOVA_POWER = 2.50
constant real FEAR_TICKS = 5.00
constant real HEALING_TOUCH_POWER = 4.50
constant real MANA_BURN_DAMAGE = 2.00
constant real SHADOW_WORD_TICKS = 8.00
constant real SHADOW_WORD_DAMAGE = 0.75
constant real FEAR_MAX_TARGETS = 5
// Paladin
constant real HOLY_LIGHT_POWER = 5.00
constant real PURGE_POWER = 2.75
constant real PURGE_MOVEMENT_FACTOR = 0.50
constant real PURGE_DURATION = 3.00
constant real CALL_OF_JUSTICE_DAMAGE = 2.0
// Shaman
constant real EARTH_SHOCK_DAMAGE = 3.0
constant real HEALING_WAVE_POWER = 4.5
constant integer HEALING_WAVE_MAX_TARGETS = 4
constant real HEALING_WAVE_LOSS_FACTOR = 0.75
constant real FIRE_AND_ICE_FACTOR = 0.15
constant real FIRE_AND_ICE_DURATION = 30.00
constant real TOTEM_DURATION = 15.00
// Rogue
constant real FAN_OF_KNIVES_DAMAGE = 1.50
constant real DEADLY_STRIKE_DAMAGE = 2.00
constant real DEADLY_STRIKE_TICKS = 5.00
constant real DEADLY_STRIKE_TICK_FACTOR = 0.3 // tick damage is multiplied with this factor
constant real BACKSTAB_DAMAGE = 3.25
constant real STEALTH_DURATION = 30.00
// Hunter
constant real CRITICAL_SHOT_DAMAGE = 3.00
constant real CRITICAL_SHOT_TICKS = 3.00
constant real CRITICAL_SHOT_TICK_FACTOR = 0.30
constant real CRITICAL_SHOT_MOVEMENT_FACTOR = 0.7
constant real MULTI_SHOT_DAMAGE = 2.00
constant real MULTI_SHOT_RANGE = 200
// Necromancer
constant real SOUL_SHIELD_HEALTH = 5.00
constant real SOUL_SHIELD_DURATION = 30.00
constant real SOUL_SHIELD_HARVEST_PERCENT = 25.00
constant real VAMPIRIC_CURSE_TICKS = 7.00
constant real VAMPIRIC_CURSE_DAMAGE = 1.00
constant real VAMPIRIC_CURSE_HEALTH_FACTOR = 0.5
constant real DARK_CONSUMPTION_DAMAGE = 1.00
constant integer DARK_CONSUMPTION_TICKS = 5
constant real DARK_CONSUMPTION_RANGE = 200
// constant real BRUTAL_STRIKE_DAMAGE = 2.50
// constant real BRUTAL_STRIKE_TICKS = 3.00
// constant real BRUTAL_STRIKE_TICK_FACTOR = 0.3
constant real BEYOND_DEATH_DAMAGE = 2.00
constant real BEYOND_DEATH_DURATION = 15.00
// Ent
constant real ROCK_DAMAGE = 3.0
constant real BEAM_DAMAGE = 2.5
// Other
constant real FLAME_SHOCK_DAMAGE = 5.00
endglobals
struct spell
integer id = 0
unit caster = null
unit target = null
real x = 0
real y = 0
location loc = null
real damage = 0.0
boolean isCrit = false
real health = 0.0
real mana = 0.0
real armor = 0.0
real speed = 0.0
integer ticks = 0
integer effect_id = 0
method onDestroy takes nothing returns nothing
call RemoveLocation(.loc)
endmethod
endstruct
function GetSpellCaster takes integer id returns unit
return spells[id].caster
endfunction
function GetSpellTarget takes integer id returns unit
return spells[id].target
endfunction
function GetSpellDamage takes integer id returns real
return spells[id].damage
endfunction
function GetSpellLocation takes integer id returns location
return spells[id].loc
endfunction
function GetSpellHealth takes integer id returns real
return spells[id].health
endfunction
function GetSpellMana takes integer id returns real
return spells[id].mana
endfunction
function GetSpellCrit takes integer id returns boolean
return spells[id].isCrit
endfunction
function GetSpellTicks takes integer id returns integer
return spells[id].ticks
endfunction
function GetSpellEffectId takes integer id returns integer
return spells[id].effect_id
endfunction
function SetSpellEffectId takes integer id, integer value returns nothing
set spells[id].effect_id = value
endfunction
function GetRandomSpellMod takes nothing returns real
return GetRandomReal(RANDOM_DAMAGE_MIN, RANDOM_DAMAGE_MAX)
endfunction
function GetSpell takes integer id returns spell
return spells[id]
endfunction
function IncSpellTicks takes integer id returns nothing
set spells[id].ticks = spells[id].ticks + 1
endfunction
function ReleaseEffect takes integer id returns nothing
if EffectTable[id ] != null then
call DestroyEffect(EffectTable[id ])
set EffectTable[id ] = null
// call Debug_Message("Destroy Effect id "+I2S(id))
endif
endfunction
function SetMoveSpeed takes unit u returns nothing
local real normal_speed = GetUnitDefaultMoveSpeed(u)
call SetUnitMoveSpeed(u, normal_speed)
// Purge
if UnitHasBuff(u, BUFF_TYPE_PURGE) then
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u)*PURGE_MOVEMENT_FACTOR )
endif
// Critical Shot
if UnitHasBuff(u, BUFF_TYPE_CRITICAL_SHOT) then
call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed(u)*CRITICAL_SHOT_MOVEMENT_FACTOR )
endif
// Roots
if UnitHasBuff(u, BUFF_TYPE_ROOTS) then
call SetUnitMoveSpeed(u, 0)
endif
// Frozen
if UnitHasBuff(u, BUFF_TYPE_FROZEN) then
call SetUnitMoveSpeed(u, 0)
endif
endfunction
private function RegisterEffectTimerCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
// call Debug_Message("Release Effect Timer Callback id "+I2S(id))
call ReleaseTimer(t)
call ReleaseEffect(id)
set t = null
endfunction
// Effects with timed life are automatically destroyed
function RegisterEffect takes effect e, real lifespan returns integer
local timer t
local integer id = EFFECT_ID
// If an old effect hasn't cleaned up -> destroy
if EffectTable[id] != null then
call DestroyEffect(EffectTable[id])
endif
// Store Effect and inc ID
set EffectTable[id] = e
if EFFECT_ID < MAX_EFFECTS - 1 then
set EFFECT_ID = EFFECT_ID + 1
else
set EFFECT_ID = 0
endif
// Timed life?
if lifespan > 0 then
set t = NewTimer()
call SetTimerData(t, id)
call TimerStart(t, lifespan, false, function RegisterEffectTimerCallback)
endif
// call Debug_Message("Effect registered, id: "+I2S(id))
set t = null
return id
endfunction
function ReleaseSpell takes integer id returns nothing
call spell.destroy(spells[id])
// call Debug_Message("Spell released: "+I2S(id))
endfunction
function RegisterSpell takes unit caster, unit target, location loc, real damage, boolean crit, real health, real mana, real armor, real speed, integer ticks, integer effect_id returns integer
local spell thisSpell = spell.create()
set thisSpell.id = Spell_Count // SetSpellId()
set thisSpell.caster = caster
set thisSpell.target = target
set thisSpell.loc = loc
set thisSpell.damage = damage
set thisSpell.isCrit = crit
set thisSpell.health = health
set thisSpell.mana = mana
set thisSpell.armor = armor
set thisSpell.speed = speed
set thisSpell.ticks = ticks
set thisSpell.effect_id = effect_id
if Spell_Count >= SPELL_MAX-1 then
set Spell_Count = 0
else
set Spell_Count = Spell_Count + 1
endif
set spells[thisSpell.id] = thisSpell
// call Debug_Message("Spell registered: "+I2S(thisSpell.id))
return thisSpell.id
endfunction
private function Init takes nothing returns nothing
set SpellTab = Table.create()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Preload_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_Preload takes nothing returns nothing
set gg_trg_Preload = CreateTrigger( )
call TriggerAddAction( gg_trg_Preload, function Trig_Preload_Actions )
call Debug_Message("Preload Abilities")
call AbilityPreload('A04T')
call AbilityPreload('A05G')
call AbilityPreload('A043')
call AbilityPreload('A03J')
call AbilityPreload('A03R')
call AbilityPreload('A04K')
call AbilityPreload('A022')
call AbilityPreload('A04L')
call AbilityPreload('A00H')
call AbilityPreload('A02H')
call AbilityPreload('S001')
call AbilityPreload('A011')
call AbilityPreload('A004')
call AbilityPreload('A01O')
call AbilityPreload('A077')
call AbilityPreload('A06Z')
call AbilityPreload('A00J')
call AbilityPreload('A04H')
call AbilityPreload('A04D')
call AbilityPreload('A01A')
call AbilityPreload('A00W')
call AbilityPreload('A05N')
call AbilityPreload('A07E')
call AbilityPreload('A054')
call AbilityPreload('A008')
call AbilityPreload('A066')
call AbilityPreload('A00T')
call AbilityPreload('A02I')
call AbilityPreload('A03Q')
call AbilityPreload('A02K')
call AbilityPreload('A06K')
call AbilityPreload('A020')
call AbilityPreload('A07A')
call AbilityPreload('A04Q')
call AbilityPreload('A03Z')
call AbilityPreload('A00K')
call AbilityPreload('A03O')
call AbilityPreload('A016')
call AbilityPreload('A013')
call AbilityPreload('A007')
call AbilityPreload('A03D')
call AbilityPreload('A04V')
call AbilityPreload('A03W')
call AbilityPreload('A026')
call AbilityPreload('A044')
call AbilityPreload('A03V')
call AbilityPreload('A01F')
call AbilityPreload('A03H')
call AbilityPreload('A03E')
call AbilityPreload('A03B')
call AbilityPreload('A063')
call AbilityPreload('A030')
call AbilityPreload('A039')
call AbilityPreload('A04E')
call AbilityPreload('A00U')
call AbilityPreload('A02V')
call AbilityPreload('A04R')
call AbilityPreload('A074')
call AbilityPreload('A04A')
call AbilityPreload('A04B')
call AbilityPreload('A02Y')
call AbilityPreload('A00F')
call AbilityPreload('A02J')
call AbilityPreload('A04O')
call AbilityPreload('A04M')
call AbilityPreload('A03L')
call AbilityPreload('A00E')
call AbilityPreload('A031')
call AbilityPreload('A025')
call AbilityPreload('A00Y')
call AbilityPreload('A03A')
call AbilityPreload
//TESH.alwaysfold=0
function Trig_Preload_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_Preload takes nothing returns nothing
set gg_trg_Preload = CreateTrigger( )
call TriggerAddAction( gg_trg_Preload, function Trig_Preload_Actions )
call Debug_Message("Preload Abilities")
call AbilityPreload('A04T')
call AbilityPreload('A05G')
call AbilityPreload('A043')
call AbilityPreload('A03J')
call AbilityPreload('A03R')
call AbilityPreload('A04K')
call AbilityPreload('A022')
call AbilityPreload('A04L')
call AbilityPreload('A00H')
call AbilityPreload('A02H')
call AbilityPreload('S001')
call AbilityPreload('A011')
call AbilityPreload('A004')
call AbilityPreload('A01O')
call AbilityPreload('A077')
call AbilityPreload('A06Z')
call AbilityPreload('A00J')
call AbilityPreload('A04H')
call AbilityPreload('A04D')
call AbilityPreload('A01A')
call AbilityPreload('A00W')
call AbilityPreload('A05N')
call AbilityPreload('A07E')
call AbilityPreload('A054')
call AbilityPreload('A008')
call AbilityPreload('A066')
call AbilityPreload('A00T')
call AbilityPreload('A02I')
call AbilityPreload('A03Q')
call AbilityPreload('A02K')
call AbilityPreload('A06K')
call AbilityPreload('A020')
call AbilityPreload('A07A')
call AbilityPreload('A04Q')
call AbilityPreload('A03Z')
call AbilityPreload('A00K')
call AbilityPreload('A03O')
call AbilityPreload('A016')
call AbilityPreload('A013')
call AbilityPreload('A007')
call AbilityPreload('A03D')
call AbilityPreload('A04V')
call AbilityPreload('A03W')
call AbilityPreload('A026')
call AbilityPreload('A044')
call AbilityPreload('A03V')
call AbilityPreload('A01F')
call AbilityPreload('A03H')
call AbilityPreload('A03E')
call AbilityPreload('A03B')
call AbilityPreload('A063')
call AbilityPreload('A030')
call AbilityPreload('A039')
call AbilityPreload('A04E')
call AbilityPreload('A00U')
call AbilityPreload('A02V')
call AbilityPreload('A04R')
call AbilityPreload('A074')
call AbilityPreload('A04A')
call AbilityPreload('A04B')
call AbilityPreload('A02Y')
call AbilityPreload('A00F')
call AbilityPreload('A02J')
call AbilityPreload('A04O')
call AbilityPreload('A04M')
call AbilityPreload('A03L')
call AbilityPreload('A00E')
call AbilityPreload('A031')
call AbilityPreload('A025')
call AbilityPreload('A00Y')
call AbilityPreload('A03A')
call AbilityPreload