[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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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