• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Trigger] Replacing a hero

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,243
This replaces a hero with another. It works if the player has only one hero. The hero must also be alive.

If you have stored all heroes into an array, skip the set hero = (Random unit...) and replace all udg_hero references with udg_yourarray[player number of triggering player].

You can add unit types like this:
  • Custom script: call SaveInteger(udg_HeroHash, 0, StringHash("paladin"), 'Hpal')
Copy and paste those lines. The paladin there is what you want the players to type to get a paladin. So typing

-paladin

will create a paladin. The Hpal is the unit type of the unit. You can check the unit type by opening object editor and hitting ctrl + D.



  • HC Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HeroHash = (Last created hashtable)
      • Custom script: call SaveInteger(udg_HeroHash, 0, StringHash("paladin"), 'Hpal')
      • Custom script: call SaveInteger(udg_HeroHash, 0, StringHash("mountainking"), 'Hmkg')
      • Custom script: call SaveInteger(udg_HeroHash, 0, StringHash("archmage"), 'Hamg')
      • Custom script: call SaveInteger(udg_HeroHash, 0, StringHash("bloodmage"), 'Hblm')
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to HC Change <gen> the event (Player - (Player((Integer A))) types a chat message containing - as A substring)
  • HC Change
    • Events
    • Conditions
    • Actions
      • Custom script: local boolean b
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Key (Substring((Entered chat string), 2, (Length of (Entered chat string))))) is stored as a Integer of 0 in HeroHash) Equal to True
        • Then - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Set hero = (Random unit from (Units owned by (Triggering player) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True))))
          • Custom script: set b = IsUnitSelected(udg_hero, GetTriggerPlayer())
          • Custom script: call ReplaceUnitBJ( udg_hero, LoadInteger(udg_HeroHash, 0, StringHash(SubString(GetEventPlayerChatString(), 1, StringLength(GetEventPlayerChatString())))), bj_UNIT_STATE_METHOD_RELATIVE )
          • Custom script: if b then
          • Selection - Add (Last replaced unit) to selection for (Triggering player)
          • Custom script: endif
        • Else - Actions
          • Set PGroup = (Player group((Triggering player)))
          • Game - Display to PGroup the text: Such hero does not ...
          • Custom script: call DestroyForce(udg_PGroup)


You can add colour codes and additional messages, like if the hero is dead then replacing will fail.

http://www.hiveworkshop.com/forums/pastebin.php?id=hy1txj
 
Status
Not open for further replies.
Top