Condition: Unit's Distance to another unit?

maldruzard

Member
Reaction score
2
Hey there!

So I'm attempting to make some sort of 'cook food' trigger, in which a player types a command, and some raw meat from his inventory is removed and cooked meat in given to him. However, a condition for this to happen is that he must be standing near a fire in order to do so. I have currently been able to trigger this successfully, despite many different attempts.

Here is what I have currently got:

Checking Distance Trigger -
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Campfire
Then - Actions
Unit Group - Pick every unit in (Units in (Region centered at (Position of (Picked unit)) with size (200.00, 200.00))) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Picked unit)) Equal to Survivor
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to Player 1 (Red)
Then - Actions
Set campfireradiusTF[1] = True

Cooking meat trigger -
Events
Player - Player 1 (Red) types a chat message containing -cook meat as An exact match
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
campfireradiusTF[1] Equal to True
Then - Actions
Item - Remove (Item carried by play1cam of type Raw Meat)
Hero - Create Crude Fencing and give it to play1cam
Else - Actions
So far the trigger is pretty basic, though it is entirely non-functional, for reasons beyond my meagre understanding of triggers. Can anyone tell me why this doesn't work, and perhaps suggest another valid method for checking whether the hero is standing next to the campfire unit?
Cheers :)
 

Solu9

You can change this now in User CP.
Reaction score
216
You could give the campfire unit a buff. Then:

Trigger:
  • Test
    • Events
      • Player - Player 1 (Red) types a chat message containing -Cook as An exact match
    • Conditions
      • ((Triggering unit) has buff Campfire) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Raw Meat) Equal to True
        • Then - Actions
          • Hero - Drop (Item carried by (Triggering unit) of type Raw Meat) from (Triggering unit)
          • Item - Remove (Last dropped item)
          • Hero - Create Cooked Meat and give it to (Triggering unit)
        • Else - Actions


Replace triggering unit with whatever you like. Fx, Unit type of unit owned by player 1 equal to hero.
 

maldruzard

Member
Reaction score
2
Aye, the campfire is based off the fountain of health anyway, so I used that buff in the trigger :) thanks!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top