obj/Court
invisibility = 99
var/
list/Team1 = list()
list/Team2 = list()
list/Watchers = list()
Battle
NPCBattle
list/Winners = list()
list/Losers = list()
proc/
Battle()
set background = 1
while(!length(Winners))
sleep(15)
//It checks that if there are no battlers to fight on either side, the opponent wins.
if(!length(Team1) && !length(Team2))
Winners += "No Contest"
break
else if(!length(Team1))
Winners = Team2.Copy()
break
else if(!length(Team2))
Winners = Team1.Copy()
break
var/list/Poke1 = list() //This will serve as a list of Pokemon in Team1
var/list/Poke2 = list() //This will serve as a list of Pokemon in Team2
//Put the pokemon in the lists.
for(var/mob/Player/M in Team1)
for(var/mob/Pokemon/P in M.Party)
Poke1 += P
for(var/mob/Player/M in Team2)
for(var/mob/Pokemon/P in M.Party)
Poke2 += P
for(var/mob/NPCTrainer/M in Team2) // NPCS WILL ALWAYS BE ON TEAM 2!!!!
for(var/mob/Pokemon/P in M.Party)
Poke2 += P
//Check if there is a winner.
if(!TotalHealth(Poke1))
Winners = Team2.Copy()
Losers = Team1.Copy()
break
else if(!TotalHealth(Poke2))
Winners = Team1.Copy()
Losers = Team2.Copy()
break
Start_Battle() //When all the details of a match have been confirmed, then start the game.
Battle = 1
Battle()
if(length(Winners) && !Winners.Find("No Contest"))
Dion()<<"Winner"
for(var/mob/M in Watchers)
M.RemoveSection("WatchingBattle")
M.Court = null
if(M.client)
M.client.eye = M
del M.Watcher
//Set the Variables Back
Winners = list()
Losers = list()
Team1 = list()
Team2 = list()
Battle = 0
NPCBattle = 0
Watchers = list()
Mob_Set_Up() //This is for setting up mobs only
var/list/All = list() //For referencing all mobs in the battle.
All += Team1.Copy()
All += Team2.Copy()
for(var/mob/Player/P in All)
if(P.ControlingPokemon) P.ControlingPokemon.ReturntoBall()
P.Watcher = new
P.Watcher.name = P.name
P.Watcher.icon = P.icon
P.Watcher.icon_state = P.icon_state
P.Watcher.overlays = P.overlays
if(P.client)
P.client.eye = src
P.client.perspective=EYE_PERSPECTIVE
P.Court = src
Watchers += P
P.AddSection("WatchingBattle", "VS")
switch(length(Team1)) // Set the Watchers up and put the View on the field.
if(1) for(var/mob/Player/P in Team1)
P.Watcher.loc = locate(x + 8,y,z)
P.Watcher.dir = get_dir(P.Watcher,locate(x - 8,y,z))
if(2)
var/Counter
for(var/mob/Player/P in Team1)
P.Watcher.loc = locate(x + 8,y - 1 + Counter,z)
P.Watcher.dir = get_dir(P.Watcher,locate(x,y - 8,z))
Counter += 2
switch(length(Team2)) // Set the Watchers up and put the View on the field.
if(1) for(var/mob/Player/P in Team2)
P.Watcher.loc = locate(x - 8,y,z)
P.Watcher.dir = get_dir(P.Watcher,locate(x + 8,y,z))
else
var/Counter
for(var/mob/Player/P in Team2)
P.Watcher.loc = locate(x - 8,y - 1 + Counter,z)
P.Watcher.dir = get_dir(P.Watcher,locate(x,y + 8,z))
Counter += length(Team2)
Court_Set_Up()
//Watchers//
mob/Watcher
Challenge
var
list/Team1 = list()
list/Team2 = list()
Active
Text
mob/verb/AcceptChallenge()
set hidden = 1
winset(src, "Challenge", "is-visible=false")
var/Challenge/CH
for(var/Challenge/C in Challenges) if(C.Active) CH = C
var/obj/Court/C
for(var/obj/Court/c in world)
if(!c.Battle)
C = c
break // We've found a court to play on, no need to continue
C.Team1 = CH.Team1.Copy()
C.Team2 = CH.Team2.Copy()
del CH
C.Mob_Set_Up()
C.Court_Set_Up()
C.Start_Battle()
mob/verb/DenyChallenge()
set hidden = 1
for(var/Challenge/C in Challenges) if(C.Active) del C
winset(src, "Challenge", "is-visible=false")
mob/Player/
proc/ViewChallenges()
set background = 1
for(var/Challenge/C in Challenges)
winset(src, "Challenge", "is-visible=true")
winset(src, "Challenge.Who", "text='[C.Text]'")
C.Active = 1
while(C)
sleep(10)
winset(src, "Challenge", "is-visible=false")
verb/Challenge()
set src in view(4)
var/mob/Player/M = usr
if(!istype(M,/mob/Player)) return
var/list/Options = list()
var/Challenge/C = new
C.Team1 += src
C.Team2 += M
Options["[M] VS [src]"] = "1 VS 1" //The challenger vs the challengee is always an option
if(M.Partner && Partner) //If they each have a team, ask if they would like a double battle.
Options["[M] + [M.Partner] VS [src] + [src.Partner]"] = "2 VS 2"
Options["[M] + [M.Partner] VS [src]"] = "2 VS 1"
Options["[M] VS [src] + [src.Partner]"] = "1 VS 2"
C.Team1 += src.Partner
C.Team2 += M.Partner
C.Text = "[M] and [M.Partner] are challenging you and [Partner] to a 2 VS 2 Battle."
var/input = input(M, "What kind of battle would you like?") in Options
//Checks//
var/area/A = loc.loc
// if(src == usr) return // You can't challenge yourself
if(M.Court || !length(M.Party)) return //The challenger can't battle because they are already battling or they have no Pokemon to battle with.
if(Court) //If the Challengee already has a Court, they are already battling
M<<System("[src] is currently in the middle of a battle.")
return
if(A && !A.ReleaseCheck)
usr<<System("Battles are not permitted in this area.")
return
if(!src || !M)
del C
return //In case the usr or the Challengee has logged out
switch(Options[input])
if("1 VS 1")
C.Text = "[M] is challenging you to a 1 VS 1 Battle."
C.Team2 = list(M)
C.Team1 = list(src)
if("1 VS 2")
C.Text = "[M] is challenging you to a 1 VS 2 Battle with your partner, [Partner]."
C.Team2 = list(M)
if("2 VS 1")
C.Text = "[M] and [M.Partner] are challenging you to a 2 VS 1 Battle."
C.Team1 = list(src)
Challenges += C
spawn(300) del C // They have 30 seconds to respond
ViewChallenges()
// If they accept, go to AcceptChallenge()
mob/NPCTrainer
var/
list/Party
area/BattleCourt
Problem description:
The server for my game is crashing. It happens randomly between 1-3 hours. The host's Dream Daemon freezes up, and stops responding. It restricts players from logging in. However, the players logged into the game simply lag really bad, their Dream Seeker doesn't stop responding. The server will still remain on the hub, even if this happens. But it will disappear if all the players log off.
From this, I think there is an infinite loops located somewhere in this code. I've narrowed it down to this one file, which when removed, does not cause the server to crash.