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

[Trigger] Mana detection for unit type

Status
Not open for further replies.
Can someone help me convert this to a trigger. The editor doesn't seem to recognize counting mana of unit-types, instead it asks for a specific unit.

So i have a plant with a mana of 100, which decreases -2 every second. (I've already finished this, i made make regeneration increment to negative to make this happen).

Now when the mana reaches 0 the plant should generate an item, tome of experience for example, then the mana should go back to 100 and the loop goes on. The player can build alot of plants, so i shouldnt specify it to a single plant.

  • Detect Plant Death
    • Events
      • Unit - (This should be a plant) mana becomes Less than 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 10) Equal to 1
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Your plant is ready...
          • Item - Create Tome of Experience at (Position of ((This should be a plant)))
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Your plant died.
Second Attempt

  • Detect Plant Death
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to Plant
          • (Integer((Mana of (Entering unit)))) Less than or equal to 1
    • Actions
      • Item - Create Tome of Experience at (Position of (Entering unit))
      • Game - Display to Player Group - Player 1 (Red) the text: Your plant is ready...
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
  • Detect Plant Death
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set PlantGroup = (Units of type Plant)
      • Unit Group - Pick every unit in PlantGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of (Picked unit)) Equal to 0.00
            • Then - Actions
              • Set ClosestPoint = (Position of (Picked unit))
              • Item - Create Tome of Experience at ClosestPoint
              • Custom script: call RemoveLocation(udg_ClosestPoint)
              • Unit - Set mana of (Picked unit) to 100.00%
            • Else - Actions
      • Custom script: call DestroyGroup(udg_PlantGroup)
Should take care of the memory leaks as well.
 
Hey, thank you very much for your help, it worked. But can i ask another favor? Is it possible to count the items near every plant? The problem is it will just keep spamming the item until the game becomes unplayable lol.

Edit: I think i can just add timer to the plant and let it die so it will not spawn indefinitely. Still thank you very much for your help. :)
 
Level 8
Joined
May 21, 2019
Messages
435
Hey, thank you very much for your help, it worked. But can i ask another favor? Is it possible to count the items near every plant? The problem is it will just keep spamming the item until the game becomes unplayable lol.

Edit: I think i can just add timer to the plant and let it die so it will not spawn indefinitely. Still thank you very much for your help. :)
Counting near every plant can be done, yeah, but if the idea is to avoid a mass-spam of tomes, then you may want to set a global cap. In either case, you can count the amount of items of that type laying on the ground and deny a new spawn above a certain threshold.
 
Last edited:
Status
Not open for further replies.
Top