• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Repo] JASS H4xx

Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
library AwesomeLibrary initializer init // v 1.1.2.3.4.7.4

    globals
        public player Local_player = GetLocalPlayer() // comment this line if you want to use your map, else it will crash on loading
    endglobals

// credit to Captain Griffen for the 2 functions below

    public function TimerAttach takes timer t, real time, real value, code func returns nothing
        call TimerStart(t, value, false, null)
        call PauseTimer(t)
        call TimerStart(t, time, false, func)
    endfunction
    
    // ONLY call on an expired timer.
    public function GetTimerInt takes timer t returns integer
        return R2I(TimerGetRemaining(t) + 0.5)
    endfunction
    
    public function TimerStopPeriodic takes timer t returns nothing
        call PauseTimer(t)
        call ResumeTimer(t)
    endfunction
    
    public function TimerRestart takes timer t returns nothing // on not paused timers
        call ResumeTimer(t)
    endfunction
    
    // when a game is loaded from a save
    public function IsGameLoaded takes nothing returns boolean
        return UnitId2String('hfoo') == null or OrderId2String(851971) == null
    endfunction
    
    // can be used to get and play with units' shadows, last time i check it even completly fuck up selection of units (at least visually)
    public function GetFutureNextImage takes nothing returns image
        local image im = CreateImage("ReplaceableTextures\\Splats\\AuraRune9b.blp",0,0,0,0,0,0,0,0,0,1 )
        call DestroyImage(im)
        return im
    endfunction
    
    // yes all these native GroupEnumUnits...Counted are just the same of the same native function without the extra integer argument
    
    public function GroupEnumUnitsInRangeBJ takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
        call GroupEnumUnitsInRangeCounted(whichGroup,x,y,radius,filter,GetRandomInt(0,1337))
    endfunction
    
    public function GroupEnumUnitsInRangeOfLocCountedBJ takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
        call GroupEnumUnitsInRangeOfLocCounted(whichGroup,whichLocation,radius,filter,GetRandomInt(0,1337))
    endfunction
    
    public function GroupEnumUnitsInRectCountedBJ takes group whichGroup, rect r, boolexpr filter returns nothing
        call GroupEnumUnitsInRectCounted(whichGroup,r,filter,GetRandomInt(0,1337))
    endfunction
    
    public function GroupEnumUnitsOfTypeCountedBJ takes group whichGroup, string unitname, boolexpr filter returns nothing
        call GroupEnumUnitsOfTypeCounted(whichGroup,unitname,filter,GetRandomInt(0,1337))
    endfunction
    
    public function IsBlizzardLazy takes nothing returns boolean
        return AbilityId2String('AHds') == null
    endfunction
    
    public function init takes nothing returns nothing
        call CommentString("plz give credits !!!!!")
    endfunction

endlibrary
I may improve it later with more functions.
 
Last edited:
wth, if this seriously works, that's awesome

JASS:
    public function TimerAttach takes timer t, real time, real value, code func returns nothing
        call TimerStart(t, value, false, null)
        call PauseTimer(t)
        call TimerStart(t, time, false, func)
    endfunction

However, this is slower than LoadInteger from my tests when I was working on TimerTools
R2I(TimerGetRemaining(t) + 0.5)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Image's brother.
JASS:
function GetNextLightning takes nothing returns lightning
    local lightning l = AddLightningEx("CLPB", true, 0, 0, 0, 0, 0, 0)
    call DestroyLightning(l)
    return l
endfunction
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It should be the same for texttag, because IIRC there is also no handle reference counter, but as far i know texttags from the game (like the one displayed when gold/wood is collected, or when an unit is hurted by a critical attack, ...) don't share the same stack.
So that would be 100 % useless.
Should be also the same for lightnings.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Yeah i've said it was him, not when though or gave the link.
Anyway by creating this thread, i just wanted to highlight silly jass bugs, not getting some people enjoy ...
They are bugs for god sake ...

The only one that i've listed from now which could be used, is for lightning but it's more likely that you will mess up with the internal image stack, maybe if you don't destroy them and only change their color (not tested).
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I have tested before, you can change colors of abilities with lightning effect.But destroying them will crash iirc.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
But i'm not 100 % sure, maybe i've read it a long time ago (2009 ?) and just remembered randomdly what Deaod said, you know how the brain stores and retrieves information is not always obvious.
So in doubt i will credit him, that isn't like it's an "hard work" anyway.
 
Level 6
Joined
Jan 17, 2010
Messages
149
The wheel was invented before too, you should credit the inventor every time you make something round and spinning.


Btw, I'm still struggling to understand what IsBlizzardLazy does ...



JASS:
 globals
        public player Local_player = GetLocalPlayer() // comment this line if you want to use your map, else it will crash on loading
    endglobals

I think global rect = GetWorldBounds() also crashes...
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The wheel was invented before too, you should credit the inventor every time you make something round and spinning.

Yep, but hopefully no wheel is involved here.


Btw, I'm still struggling to understand what IsBlizzardLazy does ...

It doesn't work maybe ?
I've used a valid ability rawcode, so it shoudln't return null, anyway check the comment for this function in the most up-to-date common.j lying in your mpq, it will be clear why i've choiced this name.

I think global rect = GetWorldBounds() also crashes...

Probably, i also know that some other functions don't work without any crash, i'm currently too lazy to test all of them, and i usually only write statements that i'm 100 % sure, let's say personnaly tested, or eventually by really reliable people (and i know only one guy).
But don't take me wrong i also sometimes make wrong statements, i just hope i'm much more reliable than the average of people.
 
  • test
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Hashtable - Save Handle Of(Last created unit) as 0 of 0 in (Last created hashtable).
      • Game - Display to Player 1 (Red) at position 0.00,0.00 the text: (Name of (Load 0 of 0 in (Last created hashtable).))
      • Hashtable - Save Handle OfNo unit as 0 of 0 in (Last created hashtable).
      • Game - Display to Player 1 (Red) at position 0.00,0.00 the text: (Name of (Load 0 of 0 in (Last created hashtable).))
This, at least in 1.36, will display 2 times "Footman".
I got the following solution :
JASS:
// Cannot null an existing value in a hashtable by doing SaveHandle(h,k,v,null)
// So we save a dummy handle to destroy it, so the value becomes null
// I picked location because it is the lightest possible handle I found
function HashtableResetHandleValue takes hashtable h, integer k, integer v returns nothing
    call SaveLocationHandle(h,k,v,Location(0,0))
    call RemoveLocation(LoadLocationHandle(h,k,v))
endfunction
Even if Blizzard fixes this my function won't break the game.
Of course it is not as fast as the intended behavior, since it makes 1 function call, 2 hashtable calls, one handle creation and one handle destruction just for 1 hashtable call.
Do not hesitate to test it with other kind of handles and explore further because I may have spoke too fast.


EDIT duh I never thought RemoveSavedHandle existed. My bad.:peasant-sad:
 
Last edited:
How does the unit shadow code work and is it still working? I haven't been able to modify them at all however I am sure I had it working once years ago, tried on latest reforged as well legacy 1.28.5.
Probably was fixed at the same time the return bug was fixed if it hasn't worked in so long.
 
My little contribution. Dunno if it already existed before but in 1.36 it happens.
Select a map with this library, then create the game and Warcraft III crashes.
JASS:
library crashYourGameAtLobbyCreation
    globals
        multiboard mapBomber=CreateMultiboard()
    endglobals
endlibrary
That's been a thing for forever. The "main" thread crashes if you try to create a unit directly in the globals block.
 
That's been a thing for forever. The "main" thread crashes if you try to create a unit directly in the globals block.
But... this is a multiboard, not a unit.
Are you talking about any handle ?
But Hashtables don't make the game crash at lobby ?
How and why it crashes at lobby creation ?
I'm curious right here.
 
But... this is a multiboard, not a unit.
Are you talking about any handle ?
But Hashtables don't make the game crash at lobby ?
How and why it crashes at lobby creation ?
I'm curious right here.
Good questions! The same issues occur in Lua as well. Some types of WarCraft 3 handles, like units, cannot be created before the "main" function is called. So I think this has to do with how the engine instantiates itself during the game's startup sequence. The "config" function is tailored to setting stuff that is relevant only to stuff that may need to exist during the game lobby menu, whereas the "main" function is designed to hit as soon as the actual loading screen starts. How it all works under the hood is a bit weird. There is no "0 second async timer" in the loading screen; the timer will always wait until the user has pressed a button to start the game.
 
Top