• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Infinite Loops - Anti One Player

Status
Not open for further replies.
Level 9
Joined
Nov 28, 2008
Messages
704
I have a simple question: is it an acceptable way to do an anti one player by causing a script to search for two different players who are playing? I know what the script is, it would invovle finding a player who is playing, then setting an integer to it, then looping through the other players until it finds one who is playing that isnt the first variable.

Thus, if only one player was playing, it would cause an infinite loop, crashing the game I am assuming, or else causing a thread death.

So, I have to ask.. is this an acceptable way? Does it violate any EULA, morals/ethics? Is it possible to fail, etc? I just thought I would ask because my map requires 2 players at least, and it randomly picks them to be different then the other players.. the way I have it WOULD in fact cause this if there was only one player.

Edit: I think it would help actually posting the code.

JASS:
    local integer random1
    local integer random2
    set random1 = GetRandomInt(0, 9)
    set random2 = ModuloInteger(random1 + GetRandomInt(0, 9), 9)
    loop
        exitwhen GetPlayerSlotState(Player(random2)) == PLAYER_SLOT_STATE_PLAYING
        set random2 = ModuloInteger(random2 + 1, 9)
    endloop
    loop
        exitwhen GetPlayerSlotState(Player(random1)) == PLAYER_SLOT_STATE_PLAYING and random1 != random2
        set random1 = ModuloInteger(random1 + 1, 9)
    endloop
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
Just asking because I want less work, and if this already does that, then Im fine.

Regardless, I believe this will be fine - even if it causes thread death, the game wont start :p, no one will get units.. thus erasing any point to playing one player.

Edit: Anyways, having tested it, it merely causes thread death, which is acceptable.
 
Last edited:
Level 6
Joined
Mar 20, 2008
Messages
208
JASS:
        local integer a = 0  
        local integer b = 0
     
 loop
     exitwhen b > 1 or a == 11  //a = max players possible
       if(GetPlayerSlotState(Player(a)) == PLAYER_SLOT_STATE_EMPTY)then
           set b = b+1
       endif        
 endloop

 if(b < 2)then
    call ForForce( GetPlayersAll(), function NoMulti )
 endif  
endfunction

function NoMulti takes nothing returns nothing
    call CustomDefeatBJ( GetEnumPlayer(), "Single Player Not Allowed!" )
endfunction

In all honesty, I don't think using a bucket search approach is a good idea for anything in WC3.
 
Status
Not open for further replies.
Top