Spell Energy Shield

the Immortal

I know, I know...
Reaction score
51
Energy Shield:

picturelh0.jpg

So ... this is the first spell I post somewhere.
It basically creates a shield around the caster that absorbs damage with its "energy". When the shield ends (currently after 20 sec.) the unit is healed for amount equal to the shield's remaining "energy".

Simple, isn't it?

Here are the things you can config:
- the raw codes of the ability & the buff
- max duration of the spell
- is the spell insta-cast or unit-cast
- the formula for the max "energy" the shield has

Known bugs:
- NONE

Please post any leaks, bugs or typos that you find. I will try to remove them as fast as I can :p

EDIT (12.11.06)
- Fixed the triggeraction leak
- Added a new shield-effect (by Tinki3's idea)
- Added picture

EDIT (14.11.06)
- Fixed the full health bug
- I hope there aren't any bugs/leaks now :)
 

Attachments

  • Energy Shield.w3x
    21.9 KB · Views: 749

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Hmmm, when I tested it, the shield didn't absorb any damage at all and the shield didn't end, when it was supposed to absorb the max damage.
 

Tinki3

Special Member
Reaction score
418
You should try and fix the leaks/bugs before you release the spell map, otherwise it doesn't get accepted for a while (I know from experience) :)

Testing out spell now.

EDIT:

Bad news. The shield did nothing except show a buff, and create an animation around the caster =(

EDIT 2:

Tested the updated version. Works perfectly. Good work +rep =)
 

Tinki3

Special Member
Reaction score
418
You could've also based the spell of mana shield, with a trigger that goes after after the mana shield has been activated that constantly sets the mana of the caster to its current mana. And if the caster happened to cast another spell, you could single the spells which the caster could cast out using conditions, then subtract mana from the caster after he uses that particular spell ;)

For this idea, you could include all that other stuff that the trigger does as well (at least I think).
 

the Immortal

I know, I know...
Reaction score
51
@ Chocobo:
I made originally the "-lvl" command in such way, but I decided to make it more specific, because the player can type something like "-lvl sdf"
For the Handle Vars - In the importing guide I wrote that you must paste the custom script in your map's header.
For the channel-spell you can see that I first based it off Channel (I didn't delete the old ability), but Channel has no buff and Effect

@Tinki3 - If I base it off Mana Shield, how I will know what damage is dealt x)? The units has mana reg. so I can't set it to constant value. Also when you import it in your map, you'll have to select the abilities the hero has & their mana cost ... and that's annoying.
 

SFilip

Gone but not forgotten
Reaction score
633
Nice one, GJ.
There is a small leak you should probably know about...triggeraction. You need to destroy it before you destroy the actual trigger.
You also need to Flush the game cache after use.
And perhaps its a better idea to use the actual Handle Vars system, makes it easier to understand and implement.

Code:
function take_dmg takes nothing returns nothing
    local trigger trg = GetTriggeringTrigger()
    local real h = GetEventDamage()
    local real absorb = GetHandleReal(trg, "absorb" )
    if GetEventDamage() > absorb then
        call SetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE, ( GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + h ) )
        [b]call TriggerRemoveAction(trg, GetHandleTA(trg, "ta"))
        call FlushHandleLocals(trg)[/b]
        call DestroyTrigger( trg )
        call UnitRemoveAbility(GetTriggerUnit(), BuffID())
    else
        call SetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE, ( GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + h ) )
        set absorb = absorb - GetEventDamage()
        call SetHandleReal(trg, "absorb", absorb)
    endif
    set trg = null
        
endfunction

function Action takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local unit targ
    local real absorb = BaseAbsorb() + LvlAbsorb() * I2R( GetUnitAbilityLevel(cast, GetSpellAbilityId()) )
    local trigger trg = CreateTrigger()
    [b]local triggeraction ta[/b]
    if not( IsCastable() ) then
        set targ = GetTriggerUnit()
    else
        set targ = GetSpellTargetUnit()
    endif
    call SetHandleReal(trg, "absorb", absorb)
    call TriggerRegisterUnitEvent( trg, targ, EVENT_UNIT_DAMAGED )
    [b]set ta =[/b] TriggerAddAction( trg, function take_dmg )
    [b]call SetHandleHandle(trg, "ta", ta)[/b]
    call PolledWait( Duration() )
    if not(trg == null)  then
        set absorb = GetHandleReal(trg, "absorb")
        call SetUnitState(targ, UNIT_STATE_LIFE, ( GetUnitState( GetTriggerUnit(), UNIT_STATE_LIFE ) + absorb ) )
    endif
    [b]call FlushHandleLocals(trg)
    call TriggerRemoveAction(trg, ta)[/b]
    call DestroyTrigger( trg )
    set trg = null
    set cast = null
    set targ = null
    [b]set ta = null[/b]
endfunction
bold=stuff I added

And add this to the handle vars system.
Code:
function GetHandleTA takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

Edit: Oh and you might wanna add a picture, these things usually promote your spell. ;)
 

SFilip

Gone but not forgotten
Reaction score
633
Before I approve this there is a bug you should fix...
When the spell is casted and you have full hp you will take the first damage and it doesn't get absorbed from some reason.
 

the Immortal

I know, I know...
Reaction score
51
Ok, fixed this bug (note that now the custom script is more hard-to-understand than before). The problem was that the event occurs before the damage is taken from the unit.
I think I fixed any bugs and leaks and the spell is ready for use.
 

emjlr3

Change can be a good thing
Reaction score
395
what is the purpose of the dmgrestore method u r using?

also, i recommend changing the functions action and cond to something that may not interfere with others in a map

and i did not see credit to the author

other then that good, and welcome to the club
 

the Immortal

I know, I know...
Reaction score
51
As I said the event occurs before the actual dmg-taking. So if the unit is on full HP, the shield won't actually heal the unit. I decided adding timer and when he expires (after 0.01 seconds) to heal the unit. I tried it and it worked. After that I tried to heal the unit after 0.00 sec. and it worked too :rolleyes:
 

emjlr3

Change can be a good thing
Reaction score
395
As I said the event occurs before the actual dmg-taking. So if the unit is on full HP, the shield won't actually heal the unit. I decided adding timer and when he expires (after 0.01 seconds) to heal the unit. I tried it and it worked. After that I tried to heal the unit after 0.00 sec. and it worked too :rolleyes:

ive made shield spells before and never had to use that method, to me it is uneeded
 
S

Shin

Guest
This spell works perfectly fine when I run it in your map, but I'm having trouble implementing this into my map, as I'm bad with JASS, so if someone could please help me out it would be greatly appreciated. The issues are as follows:

When I copy the Ability, Buff and Trigger into my map and try to save it, it shows me numerous errors in the script.

I've done everything it says in the script, replaced the raw code of the Ability, the raw code of the Buff, and created the variable "cache" of type Game Cache. Then I go to Save Map... and it returns a lot of errors, I don't want to list them all, but here are a few of them:

  • Expected a name: local real absorb = GetStoredReal( LocalVars(), I2S(H2I(trg)), "absorb" )
  • Expected a name: if GetEventDamage() > absorb then
  • Expected a function name: call DmgRestore(GetTriggerUnit(), absorb)
  • Expected a name: call TriggerRemoveAction(trg, GetHandleTA(trg, "ta"))

Since I don't understand much about JASS, it would be great if someone could explain to me what is wrong, what needs to be changed, and how to avoid this problem in the future.

I would also appreciate it if you would explain how to remove the Healing effect the target receives after the duration is over, and how to change it so it is able to cast on Ally Units as well as the caster.

This is a great spell, it works perfectly, and if I could get it to work on my own map, it would be even greater.
Thanks in advance for any help that is given.
 

Tinki3

Special Member
Reaction score
418
Code:
function LocalVars takes nothing returns gamecache
    if udg_cache==null then
        call FlushGameCache(InitGameCache("cache.w3v"))
        set udg_cache=InitGameCache("cache.w3v")
    endif
    return udg_cache
endfunction

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleTA takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

function DmgAftTime takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "unit")
    local real dmg = GetStoredReal(LocalVars(), I2S(H2I(t)), "dmg")
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + dmg)
    set u = null
    call DestroyTimer(t)
    set t = null
endfunction

function DmgAfterTime takes unit u, real dam returns nothing
    local timer t = CreateTimer()
    call StoreInteger( LocalVars(), I2S(H2I(t)), "unit", H2I(u))
    call StoreReal( LocalVars(), I2S(H2I(t)), "dmg", dam)
    call TimerStart(t, 0, false, function DmgAftTime)
    set t = null
    set u = null
endfunction

function DmgRestore takes unit u, real d returns nothing
    local real CurLife = GetUnitState(u,UNIT_STATE_LIFE)
    local real MaxLife = GetUnitState(u,UNIT_STATE_MAX_LIFE)
    if d > (MaxLife-CurLife) then
        if d>CurLife then
            call SetUnitState (u, UNIT_STATE_LIFE, MaxLife)
            call DmgAfterTime (u, (d-(MaxLife-CurLife)))
        else
            call DmgAfterTime(u, d)
        endif
    else
        call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+d)
    endif
    set u = null
endfunction

Did you copy and paste that system into your map's trigger header?

The trigger header looks like TFT map icon, located at the top of the trigger list.
 
S

Shin

Guest
Code:
function LocalVars takes nothing returns gamecache
    if udg_cache==null then
        call FlushGameCache(InitGameCache("cache.w3v"))
        set udg_cache=InitGameCache("cache.w3v")
    endif
    return udg_cache
endfunction

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleTA takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

function DmgAftTime takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t, "unit")
    local real dmg = GetStoredReal(LocalVars(), I2S(H2I(t)), "dmg")
    call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE) + dmg)
    set u = null
    call DestroyTimer(t)
    set t = null
endfunction

function DmgAfterTime takes unit u, real dam returns nothing
    local timer t = CreateTimer()
    call StoreInteger( LocalVars(), I2S(H2I(t)), "unit", H2I(u))
    call StoreReal( LocalVars(), I2S(H2I(t)), "dmg", dam)
    call TimerStart(t, 0, false, function DmgAftTime)
    set t = null
    set u = null
endfunction

function DmgRestore takes unit u, real d returns nothing
    local real CurLife = GetUnitState(u,UNIT_STATE_LIFE)
    local real MaxLife = GetUnitState(u,UNIT_STATE_MAX_LIFE)
    if d > (MaxLife-CurLife) then
        if d>CurLife then
            call SetUnitState (u, UNIT_STATE_LIFE, MaxLife)
            call DmgAfterTime (u, (d-(MaxLife-CurLife)))
        else
            call DmgAfterTime(u, d)
        endif
    else
        call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+d)
    endif
    set u = null
endfunction

Did you copy and paste that system into your map's trigger header?

The trigger header looks like TFT map icon, located at the top of the trigger list.

Ah, I hadn't noticed that little icon up there, or rather, I didn't know it was click-able... Thanks a lot for your help. I'll be trying to understand all this JASS stuff and figuring out how to make it so I can cast on ally units as well as self.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top