Healing Spell+Heal Message every second

TheCrystal

New Member
Reaction score
36
For some reason my spell "Holy" is not working. It loops once, stops, and I don't know why it is doing this. It's a simple JASS trigger with two GUI ones initializing it.

Note: I'm still learning JASS, so I basically use GUI whenever it's the simpler of things instead of finishing up basic JASS training (Events, figuring out things like this)

Trigger:
  • PaladinHoly
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Holy
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to PaladinHolyGroup
      • Set TempReal = (((Real((Level of (Ability being cast) for (Triggering unit)))) / (30.00 / (Real((Level of (Ability being cast) for (Triggering unit)))))) x (Real(ZZZWisdom[(Player number of (Owner of (Triggering unit)))])))
      • Game - Display to (All players) the text: AddedToGroup
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TempReal Less than (<) 1.00
          • Then - Actions
            • Set TempReal = 1.00
            • Game - Display to (All players) the text: LessThen1
          • Else - Actions
      • Set TempUnit = (Target unit of ability being cast)
      • Custom script: set IndexReal2[GetUnitUserData(udg_TempUnit)] = udg_TempReal


Trigger:
  • PaladinHolyPeriod05
    • Events
      • Time - AbilityTimers[0] expires
    • Conditions
    • Actions
      • Custom script: call PaladinHolyTimer()


JASS:
function InitTrig_PaladinHolyTimer takes nothing returns nothing
endfunction
function PaladinHolyTimer takes nothing returns nothing
    local real p = 0
    local real p2 = 0
    local integer i = 0
    local group g = udg_PaladinHolyGroup
    local unit u = null
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            if UnitHasBuffBJ(u,'B002')==false then
                call GroupRemoveUnit(udg_PaladinHolyGroup,u)
                call DisplayTextToPlayer(Player(0), 0, 0, "NoBuff")
            endif
        call DisplayTextToPlayer(Player(0), 0, 0, "Looped")
        set i = GetUnitUserData(u)
        set udg_TempReal = IndexReal2<i>
        call SetUnitLifeBJ(u, (GetUnitState(u,UNIT_STATE_LIFE))+udg_TempReal)
        set HolyTimerTime<i>=HolyTimerTime<i>+.05
            if HolyTimerTime<i> &gt;= 1 then
                set HolyTimerTime[1] = 0
                call GoldText(R2I(udg_TempReal)*20,u)
            endif
        call GroupRemoveUnit(g,u)

    endloop
endfunction
</i></i></i></i>


JASS:
function GoldText takes integer I, unit whichunit returns nothing
    local real p = GetUnitX(whichunit)
    local real p2 = GetUnitY(whichunit)
    local texttag T = CreateTextTag()
    set UnitID = GetUnitTypeId(whichunit)
        if IsUnitDeadBJ(whichunit) == false and UnitID !=DummyUnit1 and UnitID != DummyUnit2 and UnitID != DummyUnit3 then
            call SetTextTagPermanent(T, false )
            call SetTextTagPos(T, p, p2, 10)
            call SetTextTagFadepoint(T, 2)
            call SetTextTagLifespan(T, 3)
            call SetTextTagTextBJ(T, &quot;|c00CCCC00&quot; + I2S(I), 8)
            call SetTextTagVelocityBJ( T, 64, GetRandomReal(200.00, 245.00) )
        else
            call DestroyTextTag(T)
        endif //Nothings Wrong, but haven&#039;t tested this specifically
endfunction

It's the correct buff, "NoBuff" never appears, "Looped" appears once, both messages appear in the GUI. The buff stays on the unit.
AbilityTimers[0] is set on Map Init, lots of clutter in that wont so wont post.

If I change local group g = udg_PaladinHolyGroup
to
local group g = null
call GroupAddGroup(udg_PaladinHolyGroup,g)
Looped doesn't appear

If I change
call SetUnitLifeBJ(u,(GetUnitState(u,UNIT_STATE_LIFE))+udg_TempReal)
to
call SetUnitLifeBJ(u,(GetUnitState(u,UNIT_STATE_LIFE))+100)
it Adds 100 HP once (Loop only appears once), but not when I use GroupAddGroup

If I add a message OUTSIDE the loop it shows it every .05 seconds, like I want it to.

I dunno what's wrong with it, but I hope it isn't one of those obvious kind of things.

Edit: Whole point of ability is to heal a target X amount every .05 second then show the message of how much it healed after 1 second. Sorry for forgetting.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Bare in mind, Jass is different with GUI.
Tell us what are you trying to do, so we can help you.
 

LearningCode

New Member
Reaction score
24
Use T32x, it's a timer system some where on the forums =x

JASS:
scope Heal initializer HealInit

   globals
      private constant integer SpellID = &#039;A000&#039; //This is the rawcode of your Healing spell
   endglobals
   
   private struct H
      unit SpellTarget
      real TargetX
      real TargetY
      real HealAmount
      real TargetHP
      texttag Tag
      integer ticks


      private method periodic takes nothing returns nothing
         local H h = this
         
         if h.ticks &lt; 20 then
            set h.TargetHP = h.TargetHP + h.HealAmount
            call SetUnitState(h.SpellTarget, UNIT_STATE_LIFE, h.TargetHP) //Something like that.. =x
            set h.ticks = h.ticks + 1
         else
            set h.TargetX = GetUnitX(h.SpellTarget)
            set h.TargetY = GetUnitY(h.SpellTarget)
            //Create TextTag
            call h.stopPeriodic()
            call h.destroy()
         endif
      endmethod
      
      implement T32x

      static method HealAct takes nothing returns nothing
         local H h = H.allocate()
         local unit u = GetTriggerUnit()
         local integer i = GetUnitAbilityLevel(SpellID)
         set h.SpellTarget = GetSpellUnitTarget() //Not sure, I am not at home now, I don&#039;t know the proper native
         set h.TargetHP = GetUnitState(h.SpellTarget, UNIT_STATE_LIFE)
         set h.HealAmount = //Your formula for healing

         
         call h.startPeriodic() //This is using the timer system, but set the options to .05, the T32 timer system uses .03125, I think, alternatively, you can use a timer variable.. But I&#039;m not at home, at a cousin&#039;s house =x
      endmethod

      method onDestroy takes nothing returns nothing
         set .SpellTarget = null
         set .Tag = null
         //Clearing leaks, no need for groups.
      endmethod
   endstruct

   private function HealCond takes nothing returns boolean
      return GetSpellAbilityId() == SpellID
   endfunction

   private function HealInit takes nothing returns nothing
      local trigger t = CreateTrigger()
      local integer i = 0
     
      loop
      exitwhen i == 11 //Assuming that you have a max of 12 players..
         call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
      set i = i+1
      endloop

      call TriggerAddCondition( t, Condition(function HealCond))
      call TriggerAddAction( t, function H.HealAct)
   endfunction

endscope


Err..
Yea, at a cousin's house now, I think it may or may not work.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
He is still learning Jass, but not vJass. Your code is too difficult for him to understand. We should teach him how to get hang of it 1 by 1 .

JASS:
      local integer i = 0
     
      loop
      exitwhen i == 11 //Assuming that you have a max of 12 players..
         call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
      set i = i+1
      endloop

Instead of keep writing long code, why not to use BJ? It is better to read. The speed is really negligible.
It you want it becomes more efficient, use spell systems. They can help you to fire needed triggers instead of firing all spell triggers(evaluating conditions).

JASS:
local H h = H.allocate()

Hmm, always use "Data" as struct name, since it is neater. "caster"/"cs" for spell's caster, "targ"/"target" for targeted unit.
You will find it is easier to edit when you want to edit it later.
I used "a", "b", "c", "d", and ... as variables' name, when I was still a Jass newbie. I found it is hard to edit ><. So, experience is good. The more the effort you pay on coding, the more the experience you will get. ^_^

The usage of capital letter is important too.
constant globals should be all CAPITAL_LETTER.
globals should be Normal.
locals should be all small case.
struct methods/members should be camelCase.
 

TheCrystal

New Member
Reaction score
36
Well, I use BJ Jass sometimes, often times they seem really silly, like one of them calls a different BJ then calls ANOTHER before going back to the original JASS one. Though I do like to have my things more efficient then, well, 'quicker' to make.
My whole problem with JASS over the period of time I've been messing with it is certain things, like "private STUFF" or structs, even after reading all the tutorials it still is difficult to understand. Often times I learn better by reading other people's code then modifying it for my use.

What do you mean, Spell Systems? You mean creating a function that creates an effect of some sort and then calling them in a series? Right now I try and recycle my past code, like the "GoldText" was derived from "HealingText", just without the adding HP in the HealingText itself, but HealingText is still used from all my other healing things.
The specifics of the period in the variable name remain unknown to me.
 

cryowraith

New Member
Reaction score
7
So I'm not sure what you are trying to do. Periodic healing + text or one time heal + text?

JASS:
loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            if UnitHasBuffBJ(u,&#039;B002&#039;)==false then
                call GroupRemoveUnit(udg_PaladinHolyGroup,u)
                call DisplayTextToPlayer(Player(0), 0, 0, &quot;NoBuff&quot;)
            endif
        call DisplayTextToPlayer(Player(0), 0, 0, &quot;Looped&quot;)
        set i = GetUnitUserData(u)
        set udg_TempReal = IndexReal2<i>
        call SetUnitLifeBJ(u, (GetUnitState(u,UNIT_STATE_LIFE))+udg_TempReal)
        set HolyTimerTime<i>=HolyTimerTime<i>+.05
            if HolyTimerTime<i> &gt;= 1 then
                set HolyTimerTime[1] = 0
                call GoldText(R2I(udg_TempReal)*20,u)
            endif
        call GroupRemoveUnit(g,u)

    endloop</i></i></i></i>


You said it only looped once? It loops only once because there are only 1 unit in g or udg_PaladinHolyGroup. Since you remove the unit from the group in the 1st run, then you'll get an empty group which will exit the loop.

And I assume HolyTimerTime is a global that you declared in another function? You should remember adding a udg_ if it is defined in the variable editor.
 

TheCrystal

New Member
Reaction score
36
It loops once TOTAL once I cast a target for "Holy". As in, there's one unit in the PaladinHolyGroup, then none, until the spell is used once more.
I want the spell to be used on a target, healed for the udg_TempReal amount, then after 20 runs (AKA 1 second) for the unit to have Gold Text appear above them telling how much was healed over the 1 second.
The only time (that this should occur) is when the unit no longer has the buff that the unit stops getting healed.

HolyTimerTime is in my JASSInitialization trigger, and the indexing system works properly.
 

cryowraith

New Member
Reaction score
7
Most probably because you removed the unit during the loop.

JASS:
call GroupRemoveUnit(g,u)


Perhaps put that line inside here.

JASS:
if HolyTimerTime<i> &gt;= 1 then
                set HolyTimerTime[1] = 0
                call GoldText(R2I(udg_TempReal)*20,u)
            endif</i>
 

TheCrystal

New Member
Reaction score
36
Err, I mean I want the unit to be healed by udg_TempReal amount but not all at once in that, loop. After the whole function has been called 20 times (1 second in time total) it THEN displays the text. What you're purposing is healing the unit 20 times then displaying the text before removing it from the group, which is unwanted, since this would happen "instantly".
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top