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

Get Hero Custom Script - Tutorial

Status
Not open for further replies.
Level 9
Joined
May 22, 2009
Messages
491
Ok here is my second tutorial on my own custom script on selecting a Hero and making the hero selector die. So this script comes from my RotG game.


1. Make the hero and put a region right in front of him that is labeled "Get (hero name here) Optional - You can put a circle of power in front of him for design.

2. Then make a region where the heroes come in the game name it (for me its) God Come In Region

3. Now make the hero selector and put him by the selective heroes regions.

4. Now here comes the script...


Events-
Unit - A unit enters Get God Of Arrows <gen>

Conditions-
(Unit-type of (Triggering unit)) Equal to Hero Chooser

Actions-
Unit - Kill (Triggering unit)
Unit - Create 1 God Of Arrows for (Owner of (Triggering unit)) at (Center of God Come In <gen>) facing Default building facing degrees


There you go! I will add pictures once i get more space :)

PS: Please dont leave perverted comments Im only 13 and dont want to have to read that crap.
 
Level 15
Joined
Mar 31, 2009
Messages
1,397
wow.........

useless tutorial much?

NOW I WILL SHOW YOU A REAL TRIGGER!
  • UniversalText
    • Events
      • Player - Player 1 (Red) types a chat message containing - as A substring
      • Player - Player 2 (Blue) types a chat message containing - as A substring
      • Player - Player 3 (Teal) types a chat message containing - as A substring
      • Player - Player 4 (Purple) types a chat message containing - as A substring
      • Player - Player 5 (Yellow) types a chat message containing - as A substring
      • Player - Player 6 (Orange) types a chat message containing - as A substring
      • Player - Player 7 (Green) types a chat message containing - as A substring
      • Player - Player 8 (Pink) types a chat message containing - as A substring
      • Player - Player 9 (Gray) types a chat message containing - as A substring
      • Player - Player 10 (Light Blue) types a chat message containing - as A substring
      • Player - Player 11 (Dark Green) types a chat message containing - as A substring
      • Player - Player 12 (Brown) types a chat message containing - as A substring
    • Conditions
    • Actions
      • -------- Boot Function --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • If (((Entered chat string) Equal to -kick blue) or (((Entered chat string) Equal to -boot blue) or ((Entered chat string) Equal to -ban blue))) then do (Game - Defeat Player 2 (Blue) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick teal) or (((Entered chat string) Equal to -boot teal) or ((Entered chat string) Equal to -ban teal))) then do (Game - Defeat Player 3 (Teal) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick purple) or (((Entered chat string) Equal to -boot purple) or ((Entered chat string) Equal to -ban purple))) then do (Game - Defeat Player 4 (Purple) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick yellow) or (((Entered chat string) Equal to -boot yellow) or ((Entered chat string) Equal to -ban yellow))) then do (Game - Defeat Player 5 (Yellow) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick orange) or (((Entered chat string) Equal to -boot orange) or ((Entered chat string) Equal to -ban orange))) then do (Game - Defeat Player 6 (Orange) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick green) or (((Entered chat string) Equal to -boot green) or ((Entered chat string) Equal to -ban green))) then do (Game - Defeat Player 7 (Green) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick pink) or (((Entered chat string) Equal to -boot pink) or ((Entered chat string) Equal to -ban pink))) then do (Game - Defeat Player 8 (Pink) with the message: You were disconnect...) else do (Do nothing)
          • If ((((Entered chat string) Equal to -kick gray) or ((Entered chat string) Equal to -kick grey)) or ((((Entered chat string) Equal to -boot gray) or ((Entered chat string) Equal to -boot grey)) or (((Entered chat string) Equal to -ban grey) or ((Entered chat str then do (Game - Defeat Player 9 (Gray) with the message: You were disconnect...) else do (Do nothing)
          • If ((((Entered chat string) Equal to -kick lightblue) or ((Entered chat string) Equal to -kick light blue)) or ((((Entered chat string) Equal to -boot lightblue) or ((Entered chat string) Equal to -boot light blue)) or (((Entered chat string) Equal to -ban light then do (Game - Defeat Player 10 (Light Blue) with the message: You were disconnect...) else do (Do nothing)
          • If ((((Entered chat string) Equal to -kick darkgreen) or ((Entered chat string) Equal to -kick dark green)) or ((((Entered chat string) Equal to -boot darkgreen) or ((Entered chat string) Equal to -boot dark green)) or (((Entered chat string) Equal to -ban darkg then do (Game - Defeat Player 11 (Dark Green) with the message: You were disconnect...) else do (Do nothing)
          • If (((Entered chat string) Equal to -kick brown) or (((Entered chat string) Equal to -boot brown) or ((Entered chat string) Equal to -ban brown))) then do (Game - Defeat Player 12 (Brown) with the message: You were disconnect...) else do (Do nothing)
        • Else - Actions
          • Do nothing
      • -------- Hide/Show Leaderboard --------
      • If ((Entered chat string) Equal to -hide) then do (Leaderboard - Hide (Leaderboard of (Triggering player))) else do (Do nothing)
      • If ((Entered chat string) Equal to -show) then do (Leaderboard - Show (Leaderboard of (Triggering player))) else do (Do nothing)
      • -------- Sheep Sounds --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is in Wolf) Equal to False
        • Then - Actions
          • If ((Entered chat string) Equal to -sound 1) then do (Sound - Play GetMeOutofHere <gen>) else do (Do nothing)
          • If ((Entered chat string) Equal to -sound 2) then do (Sound - Play SaveUs <gen>) else do (Do nothing)
          • If ((Entered chat string) Equal to -sound 3) then do (Sound - Play Sheep1 <gen>) else do (Do nothing)
          • If ((Entered chat string) Equal to -sound 4) then do (Sound - Play ThankYouForHelpingMe <gen>) else do (Do nothing)
          • If ((Entered chat string) Equal to -sound 5) then do (Sound - Play UBastard <gen>) else do (Do nothing)
          • If ((Entered chat string) Equal to -sound 6) then do (Sound - Play WeMustHelpHer <gen>) else do (Do nothing)
          • Sound - Destroy (Last played sound)
        • Else - Actions
          • Do nothing
      • -------- FunStuff --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -nutterbutter
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Name Equal to False
            • Then - Actions
              • Set Name = True
              • For each (Integer A) from 1 to 12, do (Set Naming[(Integer A)] = (Name of (Player((Integer A)))))
              • Player Group - Pick every player in (All players) and do (Player - Set name of (Picked player) to Captain NutterButte...)
            • Else - Actions
              • Set Name = False
              • For each (Integer A) from 1 to 12, do (Player - Set name of (Player((Integer A))) to Naming[(Integer A)])
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -realmen
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Pinky Equal to False
            • Then - Actions
              • Set Pinky = True
              • Unit Group - Pick every unit in (Units in (Entire map)) and do (Unit - Change color of (Picked unit) to Pink)
              • Trigger - Turn on PinkyRun <gen>
            • Else - Actions
              • Set Pinky = False
              • For each (Integer A) from 1 to 12, do (Unit Group - Pick every unit in (Units in (Entire map) owned by (Player((Integer A)))) and do (Unit - Change color of (Picked unit) to (Color of (Player((Integer A))))))
              • Trigger - Turn off PinkyRun <gen>
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -bloody
          • (Triggering player) Equal to Player 1 (Red)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Bloody Equal to False
            • Then - Actions
              • Set Bloody = True
              • Trigger - Turn on BloodyFun <gen>
            • Else - Actions
              • Set Bloody = False
              • Trigger - Turn off BloodyFun <gen>
        • Else - Actions
          • Do nothing
Btw, your trigger leaks
 
Last edited by a moderator:
Level 14
Joined
Apr 20, 2009
Messages
1,543
he has a good sense of humour for a 13 year old :grin:

EDIT: ow and BlargHonk, don't be a show-off you won't impress a lot of people with it :)
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
rofl here's a tutorial of a trigger that does nothing using the DoNothing() function.

  • DoNothing
    • Events
    • Conditions
    • Actions
      • Do nothing
No really, why bother posting this as a tutorial ?

Do nothing is a useless trigger and only slows things down. I suggest doing it this way:

  • DoNothing
    • Events
    • Conditions
    • Actions
Fully leakless and bugless :grin:

Mwah atleast he tried something so I gave him rep for that :p
 
Level 9
Joined
May 22, 2009
Messages
491
Oh and BTW BlargHonk that isnt Get Hero Script thats a leaderboard kick script so why did you post that?
Maybe that type of script is more advanced that Get a Hero script so why did you post that?
And I cant to too much advanced script because I dont have the Frozen Throne.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
buy a cd-key that helps :thumbs_up:
if TFT > ROC then
YOUR RIGHT!

edit: I started with the trigger editor when I was 12 too :) So keep up the good work.... Just don't post it as a tut yet, no body cares about it untill it is something really usefull and you think it can help a lot of people to progress better trigger making... (or in any other way of improving with the editor)

I'm 17 now and never ever posted a tutorial :p I only go for proffits XD
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
EDIT: ow and BlargHonk, don't be a show-off you won't impress a lot of people with it :)
Oh and BTW BlargHonk that isnt Get Hero Script thats a leaderboard kick script so why did you post that?
Maybe that type of script is more advanced that Get a Hero script so why did you post that?

Arghh, he was kidding. I gave him rep because it was really really funny.

God, you remind me of those guys that comment on magician vids with "this is fake". Of course it's fake you dumbasses!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You want to see a real trigger? How about a main system from a tower defence.
JASS:
library SpawnTable initializer init
    //System by Dr Super Good

    globals
        public integer array SpawnType
        public integer array SpawnNumber
        public real array WaveDuration
        public sound array WaveNoise
        public string array WaveInfo

        public real array SpawnX
        public real array SpawnY
        public real array SpawnDirection

        public integer array ActiveSpawns
        public integer ActiveSpawnNumber = 8
        
        public constant integer FinalWave = 36
    endglobals
    
    private function LimateAS_forplayer takes nothing returns nothing
        set ActiveSpawns[ActiveSpawnNumber] = GetPlayerId(GetEnumPlayer())
        set ActiveSpawnNumber = ActiveSpawnNumber+1
    endfunction
    
    public function LimateAS takes nothing returns nothing
        set ActiveSpawnNumber = 0
        call ForForce(udg_ConnectedPlayers,function LimateAS_forplayer)
    endfunction
    
    private function init takes nothing returns nothing
        local integer i = 0
        set SpawnX[0]=-5376
        set SpawnY[0]=5376
        set SpawnDirection[0]=-90
        set SpawnX[1]=-768
        set SpawnY[1]=768
        set SpawnDirection[1]=180
        set SpawnX[2]=768
        set SpawnY[2]=768
        set SpawnDirection[2]=90
        set SpawnX[3]=5376
        set SpawnY[3]=5376
        set SpawnDirection[3]=180
        set SpawnX[4]=-5376
        set SpawnY[4]=-5376
        set SpawnDirection[4]=0
        set SpawnX[5]=-768
        set SpawnY[5]=-768
        set SpawnDirection[5]=-90
        set SpawnX[6]=768
        set SpawnY[6]=-768
        set SpawnDirection[6]=0
        set SpawnX[7]=5376
        set SpawnY[7]=-5376
        set SpawnDirection[7]=90
        set ActiveSpawns[0]=0
        set ActiveSpawns[1]=1
        set ActiveSpawns[2]=2
        set ActiveSpawns[3]=3
        set ActiveSpawns[4]=4
        set ActiveSpawns[5]=5
        set ActiveSpawns[6]=6
        set ActiveSpawns[7]=7
        //wave 1
        set i = i+1
        set SpawnType[i] = 'hfoo'
        set SpawnNumber[i] = 528
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 2
        set i = i+1
        set SpawnType[i] = 'hrif'
        set SpawnNumber[i] = 1288
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 3
        set i = i+1
        set SpawnType[i] = 'hsor'
        set SpawnNumber[i] = 1568
        set WaveDuration[i] = 65
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 4
        set i = i+1
        set SpawnType[i] = 'hspt'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFArmored|r"
        //wave 5
        set i = i+1
        set SpawnType[i] = 'hmpr'
        set SpawnNumber[i] = 720
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFDivine|r"
        //wave 6
        set i = i+1
        set SpawnType[i] = 'hkni'
        set SpawnNumber[i] = 1144
        set WaveDuration[i] = 71.5
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 7
        set i = i+1
        set SpawnType[i] = 'hgyr'
        set SpawnNumber[i] = 1000
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r"
        //wave 8
        set i = i+1
        set SpawnType[i] = 'hmtm'
        set SpawnNumber[i] = 1704
        set WaveDuration[i] = 71
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 9
        set i = i+1
        set SpawnType[i] = 'hmtt'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Tough|r and |CFFFF00FFExtra Fast|r"
        //wave 10
        set i = i+1
        set SpawnType[i] = 'ogru'
        set SpawnNumber[i] = 480
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 11
        set i = i+1
        set SpawnType[i] = 'ohun'
        set SpawnNumber[i] = 808
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 12
        set i = i+1
        set SpawnType[i] = 'odoc'
        set SpawnNumber[i] = 944
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 13
        set i = i+1
        set SpawnType[i] = 'oshm'
        set SpawnNumber[i] = 1152
        set WaveDuration[i] = 55
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 14
        set i = i+1
        set SpawnType[i] = 'orai'
        set SpawnNumber[i] = 1272
        set WaveDuration[i] = 55
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
        //wave 15
        set i = i+1
        set SpawnType[i] = 'otau'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFLarge Volume|r"
        //wave 16
        set i = i+1
        set SpawnType[i] = 'okod'
        set SpawnNumber[i] = 800
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
        //wave 17
        set i = i+1
        set SpawnType[i] = 'otbr'
        set SpawnNumber[i] = 240
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFArmored|r"
        //wave 18
        set i = i+1
        set SpawnType[i] = 'ospw'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFDivine|r"
        //wave 19
        set i = i+1
        set SpawnType[i] = 'ugho'
        set SpawnNumber[i] = 240
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 20
        set i = i+1
        set SpawnType[i] = 'ucry'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 21
        set i = i+1
        set SpawnType[i] = 'uban'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 59
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 22
        set i = i+1
        set SpawnType[i] = 'unec'
        set SpawnNumber[i] = 960
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 23
        set i = i+1
        set SpawnType[i] = 'ugar'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 58
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
        //wave 24
        set i = i+1
        set SpawnType[i] = 'uabo'
        set SpawnNumber[i] = 1040
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 25
        set i = i+1
        set SpawnType[i] = 'umtw'
        set SpawnNumber[i] = 800
        set WaveDuration[i] = 44
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 26
        set i = i+1
        set SpawnType[i] = 'uobs'
        set SpawnNumber[i] = 280
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 27
        set i = i+1
        set SpawnType[i] = 'ufro'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 57
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
        //wave 28
        set i = i+1
        set SpawnType[i] = 'Obla'
        set SpawnNumber[i] = 960
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFExtra Fast|r"
        //wave 29
        set i = i+1
        set SpawnType[i] = 'Edem'
        set SpawnNumber[i] = 1200
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r"
        //wave 30
        set i = i+1
        set SpawnType[i] = 'Hmkg'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r, |CFFFF00FFLarge Volume|r and |CFFFF00FFImmune|r"
        //wave 31
        set i = i+1
        set SpawnType[i] = 'ninf'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Boss
        set WaveInfo[i] = "|CFFFF00FFBoss|r"
        //wave 32
        set i = i+1
        set SpawnType[i] = 'Nngs'
        set SpawnNumber[i] = 640
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r"
        //wave 33
        set i = i+1
        set SpawnType[i] = 'Ucrl'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFArmored|r"
        //wave 34
        set i = i+1
        set SpawnType[i] = 'Udea'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFLarge Volume|r"
        //wave 35
        set i = i+1
        set SpawnType[i] = 'nrwm'
        set SpawnNumber[i] = 1160
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFImmune|r"
        //wave 36
        set i = i+1
        set SpawnType[i] = 'nsgh'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Boss
        set WaveInfo[i] = "|CFFFF00FFBoss|r"
    endfunction
endlibrary

library SpawnSystem initializer init
    globals
        public real WaveDelay

        private timer Timer = CreateTimer()
        public integer Wave = 0
        private integer Number = 0
        private integer Type
        private sound Noise = null
        
        private constant player Evil = Player(11)
    endglobals
    
    private function win_forallplayers takes nothing returns nothing
        local player p = GetEnumPlayer()
        call RemovePlayer(p, PLAYER_GAME_RESULT_VICTORY )
        call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
        if (GetPlayerController(p) == MAP_CONTROL_USER) then
            set bj_changeLevelShowScores = true
            call CustomVictoryDialogBJ(p)
        endif
        set p = null
    endfunction
    
    private function win takes nothing returns nothing
        call ForForce(udg_ConnectedPlayers,function win_forallplayers)
        call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
    endfunction
    
    private function lose_forallplayers takes nothing returns nothing
        local player p = GetEnumPlayer()
        call RemovePlayer(p,PLAYER_GAME_RESULT_DEFEAT )
        call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
        if (GetPlayerController(p) == MAP_CONTROL_USER) then
            call CustomDefeatDialogBJ(p,"TRIGSTR_1460")
        endif
        set p = null
    endfunction
    
    private function lose takes nothing returns nothing
        call ForForce(udg_ConnectedPlayers, function lose_forallplayers)
        call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
    endfunction
    
    private function endwave_delay takes nothing returns nothing
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),-1)
        call LeaderboardSortItemsByValue(udg_LEADERBOARD,false)
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
        call ExecuteFunc("SpawnSystem_endwave")
    endfunction
    
    private function batch takes nothing returns nothing
        local integer i = 0
        local integer s
        loop
            exitwhen i == SpawnTable_ActiveSpawnNumber
            set s = SpawnTable_ActiveSpawns[i]
            call CreateUnit(Evil,Type,SpawnTable_SpawnX[s],SpawnTable_SpawnY[s],SpawnTable_SpawnDirection[s])
            set i = i+1
        endloop
        set udg_CurrentlyOnMap = udg_CurrentlyOnMap+SpawnTable_ActiveSpawnNumber
        set Number = Number-SpawnTable_ActiveSpawnNumber
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
        if Number<=0 then
            call TimerStart(Timer,WaveDelay,false,function endwave_delay)
        endif
    endfunction 
    
    private function winning takes nothing returns nothing
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Congratulations, you have survived the invasion and the valley will be safe for ages to come!")
        call DestroyTrigger(gg_trg_PlayerQuit)
        set gg_trg_PlayerQuit = null
        call TimerStart(Timer,40,false,function win)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, thank you for playing and remember to play again when ever you like.")
    endfunction
    
    private function losing_forallunits takes nothing returns nothing
        local unit u = GetEnumUnit()
        call PauseUnit(u,true)
        call SetUnitTimeScale(u,0)
        set u = null
    endfunction
    
    private function losing takes nothing returns nothing
        local group g = CreateGroup()
        call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
        call ForGroup(g,function losing_forallunits)
        call DestroyGroup(g)
        set g = null
        call DestroyTrigger(gg_trg_PlayerQuit)
        set gg_trg_PlayerQuit = null
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"TRIGSTR_1458" )
        call LeaderboardSetItemValueColor(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),255,0,0,255)
        call TimerStart(Timer,40,false,function lose)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, I advise trying again or playing at a lower difficulty.")
    endfunction
    
    private function UpdateFood takes nothing returns nothing
        call SetPlayerState(GetEnumPlayer(),PLAYER_STATE_RESOURCE_FOOD_USED,Wave)
    endfunction
    
    public function endwave takes nothing returns nothing
        if udg_CurrentlyOnMap>=700 then
            call losing()
            return
        elseif udg_CurrentlyOnMap>=350 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|cffFF0000[WARNING]|r - You lose if more than 700 invaders are out at the same time at the end of a wave!")
        endif
        set Wave = Wave+1
        if Wave > SpawnTable_FinalWave then
            call winning()
            return
        endif
        set Type = SpawnTable_SpawnType[Wave]
        set Number = Number+SpawnTable_SpawnNumber[Wave]
        call ForForce(udg_ConnectedPlayers, function UpdateFood)
        if Noise != null then
            call StopSound(Noise,false,true)
        endif
        set Noise = SpawnTable_WaveNoise[Wave]
        call StartSound(Noise)
        call TimerStart(Timer,SpawnTable_WaveDuration[Wave]*SpawnTable_ActiveSpawnNumber/Number,true,function batch)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Here comes wave "+I2S(Wave)+" consisting of "+I2S(Number)+" "+GetObjectName(Type)+" units attacking over the course of "+I2S(R2I(SpawnTable_WaveDuration[Wave]))+" seconds.")
        if SpawnTable_WaveInfo[Wave] != "" then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"This wave is "+SpawnTable_WaveInfo[Wave]+".")
        endif
    endfunction
    
    private function init takes nothing returns nothing
        call TimerStart(Timer,35,false,function endwave)
    endfunction
endlibrary

Honestly, this tutorial is far to small and simplistic as most people learn more from practice in 5 seconds when new to WE than they would from this. Please post something a little more complicated in future.
Also GUI is nothing to be proud of or show off.
 
Level 9
Joined
May 22, 2009
Messages
491
xD my tower defense worked fine for a short script so I don't know but Im doing better on scripting in the past few days do you think?

Unit - A unit owned by Player 1 (Red) Begins casting an ability
(Ability being cast) Equal to Sleep
(Unit-type of (Target unit of ability being cast)) Equal to Timber Wolf
Unit - Change ownership of (Target unit of ability being cast) to Player 1 (Red) and Change color


Its for my RPG thats coming out this summer www.youtube.com/bwathke it will be on there.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
xD my tower defense worked fine for a short script so I don't know but Im doing better on scripting in the past few days do you think?

Unit - A unit owned by Player 1 (Red) Begins casting an ability
(Ability being cast) Equal to Sleep
(Unit-type of (Target unit of ability being cast)) Equal to Timber Wolf
Unit - Change ownership of (Target unit of ability being cast) to Player 1 (Red) and Change color


Its for my RPG thats coming out this summer www.youtube.com/bwathke it will be on there.

Please stop doing that. This is really too simple and short. Everyone knows how to do that, it takes you like 10 seconds.

Yeah, these one-line GUI codes can make an awesome TD....if you have 1 000 000 of them!
 
Level 9
Joined
May 22, 2009
Messages
491
Wow so I don't do GREAT triggers Ive only been using the editor for about 1 month and you guys post these great triggers because you have been doing that for awhile I think that's awesome but you also don't have to rip on the stuff I put out.
 
Level 16
Joined
Feb 22, 2006
Messages
960
you shouldn't see their posts as an offense against you it's more a tip.
You posted a "tutorial" in the wrong forum, then your tutorial shows a basic gui trigger, which one knows after some hours training.
Also it's a way too short ... but get better and try to help other people, write better tutorials and you'll maybe gain respect for what you've done but it's hard to learn from someone who is also someone whos learning the same thing and is on the same level
 
  • Like
Reactions: Rmx
Level 14
Joined
Apr 20, 2009
Messages
1,543
lol let's all poke the newb? :grin:

good way of welcomming someone to thehive XD

stop criticism, the guy is trying the best he can... Of which is not much yet.....

(yoda speaking)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Well, we're sorry if we hurt your feelings.

Also, there's a difference between this:

This tutorial sucks ass! You're the worst GUI user ever!! In the future, please post something that won't make us puke!

And this:

The tutorial is too short and basic. It's really something people can do in one day of messing with WE.

Our comments were more towards the second quote. You have to understand that we mean.

For example, when I'm learning to play a song on a piano, it sucks in the beginning, that's why I don't play it to anyone yet, but when I get better in it and it starts to sound like something, then I want to play it to someone.

I don't play the piano, it was just an example :p

Ok, I'll stop being gay now. Try to understand that whatever bad comments you got in this thread, they're mostly true. It may not be nice, but that's the way it goes.
 
You want to see a real trigger? How about a main system from a tower defence.
JASS:
library SpawnTable initializer init
    //System by Dr Super Good

    globals
        public integer array SpawnType
        public integer array SpawnNumber
        public real array WaveDuration
        public sound array WaveNoise
        public string array WaveInfo

        public real array SpawnX
        public real array SpawnY
        public real array SpawnDirection

        public integer array ActiveSpawns
        public integer ActiveSpawnNumber = 8
        
        public constant integer FinalWave = 36
    endglobals
    
    private function LimateAS_forplayer takes nothing returns nothing
        set ActiveSpawns[ActiveSpawnNumber] = GetPlayerId(GetEnumPlayer())
        set ActiveSpawnNumber = ActiveSpawnNumber+1
    endfunction
    
    public function LimateAS takes nothing returns nothing
        set ActiveSpawnNumber = 0
        call ForForce(udg_ConnectedPlayers,function LimateAS_forplayer)
    endfunction
    
    private function init takes nothing returns nothing
        local integer i = 0
        set SpawnX[0]=-5376
        set SpawnY[0]=5376
        set SpawnDirection[0]=-90
        set SpawnX[1]=-768
        set SpawnY[1]=768
        set SpawnDirection[1]=180
        set SpawnX[2]=768
        set SpawnY[2]=768
        set SpawnDirection[2]=90
        set SpawnX[3]=5376
        set SpawnY[3]=5376
        set SpawnDirection[3]=180
        set SpawnX[4]=-5376
        set SpawnY[4]=-5376
        set SpawnDirection[4]=0
        set SpawnX[5]=-768
        set SpawnY[5]=-768
        set SpawnDirection[5]=-90
        set SpawnX[6]=768
        set SpawnY[6]=-768
        set SpawnDirection[6]=0
        set SpawnX[7]=5376
        set SpawnY[7]=-5376
        set SpawnDirection[7]=90
        set ActiveSpawns[0]=0
        set ActiveSpawns[1]=1
        set ActiveSpawns[2]=2
        set ActiveSpawns[3]=3
        set ActiveSpawns[4]=4
        set ActiveSpawns[5]=5
        set ActiveSpawns[6]=6
        set ActiveSpawns[7]=7
        //wave 1
        set i = i+1
        set SpawnType[i] = 'hfoo'
        set SpawnNumber[i] = 528
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 2
        set i = i+1
        set SpawnType[i] = 'hrif'
        set SpawnNumber[i] = 1288
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 3
        set i = i+1
        set SpawnType[i] = 'hsor'
        set SpawnNumber[i] = 1568
        set WaveDuration[i] = 65
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 4
        set i = i+1
        set SpawnType[i] = 'hspt'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFArmored|r"
        //wave 5
        set i = i+1
        set SpawnType[i] = 'hmpr'
        set SpawnNumber[i] = 720
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFDivine|r"
        //wave 6
        set i = i+1
        set SpawnType[i] = 'hkni'
        set SpawnNumber[i] = 1144
        set WaveDuration[i] = 71.5
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 7
        set i = i+1
        set SpawnType[i] = 'hgyr'
        set SpawnNumber[i] = 1000
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r"
        //wave 8
        set i = i+1
        set SpawnType[i] = 'hmtm'
        set SpawnNumber[i] = 1704
        set WaveDuration[i] = 71
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 9
        set i = i+1
        set SpawnType[i] = 'hmtt'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Tough|r and |CFFFF00FFExtra Fast|r"
        //wave 10
        set i = i+1
        set SpawnType[i] = 'ogru'
        set SpawnNumber[i] = 480
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 11
        set i = i+1
        set SpawnType[i] = 'ohun'
        set SpawnNumber[i] = 808
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 12
        set i = i+1
        set SpawnType[i] = 'odoc'
        set SpawnNumber[i] = 944
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 13
        set i = i+1
        set SpawnType[i] = 'oshm'
        set SpawnNumber[i] = 1152
        set WaveDuration[i] = 55
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 14
        set i = i+1
        set SpawnType[i] = 'orai'
        set SpawnNumber[i] = 1272
        set WaveDuration[i] = 55
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
        //wave 15
        set i = i+1
        set SpawnType[i] = 'otau'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r and |CFFFF00FFLarge Volume|r"
        //wave 16
        set i = i+1
        set SpawnType[i] = 'okod'
        set SpawnNumber[i] = 800
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFExtra Fast|r"
        //wave 17
        set i = i+1
        set SpawnType[i] = 'otbr'
        set SpawnNumber[i] = 240
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFArmored|r"
        //wave 18
        set i = i+1
        set SpawnType[i] = 'ospw'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFDivine|r"
        //wave 19
        set i = i+1
        set SpawnType[i] = 'ugho'
        set SpawnNumber[i] = 240
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 20
        set i = i+1
        set SpawnType[i] = 'ucry'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 21
        set i = i+1
        set SpawnType[i] = 'uban'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 59
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = "|CFFFF00FFLarge Volume|r"
        //wave 22
        set i = i+1
        set SpawnType[i] = 'unec'
        set SpawnNumber[i] = 960
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 23
        set i = i+1
        set SpawnType[i] = 'ugar'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 58
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
        //wave 24
        set i = i+1
        set SpawnType[i] = 'uabo'
        set SpawnNumber[i] = 1040
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 25
        set i = i+1
        set SpawnType[i] = 'umtw'
        set SpawnNumber[i] = 800
        set WaveDuration[i] = 44
        set WaveNoise[i] = gg_snd_Wave_Immune
        set WaveInfo[i] = "|CFFFF00FFImmune|r"
        //wave 26
        set i = i+1
        set SpawnType[i] = 'uobs'
        set SpawnNumber[i] = 280
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Normal
        set WaveInfo[i] = ""
        //wave 27
        set i = i+1
        set SpawnType[i] = 'ufro'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 57
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFLarge Volume|r"
        //wave 28
        set i = i+1
        set SpawnType[i] = 'Obla'
        set SpawnNumber[i] = 960
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFExtra Fast|r"
        //wave 29
        set i = i+1
        set SpawnType[i] = 'Edem'
        set SpawnNumber[i] = 1200
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r"
        //wave 30
        set i = i+1
        set SpawnType[i] = 'Hmkg'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r, |CFFFF00FFLarge Volume|r and |CFFFF00FFImmune|r"
        //wave 31
        set i = i+1
        set SpawnType[i] = 'ninf'
        set SpawnNumber[i] = 360
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Boss
        set WaveInfo[i] = "|CFFFF00FFBoss|r"
        //wave 32
        set i = i+1
        set SpawnType[i] = 'Nngs'
        set SpawnNumber[i] = 640
        set WaveDuration[i] = 45
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r"
        //wave 33
        set i = i+1
        set SpawnType[i] = 'Ucrl'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 40
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFArmored|r"
        //wave 34
        set i = i+1
        set SpawnType[i] = 'Udea'
        set SpawnNumber[i] = 1800
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Hero
        set WaveInfo[i] = "|CFFFF00FFHero|r and |CFFFF00FFLarge Volume|r"
        //wave 35
        set i = i+1
        set SpawnType[i] = 'nrwm'
        set SpawnNumber[i] = 1160
        set WaveDuration[i] = 50
        set WaveNoise[i] = gg_snd_Wave_Air
        set WaveInfo[i] = "|CFFFF00FFAir|r and |CFFFF00FFImmune|r"
        //wave 36
        set i = i+1
        set SpawnType[i] = 'nsgh'
        set SpawnNumber[i] = 120
        set WaveDuration[i] = 60
        set WaveNoise[i] = gg_snd_Wave_Boss
        set WaveInfo[i] = "|CFFFF00FFBoss|r"
    endfunction
endlibrary

library SpawnSystem initializer init
    globals
        public real WaveDelay

        private timer Timer = CreateTimer()
        public integer Wave = 0
        private integer Number = 0
        private integer Type
        private sound Noise = null
        
        private constant player Evil = Player(11)
    endglobals
    
    private function win_forallplayers takes nothing returns nothing
        local player p = GetEnumPlayer()
        call RemovePlayer(p, PLAYER_GAME_RESULT_VICTORY )
        call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
        if (GetPlayerController(p) == MAP_CONTROL_USER) then
            set bj_changeLevelShowScores = true
            call CustomVictoryDialogBJ(p)
        endif
        set p = null
    endfunction
    
    private function win takes nothing returns nothing
        call ForForce(udg_ConnectedPlayers,function win_forallplayers)
        call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
    endfunction
    
    private function lose_forallplayers takes nothing returns nothing
        local player p = GetEnumPlayer()
        call RemovePlayer(p,PLAYER_GAME_RESULT_DEFEAT )
        call DisplayTimedTextFromPlayer(p, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) )
        if (GetPlayerController(p) == MAP_CONTROL_USER) then
            call CustomDefeatDialogBJ(p,"TRIGSTR_1460")
        endif
        set p = null
    endfunction
    
    private function lose takes nothing returns nothing
        call ForForce(udg_ConnectedPlayers, function lose_forallplayers)
        call DisplayTimedTextFromPlayer(Evil, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) )
    endfunction
    
    private function endwave_delay takes nothing returns nothing
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),-1)
        call LeaderboardSortItemsByValue(udg_LEADERBOARD,false)
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
        call ExecuteFunc("SpawnSystem_endwave")
    endfunction
    
    private function batch takes nothing returns nothing
        local integer i = 0
        local integer s
        loop
            exitwhen i == SpawnTable_ActiveSpawnNumber
            set s = SpawnTable_ActiveSpawns[i]
            call CreateUnit(Evil,Type,SpawnTable_SpawnX[s],SpawnTable_SpawnY[s],SpawnTable_SpawnDirection[s])
            set i = i+1
        endloop
        set udg_CurrentlyOnMap = udg_CurrentlyOnMap+SpawnTable_ActiveSpawnNumber
        set Number = Number-SpawnTable_ActiveSpawnNumber
        call LeaderboardSetItemValue(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),udg_CurrentlyOnMap)
        if Number<=0 then
            call TimerStart(Timer,WaveDelay,false,function endwave_delay)
        endif
    endfunction 
    
    private function winning takes nothing returns nothing
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Congratulations, you have survived the invasion and the valley will be safe for ages to come!")
        call DestroyTrigger(gg_trg_PlayerQuit)
        set gg_trg_PlayerQuit = null
        call TimerStart(Timer,40,false,function win)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, thank you for playing and remember to play again when ever you like.")
    endfunction
    
    private function losing_forallunits takes nothing returns nothing
        local unit u = GetEnumUnit()
        call PauseUnit(u,true)
        call SetUnitTimeScale(u,0)
        set u = null
    endfunction
    
    private function losing takes nothing returns nothing
        local group g = CreateGroup()
        call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
        call ForGroup(g,function losing_forallunits)
        call DestroyGroup(g)
        set g = null
        call DestroyTrigger(gg_trg_PlayerQuit)
        set gg_trg_PlayerQuit = null
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"TRIGSTR_1458" )
        call LeaderboardSetItemValueColor(udg_LEADERBOARD,LeaderboardGetPlayerIndex(udg_LEADERBOARD,Evil),255,0,0,255)
        call TimerStart(Timer,40,false,function lose)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The game will end in 40 seconds, I advise trying again or playing at a lower difficulty.")
    endfunction
    
    private function UpdateFood takes nothing returns nothing
        call SetPlayerState(GetEnumPlayer(),PLAYER_STATE_RESOURCE_FOOD_USED,Wave)
    endfunction
    
    public function endwave takes nothing returns nothing
        if udg_CurrentlyOnMap>=700 then
            call losing()
            return
        elseif udg_CurrentlyOnMap>=350 then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"|cffFF0000[WARNING]|r - You lose if more than 700 invaders are out at the same time at the end of a wave!")
        endif
        set Wave = Wave+1
        if Wave > SpawnTable_FinalWave then
            call winning()
            return
        endif
        set Type = SpawnTable_SpawnType[Wave]
        set Number = Number+SpawnTable_SpawnNumber[Wave]
        call ForForce(udg_ConnectedPlayers, function UpdateFood)
        if Noise != null then
            call StopSound(Noise,false,true)
        endif
        set Noise = SpawnTable_WaveNoise[Wave]
        call StartSound(Noise)
        call TimerStart(Timer,SpawnTable_WaveDuration[Wave]*SpawnTable_ActiveSpawnNumber/Number,true,function batch)
        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Here comes wave "+I2S(Wave)+" consisting of "+I2S(Number)+" "+GetObjectName(Type)+" units attacking over the course of "+I2S(R2I(SpawnTable_WaveDuration[Wave]))+" seconds.")
        if SpawnTable_WaveInfo[Wave] != "" then
            call DisplayTextToPlayer(GetLocalPlayer(),0,0,"This wave is "+SpawnTable_WaveInfo[Wave]+".")
        endif
    endfunction
    
    private function init takes nothing returns nothing
        call TimerStart(Timer,35,false,function endwave)
    endfunction
endlibrary

Honestly, this tutorial is far to small and simplistic as most people learn more from practice in 5 seconds when new to WE than they would from this. Please post something a little more complicated in future.
Also GUI is nothing to be proud of or show off.

big and spammy yes, but nicely written ;)
 
Status
Not open for further replies.
Top