• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Another Hero Selecting System

Status
Not open for further replies.
Level 19
Joined
Aug 24, 2007
Messages
2,888
Version 0.2

Change Log
-Some Leaks Removed

Used Regions (Region names must be exactly same)
Heroes1 - The Region Contains heroes of Team 1
Heroes2 - The Region Contains heroes of Team 1
SpawnPoint1 - The Spawning Region of Team 1 Heroes
SpawnPoint2 - The Spawning Region of Team 2 Heroes

Used Globals (variables): (variable names must be same)
PlayerHasHero - Variable type "Boolean", Array Size 12, False by Default
Team - Variable Type "Player Group", Array Size 2, Empty by Default

Usage:
1- Place the Heroes of Team 1 to Heroes1 and Heroes of Team 2 to Heroes2, Make them max level and give all abilities
2- Make a trigger that adds players to Team[1] and Team[2]
[Trigger="Example Trigger for Adding Players"]Player Add
Events
Map initialization
Conditions
Actions
-------- Adding to Team1 --------
Player Group - Add Player 1 (Red) to Team[1]
Player Group - Add Player 2 (Blue) to Team[1]
Player Group - Add Player 3 (Teal) to Team[1]
Player Group - Add Player 4 (Purple) to Team[1]
-------- Adding to Team2 --------
Player Group - Add Player 5 (Yellow) to Team[2]
Player Group - Add Player 6 (Orange) to Team[2]
Player Group - Add Player 7 (Green) to Team[2]
Player Group - Add Player 8 (Pink) to Team[2]
[/Trigger]

3- Create a Trigger Named Hero Selection System, Select the trigger press edit up there, choose "Convert to Custom text", Repleace the text inside it with the code bellow
[JASS="Hero Selection System"]constant function HSS_Pick_This_Hero_SpellId takes nothing returns integer
return 'A000' // Pick This Hero ability Rawcode
endfunction

constant function HSS_Pick_Random_Hero_SpellId takes nothing returns integer
return 'A001' //Pick Random Hero ability Rawcode
endfunction


function GetPlayerColorString takes player p returns string
if p == Player(0) then
return "|c00FF0303"
endif
if p == Player(1) then
return "|c000042FF"
endif
if p == Player(2) then
return "|c001CE6B9"
endif
if p == Player(3) then
return "|c00800080"
endif
if p == Player(4) then
return "|c00FFFC01"
endif
if p == Player(5) then
return "|c00FF8000"
endif
if p == Player( 6) then
return "|c0000FF00"
endif
if p == Player(7) then
return "|c00FF80FF"
endif
if p == Player(8) then
return "|c00C0C0C0"
endif
if p == Player(9) then
return "|c007EBFF1"
endif
if p == Player(10) then
return "|c00004000"
endif
if p == Player(11) then
return "|c004E2A04"
endif
return null
endfunction


function HSS_Ability_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit ur = GetTriggerUnit()
local rect a
local rect b
local player p = GetOwningPlayer(u)
local group g = CreateGroup()
local unit enum
local boolean found = false
local location loc
local integer pnum = 0
local unit lastcreatedunit
if IsPlayerInForce(p,udg_Team[1]) then
set a = gg_rct_SpawnPoint1
set b = gg_rct_Heroes1
else
set a = gg_rct_SpawnPoint2
set b = gg_rct_Heroes1
endif

set loc = GetRectCenter(a)

if udg_PlayerHasHero[GetConvertedPlayerId(GetOwningPlayer(u))] == false and GetSpellAbilityId() != HSS_Pick_This_Hero_SpellId() and GetSpellAbilityId() != HSS_Pick_Random_Hero_SpellId() then
call PauseUnit( u, true)
call IssueImmediateOrder(u, "stop" )
call PauseUnit(u, false)
call UnitRemoveBuffsBJ( bj_REMOVEBUFFS_ALL, u )
endif

if GetSpellAbilityId() == HSS_Pick_This_Hero_SpellId() and udg_PlayerHasHero[GetConvertedPlayerId(p)] == false then
set udg_PlayerHasHero[GetConvertedPlayerId(p)] = true
call UnitAddAbility(u,'Aloc')
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl",u,"chest"))
call SetUnitVertexColor(u,255,255,255,175)
if GetLocalPlayer() == p then
call SetCameraTargetController(u,0,0,false)
endif
call TriggerSleepAction(2)
set lastcreatedunit = CreateUnitAtLoc(p, GetUnitTypeId(u),loc, bj_UNIT_FACING )
call SetUnitOwner(u,Player(15),false)
set pnum = 0
loop
exitwhen pnum == 16
set pnum = pnum +1
call DisplayTimedTextToPlayer(Player(pnum), 0, 0, 10.0, GetPlayerColorString(p)+GetPlayerName(p)+"|r has picked "+ GetUnitName(u))
endloop
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(lastcreatedunit, true)
call ResetToGameCamera(0)
call SetCameraPosition(GetRectCenterX(a),GetRectCenterY(a))
endif
endif

if GetSpellAbilityId() == HSS_Pick_Random_Hero_SpellId() and udg_PlayerHasHero[GetConvertedPlayerId(p)] == false then
call GroupEnumUnitsInRect(g,b,Filter(null))
loop
set u = GroupPickRandomUnit(g)
if GetOwningPlayer(u) == Player(15) then
set found = true
else
call GroupRemoveUnit(g,u)
endif
exitwhen found
endloop
call PauseUnit( ur, true)
call IssueImmediateOrder(ur, "stop" )
call PauseUnit(ur, false)
set udg_PlayerHasHero[GetConvertedPlayerId(p)] = true
call UnitAddAbility(u,'Aloc')
call SetUnitColor(u,GetPlayerColor(p))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl",u,"chest"))
call SetUnitVertexColor(u,255,255,255,175)
call SetCameraTargetControllerNoZForPlayer( p, u, 0, 0, false )
call SetUnitOwner(ur,Player(15),true)
call TriggerSleepAction(2)
set lastcreatedunit = CreateUnitAtLoc(p, GetUnitTypeId(u),loc, bj_UNIT_FACING )
set pnum = 0
loop
exitwhen pnum == 16
set pnum = pnum +1
call DisplayTimedTextToPlayer(Player(pnum), 0, 0, 10.0, GetPlayerColorString(p)+GetPlayerName(p)+"|r has randomed to "+ GetUnitName(u))
endloop
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(lastcreatedunit, true)
call ResetToGameCamera(0)
call SetCameraPosition(GetRectCenterX(a),GetRectCenterY(a))
endif
endif
call RemoveRect(a)
call RemoveLocation(loc)
set lastcreatedunit = null
endfunction

function HSS_Initialization_Actions takes nothing returns nothing
local group g
local unit u
local integer p = 0
set g = CreateGroup()
loop
exitwhen p == 12
if IsPlayerInForce(Player( p),udg_Team[1]) then
call CreateFogModifierRectBJ(true,Player(p),ConvertFogState(4),gg_rct_Heroes1)
else
call CreateFogModifierRectBJ(true,Player(p),ConvertFogState(4),gg_rct_Heroes2)
endif
call GroupEnumUnitsInRect(g,gg_rct_Heroes1,Filter(null))
set p = p+1
endloop

loop
set u = FirstOfGroup( g)
exitwhen u == null
if GetOwningPlayer(u) == Player(PLAYER_NEUTRAL_PASSIVE) then
call UnitRemoveAbility(u,'Amov')
call UnitRemoveAbility(u,'Aatk')
call UnitAddAbility(u,HSS_Pick_Random_Hero_SpellId())
call UnitAddAbility(u,HSS_Pick_This_Hero_SpellId())
call UnitAddAbility(u,'Avul')
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = CreateGroup()
call GroupEnumUnitsInRect(g,gg_rct_Heroes2,Filter(null))
loop
set u = FirstOfGroup( g)
exitwhen u == null
if GetOwningPlayer(u) == Player(PLAYER_NEUTRAL_PASSIVE) then
call UnitRemoveAbility(u,'Amov')
call UnitRemoveAbility(u,'Aatk')
call UnitAddAbility(u,HSS_Pick_This_Hero_SpellId())
call UnitAddAbility(u,HSS_Pick_Random_Hero_SpellId())
call UnitAddAbility(u,'Avul')
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g = null
endfunction

function HSS_Selection_Actions takes nothing returns nothing
local effect e
local group g
local unit enum
local unit u = GetTriggerUnit()
local player p = GetTriggerPlayer()
local boolean removed = false
if udg_PlayerHasHero[GetConvertedPlayerId(p)] == false then
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g,p,Filter(null))
loop
set enum = FirstOfGroup( g)
exitwhen enum == null
if (enum == u) == false then
call SetUnitOwner(enum,Player(15),true)
endif
call GroupRemoveUnit(g,enum)
endloop
if GetOwningPlayer(u) == Player(15) and (RectContainsUnit(gg_rct_Heroes1,u) and IsPlayerInForce(p,udg_Team[1] )) or (RectContainsUnit(gg_rct_Heroes2,u) and IsPlayerInForce(p,udg_Team[2] )) then
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Aneu\\AneuTarget.mdl", u, "overhead")
call SetUnitOwner(u,p,true)
loop
if p != GetOwningPlayer(u) then
call DestroyEffect(e)
set removed = true
endif
call TriggerSleepAction(0.5)
exitwhen removed
endloop
endif
endif
set p = null
set e = null
endfunction

//===================================

function InitTrig_Hero_Selection_System takes nothing returns nothing
local trigger hss
local integer a = 0

set hss = CreateTrigger( )
call TriggerRegisterTimerEvent(hss, 0, false)
call TriggerAddAction( hss, function HSS_Initialization_Actions)

set hss = CreateTrigger()
loop
exitwhen a == 13
call TriggerRegisterPlayerUnitEvent(hss,Player(a),EVENT_PLAYER_UNIT_SPELL_CAST,null)
set a = a+1
endloop
set a = 0
call TriggerAddAction(hss,function HSS_Ability_Actions)

set hss = CreateTrigger()
loop
exitwhen a == 13
call TriggerRegisterPlayerUnitEvent(hss,Player(a),EVENT_PLAYER_UNIT_SELECTED,null)
set a = a+1
endloop
call TriggerAddAction(hss,function HSS_Selection_Actions)

call Preload("Abilities\\Spells\\Other\\Aneu\\AneuTarget.mdl")
call Preload("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl")
set hss = null
endfunction[/code]

4- Create an Ability named Pick this hero (name is not important) Press Ctrl-D in object editor to see your abilities raw code. Repleace the 'A000' in code (return 'A000' // Pick This Hero ability Rawcode)
with your abilities raw code
5- Do samething for Pick Random Hero ability
 
Last edited:
Status
Not open for further replies.
Top