Need a Trigger

T

Theteammax

Guest
Hello. I need help to find a Trigger.

My problem: Wen i Host my "Map" it always begin to lag becouse of too many Units.

I need something like this: Team 1 Max limit of summoned Units is 300. Same for Team 2 (If it is over "300 Units" they will be killed) (Or there will appear a message: "Your Team have summoned the Max limit of 300 Units") Or something like that.
 

BornANoob[MR]

Member
Reaction score
21
Something like

A Unit begins casting an ability
Ability equal to summon
Pick every units of unit type Summoned and do actions
If
Number of picked units greater than 300
Then
Kill last created unit
Game - display text blah blah
Else do nothing
 

Exide

I am amazingly focused right now!
Reaction score
448
This is a simple version of how you could do it..

Code:
Untitled Trigger 001
    Events
        Time - Every 2.00 seconds of game time
    Conditions
        (Number of units in (Units in (Playable map area))) Greater than or equal to 300
    Actions
        Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units in (Playable map area)))
        Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
        Game - Display to (All players) for 5.00 seconds the text: There arre too many...
        Custom script:   call DestroyGroup(udg_TempGroup)

TempGroup is a unit group variable.

This trigger should check every 2 seconds, if there are 300 or more units in the map, then take 4,5,6,7,8,9,10,11 or 12 random units from the map, and remove them from the game.
-This trigger removes units from random players, computer units can be removed as well.

Why have so many units anyway? Why not use food to limit number of units?
 

BornANoob[MR]

Member
Reaction score
21
I think he wants you to be able to have say, 50 footman aswell as 300 summoned units, not sure though, so your trigger and changing the food count may not work.
 

Exide

I am amazingly focused right now!
Reaction score
448
Who summons over 300 units? :confused:

I thought he had a map similar to Footman, that spawns units periodically..

Either way, this is probably a better trigger than the one I showed you before (but if BornANoob[MR] is correct, neither trigger matters, I guess. :p);

Code:
Untitled Trigger 001
    Events
        Time - Every 2.00 seconds of game time
    Conditions
        (Number of units in (Units in (Playable map area))) Greater than or equal to 300
    Actions
        If ((Number of units in (Units in (Playable map area) owned by Player 1 (Red))) Greater than or equal to 300) then do (Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units owned by Player 1 (Red)))) else do (Do nothing)
        If ((Number of units in (Units in (Playable map area) owned by Player 2 (Blue))) Greater than or equal to 300) then do (Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units owned by Player 2 (Blue)))) else do (Do nothing)
        If ((Number of units in (Units in (Playable map area) owned by Player 3 (Teal))) Greater than or equal to 300) then do (Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units owned by Player 3 (Teal)))) else do (Do nothing)
        If ((Number of units in (Units in (Playable map area) owned by Player 4 (Purple))) Greater than or equal to 300) then do (Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units owned by Player 4 (Purple)))) else do (Do nothing)
        Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
        Game - Display to (All players) for 5.00 seconds the text: There arre too many...
        Custom script:   call DestroyGroup(udg_TempGroup)
 
T

Theteammax

Guest
Hmm is it possible to copy and paste it into the editor? So i don't need to enter it one by one?
 

Exide

I am amazingly focused right now!
Reaction score
448
Nope, sorry.
Can be done if it's JASS. Want me to convert? :p
 

Exide

I am amazingly focused right now!
Reaction score
448
I suggest you stick to the GUI one, and look at what I did and try to copy it. (You can't copy and paste).

In JASS:
You can copy and paste this directly into your trigger. First you must make a new trigger and click 'Edit -> Convert to Custom Text -> Ok', and then delete everything that's in there, then copy the following into it:

JASS:

function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
    return ( ( CountUnitsInGroup(GetUnitsInRectAll(GetPlayableMapRect())) >= 300 ) )
endfunction

function Trig_Untitled_Trigger_001_Func006002 takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    if ( ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(0))) >= 300 ) ) then
        set udg_TempGroup = GetRandomSubGroup(GetRandomInt(4, 12), GetUnitsOfPlayerAll(Player(0)))
    endif
    if ( ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(1))) >= 300 ) ) then
        set udg_TempGroup = GetRandomSubGroup(GetRandomInt(4, 12), GetUnitsOfPlayerAll(Player(1)))
    endif
    if ( ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(2))) >= 300 ) ) then
        set udg_TempGroup = GetRandomSubGroup(GetRandomInt(4, 12), GetUnitsOfPlayerAll(Player(2)))
    endif
    if ( ( CountUnitsInGroup(GetUnitsInRectOfPlayer(GetPlayableMapRect(), Player(3))) >= 300 ) ) then
        set udg_TempGroup = GetRandomSubGroup(GetRandomInt(4, 12), GetUnitsOfPlayerAll(Player(3)))
    endif
    call ForGroup( udg_TempGroup, function Trig_Untitled_Trigger_001_Func006002 )
    call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "TRIGSTR_181" )
    call DestroyGroup(udg_TempGroup)
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 2 )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function Trig_Untitled_Trigger_001_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction


This only works for player 1 to 4, If you want more players you need to add them yourself.
Again, I suggest you use the GUI trigger.

EDIT: Oh, and I haven't tested the triggers myself, so they might not work. :p
 
T

Theteammax

Guest
Hmm. Okay :p i'll try.
Can you tell me where i find the
"then do (Set TempGroup = (Random (Random integer number between 4 and 12) units from (Units owned by Player 1(Red)"
 
T

Theteammax

Guest
Exide can you make it for me? :S I don't know how. Doesnt say anything to me.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top