[System] Hero Selection System

Hero

─║╣ero─
Reaction score
250
System: Hero Selection System

Updated Version! Now in JASS and GUI

Description:

This is my Hero Selection System....I was inspired to create this when one day I was making an AOS map...and I wanted to implement Vexorian's Hero Selection System....well I wasn't too good at jass...and I still am a little shaky with the really advanced stuff...so I created my own...it is very similar to Vexorian's Hero Selection System BUT in the exception that it is made in GUI..and to me it is a lot more customizable...yes i know vexorian's hero selection system has lots of features for AI usage and other features normal hero selection systems dont have..well mine is similar...I don't know how to implement this in a AI tutorial...so i just left the AI part alone.(besides the crappy Blood Mage One lol)..now it has a JASS trigger for the whole system

Features:

  • Easily Editable Script
  • Made in JASS and GUI
  • JASS Trigger in 1 Trigger (it takes little space and is easy to work with instead of a huge folder containing many triggers)

Requirements and Implementation:

Code:
Put this in your map's custom header

function CS_Error takes player ForPlayer, string msg returns nothing
 local sound error=CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
    if (GetLocalPlayer() == ForPlayer) then
        if (msg!="") and (msg!=null) then
            call ClearTextMessages()
            call DisplayTimedTextToPlayer( ForPlayer, 0.52, -1.00, 2.00, "|cffffcc00"+msg+"|r" )
        endif
        call StartSound( error )
    endif
 call KillSoundWhenDone( error)
 set error=null
endfunction

Copy the Selection System Trigger and find this code (it's the 3rd line)

constant function RegionX takes nothing returns rect
    return gg_rct_All_Units_InVun
endfunction

change  gg_rct_All_Units_InVun to the region name you created in WE

constant function PickAbility takes nothing returns integer
    return 'A000'
endfunction

change 'A000' to the ability raw code in your map for choosing a hero

Variables:
-Create a visibility modifier variable called V

Credits:
  • Vexorian for this Sim Error
  • Hero12341234 for this system

For Those Interested Here is the Code In JASS: (yes I know it contains a couple bj's)
Code:
// HERO'S HERO SELECTION SYSTEM IN JASS

//CHANGE THIS TO YOUR REGIONS NAME

constant function RegionX takes nothing returns rect
    return gg_rct_All_Units_InVun
endfunction

constant function PickAbility takes nothing returns integer
    return 'A000'
endfunction

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

function Trig_No_Morphing_Conditions takes nothing returns boolean
    return RectContainsUnit(RegionX(), GetOrderedUnit()) == true
endfunction

function No_Morphy takes nothing returns boolean 
    return (GetIssuedOrderIdBJ() == String2OrderIdBJ("chemicalrage") ) or ( GetIssuedOrderIdBJ() == String2OrderIdBJ("robogoblin") ) or ( GetIssuedOrderIdBJ() == String2OrderIdBJ("metamorphosis") ) or ( GetIssuedOrderIdBJ() == String2OrderIdBJ("avatar") )
endfunction

function Trig_No_Morphing_Actions takes nothing returns nothing
    if ( No_Morphy() ) then
        // Makes sure the hero can't morph
        call PauseUnit( GetOrderedUnit(),true )
        call PauseUnit( GetOrderedUnit(),false )
        call ResetUnitAnimation( GetOrderedUnit() )
    else
    endif
endfunction

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

function Trig_Visibility_and_Pan_Camera takes nothing returns nothing
    local location p
    call CreateFogModifierRectBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, RegionX())
    set udg_V=GetLastCreatedFogModifier()
    set p=GetRectCenter(RegionX())
    call PanCameraToTimedLocForPlayer( GetEnumPlayer(), p, 0 )
    call RemoveLocation (p)
endfunction

function Trig_Visibility_and_Pan_Camera_Actions takes nothing returns nothing
    call ForForce( GetPlayersAll(), function Trig_Visibility_and_Pan_Camera )
endfunction

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

function Trig_Select_This_Hero_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == PickAbility() 
endfunction

function Trig_Select_This_Hero_Actions takes nothing returns nothing
    local unit cast
    local location l
    local fogmodifier a
    set a=(udg_V)
    set cast=GetTriggerUnit()
    set l=GetPlayerStartLocationLoc(GetOwningPlayer(cast))
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(cast), GetOwningPlayer(cast),l, bj_UNIT_FACING )
    call RemoveUnit( cast )
    call DestroyFogModifier(a)
    call PanCameraToTimedLocForPlayer( GetTriggerPlayer(), l, 0 )
    call RemoveLocation (l)
    set cast=null
    set a=null
    set l=null
endfunction

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

function Trig_No_Cast_Abilities_Conditions takes nothing returns boolean
   return RectContainsUnit(RegionX(), GetSpellAbilityUnit()) == true 
endfunction

function Trig_No_Cast_Abilities_Actions takes nothing returns nothing
    // Makes sure you can't cast any abilites while the hero is in the selection region.
    call PauseUnit(GetSpellAbilityUnit(),true )
    call PauseUnit(GetSpellAbilityUnit(),false )
    call ResetUnitAnimation( GetOrderedUnit() )
endfunction

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

function Trig_De_Select_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true and RectContainsUnit(RegionX(), GetTriggerUnit()) == true 
endfunction

function Trig_De_Select_Actions takes nothing returns nothing
    // Sets the Locals so We Don't Mess Up And It IS MUI
    local player p
    set p=GetTriggerPlayer()
    if ( GetOwningPlayer(GetTriggerUnit()) != Player(PLAYER_NEUTRAL_PASSIVE) ) and GetOwningPlayer(GetTriggerUnit()) == (p) then
        call SetUnitOwner( GetTriggerUnit(), Player(PLAYER_NEUTRAL_PASSIVE), true )
    endif
    set p=null
endfunction

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

function Trig_Select_Unit_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true and  RectContainsUnit(RegionX(), GetTriggerUnit()) == true
endfunction

function Select_Unit_Actions takes nothing returns nothing
    local player p
    set p=GetTriggerPlayer()
    if (GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_PASSIVE) )  then
        call SetUnitOwner( GetTriggerUnit(), GetTriggerPlayer(), true )
    else
            // Change this to change the Error Message
            call CS_Error (p,"Someone is already looking at this hero")
    endif
    set p=null
endfunction

//==========================================================================
function Trig_Set_Up_Selection_System_Func00 takes nothing returns nothing
    call UnitRemoveAbility(GetEnumUnit(),'Aatk' )
    call UnitRemoveAbility(GetEnumUnit(),'Amov' )
    call UnitAddAbility(GetEnumUnit(),PickAbility() )
    call SetUnitInvulnerable( GetEnumUnit(), true )
endfunction

function Trig_Set_Up_Selection_System_Actions takes nothing returns nothing
    local group g=CreateGroup()
    call GroupEnumUnitsInRect(g,RegionX(),null)
    call ForGroup(g,function Trig_Set_Up_Selection_System_Func00 )
    call DestroyGroup(g)
    set g=null
endfunction

//===========================================================================
function InitTrig_Selection_System takes nothing returns nothing
    local integer i=0
    local integer j=0
    
    local trigger a=CreateTrigger()
    local trigger b=CreateTrigger()
    local trigger c=CreateTrigger()
    local trigger d=CreateTrigger()
    local trigger e=CreateTrigger()
    local trigger f=CreateTrigger()
    local trigger g=CreateTrigger()
    
    call TriggerRegisterTimerEventSingle(a , 0.01 )
    call TriggerAddAction( a, function Trig_Set_Up_Selection_System_Actions )
    
    loop 
       exitwhen i==12
        call TriggerRegisterPlayerUnitEvent(b, Player( i ),EVENT_PLAYER_UNIT_SELECTED,null)
        set i=i+1
endloop  
        call TriggerAddCondition( b, Condition( function Trig_Select_Unit_Conditions ) )
        call TriggerAddAction( b, function Select_Unit_Actions ) 
       
    loop
       exitwhen j==12
        call TriggerRegisterPlayerUnitEvent(c, Player( j ),EVENT_PLAYER_UNIT_DESELECTED,null)
        set j=j+1
endloop       
        call TriggerAddCondition( c, Condition( function Trig_De_Select_Conditions ) )
        call TriggerAddAction( c, function Trig_De_Select_Actions )
        
    call TriggerRegisterAnyUnitEventBJ(d, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( d, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( d, Condition( function Trig_No_Cast_Abilities_Conditions ) )
    call TriggerAddAction( d, function Trig_No_Cast_Abilities_Actions )
    
    call TriggerRegisterAnyUnitEventBJ( e, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( e, Condition( function Trig_Select_This_Hero_Conditions ) )
    call TriggerAddAction( e, function Trig_Select_This_Hero_Actions )
    
    call TriggerRegisterTimerEventSingle( f, 0.01 )
    call TriggerAddAction( f, function Trig_Visibility_and_Pan_Camera_Actions )


    call TriggerRegisterAnyUnitEventBJ( g, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( g, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerRegisterAnyUnitEventBJ( g, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddCondition( g, Condition( function Trig_No_Morphing_Conditions ) )
    call TriggerAddAction( g, function Trig_No_Morphing_Actions )
endfunction

Download Below:
 

Attachments

  • Hero's Hero Selection System.w3x
    27.9 KB · Views: 145

Sim

Forum Administrator
Staff member
Reaction score
534
First of all, no you're not supposed to bump until 24 hours have passed :p

Comment (//) the lines that don't belong in the map header inside your CODE tag. One might just copy-paste them and forget to delete them.

Didn't test this yet. It's in my to-do list. You should give WE Help Zone a break though :p You posted at least 4 systems and stuff up to now, and they all need approval 0.o
 

Hero

─║╣ero─
Reaction score
250
First of all, no you're not supposed to bump until 24 hours have passed :p

Comment (//) the lines that don't belong in the map header inside your CODE tag. One might just copy-paste them and forget to delete them.

Didn't test this yet. It's in my to-do list. You should give WE Help Zone a break though :p You posted at least 4 systems and stuff up to now, and they all need approval 0.o

Lol...I saved them up
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Actually, yes, you need approval, I'm pretty sure... :D

This is helpful Hero, but mainly only the GUI part because IMO many people that know a lot about WE or are experienced, would know this, but for n00bs, when looking at the JASS, they'll think,"WTF? I don't want to listen to Jazz, I like hip hop! Where can I learn Jazz? Plz help!! I want to learn Jazz! " jk... :D

But this is good.
 

Sim

Forum Administrator
Staff member
Reaction score
534
You need Approval to post demos since when?

I have post many trigger demos and no one has told me you need approvel

Unlike hero I don't post them all at one time but w/e

-----------------------------
Breaking News

The Massacred of Virginia Tech.

They don't "need" approval to be posted here, but as everyone, you will want them to be in the section they belong in. That needs approval.

This way, way more people will profit from it. Triggers and scripts belong in the Free Trigger Code section BTW.
 
G

Garfield

Guest
Um, I have no idea how the "system" works... I wish there was a description...
 
Reaction score
456
First of all you need to explain few things about it :rolleyes:..

For an example how to use it? What is the region and so on..
 

Hero

─║╣ero─
Reaction score
250
There is a documentation inside the map(or there should be)...unless you want it in the thread..
 
J

J0xs

Guest
a new selection system, so whats more special about this selection of urs than others?
 

Hero

─║╣ero─
Reaction score
250
a new selection system, so whats more special about this selection of urs than others?
Easily Editable Script
Made in JASS and GUI
JASS Trigger in 1 Trigger (it takes little space and is easy to work with instead of a huge folder containing many triggers)

Also I forgot to say easy to implement..lol
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top