• 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.

Ideas for a Race/Hero Selection System

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2011
Messages
460
Hello. I feel that this fits into this category. So I'm working on a map that I'm calling Creep Wars. Basic concept that needs to be understood for suggestions is: Players will select a race through some method, and then select a hero through preferably the same method, without the use of Entered text or through dialogs for simplicity and ensuring that they have CHOSEN the race and hero. I've tried many things and nothing has worked properly, so I really would like to get some ideas or concepts or even a link to an existing system. I simply cannot understand the problems that I encountered simply for their bizarre nature. I scrapped the latest system and am simply blundering in the dark over this. Any ideas are appreciated, as long as they have some detail and are plausible. Please note that jass coding is acceptable, I can modify jass very well and code it, I just am lost on how to actually get this system to work. Thanks in advance!
 
Level 9
Joined
Apr 23, 2011
Messages
460
What I'm looking for is something like. Player purchases an item or unit or cast a spell from a given unit in some way to pick race -> that unit/item and unit used to purchase from are deleted, updates the multiboard for race -> system repeats but instead for Heroes of which there will be 3 for each race (one for each attribute). and then after that it is deleted and it will set a variable player_ready[player number] = true. Then goes into the game design.
 
Level 9
Joined
Apr 23, 2011
Messages
460
I've run into an issue I had before... My triggers are listed below. I haven't had time to convert them to Jass and clean them up for leaks and optimization yet, because I want it to work before that :p

  • Startup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Variables --------
      • Set pos_race[1] = Pick Bandit
      • Set pos_race[2] = Pick Demon
      • Set pos_race[3] = Pick Dwarf
      • Set pos_race[4] = Pick Elf
      • Set pos_race[5] = Pick Human
      • Set pos_race[6] = Pick Naga
      • Set pos_race[7] = Pick Ogre
      • Set pos_race[8] = Pick Orc
      • Set pos_race[9] = Pick Undead
      • -------- Next Variable Set --------
      • Set pos_race_names[1] = Bandit
      • Set pos_race_names[2] = Demon
      • Set pos_race_names[3] = Dwarf
      • Set pos_race_names[4] = Elf
      • Set pos_race_names[5] = Human
      • Set pos_race_names[6] = Naga
      • Set pos_race_names[7] = Ogre
      • Set pos_race_names[8] = Orc
      • Set pos_race_names[9] = Undead
      • Set pos_race_names[10] = Draconic
      • -------- Next Variable Set --------
      • Set Color[0] = |cffffcc00
      • Set Color[1] = |c00ff0000
      • Set Color[2] = |c000000ff
      • Set Color[3] = |c0000ffff
      • Set Color[4] = |c00800080
      • Set Color[5] = |c00ffff00
      • Set Color[6] = |c00ff80000
      • Set Color_Endtag = |r
      • -------- Next Variable Set --------
      • Set Players_Group = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
      • -------- Player Setup --------
      • Player Group - Pick every player in Players_Group and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Race Selector for (Picked player) at ((Picked player) start location) facing Default building facing degrees
          • For each (Integer A) from 1 to 9, do (Actions)
            • Loop - Actions
              • Unit - Add pos_race[(Integer A)] to (Last created unit)
          • Set Picker[(Player number of (Picked player))] = (Last created unit)
          • Set Players[(Player number of (Picked player))] = (Name of (Picked player))
          • Player - Set (Picked player) Current gold to 50
  • Race
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Race Selector
    • Actions
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to pos_race[(Integer A)]
            • Then - Actions
              • Multiboard - Set the text for Multiboard item in column 2, row ((Player number of (Owner of (Casting unit))) + 1) to pos_race_names[(Integer A)]
              • Unit - Remove Picker[(Player number of (Owner of (Casting unit)))] from the game
              • Unit - Create 1 Hero Selector for (Owner of (Casting unit)) at ((Owner of (Casting unit)) start location) facing Default building facing degrees
              • Set Picker[(Player number of (Owner of (Casting unit)))] = (Last created unit)
              • Selection - Select Picker[(Player number of (Owner of (Casting unit)))] for (Owner of (Casting unit))
              • Skip remaining actions
            • Else - Actions
I'm lost as to what the error is. No matter what you select, you always will get Undead returned. This is confirmed to be because no matter what boolean or condition i put in place, it runs through every action. I placed a Game - Send Message to all players with text: pos_race_names[Integer A] and got every race. By placing turn trigger off before actions, it only runs bandit. Could this be because i Copy/pasted my spells over and over? I raw data codes and got:
  • A000:ANcl
  • A001:ANcl
  • A002:ANcl
  • A003:ANcl
  • A004:ANcl
  • A005:ANcl
  • A006:ANcl
  • A007:ANcl
  • A008:ANcl

Am I not allowed to directly compare (Ability being cast) to an ability-array variable through the use of For each integer looping?
 
Level 11
Joined
Nov 15, 2007
Messages
800
I used Channel because it's the only ability able to have its base spell order ID changed. Make sure all of your spells have a different order ID. There's a data field for it in the spell itself within the object editor.
 
Level 9
Joined
Apr 23, 2011
Messages
460
Fixed it immediately. And with the ability to check for casting unit, I'm guessing I can layer the order id's?

Edit: I converted the trigger to custom text and believe that I've made it leakless and pretty efficient. Any noticeable corrections? I noticed it uses a lot of BJ functions and converting them seems like more hassle than it's worth.

JASS:
function Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'h001' ) ) then
        return false
    endif
    return true
endfunction

function SpellCompare takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == udg_pos_race[GetForLoopIndexA()] ) ) then
        return false
    endif
    return true
endfunction

function Race takes nothing returns nothing
local integer i = 1
local integer iend = 9
local player p = GetOwningPlayer(GetSpellAbilityUnit())
    loop
        exitwhen i > iend
        if ( SpellCompare() ) then
            call DisableTrigger( GetTriggeringTrigger() )
            call DisplayTextToForce( GetPlayersAll(), udg_pos_race_names[GetForLoopIndexA()] )
            call MultiboardSetItemValueBJ( udg_Multiboard, 2, ( GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit())) + 1 ), udg_pos_race_names[GetForLoopIndexA()] )
            call RemoveUnit( udg_Picker[GetConvertedPlayerId(p)] )
            call CreateNUnitsAtLoc( 1, 'h000', p, GetPlayerStartLocationLoc(p), bj_UNIT_FACING )
            set udg_Picker[GetConvertedPlayerId(p)] = GetLastCreatedUnit()
            call SelectUnitForPlayerSingle( udg_Picker[GetConvertedPlayerId(p)], GetOwningPlayer(GetSpellAbilityUnit()) )
            return
        else
        endif
        set i = i + 1
    endloop
set p = null
endfunction

function InitTrig_Race takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Race )
    set t = null
endfunction

Edit: For those who may seek this out, a working GUI version of the system is posted below, once I get my map systems set up how I want them, I'll convert them to jass, clean them up, and post those here as well.
  • Race Select
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Race Selector
    • Actions
      • Set temp_loc = ((Owner of (Casting unit)) start location)
      • For each (Integer A) from 1 to (Amount of Races), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to pos_race[(Integer A)]
            • Then - Actions
              • Multiboard - Set the text for Multiboard item in column 2, row ((Player number of (Owner of (Casting unit))) + 1) to pos_race_names[(Integer A)]
              • Unit - Remove Picker[(Player number of (Owner of (Casting unit)))] from the game
              • Unit - Create 1 Hero_Selector[(Integer A)] for (Owner of (Casting unit)) at temp_loc facing Default building facing degrees
              • Set Picker[(Player number of (Owner of (Casting unit)))] = (Last created unit)
              • Selection - Select Picker[(Player number of (Owner of (Casting unit)))] for (Owner of (Casting unit))
              • Custom script: set udg_temp_loc = null
              • Skip remaining actions
            • Else - Actions
  • Hero Select
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Race Selector
    • Actions
      • Set temp_loc = ((Owner of (Casting unit)) start location)
      • Unit - Remove Picker[(Player number of (Owner of (Casting unit)))] from the game
      • For each (Integer A) from 1 to (Amount of Heroes), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Hero_Select[(Integer A)]
            • Then - Actions
              • Unit - Create 1 Heroes[(Integer A)] for (Owner of (Casting unit)) at temp_loc facing Default building facing degrees
              • Custom script: set udg_temp_loc = null
              • Set Player_Picked[(Player number of (Owner of (Casting unit)))] = True
              • Skip remaining actions
            • Else - Actions
  • Startup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Variables --------
      • Set pos_race[1] = Pick Bandit
      • Set pos_race[2] = Pick Demon
      • Set pos_race[3] = Pick Dwarf
      • Set pos_race[4] = Pick Elf
      • Set pos_race[5] = Pick Human
      • Set pos_race[6] = Pick Naga
      • Set pos_race[7] = Pick Ogre
      • Set pos_race[9] = Pick Undead
      • -------- Next Variable Set --------
      • Set pos_race_names[1] = Bandit
      • Set pos_race_names[2] = Demon
      • Set pos_race_names[3] = Dwarf
      • Set pos_race_names[4] = Elf
      • Set pos_race_names[5] = Human
      • Set pos_race_names[6] = Naga
      • Set pos_race_names[7] = Ogre
      • Set pos_race_names[8] = Orc
      • Set pos_race_names[9] = Undead
      • Set pos_race_names[10] = Draconic
      • -------- Next Variable Set --------
      • Set Heroes[1] = Archknight
      • Set Heroes[2] = Pirate
      • Set Heroes[3] = Pyromancer
      • Set Heroes[4] = Typhoon Blade
      • -------- Next Variable Set --------
      • Set Hero_Select[1] = Archknight
      • Set Hero_Select[2] = Pirate
      • Set Hero_Select[3] = Pyromancer
      • Set Hero_Select[4] = Typhoon Blade
      • -------- Next Variable Set --------
      • Set Hero_Selector[1] = Hero Selector (Bandit)
      • Set Hero_Selector[2] = Hero Selector (Demon)
      • Set Hero_Selector[3] = Hero Selector (Dwarf)
      • Set Hero_Selector[4] = Hero Selector (Elf)
      • Set Hero_Selector[5] = Hero Selector (Human)
      • Set Hero_Selector[6] = Hero Selector (Naga)
      • Set Hero_Selector[7] = Hero Selector (Ogre)
      • Set Hero_Selector[8] = Hero Selector (Orc)
      • Set Hero_Selector[9] = Hero Selector (Undead)
      • -------- Player Setup --------
      • Set temp_loc = ((Owner of (Casting Unit)) start location)
        • Player Group - Pick every player in Players_Group and do (Actions)
          • Loop - Actions
            • Unit - Create 1 Race Selector for (Picked player) at (temp_loc) facing Default building facing degrees
            • For each (Integer A) from 1 to 9, do (Actions)
              • Loop - Actions
                • Unit - Add pos_race[(Integer A)] to (Last created unit)
            • Set Picker[(Player number of (Picked player))] = (Last created unit)
  • "pos_race" = Ability Array
  • "Heroes" = Unit-Type Array
  • "Hero_Select" = Ability Array
  • "Hero_Selector" = Unit-Type Array
  • "temp_loc" = Point
  • "Picker" = Unit Array
  • "Player_Picked" = boolean array

I want to thank Meticulous for giving me a very sturdy system to base mine off of. It took a little time, but not much, to integrate multi race, player, and heroes of the scale I'm using, but hey, it's part of the fun. I felt that For each integer loops would be needed here just as in my Damnation Hero Defense map, and once I finish up the triggering for this map will go back, convert everything and see if I can't touch it up. This is supposed to be a simple map, so I felt that doing it entirely in Jass when I could rather do it through GUI, then put it in JASS, and learn how not to code by correcting coding, would be beneficial to me, as well as some of my side projects being written completely in JASS. I also want to remind some of you that it's been a while since I've touched JASS or GUI for that matter, for Wc3, so if you have any suggestions or any modifications please let me know, I feel like I got rid of most leaks as I can in this, and feel as if the systems are MUI. This project is more work than I thought it would be when I set out to work on it, but I'm certain once i get the blunt of it done, and get down to the little things, I'll feel more confident that I can work on similar and possibly more difficult projects in the future.
 
Last edited:
Status
Not open for further replies.
Top