• 🏆 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!

[JASS] Loop crashes game and Quests via local player?

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
Alright so first off this function crashes my game, yet I cannot see a reason for it to do so. Perhaps it's just so convoluted that it's too messy for me to read. However it's just a repeating trigger that sets ALL the players against those not in their force and with players that are in their force. Simple nuff. I imagine there's an easier/short way too. This is called via ExecuteFunc btw.

JASS:
function CycleAlliance takes nothing returns nothing
 local integer i = 0
 local integer i2 = 0

    loop
        debug call BJDebugMsg("Loop Starts 1")
     exitwhen i > bj_MAX_PLAYER_SLOTS
        set i2 = 0

        loop
            debug call BJDebugMsg("Loop Starts 2")

         exitwhen i2 > bj_MAX_PLAYER_SLOTS
        if i != i2 then
            if IsPlayerInForce(Player(i), BloodPack) then
                debug call BJDebugMsg("Start BP")
                if IsPlayerInForce(Player(i2), BloodPack) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            elseif IsPlayerInForce(Player(i), FangSquad) then
                if IsPlayerInForce(Player(i2), FangSquad) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            elseif IsPlayerInForce(Player(i), HellHorde) then
                if IsPlayerInForce(Player(i2), HellHorde) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            elseif IsPlayerInForce(Player(i), CrimsonHunters) then
                if IsPlayerInForce(Player(i2), CrimsonHunters) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            elseif IsPlayerInForce(Player(i), VileLegion) then
                if IsPlayerInForce(Player(i2), VileLegion) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            elseif IsPlayerInForce(Player(i), ChosenVampire) then
                if IsPlayerInForce(Player(i2), ChosenVampire) then
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     true)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, true)
                else
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i), Player(i2), ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_PASSIVE,       false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_REQUEST,  false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_XP,     false)
                    call SetPlayerAlliance(Player(i2), Player(i), ALLIANCE_SHARED_SPELLS, false)
                endif
            endif
        endif
         set i2 = i2 + 1
        debug call BJDebugMsg(I2S(i))
        endloop
     set i = i + 1
    endloop
    debug call BJDebugMsg("GGGGGG!!!!!!OOOOOT THROUGH IT!")
endfunction

Also, another question: Is there any way to set up Quests through Local commands via GetLocalPlayer(). I can't see to get any to work, though they dont' disconnect the game. They just give no results or unexpected results. Thanks :)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Players range from 0 to 15 in id. bj_MAX_PLAYER_SLOTS is set to 16 on default, so that's out of that range.

Quests add to agents and therefore to its id stack. This stack should not be desynced as it includes objects that are of client-shared interests. You can however set things like the description locally. In case you want to display it to only one/not all players, use QuestSetEnabled.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
you probably hit the operation limit
might happen if you try to do too much stuff at once
you can either use wait or triggersyncready or however it was called or use triggerexecute and divide your actions into different parts

and you really should use functions for this
it is unreadable that way you are doing it now
maybe you just forgot to put an i++ into the loop but I am too lazy to try to find where which loop and if begins and ends
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Only 2 loops. It's really just repetitive past the first set of Ally/Enemy if. I merely replaced the global variable with another force variable. At the bottom, I increase the second integer, end the loop, increase the first integer, then end that loop. It should increase the second integer (Player Number 2) while the first integer stays at 0, then increase the first integer after its cycled through all players on the second integer and do the next Player.

Anyways, after testing the bj_MAXSLOT theory by WaterKnight the trigger seems to work. (I also commented out some of the code to test the thread limit though so they might both be right.) Either way + rep for commenting, thanks :)
 
Status
Not open for further replies.
Top