Works Properly Once.

Crazy_Dead

New Member
Reaction score
24
My spell, which has been 54(53) posts about arguing between me and Berb( Thehive ), and now i got this compiling, and It works. ONCE :mad:.
And this makes me kinda angry, because of that simple fact, i want to make it.

Code, please look at it, and find the problem. Appreciate. Very much.

JASS:
library StrengthAura initializer Init

globals
    // CLOSE_RANGE_BONUS = How much strength you get when in Close Range
    private constant integer    CLOSE_RANGE_BONUS       = 15
    // MEDIUM_RANGE_BONUS = How much strength you get when in Medium Range
    private constant integer    MEDIUM_RANGE_BONUS      = 10
    // LONG_RANGE_BONUS = How much strength you get when in Long Range
    private constant integer    LONG_RANGE_BONUS        = 5
    // CLOSE_RANGE = Indicates how long Close Range is.
    private constant real       CLOSE_RANGE             = 200
    // MEDIUM_RANGE = Indicates how long Medium Range is.
    private constant real       MEDIUM_RANGE            = 400
    // LONG_RANGE = Indicates how long Long Range is.
    private constant real       LONG_RANGE              = 600
    // FULL_STR = Should it Include Bonuses from strength gain??
    private constant boolean    FULL_STR                = TRUE
    // SPELL_ID = ...
    private constant integer    SPELL_ID                = 'A00I'
    // BUFF_ID = ...
    private constant integer    BUFF_ID                 = 'B00C'
    // TIMERTICK = Every X seconds ticks, checking and adding strength.
    private constant real       TIMERTICK               = .05
    
//Dont Touch. Just dont do it.
//=========================================================|
/*          */real globX                                //=|
/*          */real globY                                //=|
/*          */group tmpGrp = CreateGroup()             //=|
/*          */unit picked                               //=|
/*          */unit Owner                                //=|
/*          */timer ti                                  //=|
/*          */private hashtable table = InitHashtable() //=|
/*          */unit array HeroWithAura                   //=|
/*          */integer HeroWithAuraCount = 0             //=|
//=========================================================|
endglobals

private constant function TYPES takes nothing returns boolean
return IsUnitType(picked, UNIT_TYPE_HERO) and not /*
    */ IsUnitType(picked, UNIT_TYPE_ANCIENT) and not/*
    */ IsUnitType(picked, UNIT_TYPE_ETHEREAL) and not/*
    */ IsUnitType(picked, UNIT_TYPE_MAGIC_IMMUNE) and not/*
    */ IsUnitType(picked, UNIT_TYPE_SUMMONED) and/*
    */ IsUnitInGroup(picked, tmpGrp)
endfunction

//==================================================================================================================

private struct Data
    public real x
    public real y
    public real range
    public real xx
    public real yy
    public real r
    public unit Enum

   private method ApplyBonus takes unit u, integer bonus returns nothing
        if HaveSavedInteger(table, GetHandleId(u), 1) then
            call SetHeroStr(u, GetHeroStr(u, true)-LoadInteger(table, GetHandleId(u), 1), false)
            if bonus == 0 then
                call RemoveSavedInteger(table, GetHandleId(u), 1)
            else
                call SaveInteger(table, GetHandleId(u), 1, bonus)
            endif
        else
            if bonus != 0 then
                call SaveInteger(table, GetHandleId(u), 1, bonus)
            endif
        endif
        call SetHeroStr(u, GetHeroStr(u, true)+bonus, false)
endmethod

    private method GetUnitAuraBonus takes unit u returns integer
        local integer i = 0
        local integer m = 0
        loop
            exitwhen i == HeroWithAuraCount
            if IsUnitInRange(u, HeroWithAura<i>, LONG_RANGE) then
            
                if IsUnitInRange(u, HeroWithAura<i>, CLOSE_RANGE) then
                    if CLOSE_RANGE_BONUS &gt; m then
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg &quot;)
                        set m = CLOSE_RANGE_BONUS
                    endif
                elseif IsUnitInRange(u, HeroWithAura<i>, MEDIUM_RANGE) then
                    if MEDIUM_RANGE_BONUS &gt; m then
                        set m = MEDIUM_RANGE_BONUS
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg1 &quot;)
                    endif
                else
                    if LONG_RANGE_BONUS &gt; m then
                        set m = LONG_RANGE_BONUS
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg2 \n\n\n\n\n\n LOL&quot;)
                    endif
                endif
            
            endif
            set i = i + 1
        endloop
        return 0
    endmethod

    public static method loopFuncEnum takes nothing returns nothing
        local thistype this = allocate()
        call BJDebugMsg(&quot; Mission 2: ApplyBonus &quot;)
        set Enum = GetEnumUnit()
        call ApplyBonus(Enum, GetUnitAuraBonus(Enum))
    endmethod    
    
endstruct

//==================================================================================================================

public function onLearn takes nothing returns nothing
        set HeroWithAura[HeroWithAuraCount] = GetLearningUnit()
        set HeroWithAuraCount = HeroWithAuraCount + 1
endfunction

//==================================================================================================================

private function hasBuff takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(), BUFF_ID) &gt; 0
    // Filter, which picks all units in the range Which has the buff.
endfunction

//==================================================================================================================

private function Conditions takes nothing returns boolean
    return GetLearnedSkill() == SPELL_ID
    // Gets the Learned Skill.
endfunction

//==================================================================================================================
private function doLoop takes nothing returns nothing
        call ForGroup(tmpGrp, function Data.loopFuncEnum)
        call GroupEnumUnitsInRect(tmpGrp, GetWorldBounds(), Filter(function hasBuff))
        call BJDebugMsg(&quot; Completed Mission 1: GroupEnum&quot; ) 
        call ForGroup(tmpGrp, function Data.loopFuncEnum)
endfunction
//==================================================================================================================
//==================================================================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        set ti = CreateTimer()
        call TimerStart( ti , TIMERTICK , true , function doLoop )
        //==========================================================
        set t = CreateTrigger()
            loop
                exitwhen i == 16
                    call TriggerRegisterPlayerUnitEvent( t , Player(i) , EVENT_PLAYER_HERO_SKILL , null )
                set i = i + 1
            endloop
        call TriggerAddCondition( t , Condition(function Conditions ))
        call TriggerAddAction( t , function onLearn )
        //===========================================================
            
endfunction
//==================================================================================================================
//==================================================================================================================
endlibrary</i></i></i>

EDIT: Just wanted to tell ya, that im kinda proud of this. :D
Thanks.

//Crazy_Dead :thup:
 

Bribe

vJass errors are legion
Reaction score
67
Berbanog does like to argue.

You're Chaos_Knight? OK, well, now I know there's one fewer guy who posts angry messages when his code doesn't work.

What I PM'ed to you on The Hive was that I thought you did a nice job decorating this box:

JASS:

//=========================================================|
/*          */real globX                                //=|
/*          */real globY                                //=|
/*          */group tmpGrp = CreateGroup()              //=|
/*          */unit picked                               //=|
/*          */unit Owner                                //=|
/*          */timer ti                                  //=|
/*          */private hashtable table = InitHashtable() //=|
/*          */unit array HeroWithAura                   //=|
/*          */integer HeroWithAuraCount = 0             //=|
//=========================================================|
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
You're not telling us what isn't working and it would help if you replicated the problem in a map that you should upload.

Things I suggest before moving on with this:
01) Give us a detailed explanation of what is supposed to happen
02) Give us a detailed explanation of what happens instead
03) Tell us if you've tried anything or if you have a 'hint' of what might be wrong
04) Attach a map to the OP (Original Post) with a scenario where replicating your problem is easy

=P
 

Crazy_Dead

New Member
Reaction score
24
You're not telling us what isn't working and it would help if you replicated the problem in a map that you should upload.

Things I suggest before moving on with this:
01) Give us a detailed explanation of what is supposed to happen
02) Give us a detailed explanation of what happens instead
03) Tell us if you've tried anything or if you have a 'hint' of what might be wrong
04) Attach a map to the OP (Original Post) with a scenario where replicating your problem is easy

=P

1)

The unit( Enum ) should get bonus strength based on how far distance they are from the owner.

2)

The unit doesnt get the bonus, and i get all Messeages.
Still, if i instead does this:
call ApplyBonus(GetEnumUnit(), 10/*I get 10 bonus strength once*/)
instead of the
GetUnitAuraBonus(GetEnumUnit()) Which adds nothing.

3)

I think it's the GetUnitAuraBonus which is wrong somewhere.

4)

No, sorry. Too big file and i dont have time(I'm way to lame) to make a new map. Maybe will. :thup:
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
is GetUnitAuraBonus() supposed to always return 0?

I guess not by looking at the ApplyBonus() function
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
JASS:
    private method GetUnitAuraBonus takes unit u returns integer
        local integer i = 0
        local integer m = 0
        loop
            exitwhen i == HeroWithAuraCount
            if IsUnitInRange(u, HeroWithAura<i>, LONG_RANGE) then
            
                if IsUnitInRange(u, HeroWithAura<i>, CLOSE_RANGE) then
                    if CLOSE_RANGE_BONUS &gt; m then
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg &quot;)
                        set m = CLOSE_RANGE_BONUS
                    endif
                elseif IsUnitInRange(u, HeroWithAura<i>, MEDIUM_RANGE) then
                    if MEDIUM_RANGE_BONUS &gt; m then
                        set m = MEDIUM_RANGE_BONUS
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg1 &quot;)
                    endif
                else
                    if LONG_RANGE_BONUS &gt; m then
                        set m = LONG_RANGE_BONUS
                        debug call BJDebugMsg(&quot; Mission 3: Dummy Msg2 \n\n\n\n\n\n LOL&quot;)
                    endif
                endif
            
            endif
            set i = i + 1
        endloop
        return 0 // maybe set it to return m? just a wild guess xd
    endmethod</i></i></i>
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Was that so hard? :/
JASS:
library StrengthAura requires UAC, GT

    globals
        private constant integer    CLOSE_RANGE_BONUS       = 15
        private constant integer    MEDIUM_RANGE_BONUS      = 10
        private constant integer    LONG_RANGE_BONUS        = 5
        private constant real       CLOSE_RANGE             = 200.
        private constant real       MEDIUM_RANGE            = 400.
        private constant real       LONG_RANGE              = 600.
        //<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad    :mad:" loading="lazy" data-shortname=":mad:" /> I wondered why still some people don&#039;t want to put dot for the real <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite4" alt=":mad:" title="Mad    :mad:" loading="lazy" data-shortname=":mad:" />
        private constant integer    SPELL_ID                = &#039;AEev&#039;
        private constant integer    BUFF_ID                 = &#039;B00C&#039;
        private constant boolean    IS_BONUS                = TRUE
    endglobals
    
    private struct Data extends UAC
        private static group closeRange = CreateGroup()
        private static group midRange = CreateGroup()
        private static group longRange = CreateGroup()
        
        method andFilterA takes unit picked returns boolean
            return GetUnitAbilityLevel(picked,BUFF_ID) &gt; 0
        endmethod
        
        method unitPeriodic takes unit u returns nothing
            if IsUnitInRange(u,.main,CLOSE_RANGE) then
            //Unit is in close range.
                if IsUnitInGroup(u,.midRange) then
                //Unit was in medium range.
                    call GroupRemoveUnit(.midRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - MEDIUM_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under medium range.
                elseif IsUnitInGroup(u,.longRange) then
                //Unit was in long range.
                    call GroupRemoveUnit(.longRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - LONG_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under long range.
                endif
                if not IsUnitInGroup(u,.closeRange) then
                //Unit was not affected.
                    call GroupAddUnit(.closeRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) + CLOSE_RANGE_BONUS,IS_BONUS)
                //Grants bonus under close range.
                endif
            elseif IsUnitInRange(u,.main,MEDIUM_RANGE) then
            //Unit is in medium range.
                if IsUnitInGroup(u,.closeRange) then
                //Unit was in close range.
                    call GroupRemoveUnit(.closeRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - CLOSE_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under close range.
                elseif IsUnitInGroup(u,.longRange) then
                //Unit was in long range.
                    call GroupRemoveUnit(.longRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - LONG_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under long range.
                endif
                if not IsUnitInGroup(u,.midRange) then
                //Unit was not affected.
                    call GroupAddUnit(.midRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) + MEDIUM_RANGE_BONUS,IS_BONUS)
                    //Grants bonus under medium range.
                endif
            else
            //Unit is in long range.
                if IsUnitInGroup(u,.closeRange) then
                //Unit was in close range.
                    call GroupRemoveUnit(.closeRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - CLOSE_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under close range.
                elseif IsUnitInGroup(u,.midRange) then
                //Unit was in medium range.
                    call GroupRemoveUnit(.midRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) - MEDIUM_RANGE_BONUS,IS_BONUS)
                    //Remove all bonus granted under medium range.
                endif
                if not IsUnitInGroup(u,.longRange) then
                //Unit was not affected.
                    call GroupAddUnit(.longRange,u)
                    call SetHeroStr(u,GetHeroStr(u,false) + LONG_RANGE_BONUS,IS_BONUS)
                    //Grants bonus under long range.
                endif
            endif
        endmethod
        
        method unitLeave takes unit u returns nothing
            if IsUnitInGroup(u,.closeRange) then
            //Unit was in close range.
                call GroupRemoveUnit(.closeRange,u)
                call SetHeroStr(u,GetHeroStr(u,false) - CLOSE_RANGE_BONUS,IS_BONUS)
            //Remove all bonus granted under close range.
            elseif IsUnitInGroup(u,.midRange) then
            //Unit was in medium range.
                call GroupRemoveUnit(.midRange,u)
                call SetHeroStr(u,GetHeroStr(u,false) - MEDIUM_RANGE_BONUS,IS_BONUS)
            //Remove all bonus granted under medium range.
            elseif IsUnitInGroup(u,.longRange) then
            //Remove all bonus granted under long range.
                call GroupRemoveUnit(.longRange,u)
                call SetHeroStr(u,GetHeroStr(u,false) - LONG_RANGE_BONUS,IS_BONUS)
            //Remove all bonus granted under long range.
            endif
        endmethod
        
        private static method onLearn takes nothing returns boolean
            call thistype.create(GetTriggerUnit(),LONG_RANGE)
            return false
        endmethod
        
        private static method onInit takes nothing returns nothing
            call GT_AddLearnsAbilityAction(function thistype.onLearn, SPELL_ID)
            //Lazy to use original init method. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
        endmethod
    endstruct
    
endlibrary
 

Bribe

vJass errors are legion
Reaction score
67
I think it's harder for people still in high school to figure this stuff out. No offense to the kids here.
 

Crazy_Dead

New Member
Reaction score
24
I think that I havent got problem with the UAC, the math is the real big problem.
Still, im just 11 years old, and SquareRoot and such things is abit complicated for me, im sorry. :thdown:
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I think that I havent got problem with the UAC, the math is the real big problem.
Still, im just 11 years old, and SquareRoot and such things is abit complicated for me, im sorry.

I don't think maths knowledge is a requirement to code this spell.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Did you see the code that I posted?
But I don't think you don't know what is plus and minus. :)
 
General chit-chat
Help Users
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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