• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Questions

Status
Not open for further replies.
Level 1
Joined
Jun 12, 2004
Messages
3
Hi, I've been working on a RPG map. A couple of scenarios for trigger that kept popping in my head that I don't know how to do so (since I don't know triggers advancely). So I'll ask them:

1) I want to have it somelike WoW where mobs will respawn at X seconds in certain area. Kinda like Defiance RPG where the mobs would respawn the same mob in the same location at a certain time after their death. So the player would have something to kill to level up.

2)In my map I have it to where you're going to command 25 other units along with your hero unit to places. Keep in mind I plan to make this a solo only RPG. I was wondering if their was a command to make it where your normal units would teleport to your hero unit should they get stuck. Note that you buy these units from like a barrack (item shop system).

I'm sure later on, I'll have some more questions that I'll need some help out. Thanks for your help on this. :)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
1) Well, basicly the trigger is something like this

  • Untitled Trigger 038.18
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
    • Actions
      • Wait X seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees

The problem is, it leaks a location.
I do not know how much you know about triggers, so if you don't know what leaks are, go read this and/or this.

To solve this, ill use a bug (I think its a bug), that allow us to use Local variables (you'd know what are these if you know programming) with GUI which is normaly, sadly, now allowed.

It will look like this:
  • Untitled Trigger 038.19
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
    • Actions
      • Custom script: local real x
      • Custom script: local real y
      • Set Point = (Position of (Triggering unit))
      • Set x = (X of Point)
      • Set y = (Y of Point)
      • Custom script: call RemoveLocation(udg_Point)
      • Wait X seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Point(x, y)) facing Default building facing degrees
Now to explain it a bit:

With the two custom scripts I made two local variables called "x" and "y".
Please notice that decalring local variables have to come at BEFORE any other actions.
Now I set a point variable to the units position and set 2 real variables to the X and Y of that point.
I then removed the point to prevent a leak, waited X seconds, and created the unit at the x,y variables.

Notice: the global variables you declared (normal variables) must be named exacly like the local ones you declared with the custom scripts because it is case sensitive (meaning that "X" isn't like "x") !


2) This is a bit confusing trigger.
  • Untitled Trigger 021.265
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Set Integer = (Integer + 1)
      • Set Units_Following[Integer] = (Sold unit)
  • Untitled Trigger 021.266
    • Events
      • Time - Every 4.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to Integer, do (Actions)
        • Loop - Actions
          • Set Hero_Point = (Position of (Triggering unit))
          • Set Follower_Point = (Position of Units_Following[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Hero_Point and Follower_Point) Greater than or equal to 1000.00
            • Then - Actions
              • Unit - Move Units_Following[(Integer A)] instantly to Hero_Point
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Hero_Point)
          • Custom script: call RemoveLocation(udg_Follower_Point)
 
Level 10
Joined
Nov 10, 2004
Messages
351
1) Well, basicly the trigger is something like this
  • Events
    • Unit - A unit Dies
  • Conditions
    • ((Owner of (Triggering unit)) controller) Equal to Computer
  • Actions
    • Custom script: local real x
    • Custom script: local real y
    • Set Point = (Position of (Triggering unit))
    • Set x = (X of Point)
    • Set y = (Y of Point)
    • Custom script: call RemoveLocation(udg_Point)
    • Wait X seconds
    • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (Point(x, y)) facing Default building facing degrees
Point(x, y) Creates a new location, which means it still leaks.
  • Events
    • Unit - A unit Dies
  • Conditions
    • ((Owner of (Triggering unit)) controller) Equal to Computer
  • Actions
    • Wait X seconds
    • Set TempLoc = (Position of (Triggering unit))
    • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at (TempLoc) facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_TempLoc)
This one is without leaks.

Here's a link to a system, in case you are interested: http://www.hiveworkshop.com/forums/showthread.php?t=35144
 
Status
Not open for further replies.
Top