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

Regenerating and Degenerating Health

Status
Not open for further replies.
Level 2
Joined
Aug 10, 2006
Messages
10
Hi,

I'm working on a campaign for WC3, but I've run into som obstacles. First off, since you are only controlling a single hero I want a system that makes him regenerate life very quickly when not in combat, but to not regenerate at all when being attacked. This is to avoid the situation where you just leave the game on for a while to let your hero regenerate after a tough fight, and also combat the deus ex machina with healing fountains and potions everywhere.

The second thing I struggle with is an ability I've made for the hero. It's a spell with an effect similar to Bloodlust, only I want it to drain health every second in addition to it's standard effect (3/6/9 HP/second respectively) but I can't get this to work either. I tried using a buff with an immolation aura that only affected the target of the spell, but that didn't work out.

So, any suggestions?
 
Level 9
Joined
May 27, 2006
Messages
498
1. Dont know what you mean...

2. Easy

Variables:
Caster - Unit, used to refer to the caster of ability.

  • Bloodlust init
    • Events
      • Unit - A unit starts effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bloodlust
    • Actions
      • Set Caster = (Triggering unit)
  • Bloodlust hp effect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Bloodlust) Equal to TRUE
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (3.00 x (Real((Level of Bloodlust for Caster)))))
              • //OR//
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 3/6/9/whatever)
            • Else - Actions
This will work only if your bloodlust isn`t an autocast ability. If it is autocasted, then you wont be able to refer to the Caster variable.
 
Level 2
Joined
Aug 10, 2006
Messages
10
The ability trigger worked great, thanks a lot! :)

I still can't get the regeneration right, though.
 
Level 9
Joined
May 27, 2006
Messages
498
Just set unit`s life regeneration to 0, so they wont regenerate hp. Then, make a trigger, that gives them the healing aura ability of fountain of life, or just create a dummy unit with this ability near them. The first idea is easier to make.

First of all, find the healing aura ability of fountain of life. Copy it. Change the value of healed hp to number of hp healed you want. Change the abilities name, to make it easier to find it while creating triggers. For example "Triggered Healing".

Then make trigger like this one:

  • Triggered Healing
    • Events
      • Time - Every 1 second of game time.
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Entire map) and do (Actions)
        • If, Then, Else - Multiple actions
          • If - Conditions
            • Unit is being attacked equal to FALSE (or something like that... You`ll find these at Boolean Comparison)
          • Then - Actions
            • Unit - Add Triggered Healing to (Picked unit)
          • Else - Actions
            • Unit - Remove Triggered Healing from (Picked unit)

Im not sure if there is a boolean condition that refers if unit is under attack... Dont have time to check.

@Down
Oh... Thx, didnt see that :D Fixed
 
Last edited:
Level 2
Joined
Aug 10, 2006
Messages
10
The problem I get with that route is that the "Attacked Unit" and "Attacking Unit" actions only seem to work if the trigger is initiated by a "A unit is attacked" or "A unit is attacking" event (which combats the periodic timer which would be useful for the regeneration process). This means that the unit will either always regenerate from the start, or the regeneration will begin after the first blow is truck in combat and then never quit.

I've searched through the turials on this site as well as the Helper.net, but I am quite stumped to be honest.
 
Level 9
Joined
May 27, 2006
Messages
498
I think this should be working now...

Variables:
CustomValue - C, used to store the global custom value of units.
Unit[index] - combined with CustomValue is used to refer to single unit.

Abilites:
Is Fighting - Ability, copied Health Regeneration Aura, with healed amount set to 0, targets changed to Self, AOE changed to 300. Add Fight buff (first create it) to Statistics - Effect.



Fight - Buff, copy any buff, remove the blue glow effect model, change the icon to ReplaceableTextures\CommandButtons\BTNMassTeleport.blp (i think this one is the best for this kind of system), change name to Fight and the description to "This unit is fighting; it`s not regenerating hp."

  • Triggered Regeneration Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of units in (Units in (Entire map) matching (((Matching unit) is Building) Equal to FALSE))), do (Actions)
        • Loop - Actions
          • Set CustomValue = (CustomValue + 1)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in (Entire map) matching (((Matching unit) is Building) Equal to FALSE)) and do (Unit - Set the custom value of (Picked unit) to CustomValue)
  • Triggered Regeneration Init 2
    • Events
      • Unit - A unit sells a unit
      • Unit - A unit summons a unit
      • Unit - A unit finishes training a unit
    • Conditions
    • Actions
      • Set CustomValue = (CustomValue + 1)
      • Unit - Set the custom value of (Triggering unit) to CustomValue
  • Triggered Regeneration Remove
    • Events
      • Unit - A unit is target of attack
    • Conditions
    • Actions
      • Set Unit[(Custom value of (Attacked unit))] = (Attacked unit)
      • Set Unit[(Custom value of (Attacking unit))] = (Attacking unit)
      • Unit - Add Is Fighting to (Attacked unit)
      • Unit - Add Is Fighting to (Attacking unit)
      • Wait 2.00 seconds
      • Unit - Remove Is Fighting from (Attacked unit)
      • Unit - Remove Is Fighting from (Attacking unit)
  • Triggered Regeneration Add
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Entire map) matching (((Matching unit) is Building) Equal to FALSE)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Fight ) Equal to FALSE
            • Then - Actions
              • //The line below will force units to regenerate 0.5% of their hp per second. Choose the line, that matches your needs.
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + ((Max life of (Picked unit)) / 200.00))
              • //The line below will force units to regenerate 3 hp per second.
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 3.00)
            • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top