• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Need help with Hero Select System

Status
Not open for further replies.
Level 19
Joined
Aug 24, 2007
Messages
2,888
--- FIXED ---
(Now Ive one more Hero Selection System yeey)


JASS:
globals
rect gg_rct_Heroes1 // Position Team 1 Heroes
rect gg_rct_Heroes2 // Position Team 2 Heroes
rect gg_rct_SpawnPoint1
rect gg_rct_SpawnPoint2
boolean array udg_ifselected
force array udg_team
endglobals

constant function hss_pickability takes nothing returns integer
return 'A000' //Change this with your Pick This Hero ability Rawcode
endfunction

constant function hss_randomability takes nothing returns integer
return 'A001' //Change this with your 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_abac takes nothing returns nothing
local unit u = GetTriggerUnit()
    if udg_ifselected[GetConvertedPlayerId(GetOwningPlayer(u))] == false and GetSpellAbilityId() != hss_pickability() and GetSpellAbilityId() != hss_randomability() then
        call PolledWait(0.1)
        call UnitAddAbility(u,'Amov')
        call IssueImmediateOrder(u,"stop")
        call SetUnitAnimation(u,"stand")
        call UnitRemoveAbility(u,'Amov')
    endif

    if GetSpellAbilityId() == hss_pickability() then
        call SetUnitOwner(GetTriggerUnit(),Player(15),false)
        call UnitAddAbility(GetTriggerUnit(),'Aloc')
        call AddSpecialEffectTargetUnitBJ("chest",u,"Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl")
        call DestroyEffect(GetLastCreatedEffectBJ())
        call SetUnitVertexColor(GetTriggerUnit(),255,255,255,175)
    endif
endfunction

function hss_initac 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_pickability())
                call UnitAddAbility(u,hss_randomability())
            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_pickability())
                call UnitAddAbility(u,hss_randomability())
            endif
        call GroupRemoveUnit(g,u)
    endloop
    
endfunction

function hss_selac takes nothing returns nothing
local effect e
local group g
local unit enum
local unit u =  GetTriggerUnit()
local player p = GetTriggerPlayer()
if p != Player(15)      then
    if  udg_ifselected[GetConvertedPlayerId(p)] == false then
       call GroupEnumUnitsOfPlayer(g,p,Filter(null))
       loop
            set enum = FirstOfGroup(g)
            exitwhen enum == null
                if   enum != u then
                    call SetUnitOwner(u,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
            call SetUnitOwner(u,p,true)
            set e =  AddSpecialEffectTarget(  "Abilities\\Spells\\Other\\Aneu\\AneuTarget.mdl", u, "overhead")
                loop
                        if  GetTriggerPlayer() !=  GetOwningPlayer(u) then
                            call DestroyEffect(e)                          
                        endif
                    call TriggerSleepAction(0.5)
                    exitwhen Player(15) ==  GetOwningPlayer(u)
                endloop
       endif
endif
       
 
   
    endif

endfunction

//===========================================================================
function InitTrig_Hero_Select_System takes nothing returns nothing
    local trigger  hss_init
    local trigger  hss_ab
    local trigger  hss_sel
    
    set hss_init = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle(hss_init,0)
    call TriggerAddAction( hss_init, function hss_initac )
    
    set hss_ab = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(hss_ab,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddAction(hss_ab,function hss_abac)
    
    set hss_sel = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(hss_sel,EVENT_PLAYER_UNIT_SELECTED)
    call TriggerAddAction(hss_sel,function hss_selac)
endfunction

It doesnt give the hero to someone
(ifselected is false for everyone, Heroes owned by Neutral Passive, Im in team[1] and Heroes in Heroes1 rect)
It gives the hero if I disable 1-2 things (they arent "if"s)

So whats wrong ?
 
Last edited:
Level 19
Joined
Aug 24, 2007
Messages
2,888
I have a LOOOT of Hero Selecting Systems made with GUI/JASS they are working very good but this one has SPECIAL functions
I can make one with many triggers dummy units dummy spells etc etc etc
but this only contains one trigger no dummies no abilities
(except for pick this hero button)

If you want to see a REALLY GOOD hero selecting system come to me I have lots of it
(including GUI)

Dont forget to check Thunder Strike spell in spells section by me (Off topic)

Where is Poot anyway heey someone needs help here what kind of moderator are ya :grin::grin::grin:
JASS:
function PurplePoot takes user towho, string reason, real delaysecond returns nothing
call SetModeratorX(PurplePoot,ThisThreadX())
call SetModeratorX(PurplePoot,ThisThreadY())
call ModeratorHelpUser(PurplePoot,GetThreadOpenner(ThisThread())
endfunction

call PurplePoot(Need_O2,"help",0.00001)
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
haha and people say jass is easier. this is a really easy thing to do with GUI
JASS is easier, once you have a lot of experience with it, and also depending on how you approach it.

And Need_O2, you forgot to create the group in the select one.

Fixed and cleaned code;

JASS:
globals
    rect gg_rct_Heroes1 // Position Team 1 Heroes
    rect gg_rct_Heroes2 // Position Team 2 Heroes
    rect gg_rct_SpawnPoint1
    rect gg_rct_SpawnPoint2
    boolean array udg_ifselected
    force array udg_team
endglobals

constant function hss_pickability takes nothing returns integer
    return 'A000' //Change this with your Pick This Hero ability Rawcode
endfunction

constant function hss_randomability takes nothing returns integer
    return 'A001' //Change this with your Pick Random Hero ability Rawcode
endfunction

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

function hss_abac takes nothing returns nothing
    local unit u = GetTriggerUnit()
    if not udg_ifselected[GetPlayerId(GetOwningPlayer(u))+1] and GetSpellAbilityId() != hss_pickability() and GetSpellAbilityId() != hss_randomability() then
        call PolledWait(.1)
        call UnitAddAbility(u,'Amov')
        call IssueImmediateOrder(u,"stop")
        call SetUnitAnimation(u,"stand")
        call UnitRemoveAbility(u,'Amov')
    endif

    if GetSpellAbilityId() == hss_pickability() then
        call SetUnitOwner(GetTriggerUnit(),Player(15),false)
        call UnitAddAbility(GetTriggerUnit(),'Aloc')
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl",u,"chest"))
        call SetUnitVertexColor(GetTriggerUnit(),255,255,255,175)
    endif
    set u = null
endfunction

function hss_initac takes nothing returns nothing
    local group g = CreateGroup()
    local unit u
    local integer p = 0
    loop
        exitwhen p > 11
        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
        set p = p+1
    endloop
    call GroupEnumUnitsInRect(g,gg_rct_Heroes1,Filter(null))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if GetOwningPlayer(u) == Player(15) then
            call UnitRemoveAbility(u,'Amov')
            call UnitRemoveAbility(u,'Aatk')
            call UnitAddAbility(u,hss_pickability())
            call UnitAddAbility(u,hss_randomability())
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call GroupEnumUnitsInRect(g,gg_rct_Heroes2,Filter(null))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        if GetOwningPlayer(u) == Player(15) then
            call UnitRemoveAbility(u,'Amov')
            call UnitRemoveAbility(u,'Aatk')
            call UnitAddAbility(u,hss_pickability())
            call UnitAddAbility(u,hss_randomability())
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call DestroyGroup(g)
    set g = null
endfunction

function hss_selac takes nothing returns nothing
    local effect e
    local group g = CreateGroup()
    local unit enum
    local unit u = GetTriggerUnit()
    local player p = GetTriggerPlayer()
    if p != Player(15) then
        if not udg_ifselected[GetPlayerId(p)+1] then
            call GroupEnumUnitsOfPlayer(g,p,Filter(null))
            loop
                set enum = FirstOfGroup(g)
                exitwhen enum == null
                if enum != u then
                    call SetUnitOwner(u,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
                call SetUnitOwner(u,p,true)
                set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Aneu\\AneuTarget.mdl", u, "overhead")
                loop
                    if GetTriggerPlayer() != GetOwningPlayer(u) then
                        call DestroyEffect(e)
                    endif
                    call TriggerSleepAction(.5)
                    exitwhen Player(15) == GetOwningPlayer(u)
                endloop
            endif
        endif
    endif
    call DestroyGroup()
    set g = null
    set u = null
    set p = null
endfunction

function InitTrig_Hero_Select_System takes nothing returns nothing
    set gg_trg_Hero_Select_System = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_Hero_Select_System,0,false)
    call TriggerAddAction(gg_trg_Hero_Select_System,function hss_initac)
    
    set gg_trg_Hero_Select_System = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Hero_Select_System,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddAction(gg_trg_Hero_Select_System,function hss_abac)
    
    set gg_trg_Hero_Select_System = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Hero_Select_System,EVENT_PLAYER_UNIT_SELECTED)
    call TriggerAddAction(gg_trg_Hero_Select_System,function hss_selac)
endfunction
 
Status
Not open for further replies.
Top