////////////////////////////////////////////////
// Team Rush - Formally Team Assault
// by JRPereira@Azeroth (Justin Pereira)
// [email protected]
// www.jrpereira.com
// www.jrpereira.com/warcraft3/team_rush
//////////////////////////////////////////////////
// After much thought I've decided that the best way to do this shindig is just to throw everything up at the top of the map, in a nice, clean, and organized library of functions and such, freeing myself as much as possible from the limits of the trigger UI, and also giving myself even more incentive to consolidate event handlers and functionize my code. Hopefully people interested in editing this map can just lump this dump into a text editor and go to town.
// In case you haven't already figured it out - this map is open source and completely unprotected. I want you guys to take this map and edit it and make it something special. This map in the right hands can be the solid foundation for something truly special. I've taken the time to organize this map into something that is easy to read and hopefully relatively easy to work with (as far as JASS goes anyways). If you have any questions, you can find me either on Warcaft 3 or via email. I also am a member of various Warcraft 3 forums.
// If you do decide to start a project based on this map, all I ask is that you include me (JRPereira) in the credits somewhere on the map. However, if you create something really amazing, PLEASE let me know about it. I've love to check it out.
// Good luck, guys - I can't wait to see what you have in store for this map.
// -- Update (Oct 25 2007) --
// Another rewrite of the map, completely and utterly from scatch, hopefully BJ-free. This is the one that will get rid of the desyncs, once and for all.
////////////////////////////////////////////////////////////////////////////////////////////////////
// -------------------- END HEADER -------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////
// Unfortunately I have to have a debug trigger
function jrp_func_DebugMsg takes string thismsg returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if ( (GetPlayerName(Player(intA)) == "UberMasterII") or (GetPlayerName(Player(intA)) == "JRPereira") ) then
if (udg_DebugOn == true) then
call DisplayTextToPlayer(Player(intA), 0, 0, thismsg )
endif
endif
set intA = intA + 1
endloop
endfunction
// Made to only handle one track at a time - this is primarily meant for dynamic music
function jrp_func_SetAndPlayMusic takes string musicname, real musicoffset returns nothing
call SetMapMusic(musicname + ";", false, 0)
call PlayThematicMusicEx(musicname, R2I(musicoffset * 1000))
// if (musicoffset <= I2R(0)) then // Seems to not automatically assume that 0.00 is a real
// call PlayThematicMusic(musicname)
// else
// call PlayThematicMusicEx(musicname, R2I(musicoffset * 1000))
// endif
endfunction
// Quickly creates and destroys effects. Doesn't destroy the location so you can reuse the location until you don't need it.
function jrp_func_EffectCreateAndDestroy takes location tpoint, string model returns nothing
local effect tempeffect
set tempeffect = AddSpecialEffectLoc(model,tpoint)
call DestroyEffect(tempeffect)
set tempeffect = null
endfunction
// Quickly creates and destroys effects. Doesn't destroy the location so you can reuse the location until you don't need it.
function jrp_func_EffectCreate takes location tpoint, string model returns effect
return AddSpecialEffectLoc(model,tpoint)
endfunction
// Cleaned up variation of the BJ version
function jrp_func_EffectCreateOnUnit takes string attachPointName, widget targetWidget, string modelName returns effect
return AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
endfunction
//Quickly creates and destroys effect
function jrp_func_EffectCreateAndDestroyOnUnit takes string attachPointName, widget targetWidget, string modelName returns nothing
local effect tempeffect
set tempeffect = AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
call DestroyEffect(tempeffect)
set tempeffect = null
endfunction
// Creates units at a location. Doesn't return. I'm debating on whether it's faster to use this and waste cycles on the loop or use the other one and waste cycles on the return
function jrp_func_UnitsCreateAtLoc takes integer count, integer unitid, player whichPlayer, location loc, real face returns nothing
loop
set count = count - 1
exitwhen count < 0
call CreateUnitAtLoc(whichPlayer, unitid, loc, face)
endloop
endfunction
// Create a unit and return it
function jrp_func_UnitCreateAndReturn takes integer unitid, player whichPlayer, location loc, real face returns unit
return CreateUnitAtLoc(whichPlayer, unitid, loc, face)
endfunction
// Swap items between two units
function jrp_func_UnitSwapItems takes unit unit1, unit unit2 returns nothing
local item array items1
local item array items2
local integer intA
if ( (unit1 != null) and (IsUnitDeadBJ(unit1) == false) and (unit2 != null) and (IsUnitDeadBJ(unit2) == false) ) then // bj alert, but it's a safe bj
set intA = 0
loop // Drop Everything
exitwhen (intA > 5)
set items1[intA] = UnitItemInSlot(unit1, intA)
set items2[intA] = UnitItemInSlot(unit2, intA)
call UnitRemoveItem( unit1, items1[intA] )
call UnitRemoveItem( unit2, items2[intA] )
set intA = intA + 1
endloop
set intA = 0
loop // Give everything
exitwhen (intA > 5)
call UnitAddItem( unit1, items2[intA] )
call UnitAddItem( unit2, items1[intA] )
set intA = intA + 1
endloop
endif
endfunction
// Basic slot status checker for players. Ended up a lot more bloated than I wanted. Oh well.
function jrp_func_CheckPlayerSlotStatus takes player checkplayer, integer isused, integer isplaying, integer iscomputer returns boolean
if ( (isused == 1) and (GetPlayerSlotState(checkplayer) == PLAYER_SLOT_STATE_EMPTY) ) then
return false
endif
if ( (isused == 0) and (GetPlayerSlotState(checkplayer) != PLAYER_SLOT_STATE_EMPTY) ) then
return false
endif
if ( (isplaying == 1) and (GetPlayerSlotState(checkplayer) != PLAYER_SLOT_STATE_PLAYING) ) then
return false
endif
if ( (isplaying == 0) and (GetPlayerSlotState(checkplayer) == PLAYER_SLOT_STATE_PLAYING) ) then
return false
endif
if ( (iscomputer == 1) and (GetPlayerController(checkplayer) != MAP_CONTROL_COMPUTER) ) then
return false
endif
if ( (iscomputer == 0) and (GetPlayerController(checkplayer) == MAP_CONTROL_COMPUTER) ) then
return false
endif
return true
endfunction
// BJ Replacement. Makes sure that two players are mutually allied with each other.
function jrp_func_CheckForMutualAlliance takes player playerA, player playerB returns boolean
if (playerA == playerB) then // Of course this player will be allied with itself. I'm considering returning false or putting up some sort of error if this occurs though, simple because you never would check if a player is allied with itself.
return true
endif
if GetPlayerAlliance(playerA, playerB, ALLIANCE_PASSIVE) then // A likes B
if GetPlayerAlliance(playerB, playerA, ALLIANCE_PASSIVE) then // B likes A
return true // A and B have teh sex.
endif
endif
return false // Or kill each other.
endfunction
// BJ replacement. Shares all of this player's units and such with teammates.
function jrp_func_GivePlayerControlToTeammates takes player thisplayer returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if ( (jrp_func_CheckForMutualAlliance(Player(intA),thisplayer) == true) and (Player(intA) != thisplayer) ) then
call SetPlayerAlliance(thisplayer, Player(intA), ALLIANCE_SHARED_VISION, true)
call SetPlayerAlliance(thisplayer, Player(intA), ALLIANCE_SHARED_CONTROL, true)
call SetPlayerAlliance(Player(intA), thisplayer, ALLIANCE_SHARED_CONTROL, true)
call SetPlayerAlliance(thisplayer, Player(intA), ALLIANCE_SHARED_ADVANCED_CONTROL, true)
endif
set intA = intA + 1
endloop
endfunction
// Give an array of players gold
function jrp_func_GiveGoldGiveToPlayerRange takes integer startplayer, integer endplayer, integer goldvalue returns nothing
loop
exitwhen startplayer > endplayer
if ( jrp_func_CheckPlayerSlotStatus(Player(startplayer), 1, 2, 2) == true ) then
call SetPlayerState( Player(startplayer), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(Player(startplayer), PLAYER_STATE_RESOURCE_GOLD) + goldvalue ) )
endif
set startplayer = startplayer + 1
endloop
endfunction
// Create a texttag at a location. The colors don't work and can be fudged using |c######## so all created will be white. Transparency appears to work and thus stays.
function jrp_func_TextTagCreateAtLoc takes string text, location loc, real zheight, real size, integer opacity returns texttag
local texttag tt = CreateTextTag()
set size = size * 0.023 / 10
call SetTextTagText(tt, text, size)
call SetTextTagPos(tt, GetLocationX(loc), GetLocationY(loc), zheight)
call SetTextTagColor(tt, 255, 255, 255, opacity) // Colors are explicitly set to 255 (100%) cause anything else is currently bugged. I'm not doing any fancy math for opacity->transparency because I think it becomes confusing when higher color values mean more color and the alpha value isn't like that. Besides, the less math here the better.
return tt
endfunction
// Display text to a range of players
function jrp_func_DisplayTextToRange takes integer start, integer end, string text returns nothing
loop
exitwhen start > end
call DisplayTextToPlayer(Player(start), 0, 0, text)
set start = start + 1
endloop
endfunction
// Create dialog button and return it in case we need it
function jrp_func_DialogAddButton takes dialog thisdialog, string text returns button
return DialogAddButton(thisdialog, text,0)
endfunction
// Allows you to quickly set up a chat event
function jrp_func_ChatCommandRegister takes string chatstring, code trigaction, boolean exactmatch returns nothing
local integer intA = 0
local integer intAEnd = 11
local trigger newtrigger = CreateTrigger( )
loop
exitwhen intA > intAEnd
call TriggerRegisterPlayerChatEvent( newtrigger, Player(intA), chatstring, exactmatch )
set intA = intA + 1
endloop
call TriggerAddAction( newtrigger, trigaction )
endfunction
// Used in forgroup commands - sets unit side
function jrp_func_ForGroup_SetTeamRed takes nothing returns nothing
call SetUnitOwner( GetEnumUnit(), Player(0), true )
endfunction
// Used in forgroup commands - sets unit side
function jrp_func_ForGroup_SetTeamBlue takes nothing returns nothing
call SetUnitOwner( GetEnumUnit(), Player(6), true )
endfunction
// Used in forgroup commands - sets unit side
function jrp_func_ForGroup_SetTeamNeutralHostile takes nothing returns nothing
call SetUnitOwner( GetEnumUnit(), Player(PLAYER_NEUTRAL_AGGRESSIVE), true )
endfunction
// Used in forgroup commands - removes all units
function jrp_func_ForGroup_RemoveUnit takes nothing returns nothing
call RemoveUnit( GetEnumUnit() )
endfunction
// Used in forgroup commands - sets mana to 100%
function jrp_func_ForGroup_SetFullMana takes nothing returns nothing
call SetUnitManaPercentBJ( GetEnumUnit(), 100 ) // *** BJ WARNING ***
endfunction
// Creates a quest - does away with all the "type" bullshit and instead directly sets booleans for required and discovered.
function jrp_func_QuestCreate takes boolean required, boolean discovered, string title, string description, string iconpath returns quest
local quest newquest = CreateQuest()
call QuestSetTitle(newquest, title)
call QuestSetDescription(newquest, description)
call QuestSetIconPath(newquest, iconpath)
call QuestSetRequired(newquest, required)
call QuestSetDiscovered(newquest, discovered)
call QuestSetCompleted(newquest, false)
return newquest
endfunction
function jrp_func_QuestAddItem takes quest thisquest, string description returns questitem
local questitem newitem = QuestCreateItem(thisquest)
call QuestItemSetDescription(newitem, description)
call QuestItemSetCompleted(newitem, false)
return newitem
endfunction
// Create multiboard. Doesn't display the multiboard.
function jrp_func_MultiboardCreate takes integer rows, integer cols, string title returns multiboard
local multiboard thisboard = CreateMultiboard()
call MultiboardSetRowCount(thisboard, rows)
call MultiboardSetColumnCount(thisboard, cols)
call MultiboardSetTitleText(thisboard, title)
return thisboard
endfunction
// Set multiboard item style.
function jrp_func_MultiboardSetItemStyle takes multiboard thisboard, integer row, integer col, boolean showvalue, boolean showicon returns nothing
local multiboarditem mbitem = MultiboardGetItem(thisboard, row, col)
call MultiboardSetItemStyle(mbitem, showvalue, showicon)
call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction
// Set multiboard item color.
function jrp_func_MultiboardSetItemColor takes multiboard thisboard, integer row, integer col, integer red, integer green, integer blue, integer opacity returns nothing
local multiboarditem mbitem = MultiboardGetItem(thisboard, row, col)
call MultiboardSetItemValueColor(mbitem, red, green, blue, opacity)
call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction
// Set multiboard item width
function jrp_func_MultiboardSetItemWidth takes multiboard thisboard, integer row, integer col, real width returns nothing
local multiboarditem mbitem = MultiboardGetItem(thisboard, row, col)
call MultiboardSetItemWidth(mbitem, width/100.0) // I'm keeping the math for the width.
call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction
// Set multiboard item value
function jrp_func_MultiboardSetItemValue takes multiboard thisboard, integer row, integer col, string value returns nothing
local multiboarditem mbitem = MultiboardGetItem(thisboard, row, col)
call MultiboardSetItemValue(mbitem, value)
call MultiboardReleaseItem(mbitem)
set mbitem = null
endfunction
function jrp_func_ControlPointCheckLock takes integer cappoint returns boolean
// Going to do this just straight up right now, I'm not going to save too many cycles by looping that I couldn't more easily save elsewhere with more BJ replacement.
if ( cappoint == 0 ) then
// Red defense locks it
if ( (udg_CapOwners[1] == 1) or (udg_CapOwners[2] == 1) ) then
return true
endif
return false
endif
if ( cappoint == 1 ) then
// Red defense locks it
if ( udg_CapOwners[3] != 2 ) then
return true
endif
return false
endif
if ( cappoint == 2 ) then
// Red defense locks it
if ( udg_CapOwners[3] != 2 ) then
return true
endif
return false
endif
if ( cappoint == 3 ) then
// Red offense locks it
if ( (udg_CapOwners[4] == 1) or (udg_CapOwners[5] == 1) ) then
return true
endif
// Blue offense locks it
if ( (udg_CapOwners[1] == 2) or (udg_CapOwners[2] == 2) ) then
return true
endif
return false
endif
if ( cappoint == 4 ) then
// Blue defense locks it
if ( udg_CapOwners[3] != 1 ) then
return true
endif
return false
endif
if ( cappoint == 5 ) then
// Blue defense locks it
if ( udg_CapOwners[3] != 1 ) then
return true
endif
return false
endif
if ( cappoint == 6 ) then
// Blue defense locks it
if ( (udg_CapOwners[4] == 2) or (udg_CapOwners[5] == 2) ) then
return true
endif
return false
endif
// No correct value given? return false
return false
endfunction
// I'm not exactly sure how much more efficient this is over the BJ one
function jrp_func_FogModifierCreate takes boolean enabled, player thisplayer, fogstate thisfogstate, location modloc, real radius returns fogmodifier
local fogmodifier thismodifier = CreateFogModifierRadiusLoc(thisplayer, thisfogstate, modloc, radius, true, false)
if enabled then
call FogModifierStart(thismodifier)
endif
return thismodifier
endfunction
// Seems like there may not be any other way to do this just yet. Removes the enum item.
function jrp_enum_ItemRemove takes nothing returns nothing
call RemoveItem( GetEnumItem() )
endfunction
// Random item drop
function jrp_ItemRandomDrop takes location mloc returns nothing
local integer array types_runes
local integer array types_rareweapons
local integer typestotal_runes = 5
local integer typestotal_rareweapons = 3
// I like to start from 1
// Rune of lesser healing (area)
set types_runes[1] = 'rhel'
// Rune of mana (area)
set types_runes[2] = 'rman'
// rune of dispel magic (area)
set types_runes[3] = 'rdis'
// Rune of speed (large area)
set types_runes[4] = 'rspd'
// Rune of shielding (blocks a spell)
set types_runes[5] = 'rsps'
// Neobezo
set types_rareweapons[1] = 'frgd'
// The UberMaster
set types_rareweapons[2] = 'srtl'
// L33t Curry (not a weapon, unless you know how to use it
set types_rareweapons[3] = 'pghe'
// *** Script order ***
// Decide whether or not to drop anything at all
// Decide which class to drop from
// Choose out of the class what to drop
// Should we drop anything at all?
if (GetRandomInt(1,7) > 2) then
// Should we drop a rune
if (GetRandomInt(1,3) == 2) then
call CreateItemLoc( types_runes[GetRandomInt(1, typestotal_runes)], mloc )
else
// Rare weapon drops
if (GetRandomInt(1,45) == 30) then
call CreateItemLoc( types_rareweapons[GetRandomInt(1, typestotal_rareweapons)], mloc )
else
endif
endif
call RemoveLocation( mloc )
set mloc = null
else
call RemoveLocation( mloc )
set mloc = null
return
endif
endfunction
// Display a texttag above every shop
function jrp_init_TextTagAllShops takes nothing returns nothing
local group tempgroup = CreateGroup()
local location temploc
local location temploc2
local integer intA
local integer intAEnd
local integer array shoptypes
local string array shopnames
local unit tempunit
call GroupEnumUnitsInRect(tempgroup, bj_mapInitialPlayableArea, null)
set tempgroup = GetUnitsInRectAll(bj_mapInitialPlayableArea)
set shoptypes[0] = 'ntav'
set shopnames[0] = "Select Hero Here"
set shoptypes[1] = 'nmrk'
set shopnames[1] = "Miscellaneous Items"
set shoptypes[2] = 'ngad'
set shopnames[2] = "Observatory"
set shoptypes[3] = 'ngme'
set shopnames[3] = "Single-Unit Items (repick here)"
set shoptypes[4] = 'n002'
set shopnames[4] = "Group/Team Items"
set shoptypes[5] = 'n001'
set shopnames[5] = "Attribute-Bonus Items"
set shoptypes[6] = 'n000'
set shopnames[6] = "Miscellaneous Items"
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
set intA = 0
set intAEnd = 6
loop
exitwhen intA > intAEnd
if (GetUnitTypeId(tempunit) == shoptypes[intA]) then
set temploc = GetUnitLoc(tempunit)
set temploc2 = OffsetLocation(temploc, -100.00, 0)
call jrp_func_TextTagCreateAtLoc( ("|c00FFCC00" + shopnames[intA] + "|r"), temploc2, 200.00, 10, 255 ) // Name the shop
call RemoveLocation( temploc )
call RemoveLocation( temploc2 )
endif
set intA = intA + 1
endloop
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup( tempgroup )
set tempgroup = null
set temploc = null
set temploc2 = null
set tempunit = null
endfunction
// Set up the basics for all players
function jrp_init_SetupPlayers takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if (intA < 6) then
call SetPlayerColor(Player(intA), PLAYER_COLOR_RED) // Set team colors
set udg_PlayerSides[intA] = 1 // This is a red team player
else
call SetPlayerColor(Player(intA), PLAYER_COLOR_BLUE) // Set team colors
set udg_PlayerSides[intA] = 2 // This is a blue team player
endif
call SetPlayerState(Player(intA), PLAYER_STATE_GIVES_BOUNTY, IntegerTertiaryOp(true, 1, 0)) // Turn on bounty for players
if ( (jrp_func_CheckPlayerSlotStatus(Player(intA), 1, 2, 1) == true) and (intA != 0) and (intA != 6) ) then // Make computer players share control. Until automatic team balance is in place, computer heroes have to be allowed, except for the army sides
call jrp_func_GivePlayerControlToTeammates(Player(intA))
endif
set intA = intA + 1
endloop
set udg_PlayerSides[0] = 0 // Red team army - not officially part of red team and not a candidate for auto team balance
set udg_PlayerSides[6] = 0 // Blue team army - not officially part of blue team and not a candidate for auto team balance
endfunction
function jrp_init_SetupInfoQuests takes nothing returns nothing
local quest tempquest // Required, discovered, title, description, iconpath
// Required Quests (basic map information)
set tempquest = jrp_func_QuestCreate(true, true, "Introduction", "Welcome to Team Rush - a control point assault map where two teams compete to control areas of the map, which eventually lead up to capturing the enemy team's base to win. Any questions about this map can be answered by the information contained in this area. Also, to your right, you can see a list of classes and basic descriptions.", "ReplaceableTextures\\CommandButtons\\BTNHumanCaptureFlag.blp" )
call jrp_func_QuestAddItem(tempquest, "Read the other quests for more information." )
call jrp_func_QuestAddItem(tempquest, "Map by JRPereira." )
call jrp_func_QuestAddItem(tempquest, "Lead tester: UberMasterII" )
set tempquest = jrp_func_QuestCreate(true, true, "Map Updates/Website", "You can check for new versions at the Team Rush website (see above).", "ReplaceableTextures\\CommandButtons\\BTNCryptFiendUnBurrow.blp" )
call jrp_func_QuestAddItem(tempquest, "www.jrpereira.com/warcraft3/team_rush" )
call jrp_func_QuestAddItem(tempquest, "Visit our forums!" )
set tempquest = jrp_func_QuestCreate(true, true, "Capturing and Scoring", "The main goal of Team Rush is to have your team capture control points on the map - eventually leading to capturing the enemy base. The control points are as follows:\n\n - Red Base\n - NorthWest\n - SouthWest\n - Central\n - NorthEast\n - SouthEast\n - Blue Base\n\nTo capture one of these control points, position your hero at the center of a capture area - after a small period of time, your team will have captured the capture area. To view your progress, see the multiboard at the topright of the screen.|n|nAll control points have prerequsite points - if you have not captured the prerequisite control points, a control point will be marked as locked.", "ReplaceableTextures\\CommandButtons\\BTNPillage.blp" )
call jrp_func_QuestAddItem(tempquest, "Go to one of the control points on the map." )
call jrp_func_QuestAddItem(tempquest, "Wait in a capture area to capture the point." )
call jrp_func_QuestAddItem(tempquest, "More teammates in a capture area = faster captures." )
call jrp_func_QuestAddItem(tempquest, "Once captured, points closer to the enemy may unlock." )
call jrp_func_QuestAddItem(tempquest, "Once your team captures the enemy base, you win!" )
set tempquest = jrp_func_QuestCreate(true, true, "Map Testers", "Above is a list of official testers for this map.", "ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp" )
call jrp_func_QuestAddItem(tempquest, "UberMasterII" )
call jrp_func_QuestAddItem(tempquest, "Kite253" )
call jrp_func_QuestAddItem(tempquest, "Neobezo" )
call jrp_func_QuestAddItem(tempquest, "CTM" )
call jrp_func_QuestAddItem(tempquest, "learningreborn" )
call jrp_func_QuestAddItem(tempquest, "Fenrirs_Chains" )
call jrp_func_QuestAddItem(tempquest, "DemonRazgriz" )
call jrp_func_QuestAddItem(tempquest, "Senas" )
call jrp_func_QuestAddItem(tempquest, "GhostWitTheMost" )
call jrp_func_QuestAddItem(tempquest, "Pure-THC" )
call jrp_func_QuestAddItem(tempquest, "Genso" )
call jrp_func_QuestAddItem(tempquest, "Giga" )
call jrp_func_QuestAddItem(tempquest, "L33tCurry" )
call jrp_func_QuestAddItem(tempquest, "Phyrax" )
set tempquest = jrp_func_QuestCreate(true, true, "This map is OSS!", "This map is an open source map - feel free to edit it and create derivative works - just make sure to give JRPereira credit for his hard work. Also, if you create something special, please let JRPereira know about it!", "ReplaceableTextures\\CommandButtons\\BTNRepairOn.blp" )
call jrp_func_QuestAddItem(tempquest, "Learn from this map!" )
call jrp_func_QuestAddItem(tempquest, "Use this map's resources!" )
call jrp_func_QuestAddItem(tempquest, "Create derivitive works!" )
call jrp_func_QuestAddItem(tempquest, "Give JRPeriera credit." )
// Optional Quests (Hero Information)
set tempquest = jrp_func_QuestCreate(false, true, "Scholar", "The scholar acts as the battery for the team - stealing mana from the enemy and providing mana for his team. Scholars can also steal certain buffs and debuffs, further gathering mana for the team.", "ReplaceableTextures\\CommandButtons\\BTNFurion.blp" )
call jrp_func_QuestAddItem(tempquest, "Best against heavy mana users." )
call jrp_func_QuestAddItem(tempquest, "Can keep teammates full to the brim with mana." )
set tempquest = jrp_func_QuestCreate(false, true, "Scout", "The scout is the fastest class and has the largest sight radius (which also isn't affected by the time of day). The scout is great for observing the battlefield. The scout can also see invisible units, making it great for detecting assassins. The scout's mass teleport ability allows it to quickly transport its team across the map.", "ReplaceableTextures\\CommandButtons\\BTNPriestessOfTheMoon.blp" )
call jrp_func_QuestAddItem(tempquest, "Great for quick captures." )
call jrp_func_QuestAddItem(tempquest, "Only hero with true sight." )
call jrp_func_QuestAddItem(tempquest, "Can be a spotter for snipers." )
call jrp_func_QuestAddItem(tempquest, "Longest sight range - not hindered by night." )
set tempquest = jrp_func_QuestCreate(false, true, "Assassin", "Master of stealth, the assassin can creep up to enemies and do massive damage. The assassin is adept at dodging in and out of battle, taking down enemies and preventing them from using abilities.", "ReplaceableTextures\\CommandButtons\\BTNHeroWarden.blp" )
call jrp_func_QuestAddItem(tempquest, "Great against weak targets." )
call jrp_func_QuestAddItem(tempquest, "Best at sneaking around the map." )
set tempquest = jrp_func_QuestCreate(false, true, "Priest", "Priests help to keep a team in fighting shape - healing players and shielding them from harm.", "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage.blp" )
call jrp_func_QuestAddItem(tempquest, "Good for long battles." )
call jrp_func_QuestAddItem(tempquest, "Can make teammates temporarily invulnerable." )
set tempquest = jrp_func_QuestCreate(false, true, "Mage", "The mage is adept at dealing damage to a wide area from a distance, making it great for assaults against swarms of targets and laying siege to enemy structures - especially when it's too dangerous to close in on enemy targets.", "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince.blp" )
call jrp_func_QuestAddItem(tempquest, "Great for taking down groups of enemies." )
call jrp_func_QuestAddItem(tempquest, "Can easily take down groups of structures." )
set tempquest = jrp_func_QuestCreate(false, true, "Berserker", "Berserkers can get up close to enemies and dish out lots of damage.", "ReplaceableTextures\\CommandButtons\\BTNHeroBlademaster.blp" )
call jrp_func_QuestAddItem(tempquest, "Great against swarms of enemies." )
set tempquest = jrp_func_QuestCreate(false, true, "Brute", "Best at the front of any assault, the brute is adept at absorbing damage and pushing through to capture points. The brute also can control combat through his taunts and stuns.", "ReplaceableTextures\\CommandButtons\\BTNHeroTaurenChieftain.blp" )
call jrp_func_QuestAddItem(tempquest, "Difficult to kill for most other classes." )
call jrp_func_QuestAddItem(tempquest, "Low damage is made up for with stuns/defense." )
set tempquest = jrp_func_QuestCreate(false, true, "Necromancer", "The necromancer is a master of the dead - summoning hordes of skeletons and even reanimating the corpses of his enemies.", "ReplaceableTextures\\CommandButtons\\BTNKelThuzad.blp" )
call jrp_func_QuestAddItem(tempquest, "Great against single-target attackers." )
call jrp_func_QuestAddItem(tempquest, "Can capture one territory while defending others." )
set tempquest = jrp_func_QuestCreate(false, true, "Builder", "Builders can put up base defenses and plant fountains and banners to heal and buff the team.", "ReplaceableTextures\\CommandButtons\\BTNHeroTinker.blp" )
call jrp_func_QuestAddItem(tempquest, "Great for defending territories." )
call jrp_func_QuestAddItem(tempquest, "Can booby-trap areas." )
set tempquest = jrp_func_QuestCreate(false, true, "Ranger", "Rangers are adept at picking off targets from a distance. Their high damage and ability to use their abilities from extreme range means that they can comfortably sit back and pick away at enemies without fear of retaliation. However, the ranger is pretty much defenseless up close.", "ReplaceableTextures\\CommandButtons\\BTNSylvanusWindrunner.blp" )
call jrp_func_QuestAddItem(tempquest, "Can attack from huge distances." )
call jrp_func_QuestAddItem(tempquest, "Able to pick off occupied enemies with ease." )
set tempquest = null
endfunction
// Set up the weather effects
function jrp_init_SetupWeather takes nothing returns nothing
set udg_Weather_Effects[0] = AddWeatherEffect( bj_mapInitialPlayableArea, 'RAlr' ) // Light ashenvale rain
set udg_Weather_Effects[1] = AddWeatherEffect( bj_mapInitialPlayableArea, 'RAhr' ) // Heavy ashenvale rain
set udg_Weather_Effects[2] = AddWeatherEffect( bj_mapInitialPlayableArea, 'LRma' ) // Foggy moonlight
set udg_Weather_Effects[3] = AddWeatherEffect( bj_mapInitialPlayableArea, 'RLhr' ) // Light lordaeron rain
set udg_Weather_Effects[4] = AddWeatherEffect( bj_mapInitialPlayableArea, 'RLlr' ) // Heavy lordaeron rain
endfunction
// Set up the variables required to handle creep respawning
function jrp_init_SetupCreepRespawnVars takes nothing returns nothing
local integer intA = 1
local group tempgroup = CreateGroup()
local unit tempunit
call GroupEnumUnitsOfPlayer(tempgroup, Player(PLAYER_NEUTRAL_AGGRESSIVE), null) // I've decided to avoid filters as they're more work than they're worth, probably don't save cycles, and use dreaded fallible globals.
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
if ( IsUnitType(tempunit, UNIT_TYPE_STRUCTURE) == false ) then // Buildings don't respawn! Quit messing with my head!
call SetUnitUserData( tempunit, intA ) // This allows the unit to refer back to its udg_Creep_Locs and respawn back at its home location.
set udg_Creep_Locs[intA] = GetUnitLoc(tempunit) // Records where the creep started and where it'll respawn.
set intA = intA + 1
endif
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup( tempgroup )
set tempgroup = null
set tempunit = null
endfunction
// Set up the Unit Selection tips globals
function jrp_init_SetupSelectionTipVars takes nothing returns nothing
set udg_UnitTips_Types[0] = 'Ekee' // Scholar
set udg_UnitTips_Types[1] = 'Emoo' // Scout
set udg_UnitTips_Types[2] = 'Ewar' // Assassin
set udg_UnitTips_Types[3] = 'Hamg' // Priest
set udg_UnitTips_Types[4] = 'Hblm' // Mage
set udg_UnitTips_Types[5] = 'Obla' // Berserker
set udg_UnitTips_Types[6] = 'Otch' // Brute
set udg_UnitTips_Types[7] = 'Ulic' // Necromancer
set udg_UnitTips_Types[8] = 'Nalc' // Builder
set udg_UnitTips_Types[9] = 'Hvwd' // Ranger
set udg_UnitTips_Types[10] = 'ntav' // Heros tavern
set udg_UnitTips_Types[11] = 'ewsp' // Hero selector unit
set udg_UnitTips_Types[12] = 'hctw' // Control point defense tower
set udg_UnitTips_Types[13] = 'hatw' // Spawn camp defense tower
set udg_UnitTips_Types[14] = 'hwtw' // Control point
set udg_UnitTips_TipString[0] = "Scholars are great at providing and destroying mana - this makes them great against heavy magic users and summoned units. They're also great for supplying a team with mana and protecting against magical attacks."
set udg_UnitTips_TipString[1] = "Scouts are great for capturing territory, reconaissance, and transporting teammates. They have the largest sight radius and are unaffected by night. They can also see invisible units."
set udg_UnitTips_TipString[2] = "Assassins are great single-target damage dealers, able to sneak around the battlefield and kill off units, one at a time."
set udg_UnitTips_TipString[3] = "Priests are great for healing and protecting teammates. They're also the only hero who can revive dead teammates."
set udg_UnitTips_TipString[4] = "Mages, while frail and vulnerable, are the best multi-target damage dealers, able to cause massive damage in a large area from a distance."
set udg_UnitTips_TipString[5] = "Berserkers are great at getting up close and doing a lot of damage to multiple targets. They can quickly dash up to enemy targets and can also take a fair amount of damage."
set udg_UnitTips_TipString[6] = "Brutes are the main tank units - able to shrug off massive amounts of damage without dying. Their stuns and taunts can help to control the battle and pin down enemies."
set udg_UnitTips_TipString[7] = "Necromancers can create hordes of skeletons and reanimated units to keep enemy players busy. Necromancers can also use debilitating howl to weaken enemy attackers."
set udg_UnitTips_TipString[8] = "Builders are great for defending territories - able to cover areas with mines and towers. They also can act in a support role, buffing teammates with banners and healing with fountains."
set udg_UnitTips_TipString[9] = "Rangers have the longest attack range and their abilities can hit even farther away. Given time to mark targets, they can use their snipe ability to devastating effect."
set udg_UnitTips_TipString[10] = "This is the structure where you can choose your hero."
set udg_UnitTips_TipString[11] = "This is a hero selector unit - you use it to 'buy' your hero."
set udg_UnitTips_TipString[12] = "This tower provides minor defense for territories."
set udg_UnitTips_TipString[13] = "This tower attacks nearby enemies, preventing spawn camping."
set udg_UnitTips_TipString[14] = "Wait next to this tower to capture this control point."
endfunction
function jrp_init_SetupControlPoints takes nothing returns nothing
local location tpoint
local location tpoint2
local group tempgroup
local unit tempunit
local integer intA = 0
local integer intAEnd = 6
// Set up capturable point rects
set udg_CapRects[0] = gg_rct_Capture_Point_1
set udg_CapRects[1] = gg_rct_Capture_Point_2
set udg_CapRects[2] = gg_rct_Capture_Point_3
set udg_CapRects[3] = gg_rct_Capture_Point_4
set udg_CapRects[4] = gg_rct_Capture_Point_5
set udg_CapRects[5] = gg_rct_Capture_Point_6
set udg_CapRects[6] = gg_rct_Capture_Point_7
// Set up capture point names
set udg_CapPointNames[0] = "Red Base"
set udg_CapPointNames[1] = "NorthWest"
set udg_CapPointNames[2] = "SouthWest"
set udg_CapPointNames[3] = "Central"
set udg_CapPointNames[4] = "NorthEast"
set udg_CapPointNames[5] = "SouthEast"
set udg_CapPointNames[6] = "Blue Base"
loop
exitwhen intA > intAEnd
set tpoint = Location(GetRectCenterX(udg_CapRects[intA]), GetRectCenterY(udg_CapRects[intA]))
set tempgroup = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(tempgroup, tpoint, 1500.00, null)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
if ( (GetOwningPlayer(tempunit) == Player(PLAYER_NEUTRAL_AGGRESSIVE)) and (IsUnitType(tempunit, UNIT_TYPE_STRUCTURE) == true) ) then
call GroupAddUnit( udg_CaptureStructGroups[intA], tempunit )
endif
call GroupRemoveUnit(tempgroup, tempunit)
set tempunit = null
endloop
set tpoint2 = OffsetLocation(tpoint, -35.00, 0) // Moving it a bit to the left so it looks centered
call jrp_func_TextTagCreateAtLoc( ("|c00FFCC00" + udg_CapPointNames[intA] + "|r"), tpoint2, 300.00, 10, 255 ) // The name of the control point for easy identification.
set udg_CapPointTags[intA] = jrp_func_TextTagCreateAtLoc( "| | | | | | | | | |", tpoint2, 200.00, 10, 255 ) // The progress indicator for the control point - we'll just start it out with some white pips.
// Cleanup
call RemoveLocation( tpoint )
set tpoint = null
call RemoveLocation( tpoint2 )
set tpoint2 = null
call DestroyGroup( tempgroup )
set tempgroup = null
set intA = intA + 1
endloop
endfunction
// Initialize the multiboard (but don't show it, yet)
function jrp_init_SetupMultiboard takes nothing returns nothing
local integer intA
local integer intAEnd
set udg_CapStatusBoard = jrp_func_MultiboardCreate( 11, 2, "Team Rush" )
set intA = 0
set intAEnd = 6
loop
exitwhen intA > intAEnd
call jrp_func_MultiboardSetItemStyle(udg_CapStatusBoard, intA + 1, 0, true, false)
call jrp_func_MultiboardSetItemStyle(udg_CapStatusBoard, intA + 1, 1, true, false)
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, intA + 1, 0, udg_CapPointNames[intA] )
call jrp_func_MultiboardSetItemColor( udg_CapStatusBoard, intA + 1, 0, 255, 200, 0, 255 )
set intA = intA + 1
endloop
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 0, 0, "Point" )
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 0, 1, "Status" )
set intA = 0
set intAEnd = 10
loop
exitwhen intA > intAEnd
call jrp_func_MultiboardSetItemStyle(udg_CapStatusBoard, intA, 0, true, false)
call jrp_func_MultiboardSetItemStyle(udg_CapStatusBoard, intA, 1, true, false)
call jrp_func_MultiboardSetItemWidth( udg_CapStatusBoard, intA, 0, 7.00 )
call jrp_func_MultiboardSetItemWidth( udg_CapStatusBoard, intA, 1, 4.00 )
set intA = intA + 1
endloop
call jrp_func_MultiboardSetItemColor( udg_CapStatusBoard, 8, 0, 100, 0, 0, 255 )
call jrp_func_MultiboardSetItemColor( udg_CapStatusBoard, 9, 0, 0, 0, 255, 255 )
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 8, 0, "Red Score" )
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 9, 0, "Blue Score" )
endfunction
// Puts the player stashes on the map
function jrp_init_SetupPlayerStashes takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
local location temploc
local location temploc2
loop
exitwhen intA > intAEnd
if ( (udg_PlayerSides[intA] != 0) and (jrp_func_CheckPlayerSlotStatus(Player(intA), 1, 1, 0) == true) ) then
set udg_PlayerStashes[intA] = jrp_func_UnitCreateAndReturn('hhou', Player(intA), GetStartLocationLoc(GetPlayerStartLocation(Player(intA))), bj_UNIT_FACING )
set udg_PlayerTempStashes[intA] = jrp_func_UnitCreateAndReturn('e000', Player(intA), GetStartLocationLoc(GetPlayerStartLocation(Player(intA))), bj_UNIT_FACING )
set temploc = GetUnitLoc(udg_PlayerStashes[intA])
set temploc2 = OffsetLocation(temploc, -50.00, 0)
call jrp_func_TextTagCreateAtLoc( ("|c00FFCC00" + GetPlayerName(Player(intA)) + "|r"), temploc2, 200.00, 10, 255 ) // Name the stash after the player
call RemoveLocation( temploc )
call RemoveLocation( temploc2 )
endif
set intA = intA + 1
endloop
set temploc = null
set temploc2 = null
endfunction
// Incriment player gold based on control points owned
function jrp_action_GoldGain takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
local integer array RedGain
local integer array BlueGain
set RedGain[0] = 0 // Even though this can never be awarded
set RedGain[1] = 1
set RedGain[2] = 1
set RedGain[3] = 3
set RedGain[4] = 2
set RedGain[5] = 2
set RedGain[6] = 5 // Even though this is never actually awarded
set BlueGain[0] = 5 // Even though this is never actually awarded
set BlueGain[1] = 2
set BlueGain[2] = 2
set BlueGain[3] = 3
set BlueGain[4] = 1
set BlueGain[5] = 1
set BlueGain[6] = 0 // Even though this can never be awarded
loop
exitwhen intA > intAEnd
if ( udg_CapOwners[intA] == 1 ) then
call jrp_func_GiveGoldGiveToPlayerRange(0, 5, RedGain[intA])
endif
if ( udg_CapOwners[intA] == 2 ) then
call jrp_func_GiveGoldGiveToPlayerRange(6, 11, BlueGain[intA])
endif
set intA = intA + 1
endloop
endfunction
// Incriment hero XP based on control points owned
function jrp_action_XPGain takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
local integer array RedXPGain
local integer array BlueXPGain
local integer intB
local integer intBEnd
set RedXPGain[0] = 0 // Even though this can never be awarded
set RedXPGain[1] = 2
set RedXPGain[2] = 2
set RedXPGain[3] = 5
set RedXPGain[4] = 8
set RedXPGain[5] = 8
set RedXPGain[6] = 25 // Even though this is never actually awarded
set BlueXPGain[0] = 25 // Even though this is never actually awarded
set BlueXPGain[1] = 8
set BlueXPGain[2] = 8
set BlueXPGain[3] = 5
set BlueXPGain[4] = 2
set BlueXPGain[5] = 2
set BlueXPGain[6] = 0 // Even though this can never be awarded
loop
exitwhen intA > intAEnd
if ( udg_CapOwners[intA] == 1 ) then
set intB = 0
set intBEnd = 5
loop
exitwhen intB > intBEnd
if (udg_PlayerHeroes[intB] != null) then
call AddHeroXPSwapped( RedXPGain[intA], udg_PlayerHeroes[intB], true )
endif
set intB = intB + 1
endloop
endif
if ( udg_CapOwners[intA] == 2 ) then
set intB = 6
set intBEnd = 11
loop
exitwhen intB > intBEnd
if (udg_PlayerHeroes[intB] != null) then
call AddHeroXPSwapped( BlueXPGain[intA], udg_PlayerHeroes[intB], true )
endif
set intB = intB + 1
endloop
endif
set intA = intA + 1
endloop
endfunction
// Enable or disable the triggers that regularly funciton only during a round
function jrp_action_ToggleRoundTriggers takes boolean enabled returns nothing
if (enabled == true) then
call EnableTrigger( udg_GlobalTrigs[2] ) // Unit dies
call EnableTrigger( udg_GlobalTrigs[5] ) // Unit enters hero select
call EnableTrigger( udg_GlobalTrigs[6] ) // Unit receives item
call EnableTrigger( udg_GlobalTrigs[11] ) // Every second
else
call DisableTrigger( udg_GlobalTrigs[2] ) // Unit dies
call DisableTrigger( udg_GlobalTrigs[5] ) // Unit enters hero select
call DisableTrigger( udg_GlobalTrigs[6] ) // Unit receives item
call DisableTrigger( udg_GlobalTrigs[11] ) // Every second
endif
endfunction
// Spawn control point defense towers around a control point (in those convenient little holes)
function jrp_action_ControlPointSpawnPointDefenseTowers takes integer thispoint, player thisplayer returns nothing
local location tpoint1
local location targloc = Location(GetRectCenterX(udg_CapRects[thispoint]), GetRectCenterY(udg_CapRects[thispoint]))
set tpoint1 = OffsetLocation(targloc, 150.00, 150.00)
call jrp_func_UnitsCreateAtLoc( 1, 'hctw', thisplayer, tpoint1, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( tpoint1, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
call RemoveLocation( tpoint1 )
set tpoint1 = null
set tpoint1 = OffsetLocation(targloc, -200.00, 150.00)
call jrp_func_UnitsCreateAtLoc( 1, 'hctw', thisplayer, tpoint1, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( tpoint1, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
call RemoveLocation( tpoint1 )
set tpoint1 = null
set tpoint1 = OffsetLocation(targloc, 150.00, -200.00)
call jrp_func_UnitsCreateAtLoc( 1, 'hctw', thisplayer, tpoint1, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( tpoint1, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
call RemoveLocation( tpoint1 )
set tpoint1 = null
set tpoint1 = OffsetLocation(targloc, -200.00, -200.00)
call jrp_func_UnitsCreateAtLoc( 1, 'hctw', thisplayer, tpoint1, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( tpoint1, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
call RemoveLocation( tpoint1 )
set tpoint1 = null
// Luckily we clean up the targloc too
call RemoveLocation( targloc )
set targloc = null
endfunction
// Spawn army units around a control point
function jrp_action_ControlPointSpawnArmyUnits takes integer thispoint, player thisplayer returns nothing
local location targloc = Location(GetRectCenterX(udg_CapRects[thispoint]), GetRectCenterY(udg_CapRects[thispoint]))
call jrp_func_UnitsCreateAtLoc( 2, 'hfoo', thisplayer, targloc, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( targloc, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
call jrp_func_UnitsCreateAtLoc( 1, 'hrif', thisplayer, targloc, bj_UNIT_FACING )
call jrp_func_EffectCreateAndDestroy( targloc, "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl" )
// Luckily we clean up the targloc too
call RemoveLocation( targloc )
set targloc = null
endfunction
// Spawns army units around all team-owned control points
function jrp_action_ControlPointSpawnArmyUnitsAtPoints takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
loop
exitwhen intA > intAEnd
if (udg_CapOwners[intA] == 1) then
call jrp_action_ControlPointSpawnArmyUnits(intA, Player(0))
endif
if (udg_CapOwners[intA] == 2) then
call jrp_action_ControlPointSpawnArmyUnits(intA, Player(6))
endif
set intA = intA + 1
endloop
endfunction
// Orders all army units to patrol to the enemy control points
function jrp_action_ControlPointArmyOrderUnits takes nothing returns nothing
local group tempgroup
local unit tempunit
local location tpoint
set tpoint = GetRectCenter(udg_CapRects[6])
set tempgroup = CreateGroup()
set bj_groupEnumTypeId = 'hfoo' // *** BJ ALERT! ***
call GroupEnumUnitsOfPlayer(tempgroup, Player(0), filterGetUnitsOfPlayerAndTypeId)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
call IssuePointOrderLocBJ( tempunit, "patrol", tpoint )
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup(tempgroup)
set tempgroup = null
set tempgroup = CreateGroup()
set bj_groupEnumTypeId = 'hrif' // *** BJ ALERT! ***
call GroupEnumUnitsOfPlayer(tempgroup, Player(0), filterGetUnitsOfPlayerAndTypeId)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
call IssuePointOrderLocBJ( tempunit, "patrol", tpoint )
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup(tempgroup)
set tempgroup = null
call RemoveLocation(tpoint)
set tpoint = null
// ====================================================
set tpoint = GetRectCenter(udg_CapRects[0])
set tempgroup = CreateGroup()
set bj_groupEnumTypeId = 'hfoo' // *** BJ ALERT! ***
call GroupEnumUnitsOfPlayer(tempgroup, Player(6), filterGetUnitsOfPlayerAndTypeId)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
call IssuePointOrderLocBJ( tempunit, "patrol", tpoint )
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup(tempgroup)
set tempgroup = null
set tempgroup = CreateGroup()
set bj_groupEnumTypeId = 'hrif' // *** BJ ALERT! ***
call GroupEnumUnitsOfPlayer(tempgroup, Player(6), filterGetUnitsOfPlayerAndTypeId)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
call IssuePointOrderLocBJ( tempunit, "patrol", tpoint )
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup(tempgroup)
set tempgroup = null
call RemoveLocation(tpoint)
set tpoint = null
endfunction
// Does everything you need to assign ownership of a control point to a team
function jrp_action_ControlPointSetOwnership takes integer cpoint, integer team returns nothing
set udg_CapOwners[cpoint] = team
call ForGroup( udg_CaptureStructGroups[cpoint], function jrp_func_ForGroup_SetFullMana )
if (team > 0) then
// *** I'm taking out the territory defense squad for now - they're just a waste of time and energy.
if (team == 1) then
set udg_CapScoresRed[cpoint] = udg_ScoreToCap
set udg_CapScoresBlue[cpoint] = 0
call ForGroup( udg_CaptureStructGroups[cpoint], function jrp_func_ForGroup_SetTeamRed )
endif
if (team == 2) then
set udg_CapScoresRed[cpoint] = 0
set udg_CapScoresBlue[cpoint] = udg_ScoreToCap
call ForGroup( udg_CaptureStructGroups[cpoint], function jrp_func_ForGroup_SetTeamBlue )
endif
else
call ForGroup( udg_CaptureStructGroups[cpoint], function jrp_func_ForGroup_SetTeamNeutralHostile )
set udg_CapScoresRed[cpoint] = 0
set udg_CapScoresBlue[cpoint] = 0
endif
endfunction
function jrp_action_ControlPointAddProgress takes integer cappoint, string capteam returns nothing
if (capteam == "red") then
// Add and deduct points
set udg_CapScoresRed[cappoint] = udg_CapScoresRed[cappoint] + 1
set udg_CapScoresBlue[cappoint] = udg_CapScoresBlue[cappoint] - 1
// Set maximum score
if ( udg_CapScoresRed[cappoint] > udg_ScoreToCap ) then
set udg_CapScoresRed[cappoint] = udg_ScoreToCap
endif
// Set minimum score
if ( udg_CapScoresBlue[cappoint] < 0 ) then
set udg_CapScoresBlue[cappoint] = 0
endif
endif
if (capteam == "blue") then
// Add and deduct points
set udg_CapScoresBlue[cappoint] = udg_CapScoresBlue[cappoint] + 1
set udg_CapScoresRed[cappoint] = udg_CapScoresRed[cappoint] - 1
// Set maximum score
if ( udg_CapScoresBlue[cappoint] > udg_ScoreToCap ) then
set udg_CapScoresBlue[cappoint] = udg_ScoreToCap
endif
// Set minimum score
if ( udg_CapScoresRed[cappoint] < 0 ) then
set udg_CapScoresRed[cappoint] = 0
endif
endif
endfunction
function jrp_action_ControlPointCheckProgress takes nothing returns nothing
local integer intA
local integer intAEnd
local integer intB
local integer intBEnd
set intA = 0
set intAEnd = 6
loop
exitwhen intA > intAEnd
// Capture progress for Red Players
set intB = 0
set intBEnd = 5
loop
exitwhen intB > intBEnd
if ( ( RectContainsUnit(udg_CapRects[intA], udg_PlayerHeroes[intB]) == true ) and ( IsUnitAliveBJ(udg_PlayerHeroes[intB]) == true ) ) then
if (jrp_func_ControlPointCheckLock(intA) != true) then
call jrp_action_ControlPointAddProgress( intA, "red")
else
if (udg_CapOwners[intA] == 1) then
// call DisplayTextToPlayer(Player(intB), 0, 0, "|c00FF0000Red Team|r already owns this point! This point is |c00BBBBBB[LOCKED]|r")
else
call DisplayTextToPlayer(Player(intB), 0, 0, "|c000000FFBlue Team|r owns a prerequisite point! This point is |c00BBBBBB[LOCKED]|r")
endif
endif
endif
set intB = intB + 1
endloop
// Capture progress for Blue Players
set intB = 6
set intBEnd = 11
loop
exitwhen intB > intBEnd
if ( ( RectContainsUnit(udg_CapRects[intA], udg_PlayerHeroes[intB]) == true ) and ( IsUnitAliveBJ(udg_PlayerHeroes[intB]) == true ) ) then
if (jrp_func_ControlPointCheckLock(intA) != true) then
call jrp_action_ControlPointAddProgress( intA, "blue")
else
if (udg_CapOwners[intA] == 1) then
call DisplayTextToPlayer(Player(intB), 0, 0, "|c00FF0000Red Team|r owns a prerequisite point! This point is |c00BBBBBB[LOCKED]|r")
else
// call DisplayTextToPlayer(Player(intB), 0, 0, "|c000000FFBlue Team|r already owns this point! This point is |c00BBBBBB[LOCKED]|r")
endif
endif
endif
set intB = intB + 1
endloop
set intA = intA + 1
endloop
endfunction
// Not only awards the gold, but returns the gold given so that it can be used to display the reward in jrp_action_ControlPointCheckOwnership
function jrp_action_ControlPointCapGoldReward takes integer cpoint, integer team returns integer
local integer array RedRewards
local integer array BlueRewards
set RedRewards[0] = 0 // Even though this can never be awarded
set RedRewards[1] = 50
set RedRewards[2] = 50
set RedRewards[3] = 150
set RedRewards[4] = 250
set RedRewards[5] = 250
set RedRewards[6] = 500 // Even though this is never actually awarded
set BlueRewards[0] = 500 // Even though this is never actually awarded
set BlueRewards[1] = 250
set BlueRewards[2] = 250
set BlueRewards[3] = 150
set BlueRewards[4] = 50
set BlueRewards[5] = 50
set BlueRewards[6] = 0 // Even though this can never be awarded
if (team == 1) then // We're going to follow the convention of 1 for Red, 2 for Blue, and 0 for Neutral
call jrp_func_GiveGoldGiveToPlayerRange(0, 5, RedRewards[cpoint])
return RedRewards[cpoint]
endif
if (team == 2) then
call jrp_func_GiveGoldGiveToPlayerRange(6, 11, BlueRewards[cpoint])
return BlueRewards[cpoint]
endif
return 0
endfunction
// Decides if the music should change based on players capturing control points
function jrp_action_ControlPointCaptureMusic takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
local integer caps = 0
local integer maxcaps = 0
loop
exitwhen intA > intAEnd
if (udg_CapOwners[intA] == 1) then
set caps = caps + 1
endif
set intA = intA + 1
endloop
set maxcaps = caps
set caps = 0
set intA = 0
loop
exitwhen intA > intAEnd
if (udg_CapOwners[intA] == 2) then
set caps = caps + 1
endif
set intA = intA + 1
endloop
if (caps > maxcaps) then
set maxcaps = caps
endif
if ( (maxcaps == 4) and (udg_PrevMaxCaps != 4) and (udg_PrevMaxCaps != 5) ) then
call jrp_func_SetAndPlayMusic("Sound\\Music\\mp3Music\\Orc3.mp3", 49.00)
set udg_PrevMaxCaps = maxcaps
endif
if ( (maxcaps == 6) and (udg_PrevMaxCaps == 5) ) then
call jrp_func_SetAndPlayMusic("Sound\\Music\\mp3Music\\OrcX1.mp3", 92.00)
set udg_PrevMaxCaps = maxcaps
endif
if ( (maxcaps == 5) and (udg_PrevMaxCaps == 4) ) then
set udg_PrevMaxCaps = maxcaps
endif
endfunction
// Decide if anyone's captured a control point
function jrp_action_ControlPointCheckOwnership takes nothing returns nothing
local integer intA
local integer intAEnd
local boolean cap_made = false
set intA = 0
set intAEnd = 6
loop
exitwhen intA > intAEnd
// If the point isn't locked anyways. This prevents a bug where both teams make a cap at the exact same time (extremely rare but it's happened) and end up perma-locking points.
if (jrp_func_ControlPointCheckLock(intA) != true) then
// Check to see if Red captured
if ( (udg_CapOwners[intA] != 1) and (udg_CapScoresRed[intA] == udg_ScoreToCap) ) then
call jrp_func_DisplayTextToRange( 0, 11, ( "|c00FF0303Red Team|r has captured the |c00FFCC00 " + udg_CapPointNames[intA] ) + " |rpoint. |c0000FFFF" + I2S(jrp_action_ControlPointCapGoldReward(intA, 1)) + "|r gold has been awarded to each Red player." )
// Play notification sound
call StartSound( gg_snd_ItemReceived )
// Set towers owner
call jrp_action_ControlPointSetOwnership( intA, 1 )
set cap_made = true
endif
// Check to see if Blue captured
if ( (udg_CapOwners[intA] != 2) and (udg_CapScoresBlue[intA] == udg_ScoreToCap) ) then
call jrp_func_DisplayTextToRange( 0, 11, ( "|c000042FFBlue Team|r has captured the |c00FFCC00 " + udg_CapPointNames[intA] ) + " |rpoint. |c0000FFFF" + I2S(jrp_action_ControlPointCapGoldReward(intA, 2)) + "|r gold has been awarded to each Blue player." )
// Play notification sound
call StartSound( gg_snd_ItemReceived )
// Set towers owner
call jrp_action_ControlPointSetOwnership( intA, 2 )
set cap_made = true
call jrp_func_GiveGoldGiveToPlayerRange(6, 11, 100)
endif
endif
set intA = intA + 1
endloop
if (cap_made == true) then
call jrp_action_ControlPointCaptureMusic() // Change music if necessary
endif
endfunction
// Lazy timer - just decriments the respawn timers
function jrp_action_HeroUpdateRespawnTimers takes nothing returns nothing
local integer intA
local integer intAEnd
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
set udg_PlayerDeathTimers[intA] = ( udg_PlayerDeathTimers[intA] - 1 )
if ( udg_PlayerDeathTimers[intA] < -1 ) then
set udg_PlayerDeathTimers[intA] = -1
endif
set intA = intA + 1
endloop
endfunction
function jrp_action_HeroResetAllRespawnTimers takes nothing returns nothing
local integer intA
local integer intAEnd
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
set udg_PlayerDeathTimers[intA] = -1
set intA = intA + 1
endloop
endfunction
// Revive a player hero, placing them at a location
// The camera moves as well so the player can get right back to their hero on revival
function jrp_action_HeroRevive takes player thisplayer, location thisloc returns nothing
local group tempgroup = GetUnitsOfPlayerAndTypeId(thisplayer, 'ndh1') // *** BJ ALERT! ***
local location tpoint
if ( thisplayer == GetLocalPlayer() ) then // Not functionzing this, too few uses and too few lines
call SetCameraPosition(GetLocationX(thisloc), GetLocationY(thisloc))
endif
call ReviveHeroLoc( udg_PlayerHeroes[GetPlayerId(thisplayer)], thisloc, true )
set udg_PlayerDeathTimers[GetPlayerId(thisplayer)] = -1
set tpoint = GetUnitLoc(FirstOfGroup(tempgroup))
call jrp_func_EffectCreateAndDestroy( tpoint, "Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl" )
call RemoveUnit( FirstOfGroup(tempgroup) )
call DestroyGroup( tempgroup )
set tempgroup = null
call RemoveLocation( thisloc )
call RemoveLocation( tpoint )
set tpoint = null
set thisloc = null
endfunction
// Checks the respawn timers.
function jrp_action_HeroCheckForRevive takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
local location temploc
// Loop through the timer array and decide who's going to respawn
loop
exitwhen (intA > intAEnd)
if ( (udg_HeroDead[intA] == true) and (udg_PlayerDeathTimers[intA] == 0)) then
// Set spawn location
if (udg_PlayerSides[intA] == 1) then
set temploc = GetRandomLocInRect(gg_rct_PlayerSpawnRed)
else // Going to make it cover anything else just in case, however this should generally always be blue
set temploc = GetRandomLocInRect(gg_rct_PlayerSpawnBlue)
endif
call jrp_action_HeroRevive(Player(intA),temploc)
call RemoveLocation( temploc )
set temploc = null
endif
set intA = intA + 1
endloop
endfunction
function jrp_action_HeroGiveRandom takes player thisplayer returns nothing
local location temploc
local integer array classtypes
set classtypes[0] = 'Ekee'
set classtypes[1] = 'Emoo'
set classtypes[2] = 'Ewar'
set classtypes[3] = 'Hamg'
set classtypes[4] = 'Hblm'
set classtypes[5] = 'Obla'
set classtypes[6] = 'Otch'
set classtypes[7] = 'Ulic'
set classtypes[8] = 'Nalc'
set classtypes[9] = 'Hvwd'
if (GetPlayerId(thisplayer) < 6) then // If Red
set temploc = GetRectCenter(gg_rct_Class_Select_Area_Red) // While getrectcenter isn't a native, it's 100% exactly efficient and what I want
else // Blue
set temploc = GetRectCenter(gg_rct_Class_Select_Area_Blue)
endif
call jrp_func_UnitsCreateAtLoc( 1, classtypes[GetRandomInt(0, 9)], thisplayer, temploc, bj_UNIT_FACING )
call RemoveLocation( temploc )
set temploc = null
endfunction
// Give the player the ability to choose a hero
function jrp_action_HeroMakePlayerSelect takes player choosingplayer returns nothing
local location temploc
if ( jrp_func_CheckPlayerSlotStatus(choosingplayer, 1, 1, 0) == true ) then // Active non-computer player
if (GetPlayerId(choosingplayer) < 6) then // If Red
set temploc = GetRectCenter(gg_rct_Class_Select_Area_Red) // While getrectcenter isn't a native, it's 100% exactly efficient and what I want
else // Ah, so Blue. Very clever, Mr.Bond! But I'm not here to ascertain the placement of the hero selector. I'm here to watch you die.
set temploc = GetRectCenter(gg_rct_Class_Select_Area_Blue)
endif
call jrp_func_UnitsCreateAtLoc( 1, 'ewsp', choosingplayer, temploc, bj_UNIT_FACING ) // Place hero selector
if ( choosingplayer == GetLocalPlayer() ) then // Not functionzing this, too few uses and too few lines
call SetCameraPosition(GetLocationX(temploc), GetLocationY(temploc))
endif
call RemoveLocation( temploc )
set temploc = null
call SetPlayerState( choosingplayer, PLAYER_STATE_RESOURCE_LUMBER, 1 ) // Gotta have lumber to choose a hero
// Hero selector, in the flesh - or rather, in the middle of your team's hero select area. I took the liberty of relieving you of the items and experience of your last hero. Most of them made you overpowered. As for the lumber, I think you've earned it. The control points, for your team, are in your team's control, for the time being... thanks to you. Quiet a nasty piece of work you managed over there; I am impressed. That's why I'm here, hero selector. I have recommended your services to my... team, and they have authorized me to offer you a hero. They agree with me that you have limitless potential. You've proved yourself a decisive hero selector so I don't expect you'll have any trouble deciding which hero to choose. If you're interested, just select the tavern and I will take that as a yes. Otherwise, well, I can offer you a battle that you have no chance of participating in... rather an anticlimax if you've just started the game. Time to choose...
call DisplayTextToPlayer(choosingplayer, 0, 0, "Time to |c00FFCC00choose a hero|r. |c0000FFFFYou can repick|r at the goblin merchant.")
else // Eh fuck it, the bitch left or never was there in the first place.
if ((GetPlayerId(choosingplayer) != 0) and (GetPlayerId(choosingplayer) != 6)) then
call jrp_action_HeroGiveRandom(choosingplayer) // Just give a random hero
endif
endif
endfunction
// Ping Control Points
function jrp_action_PingControlPoints takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
local location tpoint
loop
exitwhen intA > intAEnd
if (jrp_func_ControlPointCheckLock(intA) != true) then
set tpoint = GetRectCenter(udg_CapRects[intA])
if (udg_CapOwners[intA] == 0) then
call PingMinimapLocForForceEx( udg_P_Allplayers, tpoint, 3.00, bj_MINIMAPPINGSTYLE_FLASHY, 100, 100, 100 )
endif
if (udg_CapOwners[intA] == 1) then
call PingMinimapLocForForceEx( udg_P_Allplayers, tpoint, 3.00, bj_MINIMAPPINGSTYLE_FLASHY, 100, 0.00, 0.00 )
endif
if (udg_CapOwners[intA] == 2) then
call PingMinimapLocForForceEx( udg_P_Allplayers, tpoint, 3.00, bj_MINIMAPPINGSTYLE_FLASHY, 0.00, 0.00, 100 )
endif
call RemoveLocation( tpoint )
set tpoint = null
endif
set intA = intA + 1
endloop
endfunction
// Who says humans can't control the weather?
function jrp_action_WeatherChange takes nothing returns nothing
local integer weatherint = GetRandomInt(0, 6) // 0 would be no change
// Clear skies (all off)
if ( weatherint == 1 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], false )
call EnableWeatherEffect( udg_Weather_Effects[1], false )
call EnableWeatherEffect( udg_Weather_Effects[2], false )
call EnableWeatherEffect( udg_Weather_Effects[3], false )
call EnableWeatherEffect( udg_Weather_Effects[4], false )
endif
// Light rain
if ( weatherint == 2 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], true )
call EnableWeatherEffect( udg_Weather_Effects[1], false )
call EnableWeatherEffect( udg_Weather_Effects[2], false )
call EnableWeatherEffect( udg_Weather_Effects[3], false )
call EnableWeatherEffect( udg_Weather_Effects[4], false )
endif
// Heavy rain
if ( weatherint == 3 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], false )
call EnableWeatherEffect( udg_Weather_Effects[1], true )
call EnableWeatherEffect( udg_Weather_Effects[2], false )
call EnableWeatherEffect( udg_Weather_Effects[3], false )
call EnableWeatherEffect( udg_Weather_Effects[4], false )
endif
// Foggy moonlight
if ( weatherint == 4 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], false )
call EnableWeatherEffect( udg_Weather_Effects[1], false )
call EnableWeatherEffect( udg_Weather_Effects[2], true )
call EnableWeatherEffect( udg_Weather_Effects[3], false )
call EnableWeatherEffect( udg_Weather_Effects[4], false )
endif
// Heavy lordaeron rain
if ( weatherint == 5 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], false )
call EnableWeatherEffect( udg_Weather_Effects[1], false )
call EnableWeatherEffect( udg_Weather_Effects[2], false )
call EnableWeatherEffect( udg_Weather_Effects[3], true )
call EnableWeatherEffect( udg_Weather_Effects[4], false )
endif
// Light lodaeron rain
if ( weatherint == 6 ) then
call EnableWeatherEffect( udg_Weather_Effects[0], false )
call EnableWeatherEffect( udg_Weather_Effects[1], false )
call EnableWeatherEffect( udg_Weather_Effects[2], false )
call EnableWeatherEffect( udg_Weather_Effects[3], false )
call EnableWeatherEffect( udg_Weather_Effects[4], true )
endif
endfunction
// Does the introduction dialog, allowing players time to read the dialog before proceeding
function jrp_action_DoIntroDialog takes nothing returns nothing
local integer intA
local integer intAEnd
local integer intB
local integer intBEnd
local integer stillvoting
call TriggerSleepAction( 0.25 ) // Need to wait before setting dialog properties (we can't do this on map init.
call DialogSetMessage( udg_GameInfoDialog, "|c00FFCC00About this map:|r|n|n|c0000FFFFYour Goal:|r|n|c00FFFFFFCapture the enemy Base.|r|n|n|c0000FFFFHow to Capture:|r|n|c00FFFFFFWait in the center of a|ncontrol point.|r|n|n|c0000FFFFCheck your progress:|r|n|c00FFFFFFView the multiboard on the|n topright of the screen.|r|n|n|c00FFCC00More Information:|r|n|c00FFFFFFPress F9 for more information.|r" )
call jrp_func_DialogAddButton( udg_GameInfoDialog, "Alright! Let's go!" )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFCC00Introduction:|r giving players up to 10 seconds to read the |c0000FFFFintroduction dialog|r ..." )
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
call DialogDisplay( Player(intA), udg_GameInfoDialog, true )
set intA = intA + 1
endloop
set intA = 1 // Current second
set intAEnd = 10 // Maximum seconds to wait
loop // *** Layer 1 - seconds to wait ***
exitwhen intA >= intAEnd
set stillvoting = 0 // Count of valid players who haven't voted
set intB = 0
set intBEnd = 11
loop // *** Layer 2 - Checking each player's vote status ***
exitwhen intB > intBEnd
if ( (udg_GameInfoDialogClicks[intB] == 0) and (jrp_func_CheckPlayerSlotStatus(Player(intB), 1, 1, 0) == true) ) then
set stillvoting = stillvoting + 1
endif
set intB = intB + 1
endloop
if (stillvoting == 0) then // Nobody's still voting
set intA = intAEnd
else // Someone's holding up the fucking game! Host!; Kick him!
call TriggerSleepAction( 1 ) // And we wait
endif
set intA = intA + 1
endloop
// Hide it, we're done with this
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
call DialogDisplay(Player(0), udg_GameInfoDialog, false)
set intA = intA + 1
endloop
endfunction
// Show rounds dialog, giving players time to vote
function jrp_action_DoRoundsDialog takes nothing returns nothing
local integer intA
local integer intAEnd
// Specific to the dialog display:
local integer intB
local integer intBEnd
local integer stillvoting
// Specific to the tallying:
local integer totalvotevalue = 0
local integer totalvotes = 0
local integer averagevote
local string array round_strings
set round_strings[1] = "Win 1 round" // Not actually used!
set round_strings[2] = "Win 2 out of 3"
set round_strings[3] = "Win 3 out of 5"
set round_strings[4] = "Win 4 out of 6"
set round_strings[5] = "Win 5 out of 8"
set round_strings[6] = "Win 6 out of 10"
call DialogSetMessage( udg_RoundsDialog, "|c00FFCC00Round vote.|r|n|n|c00FFFFFFVote for rounds required to win |nthe game." )
// These specifically have to be numbered here so it's easy to associate each button with the wins required to end the game.
set udg_RoundsDialogButtons[1] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[1] )
set udg_RoundsDialogButtons[2] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[2] )
set udg_RoundsDialogButtons[3] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[3] )
// Otherwise there's too many fucking rounds
// set udg_RoundsDialogButtons[4] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[4] )
// set udg_RoundsDialogButtons[5] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[5] )
// set udg_RoundsDialogButtons[6] = jrp_func_DialogAddButton( udg_RoundsDialog, round_strings[6] )
call TriggerSleepAction( .25 ) // Need to wait before showing dialogs. I'm pausing here so the displayed text is roughly in sync with the start of the dialog.
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFCC00Voting for total rounds:|r giving players up to 10 seconds to vote for the |c0000FFFFtotal rounds|r that will be played..." )
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
call DialogDisplay( Player(intA), udg_RoundsDialog, true )
set intA = intA + 1
endloop
set intA = 1 // Current second
set intAEnd = 10 // Maximum seconds to wait
loop // *** Layer 1 - seconds to wait ***
exitwhen intA >= intAEnd
set stillvoting = 0 // Count of valid players who haven't voted
set intB = 0
set intBEnd = 11
loop // *** Layer 2 - Checking each player's vote status ***
exitwhen intB > intBEnd
if ( (udg_RoundsDialogVotes[intB] == 0) and (jrp_func_CheckPlayerSlotStatus(Player(intB), 1, 1, 0) == true) ) then
set stillvoting = stillvoting + 1
endif
set intB = intB + 1
endloop
if (stillvoting == 0) then // Nobody's still voting
set intA = intAEnd
else // Someone's holding up the fucking game! Host!; Kick him!
call TriggerSleepAction( 1 ) // And we wait
endif
set intA = intA + 1
endloop
// Hide it, we're done with this
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
call DialogDisplay(Player(0), udg_RoundsDialog, false)
set intA = intA + 1
endloop
call ClearTextMessages() // Get rid of text messages
// *** Time to tally the votes ***
set intA = 0
set intAEnd = 11
loop
exitwhen intA > intAEnd
if (udg_RoundsDialogVotes[intA] > 0) then
set totalvotevalue = totalvotevalue + udg_RoundsDialogVotes[intA]
set totalvotes = totalvotes + 1
endif
set intA = intA + 1
endloop
if (totalvotes > 0) then
set averagevote = totalvotevalue / totalvotes
set udg_Rounds_ToWin = averagevote
endif
call StartSound( gg_snd_ItemReceived )
call jrp_func_DisplayTextToRange( 0, 11, "Round votes tallied: |c00FFC000" + round_strings[udg_Rounds_ToWin] )
call TriggerSleepAction( 3 ) // Going to wait a few seconds before we go any further.
endfunction
// Updates the multiboard.
function jrp_action_MultiboardUpdate takes nothing returns nothing
local integer intA
local integer intAEnd
local integer intB
local integer intBEnd
local string tempstring
local string progstring
local integer redpercent
local integer bluepercent
// I'm grouping all of the "rounds to win" stuff together for ease of updating
local string array round_strings
set round_strings[1] = "Win 1 round"
set round_strings[2] = "Win 2 / 3"
set round_strings[3] = "Win 3 / 5"
set round_strings[4] = "Win 4 / 6"
set round_strings[5] = "Win 5 / 8"
set round_strings[6] = "Win 6 / 10"
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 10, 0, round_strings[udg_Rounds_ToWin])
// Total rounds won
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 8, 1, I2S(udg_Rounds_RedWins) )
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, 9, 1, I2S(udg_Rounds_BlueWins) )
// *** The Meat - loops through and updates the progress indicators ***
set intA = 0
set intAEnd = 6
loop
exitwhen intA > intAEnd
set redpercent = R2I( ( I2R(udg_CapScoresRed[intA]) / I2R(udg_ScoreToCap) ) * 100 )
set bluepercent = R2I( ( I2R(udg_CapScoresBlue[intA]) / I2R(udg_ScoreToCap) ) * 100 )
set progstring = ""
set intB = 1
set intBEnd = 10
loop
exitwhen intB > intBEnd
if (jrp_func_ControlPointCheckLock(intA) == true) then
if (udg_CapOwners[intA] == 0) then
set progstring = "|c00888888[LOCK]|r"
endif
if (udg_CapOwners[intA] == 1) then
set progstring = "|c00880000[LOCK]|r"
endif
if (udg_CapOwners[intA] == 2) then
set progstring = "|c00000088[LOCK]|r"
endif
else
set tempstring = "I"
if ( redpercent >= (intB * 10) ) then
set tempstring = "|c00FF0000I|r"
endif
if ( (100 - bluepercent) < (intB * 10) ) then
set tempstring = "|c000000FFI|r"
endif
set progstring = progstring + tempstring
endif
set intB = intB + 1
endloop
call jrp_func_MultiboardSetItemValue( udg_CapStatusBoard, intA + 1, 1, progstring )
call SetTextTagText(udg_CapPointTags[intA], progstring, 10 * 0.023 / 10 ) // Will probably replace this if I end up having to change texttag text a lot
set intA = intA + 1
endloop
endfunction
// Announce final win for team and wrap up the game
function jrp_action_DoEndGameForTeam takes integer winners returns nothing
local integer WinnerS
local integer WinnerE
local integer LoserS
local integer LoserE
local group tempgroup
local rect temprect
local integer intA
if (winners == 0) then
return
endif
call ClearTextMessages() // Get rid of text messages
call FogEnable( false ) // Let everyone see everything
call PauseAllUnitsBJ( true ) // *** BJ Alert! ***
if (winners == 1) then
set WinnerS = 0
set WinnerE = 5
set LoserS = 6
set LoserE = 11
call jrp_func_DisplayTextToRange( 0, 11, "|c00FF0303Red Team|r is first to " + I2S(udg_Rounds_ToWin) + " wins! |c00FFCC00Red Team has prevailed!" )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\HeroicVictory.mp3" ) // *** BJ Alert! ***
endif
if (winners == 2) then
set WinnerS = 6
set WinnerE = 11
set LoserS = 0
set LoserE = 5
call jrp_func_DisplayTextToRange( 0, 11, "|c000042FFBlue Team|r is first to " + I2S(udg_Rounds_ToWin) + " wins! |c00FFCC00Blue Team has prevailed!" )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\HeroicVictory.mp3" ) // *** BJ Alert! ***
endif
call PolledWait( 5.00 )
call DisplayTextToForce( udg_P_Allplayers, "Now that a victor has been decided, the game will end in 60 seconds." )
call StartTimerBJ( udg_EndGame_Timer, false, 60.00 )
call CreateTimerDialogBJ( udg_EndGame_Timer, "Game ends in " )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "Map by : |c00FFC000JRPereira|r@Azeroth ([email protected])" )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "Thanks to the following people for various kinds of help..." )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFC000Lead Testers: |r UberMasterII, Auraiken" )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFC000Additional Official Testers: |r Kite253, Neobezo, CTM, learningreborn, Fenrirs_Chains, DemonRazgriz, Senas, GhostWitTheMost, Pure-THC, Genso, Giga, L33tCurry" )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFC000Additional Help: |r Phyrax" )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFC000Blizzard: |r For making this map possible." )
call PolledWait( 5.00 )
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFC000Thanks for playing! |r" )
call PolledWait( 25.00 )
set intA = WinnerS
loop
exitwhen(intA > WinnerE)
call CustomVictoryBJ( Player(intA), true, true )
set intA = intA + 1
endloop
set intA = LoserS
loop
exitwhen(intA > LoserE)
call CustomDefeatBJ( Player(intA), "You have been Defeated" )
set intA = intA + 1
endloop
endfunction
// If a player leaves (functionized to handle kicks and such)
function jrp_action_CleanupLeftPlayer takes player leftplayer returns nothing
call jrp_func_DisplayTextToRange( 0, 11, ( GetPlayerName(leftplayer) + " has left the game." ) )
call jrp_func_GivePlayerControlToTeammates( leftplayer )
// call jrp_set_player_gold_distribution(GetConvertedPlayerId(leftplayer))
if ( udg_Round_InProgress == true ) then
call MultiboardDisplay( udg_CapStatusBoard, true )
if (udg_PlayerHeroes[GetPlayerId(leftplayer)] == null) then
call jrp_action_HeroGiveRandom(leftplayer)
endif
endif
endfunction
// Resets control points to neutral hostile.
function jrp_roundinit_ResetControlPointsToNeutral takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 6
loop // While I could save a single line here by skipping the loop, It's just slightly more tedius to edit this later.
exitwhen intA > intAEnd
call jrp_action_ControlPointSetOwnership(intA, 0)
set intA = intA + 1
endloop
endfunction
// Clean up any upgrades players may have researched
function jrp_roundinit_CleanUpUpgrades takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
call SetPlayerTechResearched(Player(intA), 'Rhra', 0) // Attack range bonus
call SetPlayerTechResearched(Player(intA), 'Rhac', 0) // Movement speed bonus
call SetPlayerTechResearched(Player(intA), 'Rhme', 0) // Attack damage bonus
call SetPlayerTechResearched(Player(intA), 'Rhar', 0) // Maximum health bonus
call SetPlayerTechResearched(Player(intA), 'Rhri', 0) // Summoned unit damage bonus
call SetPlayerTechResearched(Player(intA), 'Rhpt', 0) // Maximum mana bonus
set intA = intA + 1
endloop
endfunction
// Clean up items from the map
function jrp_roundinit_CleanUpItems takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
local integer intB
local integer intBEnd
// Cause stashes to drop all items
loop
exitwhen intA > intAEnd
if ( (udg_PlayerStashes[intA] != null) and (IsUnitDeadBJ(udg_PlayerStashes[intA]) == false) ) then // bj alert, but it's a safe bj
set intB = 0
set intBEnd = 5
loop
exitwhen intB > intBEnd
call UnitRemoveItem( udg_PlayerStashes[intA], UnitItemInSlot(udg_PlayerStashes[intA], intB) )
set intB = intB + 1
endloop
endif
set intA = intA + 1
endloop
// Clean up all map items
call EnumItemsInRect(bj_mapInitialPlayableArea, null, function jrp_enum_ItemRemove)
endfunction
// Get rid of stray units between rounds
function jrp_roundinit_CleanUpUnits takes nothing returns nothing
local integer array keeptypes
local unit tempunit
local group tempgroup
local integer intA = 0
local integer intAEnd = 11
local integer intB
local integer intBEnd
local boolean toremove = true
// Fountain of health
set keeptypes[1] = 'nfoh'
// Spawn defense tower
set keeptypes[2] = 'hatw'
// Player Stashes
set keeptypes[3] = 'hhou'
// Observatory/army upgrades
set keeptypes[4] = 'ngad'
// Temporary item container (for repicks)
set keeptypes[5] = 'e000'
loop
exitwhen intA > intAEnd
set tempgroup = CreateGroup()
call GroupEnumUnitsInRect(tempgroup, bj_mapInitialPlayableArea, null) // I've decided to avoid filters as they're more work than they're worth, probably don't save cycles, and use dreaded fallible globals.
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
set toremove = true
set intB = 1
set intBEnd = 5
loop
exitwhen intB > intBEnd
if (GetUnitTypeId(tempunit) == keeptypes[intB]) then
set toremove = false
endif
set intB = intB + 1
endloop
if ( (toremove == true) and (GetOwningPlayer(tempunit) != Player(PLAYER_NEUTRAL_AGGRESSIVE)) and (GetOwningPlayer(tempunit) != Player(PLAYER_NEUTRAL_PASSIVE)) ) then
call RemoveUnit( tempunit )
endif
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup( tempgroup )
set tempgroup = null
set intA = intA + 1
endloop
endfunction
// Give Red and Blue ownership of their control points. Neutral gets center.
function jrp_roundinit_AssignControlPoints takes nothing returns nothing
call jrp_action_ControlPointSetOwnership(0, 1) // Red
call jrp_action_ControlPointSetOwnership(1, 1) // Red
call jrp_action_ControlPointSetOwnership(2, 1) // Red
call jrp_action_ControlPointSetOwnership(4, 2) // Blue
call jrp_action_ControlPointSetOwnership(5, 2) // Blue
call jrp_action_ControlPointSetOwnership(6, 2) // Blue
call jrp_action_ControlPointSpawnPointDefenseTowers(0, Player(0)) // Red
call jrp_action_ControlPointSpawnPointDefenseTowers(1, Player(0)) // Red
call jrp_action_ControlPointSpawnPointDefenseTowers(2, Player(0)) // Red
call jrp_action_ControlPointSpawnPointDefenseTowers(4, Player(6)) // Blue
call jrp_action_ControlPointSpawnPointDefenseTowers(5, Player(6)) // Blue
call jrp_action_ControlPointSpawnPointDefenseTowers(6, Player(6)) // Blue
endfunction
// Announce the start of a new round
function jrp_roundinit_AnnounceNewRound takes nothing returns nothing
call ClearTextMessages() // Get rid of text messages
call jrp_func_SetAndPlayMusic("Sound\\Music\\mp3Music\\Orc2.mp3", 0.00)
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFCC00Now Starting:|r Round " + I2S(udg_Rounds_Count) + "..." )
call TriggerSleepAction( 2 )
call ClearTextMessages() // Get rid of text messages
endfunction
// Gives players some gold for the start of a round
function jrp_roundinit_SetStartingGold takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if ( jrp_func_CheckPlayerSlotStatus(Player(intA), 1, 2, 2) == true ) then
call SetPlayerState(Player(intA), PLAYER_STATE_RESOURCE_GOLD, 250)
endif
set intA = intA + 1
endloop
endfunction
// Give players their fist hero choice
function jrp_roundinit_FirstHeroChoice takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if ( jrp_func_CheckPlayerSlotStatus(Player(intA), 1, 2, 2) == true ) then
call jrp_action_HeroMakePlayerSelect( Player(intA) )
endif
set intA = intA + 1
endloop
endfunction
// Remove all heroes - this is required in order to cover dead heroes
function jrp_roundinit_RemoveAllHeroes takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
if (udg_PlayerHeroes[intA] != null) then
call RemoveUnit( udg_PlayerHeroes[intA] )
endif
set intA = intA + 1
endloop
endfunction
// Reset hero experience
function jrp_roundinit_ResetHeroXP takes nothing returns nothing
local integer intA = 0
local integer intAEnd = 11
loop
exitwhen intA > intAEnd
set udg_HeroXP[intA] = 0
set intA = intA + 1
endloop
endfunction
// The basics to start a new round - this repeats for each round and isn't really part of the main game initialization
function jrp_roundinit_StartNewRound takes nothing returns nothing
call jrp_roundinit_ResetControlPointsToNeutral() // Got to do this before cleaning up units so I don't clean up the control points
call jrp_action_HeroResetAllRespawnTimers() // Reset all hero respawn timers
call jrp_roundinit_CleanUpUpgrades() // Resets the level of all upgrades to 0
call jrp_roundinit_CleanUpUnits() // Get rid of all units
call jrp_roundinit_RemoveAllHeroes() // The above should've been sufficient, but this makes sure that dead heroes don't carry over
call jrp_roundinit_CleanUpItems() // Get rid of all items
call jrp_roundinit_AssignControlPoints() // Gives Red and Blue their share of the control points
call jrp_action_MultiboardUpdate() // Update the multiboard
call MultiboardDisplay( udg_CapStatusBoard, true) // Display the multiboard
set udg_Rounds_Count = udg_Rounds_Count + 1 // New round. I do this before the announcement so I can do "Now Starting: Round #"
call jrp_roundinit_AnnounceNewRound() // Small announcement regarding the new round.
call FogEnable(true) // Fog of war - was going to do a vote for this but it kind of defeats some of the functionality that scouts have and bores up the strategy.
call jrp_action_ToggleRoundTriggers(true) // Activate the triggers required for rounds to work (unit death, spelltriggers, etc)
set udg_Round_InProgress = true // And we're off! This is used for a couple of things including the creep respawns.
call jrp_roundinit_SetStartingGold() // Give players a small amount of gold to start the round with
call jrp_roundinit_ResetHeroXP() // Reset saved hero experience (no carryover from last round)
call jrp_roundinit_FirstHeroChoice() // Lets players select their hero. Comes with a side salad and their choice of wine.
endfunction
// Award a team with their win
function jrp_action_DoWinForTeam takes integer winners returns nothing
local integer WinnerS
local integer WinnerE
local integer LoserS
local integer LoserE
local group tempgroup
local rect temprect
local integer intA
if (winners == 0) then
return
endif
set udg_Round_InProgress = false // Round over
call ClearTextMessages() // Get rid of text messages
call FogEnable( false ) // Let everyone see everything
call PauseAllUnitsBJ( true ) // *** BJ Alert! ***
call jrp_action_ToggleRoundTriggers(false) // Disable triggers (will enable next round)
if (winners == 1) then
set udg_Rounds_RedWins = udg_Rounds_RedWins + 1
endif
if (winners == 2) then
set udg_Rounds_BlueWins = udg_Rounds_BlueWins + 1
endif
call jrp_action_MultiboardUpdate() // One last update of the scoreboard for this round
if (udg_Rounds_RedWins == udg_Rounds_ToWin) then
// Do endgame (winning team)
call jrp_action_DoEndGameForTeam(1)
return
endif
if (udg_Rounds_BlueWins == udg_Rounds_ToWin) then
// Do endgame (winning team)
call jrp_action_DoEndGameForTeam(2)
return
endif
if (winners == 1) then
set WinnerS = 1
set WinnerE = 6
set LoserS = 7
set LoserE = 12
call jrp_func_DisplayTextToRange( 0, 11, "|c00FF0303Red Team|r has captured Blue Team's base! |c00FFCC00Red Team has won the round!" )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\OrcVictory.mp3" )
endif
if (winners == 2) then
set WinnerS = 7
set WinnerE = 12
set LoserS = 1
set LoserE = 6
call jrp_func_DisplayTextToRange( 0, 11, "|c000042FFBlue Team|r has captured Red Team's base! |c00FFCC00Blue Team has won the round!" )
call PlayThematicMusicBJ( "Sound\\Music\\mp3Music\\OrcVictory.mp3" )
endif
call PolledWait( 5 )
call ClearTextMessages() // Get rid of text messages
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFCC00Map will be reset:|r in 10 seconds." )
call PolledWait( 10 )
call PauseAllUnitsBJ( false ) // Unpause everything
call jrp_roundinit_StartNewRound() // Start round
endfunction
// Check to see if any rounds were won or if the game has been won
function jrp_action_CheckForWins takes nothing returns nothing
local integer intA
local integer intAEnd
local integer maxcaps
// Check to see if red team has won
set intA = 0
set intAEnd = 6
set maxcaps = 0
loop
exitwhen intA > intAEnd
if (udg_CapOwners[intA] == 1) then
set maxcaps = maxcaps + 1
endif
set intA = intA + 1
endloop
if (maxcaps == 7) then
call jrp_action_DoWinForTeam(1)
endif
// Check to see if blue team has won
set intA = 0
set intAEnd = 6
set maxcaps = 0
loop
exitwhen intA > intAEnd
if (udg_CapOwners[intA] == 2) then
set maxcaps = maxcaps + 1
endif
set intA = intA + 1
endloop
if (maxcaps == 7) then
call jrp_action_DoWinForTeam(2)
endif
endfunction
// Dash at a target
function jrp_spell_Dash takes unit trigunit, unit targunit, integer spell_id returns nothing
local effect spell_effect1
local effect spell_effect2
local effect spell_effect3
local location tpoint1
call SetUnitInvulnerable( trigunit, true )
call SetUnitVertexColorBJ( trigunit, 100, 100, 100, 100.00 )
set tpoint1 = GetUnitLoc(trigunit)
call PlaySoundAtPointBJ( gg_snd_VolcanicRockLaunch1, 100, tpoint1, 0 )
call RemoveLocation( tpoint1 )
set tpoint1 = null
set spell_effect1 = jrp_func_EffectCreateOnUnit( "right hand", trigunit, "Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl" )
set spell_effect2 = jrp_func_EffectCreateOnUnit( "left hand", trigunit, "Abilities\\Weapons\\CryptFiendMissile\\CryptFiendMissile.mdl" )
call TriggerSleepAction( 0.40 )
set tpoint1 = GetUnitLoc(targunit)
call PlaySoundAtPointBJ( gg_snd_TinkerMissileLaunch1, 100, tpoint1, 0 )
call SetUnitPositionLoc( trigunit, tpoint1 )
call RemoveLocation( tpoint1 )
set tpoint1 = null
call jrp_func_EffectCreateAndDestroyOnUnit( "origin", targunit, "Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl" )
set spell_effect3 = jrp_func_EffectCreateOnUnit( "origin", GetTriggerUnit(), "units\\creeps\\NetherDragon\\NetherDragon.mdl" )
call SetUnitInvulnerable( trigunit, false )
call SetUnitVertexColorBJ( trigunit, 100, 100, 100, 0.00 )
call DestroyEffect( spell_effect1 )
set spell_effect1 = null
call DestroyEffect( spell_effect2 )
set spell_effect2 = null
call DestroyEffect( spell_effect3 )
set spell_effect3 = null
set spell_effect1 = null
set spell_effect2 = null
set spell_effect3 = null
endfunction
// Snipe a target (if they have ranger's mark anyways)
function jrp_spell_Snipe takes unit trigunit, unit targunit, integer spell_id returns nothing
local effect spell_effect1
local real spell_targlife
local real spell_damage = 300
local location tpoint1
local location tpoint2
set tpoint1 = GetUnitLoc(trigunit)
set tpoint2 = GetUnitLoc(targunit)
call TriggerSleepAction( ( DistanceBetweenPoints(tpoint1, tpoint2) / 1500.00 ) )
call RemoveLocation( tpoint1 )
set tpoint1 = null
call RemoveLocation( tpoint2 )
set tpoint2 = null
set tpoint1 = GetUnitLoc(targunit)
call jrp_func_EffectCreateAndDestroy(tpoint1, "Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl")
set spell_targlife = GetUnitStateSwap(UNIT_STATE_LIFE, targunit)
set spell_targlife = spell_targlife - spell_damage
if ( spell_targlife < 0.00 ) then
set spell_targlife = 0.00
endif
call UnitDamageTargetBJ( trigunit, targunit, spell_damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC ) // *** BJ Warning ***
// call SetUnitLifeBJ( targunit, spell_targlife ) // *** BJ Warning ***
call SetUnitState(targunit, UNIT_STATE_LIFE, spell_targlife)
call RemoveLocation( tpoint1 )
set tpoint1 = null
call UnitRemoveBuffBJ( 'Bfae', targunit )
endfunction
// Poison spell
function jrp_spell_Poison takes unit trigunit, unit targunit, integer spell_id returns nothing
local unit poisoner
local location targpoint = GetUnitLoc(targunit)
set poisoner = jrp_func_UnitCreateAndReturn('Emfr', GetOwningPlayer(trigunit), targpoint, GetUnitFacing(trigunit) )
call UnitAddAbility(poisoner, 'Aspo')
call IssueTargetOrder( poisoner, "attack", targunit )
call TriggerSleepAction( 1.00 )
call RemoveUnit( poisoner )
call RemoveLocation( targpoint )
set targpoint = null
endfunction
// Spell to revive allies
function jrp_spell_Revive takes unit trigunit, unit targunit, integer spell_id returns nothing
local location targpoint = GetUnitLoc(targunit)
call TriggerSleepAction( 1.25 )
call jrp_action_HeroRevive(GetOwningPlayer(targunit),targpoint)
call RemoveLocation( targpoint )
set targpoint = null
endfunction
// Summon allies to the caster
function jrp_spell_SummonAllies takes unit trigunit, location targloc, integer spell_id returns nothing
local unit tempunit
local group tempgroup
local location tpoint1 = GetUnitLoc(trigunit)
local location tpoint2
local effect tele01 = jrp_func_EffectCreate(tpoint1, "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl" )
local effect tele02 = jrp_func_EffectCreate(targloc, "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl" )
call PolledWait( 1.75 )
set tempgroup = GetUnitsInRangeOfLocAll(600, targloc)
loop
exitwhen(FirstOfGroup(tempgroup) == null)
set tempunit = FirstOfGroup(tempgroup)
if ( (GetOwningPlayer(tempunit) != GetOwningPlayer(trigunit)) and (IsPlayerAlly(GetOwningPlayer(trigunit), GetOwningPlayer(tempunit)) == true) and (IsUnitType(tempunit, UNIT_TYPE_STRUCTURE) == false) and (GetUnitTypeId(tempunit) != 'earc') ) then
set tpoint2 = GetUnitLoc(tempunit)
call jrp_func_EffectCreateAndDestroy( tpoint2, "Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl" )
call RemoveLocation( tpoint2 )
set tpoint2 = null
call SetUnitPositionLoc( tempunit, tpoint1 )
set tpoint2 = GetUnitLoc(tempunit)
call jrp_func_EffectCreateAndDestroy( tpoint2, "Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl" )
call RemoveLocation( tpoint2 )
set tpoint2 = null
endif
call GroupRemoveUnit(tempgroup, tempunit)
endloop
call DestroyGroup( tempgroup )
set tempgroup = null
call RemoveLocation( tpoint1 )
set tpoint1 = null
call RemoveLocation( targloc )
set targloc = null
call DestroyEffect( tele01 )
set tele01 = null
call DestroyEffect( tele02 )
set tele02 = null
endfunction
function jrp_trig_ChatCommand_Website takes nothing returns nothing
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|c00FFCC00Map Website|r - www.jrpereira.com/warcraft3/team_rush" )
endfunction
function jrp_trig_ChatCommand_Help takes nothing returns nothing
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|c00FFCC00Help|r - Press F9 for detailed information about this map." )
endfunction
// Repick
function jrp_trig_ChatCommand_Repick takes nothing returns nothing
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|c00FFCC00Repicking|r - The goblin merchant sells a hero repick item for 100 gold. There is one right near your spawn area." )
endfunction
function jrp_trig_ChatCommand_Commands takes nothing returns nothing
call DisplayTextToPlayer(GetTriggerPlayer(), 0, 0, "|c00FFCC00Chat Commands|r : -website, -help, -repick, -classinfo [classname]" )
endfunction
function jrp_trig_ChatCommand_HeroInfo takes nothing returns nothing
local integer playerid = GetPlayerId(GetTriggerPlayer())
local string array classnames
local string array classinfos
local string msgtemp
local integer intA = 0
local integer intAEnd = 9
local string classtype = SubStringBJ(GetEventPlayerChatString(), 11, 23)
set classnames[0] = "Scholar"
set classnames[1] = "Scout"
set classnames[2] = "Assassin"
set classnames[3] = "Priest"
set classnames[4] = "Mage"
set classnames[5] = "Berserker"
set classnames[6] = "Brute"
set classnames[7] = "Necromancer"
set classnames[8] = "Builder"
set classnames[9] = "Ranger"
set classinfos[0] = "Great against magic users, and also excels at providing the team with a constant influx of mana."
set classinfos[1] = "Fastest and best scouting unit in the game. Also is excellent at capturing territories and transporting teammates."
set classinfos[2] = "Excellent close-range killer - able to kill off enemies one at a time and disappear without a trace."
set classinfos[3] = "Can heal and protect the team using a variety of very potent abilities. Also the only class that can revive teammates."
set classinfos[4] = "Can do a lot of damage in a very large area, but is relatively frail and vulnerable if not defended."
set classinfos[5] = "Can do damage to a lot of enemies up close, and can take a fair amount of damage. Great for clearing swarms of units."
set classinfos[6] = "The most difficult hero to kill in a straight fight, and can absorb a lot of damage. Can stun and taunt very well."
set classinfos[7] = "Can create legions of undead units to attack the enemy. Great against single-target attackers."
set classinfos[8] = "Great for defending territories and supporting the team. Also can absorb a fair amount of damage."
set classinfos[9] = "Best at taking out single targets from afar - can do massive damage with its snipe ability. Is very vulnerable up close."
loop
exitwhen intA > intAEnd
if ( StringCase(classtype, false) == StringCase(classnames[intA], false) ) then
call DisplayTextToPlayer(Player(playerid), 0, 0, "|c00FFCC00" + classnames[intA] + "|r - " + classinfos[intA] )
return
endif
set intA = intA + 1
endloop
set msgtemp = "Scholar, Scout, Assassin, Priest, Mage, Berserker, Brute, Necromancer, Builder, Ranger"
call DisplayTextToPlayer(Player(playerid), 0, 0, "|c00FFCC00Heroinfo|r - Valid heroes are: " + msgtemp )
endfunction
function jrp_trig_ChatCommand_TipsOff takes nothing returns nothing
local integer playerid = GetPlayerId(GetTriggerPlayer())
set udg_Player_TipsOn[playerid] = false
call DisplayTextToPlayer(Player(playerid), 0, 0, "|c00FFCC00Tips Off|r - The tips system is now off." )
endfunction
function jrp_trig_ChatCommand_TipsOn takes nothing returns nothing
local integer playerid = GetPlayerId(GetTriggerPlayer())
set udg_Player_TipsOn[playerid] = true
call DisplayTextToPlayer(Player(playerid), 0, 0, "|c00FFCC00Tips On|r - The tips system is now on." )
endfunction
// Gets the player name using their ID. Used to confirm that I'm going to kick the right ID.
function jrp_trig_ChatCommand_Guid takes nothing returns nothing
local string nametocheck = SubStringBJ(GetEventPlayerChatString(), 7, 8)
local integer pguid = S2I(nametocheck)
local player trigplayer = GetTriggerPlayer()
if ( (GetPlayerName(trigplayer) == "JRPereira") or (GetPlayerName(trigplayer) == "UberMasterII") ) then
if ( (pguid >= 0) and (pguid <= 11) ) then
call DisplayTextToPlayer(trigplayer, 0, 0, "Name for GUID: " + GetPlayerName(Player(pguid)) )
else
call DisplayTextToPlayer(trigplayer, 0, 0, "Unknown Player" )
endif
else
call DisplayTextToPlayer(trigplayer, 0, 0, "NOPE!" )
endif
endfunction
function jrp_trig_ChatCommand_Kick takes nothing returns nothing
local integer id2kick = S2I(SubStringBJ(GetEventPlayerChatString(), 7, 8))
local player player2kick
if ( ( id2kick >= 0 ) and ( id2kick <= 11 ) and ( GetPlayerSlotState(Player(id2kick)) == PLAYER_SLOT_STATE_PLAYING ) ) then
// Seperate if statement so I can comment out as necessary
if ( GetPlayerName(GetTriggerPlayer()) == "JRPereira" ) then
set player2kick = Player(id2kick)
call CustomDefeatBJ( player2kick, "You're gone, beeyotch!" )
call jrp_func_DisplayTextToRange( 0, 11, ( "Your host " + ( GetPlayerName(GetTriggerPlayer()) + ( " just kicked " + ( GetPlayerName(player2kick) + " from the game." ) ) ) ) )
call StartSound( gg_snd_UtherTaunt2 )
call jrp_action_CleanupLeftPlayer(player2kick)
endif
endif
if ( ( id2kick >= 0 ) and ( id2kick <= 11 ) and ( GetPlayerSlotState(Player(id2kick)) == PLAYER_SLOT_STATE_PLAYING ) ) then
// Seperate if statement so I can comment out as necessary
if ( GetPlayerName(GetTriggerPlayer()) == "UberMasterII" ) then
set player2kick = Player(id2kick)
call CustomDefeatBJ( player2kick, "UberKicked!!!" )
call jrp_func_DisplayTextToRange( 0, 11, ( "Your host " + ( GetPlayerName(GetTriggerPlayer()) + ( " just kicked " + ( GetPlayerName(player2kick) + " from the game." ) ) ) ) )
call StartSound( gg_snd_UtherTaunt2 )
call jrp_action_CleanupLeftPlayer(player2kick)
endif
endif
endfunction
// Turn debug messages on
function jrp_trig_ChatCommand_DebugOn takes nothing returns nothing
if ( (GetPlayerName(GetTriggerPlayer()) == "UberMasterII") or (GetPlayerName(GetTriggerPlayer()) == "JRPereira") ) then
set udg_DebugOn = true
endif
endfunction
// Turn debug messages off
function jrp_trig_ChatCommand_DebugOff takes nothing returns nothing
if ( (GetPlayerName(GetTriggerPlayer()) == "UberMasterII") or (GetPlayerName(GetTriggerPlayer()) == "JRPereira") ) then
set udg_DebugOn = false
endif
endfunction
// Player selects a unit
function jrp_trig_PlayerSelectsUnit takes nothing returns nothing
local player trigplayer = GetTriggerPlayer()
local string tempstring
local integer playerid = GetConvertedPlayerId(trigplayer) - 1
local integer trigtype = GetUnitTypeId(GetTriggerUnit())
local string player_bool = ""
// Per unit type
local integer intA = 0
local integer intAEnd = 14
// Per player
local integer intB
local integer intBEnd
// Per player (looping through and resetting the N/Y's for udg_UnitTips_PlayerClicked
local integer intC
local integer intCEnd
// For each unit type
loop
exitwhen intA > intAEnd
// For each player
if (udg_UnitTips_Types[intA] == trigtype) then
set intB = 0
set intBEnd = 11
loop
exitwhen intB > intBEnd
set player_bool = SubStringBJ(udg_UnitTips_PlayerClicked[intA], intB + 1, intB + 1)
if ( (player_bool == "N") and (playerid == intB) and (udg_Player_TipsOn[intB + 1] == true) ) then
// Display tip for player
call DisplayTextToPlayer(Player(intB), 0, 0, "|c00FFCC00Selection Tip|r - " + udg_UnitTips_TipString[intA] + " |c00777777(Say '-tips off' to turn these tips off.)|r" )
// Loop til you get to the player in order to turn future tips off for this unit type for this player
set tempstring = ""
set intC = 0
set intCEnd = 11
loop
exitwhen intC > intCEnd
if (intB == intC) then
set tempstring = tempstring + "Y"
else
set tempstring = tempstring + player_bool
endif
set intC = intC + 1
endloop
set udg_UnitTips_PlayerClicked[intA] = tempstring
// We're done, this was the unit type they clicked
return
endif
set intB = intB + 1
endloop
endif
set intA = intA + 1
endloop
endfunction
// Unit dies
function jrp_trig_UnitDies takes nothing returns nothing
// General/for hero death
local unit dyingunit = GetTriggerUnit()
local location dyingloc
local player dyingplayer = GetOwningPlayer(dyingunit)
local integer deadplayerID = GetPlayerId(dyingplayer)
local unit killingunit = GetKillingUnit()
local player killingplayer = GetOwningPlayer(killingunit)
local integer killingplayerID = GetPlayerId(killingplayer)
// For creep respawn
local integer deadtype = GetUnitTypeId(dyingunit)
local integer customint = GetUnitUserData(dyingunit)
local integer deathtimer = 0
local integer deathtimerEnd = 60
local unit tempunit
// Did a player hero die?
if ( IsUnitType(dyingunit, UNIT_TYPE_HERO) == true ) then
set dyingloc = GetUnitLoc(dyingunit)
call jrp_func_UnitsCreateAtLoc(1, 'ndh1', dyingplayer, dyingloc, bj_UNIT_FACING)
if ( udg_PlayerSides[deadplayerID] == 1 ) then
call jrp_func_DisplayTextToRange( 0, 5, "|c00FFCC00Hero Death|r - " + GetPlayerName(dyingplayer) + " will respawn in 15 seconds." )
if ( (killingunit != null) and (udg_PlayerSides[killingplayerID] == 2) ) then
call jrp_func_DisplayTextToRange( 6, 11, "|c00FFCC00" + GetPlayerName(killingplayer) + "|r has killed |c00FFCC00" + GetPlayerName(dyingplayer) + "|r and has earned |c0000FFFF100 gold|r." )
endif
else
call jrp_func_DisplayTextToRange( 6, 11, "|c00FFCC00Hero Death|r - " + GetPlayerName(dyingplayer) + " will respawn in 15 seconds." )
if ( (killingunit != null) and (udg_PlayerSides[killingplayerID] == 1) ) then
call jrp_func_DisplayTextToRange( 0, 5, "|c00FFCC00" + GetPlayerName(killingplayer) + "|r has killed |c00FFCC00" + GetPlayerName(dyingplayer) + "|r and has earned |c0000FFFF100 gold|r." )
endif
endif
// call jrp_create_units_at_loc( 1, 'n00N', dyingplayer, dyingloc, bj_UNIT_FACING )
set udg_HeroDead[deadplayerID] = true
set udg_PlayerDeathTimers[deadplayerID] = 15
call RemoveLocation(dyingloc)
set dyingloc = null
return
endif
// Creep
if ( (GetOwningPlayer(dyingunit) == Player(PLAYER_NEUTRAL_AGGRESSIVE)) and (IsUnitType(dyingunit, UNIT_TYPE_STRUCTURE) == false) ) then
call jrp_ItemRandomDrop(GetUnitLoc(dyingunit))
loop
exitwhen deathtimer > deathtimerEnd
if ( udg_Round_InProgress == false ) then
set deathtimer = deathtimerEnd
endif
call TriggerSleepAction( 1 )
set deathtimer = deathtimer + 1
endloop
call jrp_func_EffectCreateAndDestroy( udg_Creep_Locs[customint], "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl" )
set tempunit = jrp_func_UnitCreateAndReturn(deadtype, Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Locs[customint], bj_UNIT_FACING )
call SetUnitUserData( tempunit, customint )
set tempunit = null
return
endif
endfunction
// Player leaves trigger - I need this so I can have it be the action for a trigger
function jrp_trig_PlayerLeaves takes nothing returns nothing
call jrp_action_CleanupLeftPlayer(GetTriggerPlayer())
endfunction
function jrp_trig_UnitReceivesItem takes nothing returns nothing
// For repick
local player repickplayer
local integer playerid
// For item stacking
local integer intI = 0
local integer intA
local integer intAEnd
local unit trigunit = GetTriggerUnit()
local item trigitem = GetManipulatedItem()
// Random Hero
if ( GetItemTypeId(GetManipulatedItem()) == 'lmbr' ) then
call jrp_action_HeroGiveRandom(GetOwningPlayer(GetTriggerUnit()))
return
endif
// Repick
if ( GetItemTypeId(GetManipulatedItem()) == 'tst2' ) then
set repickplayer = GetOwningPlayer(GetTriggerUnit())
set playerid = GetPlayerId(repickplayer)
set udg_HeroXP[playerid] = GetHeroXP(udg_PlayerHeroes[playerid])
call jrp_func_UnitSwapItems(udg_PlayerHeroes[playerid],udg_PlayerTempStashes[playerid])
call RemoveUnit( udg_PlayerHeroes[playerid] )
set udg_PlayerHeroes[playerid] = null
call jrp_action_HeroMakePlayerSelect(repickplayer)
return
endif
// Item stacking
if ( GetItemCharges(trigitem) > 0 ) then
set intI = 0
set intA = 0
set intAEnd = 5
loop
exitwhen intA > intAEnd
if ( ( GetItemTypeId(UnitItemInSlot(trigunit, intA)) == GetItemTypeId(trigitem) ) and ( UnitItemInSlot(trigunit, intA) != trigitem ) ) then
set intI = ( intI + GetItemCharges(UnitItemInSlot(trigunit, intA)) )
call RemoveItem( UnitItemInSlot(trigunit, intA) )
endif
set intA = intA + 1
endloop
call SetItemCharges( trigitem, ( intI + GetItemCharges(trigitem) ) )
return
endif
endfunction
// Made to trigger every 1 second. Will handle all events that happen at regular intervals
function jrp_trig_EverySecondPeriodic takes nothing returns nothing
local integer intA
local integer intAEnd
local integer maxcaps
////////////////////////////////////////////////
// Every 1 second
//////////////////////////////////////////////////
call jrp_action_GoldGain()
call jrp_action_HeroUpdateRespawnTimers()
call jrp_action_HeroCheckForRevive()
call jrp_action_ControlPointCheckProgress()
call jrp_action_ControlPointCheckOwnership()
call jrp_action_MultiboardUpdate()
call jrp_action_CheckForWins()
// Incriment all of the timer integer timers
set intA = 1
set intAEnd = 5
loop
exitwhen intA > intAEnd
set udg_IntTimers[intA] = udg_IntTimers[intA] + 1
set intA = intA + 1
endloop
////////////////////////////////////////////////
// Periodic events over 1 second
//////////////////////////////////////////////////
// Does't really matter how I order these, although for readability I'll probably order them asc from time to time.
// -1- Every 5 seconds
if (udg_IntTimers[1] >= 5) then
set udg_IntTimers[1] = 0
call jrp_action_XPGain()
// Do gold distribution for left players
// call jrp_DebugMsg("jrp_gold_distribution 1-6")
// call jrp_gold_distribution(1,6)
// call jrp_DebugMsg("jrp_gold_distribution 7-12")
// call jrp_gold_distribution(7,12)
endif
// -2- Every 15 seconds
if (udg_IntTimers[2] >= 15) then
set udg_IntTimers[2] = 0
// Ping minimap
call jrp_action_PingControlPoints()
endif
// -3- Every 30 seconds
if (udg_IntTimers[3] >= 30) then
set udg_IntTimers[3] = 0
// Update weather
call jrp_action_WeatherChange()
endif
// -4- Every 300 seconds
if (udg_IntTimers[4] >= 300) then
set udg_IntTimers[4] = 0
// Do round notification.
call jrp_func_DisplayTextToRange( 0, 11, "|c00FFCC00Current Round:|r you are currently playing round |c0000FFFF" + I2S(udg_Rounds_Count) + "|r. |c0000FFFF" + I2S(udg_Rounds_ToWin) + "|r total rounds must be won to beat the enemy team.")
endif
// -5- Every 60 seconds
if (udg_IntTimers[5] >= 60) then
set udg_IntTimers[5] = 0
// Create army guys
call jrp_action_ControlPointSpawnArmyUnitsAtPoints()
call jrp_action_ControlPointArmyOrderUnits()
endif
endfunction
// Hero unit enters hero selection area
function jrp_trig_HeroChoiceMade takes nothing returns nothing
local unit selected_unit = GetTriggerUnit()
local effect tele1
local effect tele2
local location tpoint1
local fogmodifier playerstartvis
local player selecting_player = GetOwningPlayer(selected_unit)
local integer selecting_id = GetPlayerId(selecting_player)
local group heroselectors = GetUnitsOfPlayerAndTypeId(selecting_player, 'ewsp') // *** BJ TO REPLACE ***
local location playerstartpos
// Skip if this isn't a hero
if ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) != true ) then
return
endif
// Set spawn location
if (udg_PlayerSides[selecting_id] == 1) then
set playerstartpos = GetRandomLocInRect(gg_rct_PlayerSpawnRed)
else // Going to make it cover anything else just in case, however this should generally always be blue
set playerstartpos = GetRandomLocInRect(gg_rct_PlayerSpawnBlue)
endif
// Set chosen hero
set udg_PlayerHeroes[selecting_id] = selected_unit
set udg_HeroDead[selecting_id] = false
if (udg_HeroXP[selecting_id] > 0) then
call SetHeroXP( udg_PlayerHeroes[selecting_id], udg_HeroXP[selecting_id], true )
endif
call jrp_func_UnitSwapItems(udg_PlayerHeroes[selecting_id],udg_PlayerTempStashes[selecting_id])
// Get rid of startup wisp
call ForGroup( heroselectors, function jrp_func_ForGroup_RemoveUnit )
call DestroyGroup( heroselectors )
set heroselectors = null
call StartSound( gg_snd_QuestNew )
if ( GetPlayerId(selecting_player) < 6 ) then
call jrp_func_DisplayTextToRange( 0, 5, ( GetPlayerName(selecting_player) + " has chosen a " + GetUnitName(udg_PlayerHeroes[selecting_id]) ) )
else
call jrp_func_DisplayTextToRange( 6, 11, ( GetPlayerName(selecting_player) + " has chosen a " + GetUnitName(udg_PlayerHeroes[selecting_id]) ) )
endif
set tpoint1 = GetUnitLoc(selected_unit)
set tele1 = jrp_func_EffectCreate(tpoint1, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTo.mdl" )
call RemoveLocation( tpoint1 )
set tpoint1 = null
call PauseUnit( selected_unit, true )
call SetUnitInvulnerable( selected_unit, true )
// call TriggerSleepAction( 3.00 )
if ( selecting_player == GetLocalPlayer() ) then // Not functionzing this, too few uses and too few lines
call SetCameraPosition(GetLocationX(playerstartpos), GetLocationY(playerstartpos))
endif
set playerstartvis = jrp_func_FogModifierCreate( true, selecting_player, FOG_OF_WAR_VISIBLE, playerstartpos, 500.00 )
set tele2 = jrp_func_EffectCreate(playerstartpos, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTo.mdl" )
call TriggerSleepAction( 3.00 )
call SetUnitPositionLoc( selected_unit, playerstartpos)
call jrp_func_EffectCreateAndDestroy( playerstartpos, "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl" )
call PauseUnit( selected_unit, false )
call DestroyEffect( tele1 )
set tele1 = null
call DestroyEffect( tele2 )
set tele2 = null
call RemoveLocation( playerstartpos )
set playerstartpos = null
call DestroyFogModifier( playerstartvis )
set playerstartvis = null
call TriggerSleepAction( 5.00 )
call SetUnitInvulnerable( selected_unit, false )
endfunction
// Player presses escape in order to trigger an inventory swap with stash
function jrp_trig_StashInventorySwap takes nothing returns nothing
local integer playerid = GetPlayerId(GetTriggerPlayer())
call jrp_func_UnitSwapItems(udg_PlayerHeroes[playerid],udg_PlayerStashes[playerid])
endfunction
// Player clicks a button on the intro dialog
function jrp_trig_DialogIntroClick takes nothing returns nothing
local player triggerplayer = GetTriggerPlayer()
set udg_GameInfoDialogClicks[GetPlayerId(triggerplayer)] = 1
call DisplayTextToPlayer(triggerplayer, 0, 0, "|c00FFCC00Good luck!|r - and have fun. If you'd like to turn on |c0000FFFFunit selection tips|r, type '-tips on'.")
endfunction
// Player clicks a button on the rounds dialog
function jrp_trig_DialogRoundsClick takes nothing returns nothing
local player triggerplayer = GetTriggerPlayer()
local integer intA = 1
local integer intAEnd = 6
loop
exitwhen intA > intAEnd
if ( GetClickedButton() == udg_RoundsDialogButtons[intA] ) then
set udg_RoundsDialogVotes[GetPlayerId(triggerplayer)] = intA
call DisplayTextToPlayer(triggerplayer, 0, 0, "Your vote has been cast.")
endif
set intA = intA + 1
endloop
endfunction
// Master controller for all spelltriggers
function jrp_trig_SpellTriggerMaster takes nothing returns nothing
// GetSpellAbilityUnit()
local unit spell_trigger
// GetSpellTargetUnit()
local unit spell_target
// GetSpellTargetLoc()
local location spell_targloc
local integer ability_id = GetSpellAbilityId()
// -----------------------------------
// Dash (Berserker)
if (ability_id == 'ACcb') then
// Only set these if necessary
set spell_trigger = GetSpellAbilityUnit()
set spell_target = GetSpellTargetUnit()
// Call abil
call jrp_spell_Dash(spell_trigger,spell_target,ability_id)
endif
// -----------------------------------
// Summon Allies (Scout)
if (ability_id == 'ACsh') then
// Only set these if necessary
set spell_trigger = GetSpellAbilityUnit()
set spell_targloc = GetSpellTargetLoc()
// Call abil
call jrp_spell_SummonAllies(spell_trigger,spell_targloc,ability_id)
endif
// -----------------------------------
// Snipe (Ranger)
if (ability_id == 'ACfb') then
// Only set these if necessary
set spell_trigger = GetSpellAbilityUnit()
set spell_target = GetSpellTargetUnit()
// Does the unit have the Ranger's Mark debuff?
if (UnitHasBuffBJ(spell_target, 'Bfae') == true) then
// Call abil
call jrp_spell_Snipe(spell_trigger,spell_target,ability_id)
endif
endif
// -----------------------------------
// Poison (Assassin)
if (ability_id == 'ACfd') then
// Only set these if necessary
set spell_trigger = GetSpellAbilityUnit()
set spell_target = GetSpellTargetUnit()
// Call abil
call jrp_spell_Poison(spell_trigger,spell_target,ability_id)
endif
// -----------------------------------
// Revive (Priest)
if (ability_id == 'ACf3') then
// Only set these if necessary
set spell_trigger = GetSpellAbilityUnit()
set spell_target = GetSpellTargetUnit()
// Call abil
call jrp_spell_Revive(spell_trigger,spell_target,ability_id)
endif
// -----------------------------------
set spell_targloc = null
endfunction
// Initialize the game environment
function jrp_trig_GameInitialization takes nothing returns nothing
local integer intA
local integer intAEnd
call FogMaskEnable(false) // Turn off black mask
call FogEnable(false) // Turn off fog of war
call jrp_func_SetAndPlayMusic("Sound\\Music\\mp3Music\\Orc1.mp3;", 0.00) // Initial music
// Done
call jrp_action_ToggleRoundTriggers(false) // Turn off triggers required for a round (we'll enable those later)
call jrp_init_SetupPlayers() // Set up basic vars for all players
call jrp_init_SetupWeather() // Set up weather
call jrp_init_SetupCreepRespawnVars() // Set up everything we need so creeps can respawn after death
call jrp_init_SetupSelectionTipVars() // Set up the global variables used for selection tips
call jrp_init_SetupControlPoints() // Set up the control points on the map
call jrp_init_SetupInfoQuests() // Set up the generic information quests
call jrp_init_TextTagAllShops() // Display informative texttags above all shops
call jrp_action_DoIntroDialog() // Does intro dialog and gives players time to read it.
call ClearTextMessages() // Just clearing the leftover text from the dialog - I'm not including this in the function ...yet...
call jrp_action_DoRoundsDialog() // Does rounds vote dialog and gives players time to vote.
call jrp_init_SetupMultiboard() // Initialize the multiboard
call jrp_action_WeatherChange() // Random weather choice
call jrp_init_SetupPlayerStashes() // Place player stashes
call jrp_roundinit_StartNewRound() // Initializes and starts a new round (first cleaning up the old round)
endfunction
Name | Type | is_array | initial_value |
CapOwners | integer | Yes | 0 |
CapPointNames | string | Yes | |
CapPointTags | texttag | Yes | |
CapRects | rect | Yes | |
CapScoresBlue | integer | Yes | |
CapScoresRed | integer | Yes | |
CapStatusBoard | multiboard | No | |
CaptureStructGroups | group | Yes | |
Class_Tavern | unit | No | |
Creep_Locs | location | Yes | |
DebugOn | boolean | No | false |
EndGame_Timer | timer | No | |
FogDialog | dialog | No | |
FogDialogButtons | button | Yes | |
GameInfoDialog | dialog | No | |
GameInfoDialogClicks | integer | Yes | |
GlobalTrigs | trigger | Yes | |
HeroDead | boolean | Yes | |
HeroXP | integer | Yes | |
IntTimers | integer | Yes | |
P_Allplayers | force | No | |
Player_TipsOn | boolean | Yes | false |
PlayerDeathTimers | integer | Yes | -1 |
PlayerHeroes | unit | Yes | UnitNull |
Players | player | Yes | |
Players_Blue | force | No | |
Players_Red | force | No | |
PlayerSides | integer | Yes | 0 |
PlayerStashes | unit | Yes | |
PlayerTempStashes | unit | Yes | |
PrevMaxCaps | integer | No | |
Round_InProgress | boolean | No | |
Rounds_BlueWins | integer | No | 0 |
Rounds_Count | integer | No | 0 |
Rounds_RedWins | integer | No | 0 |
Rounds_ToWin | integer | No | 2 |
RoundsDialog | dialog | No | |
RoundsDialogButtons | button | Yes | |
RoundsDialogVotes | integer | Yes | |
ScoreToCap | integer | No | 10 |
Singleplayer_Groups | force | Yes | |
UnitTips_PlayerClicked | string | Yes | NNNNNNNNNNNN |
UnitTips_TipString | string | Yes | |
UnitTips_Types | integer | Yes | |
Weather_Effects | weathereffect | Yes |
function Trig_Event_Initialization_Actions takes nothing returns nothing
local integer intA
local integer intAEnd
// -1- Player clicks unit
set intA = 0
set intAEnd = 11
set udg_GlobalTrigs[1] = CreateTrigger( )
loop
exitwhen intA > intAEnd
call TriggerRegisterPlayerUnitEvent(udg_GlobalTrigs[1], Player(intA), EVENT_PLAYER_UNIT_SELECTED, null)
set intA = intA + 1
endloop
call TriggerAddAction( udg_GlobalTrigs[1], function jrp_trig_PlayerSelectsUnit )
// -2- Unit dies
set udg_GlobalTrigs[2] = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( udg_GlobalTrigs[2], EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( udg_GlobalTrigs[2], function jrp_trig_UnitDies )
// -4- Player leaves
set intA = 0
set intAEnd = 11
set udg_GlobalTrigs[4] = CreateTrigger( )
loop
exitwhen intA > intAEnd
call TriggerRegisterPlayerEventLeave( udg_GlobalTrigs[4], Player(intA) )
set intA = intA + 1
endloop
call TriggerAddAction( udg_GlobalTrigs[4], function jrp_trig_PlayerLeaves )
// -5- Unit enters class select area (player chooses hero)
set udg_GlobalTrigs[5] = CreateTrigger( )
call TriggerRegisterEnterRectSimple( udg_GlobalTrigs[5], gg_rct_Class_Select_Area_Red )
call TriggerRegisterEnterRectSimple( udg_GlobalTrigs[5], gg_rct_Class_Select_Area_Blue )
call TriggerAddAction( udg_GlobalTrigs[5], function jrp_trig_HeroChoiceMade )
// -6- Unit recieves item
set udg_GlobalTrigs[6] = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( udg_GlobalTrigs[6], EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( udg_GlobalTrigs[6], function jrp_trig_UnitReceivesItem )
// -11- Every 1 second (various things)
set udg_GlobalTrigs[11] = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( udg_GlobalTrigs[11], 1.00 )
call TriggerAddAction( udg_GlobalTrigs[11], function jrp_trig_EverySecondPeriodic )
// -13- Player clicks intro dialog
set udg_GlobalTrigs[13] = CreateTrigger( )
call TriggerRegisterDialogEventBJ( udg_GlobalTrigs[13], udg_GameInfoDialog )
call TriggerAddAction( udg_GlobalTrigs[13], function jrp_trig_DialogIntroClick )
// -14- Player clicks rounds dialog
set udg_GlobalTrigs[14] = CreateTrigger( )
call TriggerRegisterDialogEventBJ( udg_GlobalTrigs[14], udg_RoundsDialog )
call TriggerAddAction( udg_GlobalTrigs[14], function jrp_trig_DialogRoundsClick )
call jrp_func_ChatCommandRegister( "-website", function jrp_trig_ChatCommand_Website, true )
call jrp_func_ChatCommandRegister( "-help", function jrp_trig_ChatCommand_Help, true )
call jrp_func_ChatCommandRegister( "-repick", function jrp_trig_ChatCommand_Repick, true )
call jrp_func_ChatCommandRegister( "-commands", function jrp_trig_ChatCommand_Commands, true )
call jrp_func_ChatCommandRegister( "-heroinfo", function jrp_trig_ChatCommand_HeroInfo, false )
call jrp_func_ChatCommandRegister( "-tips off", function jrp_trig_ChatCommand_TipsOff, true )
call jrp_func_ChatCommandRegister( "-tips on", function jrp_trig_ChatCommand_TipsOn, true )
call jrp_func_ChatCommandRegister( "-guid", function jrp_trig_ChatCommand_Guid, false )
call jrp_func_ChatCommandRegister( "-kick", function jrp_trig_ChatCommand_Kick, false )
// Wish I didn't need these...
call jrp_func_ChatCommandRegister( "-debug on", function jrp_trig_ChatCommand_DebugOn, true )
call jrp_func_ChatCommandRegister( "-debug off", function jrp_trig_ChatCommand_DebugOff, true )
// -15- Unit casts spell
set udg_GlobalTrigs[15] = CreateTrigger( )
call TriggerAddAction( udg_GlobalTrigs[15], function jrp_trig_SpellTriggerMaster )
call TriggerRegisterAnyUnitEventBJ( udg_GlobalTrigs[15], EVENT_PLAYER_UNIT_SPELL_CAST )
// Player presses escape (to swap inventory)
set intA = 0
set intAEnd = 11
set udg_GlobalTrigs[16] = CreateTrigger( )
loop
exitwhen intA > intAEnd
call TriggerRegisterPlayerEventEndCinematic( udg_GlobalTrigs[16], Player(intA) )
set intA = intA + 1
endloop
call TriggerAddAction( udg_GlobalTrigs[16], function jrp_trig_StashInventorySwap )
// *** WARNING *** - This MUST be down here or all wierd wonkeyness results
call jrp_trig_GameInitialization()
endfunction
//===========================================================================
function InitTrig_Event_Initialization takes nothing returns nothing
set gg_trg_Event_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Event_Initialization, function Trig_Event_Initialization_Actions )
endfunction