The 300 Spartans!!!...doesn't work anymore...

Light Alkmst

New Member
Reaction score
20
I've been trying to find a way to optimize this when I thought of a way to do it. I didn't want 10 individual triggers running each unit death, and came up with this solution, that unfortunately doesn't work.

JASS:

library Sparta initializer Absolute
    private function End takes nothing returns nothing
        local group g = CreateGroup()
        local unit u
        
        call GroupEnumUnitsInRect(g, GetWorldBounds(), null)
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            call GroupRemoveUnit(g, u)
            
            call SetHeroXP(u, GetHeroXP(u) * 300, true)
        endloop
    endfunction
    
    //! textmacro SPARTANS takes NUMBER, HEALTH, NEXT
    // //! external ObjectMerger w3u n001 s$NUMBER$ unam "$NUMBER$ Spartan" ua1d $NUMBER$ udef $NUMBER$ uhpm $HEALTH$
    private function Filt$NUMBER$ takes nothing returns boolean
        return GetUnitTypeId(GetFilterUnit()) == 's$NUMBER$' and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0. and IsUnitAlly(GetFilterUnit(), GetTriggerPlayer())
    endfunction
    
    private function Conditions$NUMBER$ takes nothing returns boolean
        return GetUnitTypeId(GetTriggerUnit()) == 's$NUMBER$'
    endfunction
    
    private function Actions$NUMBER$ takes nothing returns nothing
        local group g = CreateGroup()
        local integer c = 0
        local integer next = $NUMBER$ + 1
        local real x = GetUnitX(GetTriggerUnit())
        local real y = GetUnitY(GetTriggerUnit())
        local real a = GetUnitFacing(GetTriggerUnit())
        
        call GroupEnumUnitsInRect(g, GetWorldBounds(), Condition(function Filt$NUMBER$))
        if (FirstOfGroup(g) == null) then
            if ($NUMBER$ != 300) then
                loop
                    exitwhen I2R(300 / next) == 300. / I2R(next)
                    set next = next + 1
                endloop
                debug call BJDebugMsg("Next Spartan count: " + I2S(next))
                debug call BJDebugMsg("Next Spartan count: " + I2S('s000' + next))
                loop
                    exitwhen c == $NEXT$ or $NEXT$ == 0
                    //call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 's$NEXT$', x, y, a)
                    call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), 's000' + next, x, y, a)
                    set c = c + 1
                endloop
            else
                //call End()
            endif
        endif
        
        call DestroyGroup(g)
        set g = null
    endfunction
    
    private function Init$NUMBER$ takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(t, Condition(function Conditions$NUMBER$))
        call TriggerAddAction(t, function Actions$NUMBER$)
    endfunction
    //! endtextmacro
    //! runtextmacro SPARTANS("001", "300", "002")
    //! runtextmacro SPARTANS("002", "150", "003")
    //! runtextmacro SPARTANS("003", "100", "004")
    //! runtextmacro SPARTANS("004", "075", "005")
    //! runtextmacro SPARTANS("005", "060", "006")
    //! runtextmacro SPARTANS("006", "050", "010")
    //! runtextmacro SPARTANS("010", "030", "012")
    //! runtextmacro SPARTANS("012", "025", "015")
    //! runtextmacro SPARTANS("015", "020", "020")
    //! runtextmacro SPARTANS("020", "015", "025")
    //! runtextmacro SPARTANS("025", "012", "030")
    //! runtextmacro SPARTANS("030", "010", "050")
    //! runtextmacro SPARTANS("050", "006", "060")
    //! runtextmacro SPARTANS("060", "005", "075")
    //! runtextmacro SPARTANS("075", "004", "100")
    //! runtextmacro SPARTANS("100", "003", "150")
    //! runtextmacro SPARTANS("150", "002", "300")
    //! runtextmacro SPARTANS("300", "001", "000")
    
    private function Absolute takes nothing returns nothing
        call Init001()
        call Init002()
        call Init003()
        call Init004()
        call Init005()
        call Init006()
        call Init010()
        call Init012()
        call Init015()
        call Init020()
        call Init025()
        call Init030()
        call Init050()
        call Init060()
        call Init075()
        call Init100()
        call Init150()
        call Init300()
    endfunction
endlibrary


Somehow, although the "next" variable displays the right numbers, and adding the 's000' makes sense, and the end ID is right, it mysteriously stops at the 10 Spartans. 1-6 work fine, but it stops when the 10 should spawn. I know the trouble is within the Actions function, but it's beyond me why it doesn't work now...
 

Light Alkmst

New Member
Reaction score
20
Yes

EDIT: when it was hardcoded with the right values, it worked perfectly. I wanted to remove the hardcoding, and made the function to set the "next" to integrate it all into 1 trigger. That's when it stopped working, and I don't want to revert.
 
Reaction score
341
Try adding this..

debug call BJDebugMsg(R2S(I2R(300 / next)) + " == " + R2S(300. / I2R(next)))

To see if the exitwhen is causing it.
 

Light Alkmst

New Member
Reaction score
20
I'm going to sleep now. I'll make sure the ID's are right tomorrow. I'll just line them up instead of putting them like they are now I guess...
 

Light Alkmst

New Member
Reaction score
20
I think I've figured it out. In the text macros, the integers I have have preceding 0s. I left them there to just hold place to make it tidy, but they're actually turning my numbers into octal! 010 != 10. 010 == 8
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
    +2
  • 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