1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest.
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Simple Spell Triggers

Discussion in 'Requests' started by Lee_Go, Mar 21, 2010.

  1. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    I'm trying to make it so a certain item, "Meat" will disappear after a minute on the ground...

    That's a simple one but the one i really was lookin' for is a problem i'm having with a torch spell im using.
    Torch Spell
    • LightCreate
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Unit - Create 1 Light for Player 1 (Red) at (Position of Villager (Male 2) 0011 <gen>) facing Default building facing degrees
        • Set LightUnit = (Last created unit)
        • Custom script: call SetDayNightModels("","")

    • Light
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
        • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to 1.00
      • Actions
        • Set TempPoint = (Position of Villager (Male 2) 0011 <gen>)
        • Set TempPoint2 = (TempPoint offset by 140.00 towards (Facing of Villager (Male 2) 0011 <gen>) degrees)
        • Unit - Move LightUnit instantly to TempPoint2
        • Custom script: call RemoveLocation(udg_TempPoint)
        • Custom script: call RemoveLocation(udg_TempPoint2)


    These triggers make the LightUnit follow the Villager but I need it so when you drop the torch it just stays where it last was and then it starts following him again when he regrabs it...

    Also the player can store the torch thus removing it from the game, i need a trigger that will remove the LightUnit from the game its removed from the game and then is remade when put into the game again. I can add this part to the trigger that removes and adds the torch.
     
  2. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    You would mod
    • Light
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
        • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to 1.00
      • Actions
        • Set TempPoint = (Position of Villager (Male 2) 0011 <gen>)
        • Set TempPoint2 = (TempPoint offset by 140.00 towards (Facing of Villager (Male 2) 0011 <gen>) degrees)
        • Unit - Move LightUnit instantly to TempPoint2
        • Custom script: call RemoveLocation(udg_TempPoint)
        • Custom script: call RemoveLocation(udg_TempPoint2)



    into:
    • Light
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
        • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to 1.00
      • Actions
        • If (Conditions) then (Actions) else (Actions)
          • If (CarryingLight) equals to (True) then (Multiple Actions)
            • Set TempPoint = (Position of Villager (Male 2) 0011 <gen>)
            • Set TempPoint2 = (TempPoint offset by 140.00 towards (Facing of Villager (Male 2) 0011 <gen>) degrees)
          • else
            • If (Conditions) then (Actions) else (Actions)
              • If (Dropped = (False) && (CarryingLight) = (False))
                • Set DropPoint = (Position of Villager (Male 2) 0011 <gen>)
                • Set Dropped = (True)
        • If (Conditions) then (Actions) else (Actions)
          • If (CarryingLight) equals to (True)
            • Unit - Move LightUnit instantly to TempPoint2
          • Else
        • Custom script: call RemoveLocation(udg_TempPoint)
        • Custom script: call RemoveLocation(udg_TempPoint2)


    And then create some triggers to make him lay it down/pick it up again which would set Dropped to either True/False and CarryingLight to False/True.

    The create thing would be similar to the above triggers, just using (CurrentlyInGame) as a variable and then setting it to True/False

    Hoping you get the idea. This is nonehow MUI, but from the triggers you posted, I'm guessing its not needed either.

    BTW, apologize if I messed the code up. I'm working on some flash, so I might mix the two things up sometimes.
     
  3. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    what kind of variable is CarryingLight
     
  4. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    It's a boolean, due to the fact that it can be set as True or False ^^
     
  5. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    I did it like this but I don't know if it's what you were trying to say and how can this specify he is holding the item "Torch" ?
    My Version
    • Light
      • Events
        • Time - Every 0.02 seconds of game time
      • Conditions
        • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to 1.00
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CarryingLight Equal to True
          • Then - Actions
            • Set TempPoint = (Position of Villager (Male 2) 0011 <gen>)
            • Set TempPoint2 = (TempPoint offset by 140.00 towards (Facing of Villager (Male 2) 0011 <gen>) degrees)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Dropped Equal to False) and (CarryingLight Equal to False)
              • Then - Actions
                • Set DropPoint = (Position of Villager (Male 2) 0011 <gen>)
                • Set Dropped = True
              • Else - Actions
                • Do nothing
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • CarryingLight Equal to True
          • Then - Actions
            • Unit - Move LightUnit instantly to TempPoint2
          • Else - Actions
            • Do nothing
        • Custom script: call RemoveLocation(udg_TempPoint)
        • Custom script: call RemoveLocation(udg_TempPoint2)


    Anyone know how to remove an item from the game if its been on the ground for over a minute? (First Request)
     
  6. dab

    dab

    Joined:
    Oct 30, 2008
    Messages:
    382
    Resources:
    2
    Skins:
    1
    Tutorials:
    1
    Resources:
    2
    Well, CarryingLight should handle that. And for the removal, you would do a trigger like
    This
    • Events
      • A Unit Looses an Item
    • Conditions
      • (Last dropped Item) Equal to (Torch)
    • Actions
      • Set Torch = (Last Dropped Item)
      • Countdown Timer - Start (TorchBurnOut) as a One-Shot timer that will expire in 60.00 seconds


    Do one to destory it like
    This
    • Events
      • Time - TorchBurnOut expires
    • Conditions
      • And - All (Conditions) are true
        • (CarryingLight) equals (False)
        • (Dropped) equals (True)
    • Actions
      • Item - Remove (Torch)


    Now, guessing you also want one to prevent it from disappering by picking it up again? Something like
    This
    • Events
      • A Unit Acquires a Item
    • Conditions
      • (Last Acquired Item) Equal to (Torch)
    • Actions
      • Countdown Timer - Pause (TorchBurnOut)



    You will need a item named Torch of cause, but guessing you've already got one of those?
     
  7. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,128
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    Lee_Goo, some things to mention.
    • Jass's way to find whether a unit is dead in an instant way (because Unit - Unit is alive is a bit slow, it requires the unit to have its decay animation started) is if its life it Less than or Equal to 0.405. So, instead of the conditions you've placed:
    • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to 1.00

    Use
    • (Life of Villager (Male 2) 0011 <gen>) Greater than or equal to (0.41 - 0.05)

    Simply because 0.405 is not supported in one field function.

    • To remove an item that has been on the ground for over a minute, there are two ways. Either create a dummy and attach it via hashtables on the item, add expiration timer, and, when the dummy dies, remove the item or set the custom value of your item to 1 and pick every item with a periodic event, that has custom value = 1, substract - 1 from an integer, attached on the item and finally, if the integer equals to 60, remove the item.
    Here is a test map, it contains both ways:

    I added "3" seconds for testing purposes, change it to 60.

    View attachment Remove Item From Ground (Timed).w3x

    Both ways work fine; enable the "Way 2" trigger and disbale the "Way1" and "Way1b" trigger to test the second way.