1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  5. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  6. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  7. The results are out! Check them out.
    Dismiss Notice
  8. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  9. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Health Reserve System v1.5

Submitted by hell gate
This bundle is marked as approved. It works and satisfies the submission rules.
Health Reserve System v1.0
by hell gate and Deaod

about the system:
this system creates a "ball" that follows physical correct a target unit with a constant garavitation. if it comes close to the target it heals x HP

how to use:
call NewHealthBall(X,Y,Z,Heal,SpeedX,SpeedY,SpeedZ,HealingUnit)

note:
you need BoundSentinel inside your map else this system can cause an fatal error!

Updates

v1.0 => Uploaded
v1.3 => added new options (Mana_Add,Red,Green,Blue,Scale); fixed Deaod's name :S
v1.5 => remove Red,Green,Blue bacause a bug, added dummy recycling, Deaod changes some movement things, now you can choose your model


Code
Code (vJASS):
//=====================================================================================
//                         |      Health Reserve System      |
//                         |     by hell gate and Deaod      |  
//=====================================================================================
// how to use:
// Cnp this system in your map
// if you don't have BoundSentinel in your map also Cnp it else this system can cause a critical error!
// how to create a new Health Ball:
// call NewHealthBall(X     ,Y     ,Z      ,ModelPath  ,Heal   ,ManaHeal ,SpeedX ,SpeedY ,SpeedZ ,HealingUnit, Red      ,Green    ,Blue    ,Scale)
//                    real   real   real    string      real    real      real    real    real    unit         intger    intger    intger   real  
//=====================================================================================


library HealthReserve initializer Init //requires BoundSentinel
    globals
        private             real        SpeedIncraise   = 10.       //
        private             real        MaxSpeed        = 500.      //the maximum speed of a ball
        private constant    real        RopeLength      = 750.      //
        private constant    real        RefreshTime     = 1./40     //refresh intervall
        private constant    integer     DummyId         = 'h000'    //the health reserve dummy
        private constant    real        DistanceNeeded  = 100.      //how far away the ball have to be to heal
        private constant    string      HealEffect      = "Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl"
    endglobals
   
    private struct HealthBalls
        real    x
        real    y
        real    z
        //----- vectors -----
        real    Heal
        real    Mana
        unit    Ball
        unit    Target
        effect  Model
       
        private integer i
       
        private static group RecycledDummys=CreateGroup()
        private static integer Count       =0
       
        private static timer Tim           = CreateTimer()
        private static integer Total       = 0
        private static thistype array Balls
       
        private static location LocZ=Location(0,0)
       
        private static method GetUnitZ takes unit u returns real
            call MoveLocation(LocZ, GetUnitX(u), GetUnitY(u))
            return GetLocationZ(LocZ)+GetUnitFlyHeight(u)
        endmethod
       
        private static method SetUnitZ takes unit u, real z returns nothing
            call MoveLocation(LocZ, GetUnitX(u), GetUnitY(u))
            call SetUnitFlyHeight(u, z-GetLocationZ(LocZ), 0)
        endmethod
       
        private method onDestroy takes nothing returns nothing
            set Total = Total - 1
            set Balls[i] = Balls[Total]
            set Balls[i].i=i
            if Total==0 then
                call PauseTimer(Tim)
            endif
        endmethod
       
        private static method BallLoop takes nothing returns nothing
        local thistype dat
        local integer i = Total-1
        local real x
        local real y
        local real z
        local real dx // delta x
        local real dy // delta y
        local real dz // delta z
        local real d // absolute distance
            loop
                exitwhen i < 0
                set dat = Balls[i]
                if IsUnitType(dat.Target, UNIT_TYPE_DEAD) == false then
                    set x=GetUnitX(dat.Ball)
                    set y=GetUnitY(dat.Ball)
                    set z=GetUnitZ(dat.Ball)
                    set dx=GetUnitX(dat.Target)-x
                    set dy=GetUnitY(dat.Target)-y
                    set dz=GetUnitZ(dat.Target)-z
                    set d=SquareRoot(dx*dx+dy*dy+dz*dz)
                    set dat.x=dat.x+dx/d*(SpeedIncraise*RopeLength/d)
                    set dat.y=dat.y+dy/d*(SpeedIncraise*RopeLength/d)
                    set dat.z=dat.z+dz/d*(SpeedIncraise*RopeLength/d)
                    // reuse d
                    if d <= DistanceNeeded then
                        call DestroyEffect(dat.Model)
                        call GroupAddUnit(RecycledDummys,dat.Ball)
                        set Count=Count+1
                        call SetWidgetLife(dat.Target,GetWidgetLife(dat.Target)+dat.Heal)
                        call SetUnitState(dat.Target, UNIT_STATE_MANA, GetUnitState(dat.Target,UNIT_STATE_MANA)+dat.Mana)
                        call DestroyEffect(AddSpecialEffectTarget(HealEffect,dat.Target,"origin"))
                        call dat.destroy()
                    else
                        set d=SquareRoot(dat.x*dat.x+dat.y*dat.y+dat.z*dat.z)
                        if d>MaxSpeed then
                            set dat.x=dat.x/d*MaxSpeed
                            set dat.y=dat.y/d*MaxSpeed
                            set dat.z=dat.z/d*MaxSpeed
                        endif
                        call SetUnitX(dat.Ball, x+dat.x)
                        call SetUnitY(dat.Ball, y+dat.y)
                        call SetUnitZ(dat.Ball, z+dat.z)
                    endif
                else
                    call RemoveUnit(dat.Ball)
                    call dat.destroy()
                endif
                set i = i-1
            endloop
        endmethod
       
        static method create takes real X, real Y, real Z, string modeleffect, real HP_Add, real Mana_Add, real vX, real vY, real vZ, unit TargetUnit, real Scale returns thistype
            local thistype dat = allocate()
            set Balls[Total] = dat
            if Total==0 then
                call TimerStart(Tim,RefreshTime,true,function thistype.BallLoop)
            endif
            set dat.i=Total
            set Total = Total+1
            set dat.Heal = HP_Add
            set dat.Mana = Mana_Add
            set dat.x = vX
            set dat.y = vY
            set dat.z = vZ
            set dat.Target = TargetUnit
            if Count == 0 then
                set dat.Ball=CreateUnit(Player(15),DummyId,X,Y,0.)
                call UnitAddAbility(dat.Ball,'Amrf')
                call UnitRemoveAbility(dat.Ball,'Amrf')
                call SetUnitPathing(dat.Ball,false)
            else
                set dat.Ball=FirstOfGroup(RecycledDummys)
                call GroupRemoveUnit(RecycledDummys,dat.Ball)
                set Count=Count-1
                call SetUnitX(dat.Ball,X)
                call SetUnitY(dat.Ball,Y)
            endif
            set dat.Model = AddSpecialEffectTarget(modeleffect,dat.Ball,"chest")
            call SetUnitFlyHeight(dat.Ball,Z,0.)
            call SetUnitScale(dat.Ball,Scale*0.01,Scale*0.01,Scale*0.01)
            return dat
        endmethod
    endstruct
   
    function NewHealthBall takes real X, real Y, real Z, string modeleffect, real HP_Add, real Mana_Add, real vX, real vY, real vZ, unit TargetUnit, real Scale returns nothing
        call HealthBalls.create( X, Y, Z, modeleffect, HP_Add, Mana_Add, vX, vY, vZ, TargetUnit, Scale)
    endfunction
   
    private function Init takes nothing returns nothing
        set SpeedIncraise = SpeedIncraise*RefreshTime
        set MaxSpeed = MaxSpeed*RefreshTime
    endfunction
endlibrary


Keywords:
Life, health, mana, gravitation, physik, heal, fly, orb monsters follow me!! help
Contents

Noch eine WARCRAFT-III-Karte (Map)

Reviews
Moderator
12:21, 17th Jun 2010 TriggerHappy: The dummy player should be configurable and please try to use dummy recycling. Regardless it's good enough to be approved.
  1. 12:21, 17th Jun 2010
    TriggerHappy:

    The dummy player should be configurable and please try to use dummy recycling. Regardless it's good enough to be approved.
     
  2. xxdingo93xx

    xxdingo93xx

    Joined:
    Sep 8, 2007
    Messages:
    746
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    great idea. This could make a map unique! I like it, 5/5 from me. The coding seems fine, too, the only thing I don't like is the healthball model :p there are sure better models than the whisp but well, changing a units model isn't that hard :p
     
  3. Gamecrafter_DK

    Gamecrafter_DK

    Joined:
    Sep 25, 2007
    Messages:
    1,235
    Resources:
    3
    Maps:
    1
    Tutorials:
    2
    Resources:
    3
    Great idea! But they close in waaaaaay to slowly... 4/5
     
  4. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    @xxdingo93xx
    thx :) but i found no better model

    @Gamecrafter
    you can change this
    just set SpeedIncraise and MaxSpeed higher
     
  5. Gamecrafter_DK

    Gamecrafter_DK

    Joined:
    Sep 25, 2007
    Messages:
    1,235
    Resources:
    3
    Maps:
    1
    Tutorials:
    2
    Resources:
    3
    Yeah. i could. But then i'd have to learn JASS first XD (or not.) Nay, i create systems and such for the common folk ;) Well, then take my suggestion as an improvement to your 'basic system' also - it's physics*
     
  6. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
  7. NFWar

    NFWar

    Joined:
    Jul 27, 2008
    Messages:
    1,314
    Resources:
    227
    Models:
    1
    Icons:
    215
    Packs:
    1
    Skins:
    2
    Spells:
    6
    Tutorials:
    2
    Resources:
    227
    Yeah! You uploaded it! It seems like a bit diferent than last I saw. Seems like heal balls fly with Z too :)
    Owesome.
     
  8. Gamecrafter_DK

    Gamecrafter_DK

    Joined:
    Sep 25, 2007
    Messages:
    1,235
    Resources:
    3
    Maps:
    1
    Tutorials:
    2
    Resources:
    3
    They do fly Z ... if you scroll down the view, and kill with the gryphon rider, it's noticable.
     
  9. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    i'll add the link in the next update

    and don't forgett to give credits to me and deaod if you use :p
     
    Last edited: Feb 21, 2010
  10. Catch_ya

    Catch_ya

    Joined:
    May 21, 2009
    Messages:
    982
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Do you and deaod make everything together atm :p?
     
  11. Deaod

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    805
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    Actually, im just helping him out with a few of his questions.
     
  12. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    You could use General's Frank blood orb model imo.

    Also you could make it extend an interface with a onHit method if someone wants to make custom orbs.

    Example:
    Code (vJASS):

                            call RemoveUnit(dat.Ball)
                            call SetWidgetLife(dat.Target,GetWidgetLife(dat.Target)+dat.Heal)
                            call SetUnitState(dat.Target, UNIT_STATE_MANA, GetUnitState(dat.Target,UNIT_STATE_MANA)+dat.Mana)
                            call DestroyEffect(AddSpecialEffectTarget(HealEffect,dat.Target,"origin"))
                           


    This could be just moved to a onHit method which is extended by the struct HealthOrb or something.

    It would provide great modification ability to the users, allowing them to make Exp orbs, mana orbs, damage orbs, etc...

    Another Example(OrbEntity should represent your main struct):
    Code (vJASS):

    struct HealOrb extends OrbInterface

    method onHit takes OrbEntity dat returns nothing defaults
          call RemoveUnit(dat.Ball)
          call SetWidgetLife(dat.Target,GetWidgetLife(dat.Target)+dat.Heal)
          call SetUnitState(dat.Target, UNIT_STATE_MANA, GetUnitState(dat.Target,UNIT_STATE_MANA)+dat.Mana)
          call DestroyEffect(AddSpecialEffectTarget(HealEffect,dat.Target,"origin"))
    endmethod

    endinterface


    EDIT:

    Interface could also consist of:
    *Special effects on hit string variable
    *OnSpawn method
    *OnLoop method

    Just to make it more customizable, if not nevermind, was just an idea.

    EDIT2:

    I didn't see a Timeout variable (a time after an orb dies/disapears) which could be quite handy in order to prevent, let's see i miss an orb and the system never stops running :p
     
  13. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    i don't think i will add this :/

    but thx for the timeout... my bad
     
  14. FhelZone

    FhelZone

    Joined:
    Dec 20, 2007
    Messages:
    112
    Resources:
    5
    Icons:
    3
    Maps:
    2
    Resources:
    5
    Reminds me of two things, neat spell by the way, I might use it if the code is confirmed to be flawless. I don't know any vJASS :) Anywya reminds me of 1.) Life steal from heroes of newerth and 2.) Onimusha's soul sucking system... 5/5 for the idea (does not rate code ^^) been looking for one for a long time already.
     
  15. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    Jass tags are broken in the description.
     
  16. hell gate

    hell gate

    Joined:
    Nov 23, 2008
    Messages:
    477
    Resources:
    10
    Models:
    1
    Spells:
    9
    Resources:
    10
    thx will fix it