• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Unit regenerating hp in water

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Periodic loop. Once the unit learns the ability every 1 second check if the unit is standing on water and do the healing.
 
Level 5
Joined
Nov 30, 2012
Messages
200
I tested these triggers out and they work fine. Once you research Naga Siren Adept Training, Naga Sirens will regenerate in deep water only.

  • Heal Upgrade
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Naga Siren Adept Training
    • Actions
      • Set HealsInWater[(Player number of (Owner of (Researching unit)))] = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Execution count of (This trigger)) Greater than or equal to 1
        • Then - Actions
          • Trigger - Turn on Heal In Water <gen>
        • Else - Actions

  • Heal In Water
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Int) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HealsInWater[Int] Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Player(Int)) of type Naga Siren) and do (Actions)
                • Loop - Actions
                  • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
                  • Set Point = (Position of (Picked unit))
                  • Custom script: set udg_Real = GetLocationZ( udg_Point )
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Real Less than or equal to 166.40
                    • Then - Actions
                      • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Objects\InventoryItems\Rune\Rune.mdl
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 1.00)
                    • Else - Actions
            • Else - Actions
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Too complicated.

Just add the unit when it receives the ability to a unit group, and loop the group every 1 second.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You can do this if the real condition does not work.
  • (Terrain pathing at Point of type Floatability is off) Equal to False

And remember to remove the point variable. Also filter out dead units.

A better solution is to use Unit enters map, if condition then add unit to group. Only pick those units in group. Also add existing units to group when the research is finished.
 
Level 5
Joined
Nov 30, 2012
Messages
200
I did not know that this existed: (Terrain pathing at Point of type Floatability is off) Equal to False

Let me make a simpler trigger that is worthy of pleasing Spartipilo. :)
 
Level 5
Joined
Nov 30, 2012
Messages
200
This works:

  • Heal Upgrade
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Naga Siren Adept Training
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Owner of (Researching unit)) of type Naga Siren) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to UnitsThatHealInWater
      • Set HealsInWater[(Player number of (Owner of (Researching unit)))] = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Execution count of (This trigger)) Greater than or equal to 1
        • Then - Actions
          • Trigger - Turn on Heal In Water <gen>
        • Else - Actions
  • Add Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealsInWater[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Unit Group - Add (Triggering unit) to UnitsThatHealInWater
        • Else - Actions
  • Heal In Water
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UnitsThatHealInWater and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at Point of type Floatability is off) Equal to False
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 1.00)
            • Else - Actions
I have Heal In Water off at first so the game goes a little faster until someone researches Nada Siren Adept Training. Also, this probably goes much much faster than my past trigger. Enjoy!
 
Level 19
Joined
Jan 12, 2011
Messages
1,523
This works:

  • Heal Upgrade
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Naga Siren Adept Training
    • Actions
      • Unit Group - Pick every unit in (Units owned by (Owner of (Researching unit)) of type Naga Siren) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to UnitsThatHealInWater
      • Set HealsInWater[(Player number of (Owner of (Researching unit)))] = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Execution count of (This trigger)) Greater than or equal to 1
        • Then - Actions
          • Trigger - Turn on Heal In Water <gen>
        • Else - Actions
  • Add Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealsInWater[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Unit Group - Add (Triggering unit) to UnitsThatHealInWater
        • Else - Actions
  • Heal In Water
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UnitsThatHealInWater and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at Point of type Floatability is off) Equal to False
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 1.00)
            • Else - Actions
I have Heal In Water off at first so the game goes a little faster until someone researches Nada Siren Adept Training. Also, this probably goes much much faster than my past trigger. Enjoy!

Woah thanks man +rep!
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. Pick Every Unit of Type LEAKS. Instead Pick Every Unit and do "If Unit Type of Picked Unit = xxx, then..."

2. (Owner of (Researching unit)) is used twice. Store it into a variable in the trigger beginning, and use the variable instead.

3. After " Trigger - Turn on Heal In Water <gen>" use "Custom script: call DestroyTrigger(GetTriggeringTrigger())or "DestroyTrigger(gg_trg_Heal Upgrade)"

4. In "Add Units" trigger you have to filter the unit type, since you only heal Naga types.

5. "Heal In Water" trigger Leaks position: Also repeats several times the "Picked Unit", Set Picked Unit to a variable and use the variable instead. Also I would prefer adding a Life Regeneration ability rather than triggering the life modification

set u = Picked Unit
set L = Life Of u
Unit - set life of u = L + 1
 
Level 5
Joined
Nov 30, 2012
Messages
200
1. Pick Every Unit of Type LEAKS. Instead Pick Every Unit and do "If Unit Type of Picked Unit = xxx, then..."

2. (Owner of (Researching unit)) is used twice. Store it into a variable in the trigger beginning, and use the variable instead.

3. After " Trigger - Turn on Heal In Water <gen>" use "Custom script: call DestroyTrigger(GetTriggeringTrigger())or "DestroyTrigger(gg_trg_Heal Upgrade)"

4. In "Add Units" trigger you have to filter the unit type, since you only heal Naga types.

5. "Heal In Water" trigger Leaks position: Also repeats several times the "Picked Unit", Set Picked Unit to a variable and use the variable instead. Also I would prefer adding a Life Regeneration ability rather than triggering the life modification

set u = Picked Unit
set L = Life Of u
Unit - set life of u = L + 1

OK, OK, you're right on all these points.

1. Done
2. Done
3. If the map is multiplayer then this change should not be implemented
4. Done
5. I would prefer that too, but I suck with abilities and it would require more triggers to make the ability invisible if he wanted to

I would advise using these triggers instead to avoid leaks.

  • Heal Upgrade
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Naga Siren Adept Training
    • Actions
      • Set Unit = (Researching unit)
      • Set HealsInWater[(Player number of (Owner of Unit))] = True
      • Unit Group - Pick every unit in (Units owned by (Owner of Unit)) and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of Unit) Equal to Naga Siren
            • Then - Actions
              • Unit Group - Add Unit to UnitsThatHealInWater
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Execution count of (This trigger)) Greater than or equal to 1
        • Then - Actions
          • Trigger - Turn on Heal In Water <gen>
        • Else - Actions
  • Add Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Naga Siren
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealsInWater[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Unit Group - Add (Triggering unit) to UnitsThatHealInWater
        • Else - Actions
  • Heal In Water
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UnitsThatHealInWater and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • Set Point = (Position of Unit)
          • Set Real = (Life of Unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at Point of type Floatability is off) Equal to False
            • Then - Actions
              • Unit - Set life of Unit to (Real + 1.00)
            • Else - Actions
          • Custom script: call RemoveLocation( udg_Point )
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
About 3: You're right about the Multiplayer thing.
About 5: There are works around, like Fountain Life Regeneration, which doesn't display. With 2 levels, healing 0 at lvl 1, and 2 at lvl 2. Doesn't matter pretty much anyway

New 1: Add a trigger to remove units that die from the group.
New 2: Now my new and most aggresive suggestion- Turn everything to JASS, use locals, remove BJ's, optimize code in general.
New 3: No need for this on the first trigger: Set Unit = (Researching unit). You can use (Triggering Player) instead of (Owner of(Unit))
New 4: No need for this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Execution count of (This trigger)) Greater than or equal to 1
  • Then - Actions
  • Trigger - Turn on Heal In Water <gen>
Just turn on the Heal in Water. If the trigger runs twice, it won't do anything, it won't turn on the other trigger twice.

New 5: Before the Unit Group Declaration in the firs trigger (Units owned by...) add a Custom Script: set bj_wantDestroyGroup = true.
 
Level 19
Joined
Jan 12, 2011
Messages
1,523
1. Pick Every Unit of Type LEAKS. Instead Pick Every Unit and do "If Unit Type of Picked Unit = xxx, then..."

2. (Owner of (Researching unit)) is used twice. Store it into a variable in the trigger beginning, and use the variable instead.

3. After " Trigger - Turn on Heal In Water <gen>" use "Custom script: call DestroyTrigger(GetTriggeringTrigger())or "DestroyTrigger(gg_trg_Heal Upgrade)"

4. In "Add Units" trigger you have to filter the unit type, since you only heal Naga types.

5. "Heal In Water" trigger Leaks position: Also repeats several times the "Picked Unit", Set Picked Unit to a variable and use the variable instead. Also I would prefer adding a Life Regeneration ability rather than triggering the life modification

set u = Picked Unit
set L = Life Of u
Unit - set life of u = L + 1

I know about the custom scripts i added 2 i don't see the problem with the other things though


Custom script: call DestroyGroup(udg_unitsthathealinwater)
Custom script: call RemoveLocation(udg_Pointwater)


BTW why do you people insist in using naga siren? i said i want for ALL naga units who have the passive, making 6 triggers for each of the naga will generate more lag than using the old one wouldn't it?


and no thanks i don't want a jass trigger as it's a pain in the ass to import you gotta import libraries and all that shit
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, you just have to Copy/Paste and maybe edit two or three global values :)

This MUST NOT BE DONE: Custom script: call DestroyGroup(udg_unitsthathealinwater). You need that group.

Then just filter the units with the ability instead of the unit type.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
If you destroy that group, where are you going to hold the units with the ability?

When a unit enters the map, if it has the ability, add it to the group.

A unit enters playable map area
If Level of HealInWater of TriggeringUnit > 0
Add unit to HealInwaterGroup.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. This is the unit group you have to destroy placing "set bj_wantDestroyGroup = true" before declaring it: (Units owned by (Owner of unit)). Besides, the owner of a generic unit event can always be referenced as (Triggering Player), so, no need for (Owner of (Unit)).

2. Instead of a long chain of If Then else with Unit Type Comparisons, just add the ability to those units, and check if the unit has the ability (level of ability is > 0)

3. THIS IS BAD
  • (Unit-type of (Triggering unit)) Equal to (==) Naga Royal Guard
  • (Unit-type of (Triggering unit)) Equal to (==) Naga Myrmidon
  • (Unit-type of (Triggering unit)) Equal to (==) Naga Siren
  • (Unit-type of (Triggering unit)) Equal to (==) Naga Summoner
This is GOOD
  • Level of HealINwater for (Triggering Unit) is greater than 0
4. No need for this. The trigger will turn on anyway. No need for a comparison check, mostly because it will always be true.
  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Execution count of (This trigger)) Greater than or equal to (>=) 1
  • Then - Actions
  • Trigger - Turn on Heal In Water <gen>
  • Else - Actions
5. No need for this: " Custom script: call DestroyGroup(udg_unitsthathealinwater)" In fact, that's what screwing things up. You're destroying the group where you're holding your units. That group must not be destroyed.

6- Special effect leak
  • Special Effect - Create a special effect attached to the chest of (Picked unit) using war3mapImported\Large Bubbles.mdx
Remember to destroy it.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. On "Mend Upgrade" trigger replace "Owner of Unit" with (Triggering Player). How many times do I have to say it?.

2. You're leaking. set bj_wantDestroyGroup = true before declaring the "Units owned by (Triggering Player)". I've said it tons of times too.

3. I hope you see it
Set unit = (Picked unit)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Naga Mend (Naga) for (Triggering unit)) Greater than (>) 0

In this case the Triggering Unit is the Researching Unit... doesn't makes sense :)
 
Status
Not open for further replies.
Top