• 🏆 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 region based trigger

Status
Not open for further replies.
Level 2
Joined
Aug 14, 2015
Messages
14
I need some help with a region based trigger, my map has some reef's and i would like to create a trigger that damages any boats that enter over time until they leave the region, i've tried my hand at creating this trigger, but it seems creating complex triggers is not my forte :/
 

Attachments

  • Trigger.jpg
    Trigger.jpg
    50.6 KB · Views: 92
Level 17
Joined
Dec 11, 2014
Messages
2,004
1) You make a Unit Group Variable.
2) You Create another Trigger.
3) You set the new Trigger's Event to "Every 0.10 seconds of game Time".
4) You Pick Everybody in your Unit Group and cause (Picked unit) to damage (Picked Unit).
5) You head to the Trigger you posted.
6) Delete the Damage action.
7) Change it with "Add (Triggering Unit) to (Name of you Unit Group Variable)"

Pros: Works the Way intended.
Cons: Has a VERY SMALL leak.
 
Level 25
Joined
May 11, 2007
Messages
4,651
  • Events:
    • Every 0.10 seconds
  • Conditions:
  • Actions:
  • set tempGroup1 = units in region 001
  • Unit group - pick every unit in tempGroup1
    • Unit - set health of (Picked Unit) to arithmetic ((health of (Picked Unit)) - 1)
  • //Keep the custom script OUTSIDE the pick every unit loop. It's VERY important that you have the custom script or your map is going to lag to hell.
  • Custom script: call DestroyGroup(udg_tempGroup1)
Currently not at a computer with wc3 on it, so the syntax is a bit wrong but that's how you do it.
 
Level 2
Joined
Aug 14, 2015
Messages
14
I have no idea where to even start with that, i'm a complete novice with triggers, i've only ever done simple stuff, so can someone give me a step by step guide or something?


(Soz for my crap trigger knowledge) :(
 
Level 4
Joined
Mar 6, 2008
Messages
72
You can just create a dummy unit at each Reef and give them a custom Permanent Immolation for simplicity.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
Yeah But Rects (Same as Regions) are Rectangular, but Immolation is Circular.


@MapCrafter: Oh No....

First of all, you don't need to post pictures.
http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/


First, the Custom script must be on top of your Action, Not Under it.
Why you use (Triggering Unit) in the second Trigger? It should Be (Picked Unit).
Why did you Pick Everybody in Playable Map Area? It Should be Boats.


And I made Two Mistakes:
1) Remove the Custom Script.
2) Create Another trigger, Set the Event to "A Unit Leaves a Region" And set the Region to Your Regions.
On actions, Just Remove (Triggering Unit) from Boats.



After Everything, It should look like this:


  • Shipwreak Enter
    • Events
      • Unit - A unit enters Shipwreak 1 <gen>
      • Unit - A unit enters Shipwreak 2 <gen>
      • Unit - A unit enters Shipwreak 3 <gen>
      • Unit - A unit enters Shipwreak 4 <gen>
      • Unit - A unit enters Shipwreak 5 <gen>
      • Unit - A unit enters Shipwreak 6 <gen>
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to Boats


  • Shipwreak Loop
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Boats and do (Actions)
        • Loop - Actions
          • Unit - Cause (Picked unit) to damage (Picked unit), dealing 15.00 damage of attack type Siege and damage type Normal


  • Shipwreak Leave
    • Events
      • Unit - A unit leaves Shipwreak 1 <gen>
      • Unit - A unit leaves Shipwreak 2 <gen>
      • Unit - A unit leaves Shipwreak 3 <gen>
      • Unit - A unit leaves Shipwreak 4 <gen>
      • Unit - A unit leaves Shipwreak 5 <gen>
      • Unit - A unit leaves Shipwreak 6 <gen>
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from Boats





However, there Is a Plan B.

Go Delete that Unit Group Variable and All those triggers, and Create another Trigger.

Select that Trigger, and Find "Edit" on the Top left of your Window. There, Select "Convert to Custom Text".
When you Did, CnP the Following There:
JASS:
function Trig_Shipwreak_Loop_Func002A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Func004A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Func006A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Func008A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Func010A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Func012A takes nothing returns nothing
    call UnitDamageTargetBJ( GetEnumUnit(), GetEnumUnit(), 15.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Shipwreak_Loop_Actions takes nothing returns nothing
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_1), function Trig_Shipwreak_Loop_Func002A )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_2), function Trig_Shipwreak_Loop_Func004A )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_3), function Trig_Shipwreak_Loop_Func006A )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_4), function Trig_Shipwreak_Loop_Func008A )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_5), function Trig_Shipwreak_Loop_Func010A )
    set bj_wantDestroyGroup = true
    call ForGroupBJ( GetUnitsInRectAll(gg_rct_Shipwreak_6), function Trig_Shipwreak_Loop_Func012A )
endfunction

//===========================================================================
function InitTrig_Shipwreak_Loop takes nothing returns nothing
    set gg_trg_Shipwreak_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Shipwreak_Loop, 2 )
    call TriggerAddAction( gg_trg_Shipwreak_Loop, function Trig_Shipwreak_Loop_Actions )
endfunction

NOTE: If you use Plan B, You will have a little Lag every 2 seconds and If you Change the Name of your Regions, EVERYTHING WILL MESS UP.
 
Status
Not open for further replies.
Top