• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[System] Mode Manager

Level 7
Dec 3, 2006
                call TriggerRegisterPlayerChatEvent(t,Player(i),MODE_CHARACTER,false)
                exitwhen 0==i
                set i=i-1

Add a check to see if the player is playing and a check for if the player is human similar to what purge does a lot like in his scripts like Track.
ForceEnumPlayersCounted, according to my best judgment, doesn't stop at just 1 player. It continues to loop through every player (inexplicably). I will test this on battle.net soon though I have been extremely short on time when I've been home lately.

For now I advise changing it. You can still use the ForForce trick, but that takes a code argument which obviously doesn't work with storing it into an array.
Broke backwards compatibility for the sixth time.

- Modes are now static (cannot be destroyed)
- Now uses StringIndexer
- Algorithm optimized (Super efficient now)

The algorithm used to be an O(k*n), so I changed it to an O(n) :3

I also changed the method of function execution from using ForceEnumPlayersCounted to adding conditions in a loop and evaluating a trigger once.
Yes, all modes in one line.

The checks for mode disabling are supposed to be done by the user.
I can make them automatic though.

The way you would do it currently is:

function ap takes nothing returns nothing
    if not ModeAR.flag then
        set ModeAP.flag = true
        // do mode ap shit

function ar takes nothing returns nothing
    if not ModeAP.flag then
        set ModeAR.flag = true
        // do mode ar shit
Well, I could share the algorithm :p
What I'm doing is just moving projectiles by their xVel, their yVel and zVel 32x a second.

For homing missiles, I would only recompute the x,y,zVels.

For bouncing missiles, I would use normal missiles and just give a new target each time.

A missile would be destroyed if bounces == 0 and the the difference between the current and target coordinates is less than the velocity on each axis (xVel, yVel, zVel)

It's very, very simple and incredibly efficient :p
The efficiency is required here because we might end up doing crazy things in the future like using a projectile system for unit attacks xD
Level 8
Jan 23, 2015
        method authorize takes integer id returns nothing
            debug if 0 > id or 15 < id then
                debug call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "[Mode Manager]Error: Attempted to authorize an invalid player!")
                debug return
            debug endif
            set authorized[this * 12 + id] = true
Well,... shouldn't that 15 be 11? Because if someone will debug code like
local GameMode m1 = GameMode.create(...) // m1 = x
local GameMode m2 = GameMode.create(...) // m2 = x + 1
call m1.authorize(12) // authorized[12x + 12] = true // <- that's not a smart action since 13th player is definetly not a real player
call m2.authorize(0)   // authorized[12(x + 1)] = true
call m2.unauthorize(0) // authorized[12(x + 1)] = false
if(m1.isPlayerAuthorized(12)) then
    call BJDebugMsg("Something had actually gone not by plan")
endif // because 12(x+1) == 12x + 12, wow
- he would not get any errors.
It's just confusing value that could make one mad if he don't understand enough this system.
Last edited: