• 🏆 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!

Simple Spell Triggers

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
156
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.
  • 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.
 

dab

dab

Level 10
Joined
Oct 30, 2008
Messages
412
I'm trying to make it so a certain item, "Meat" will disappear after a minute on the ground...

That's a simple on but the one i really was lookin' for is a problem i'm having with a torch spell im using.
  • 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)

I need 2 more triggers to make it so when you drop the item "Torch" the light stays on the ground with the torch, basically stops following "Villager (Male 2)"... and so it refollows him when you re pick it up. With that I'm wondering if you can have so when I remove the torch and then add it again it will create the LightUnit and follow him, the player can destroy the torch and so the light needs to go away.

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.
 
Level 6
Joined
May 1, 2009
Messages
156
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" ?
  • 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)
 

dab

dab

Level 10
Joined
Oct 30, 2008
Messages
412
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" ?
  • 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)

Well, CarryingLight should handle that. And for the removal, you would do a trigger like
  • 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
  • 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
  • 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?
 
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.
 
Status
Not open for further replies.
Top