Big problim with new battle system code in Developer Help
|
|
We are haveing a problem in a multy mon group battle. Only the first mon takes his turns, the other mon wont go.Any help would be greatly apreciated.
mob/New() tempbatspell = list() ..() mob/var/tmp battle=1 escape=0 isturn=0 inbattle=0 XLoc YLoc ZLoc mob/proc randomencounter1(probchance as num,mob/M as mob) var turf battlearea T music list/monsterlist[] = new() if(prob(probchance) && M.preslocation != "town") if(M.oldlocx != M.x || M.oldlocy != M.y) for(T in world) if(!T.occupied) usr << sound(null) src.verbs -= /mob/verb/Cast src.verbs -= /mob/verb/Item src.verbs -= /mob/verb/Talk src.verbs -= /mob/verb/PVP src.verbs -= /mob/verb/masterequip src.verbs -= /mob/verb/Search music = 'DW4BATL.mid' usr << sound(music,1) battlecounter = 0 M.battlearea = T T.occupied = 1 M.oldlocx = M.x M.oldlocy = M.y M.oldlocz = M.z M.battlearea = T M.invisibility = 1 M.oldbattlefield = 1 M.oldlocation = M.preslocation M.preslocation = "town" spawn(1)M.Move(M.battlearea) M.disabledbattlefield = 0 M.endbattle = 0 M.inbat = 1 M.battlestr = M.strequip M.battledef = M.defequip M.battleagl = M.aglequip olddef = M.defequip oldagl = M.aglequip M.logoutinbattle = 1 if(usr.oldlocation == "area1") monsterlist = list("stagbeetle","blackraven","slime") mon1 = pick(monsterlist) if(mon1 == "slime") mon1 = new/mob/monster/slime(locate(M.battlearea.x,M.battlearea.y,M.battlearea.z)) if(mon1 == "stagbeetle") mon1 = new/mob/monster/stagbeetle(locate(M.battlearea.x,M.battlearea.y,M.battlearea.z)) if(mon1 == "blackraven") mon1 = new/mob/monster/blackraven(locate(M.battlearea.x,M.battlearea.y,M.battlearea.z)) M.montargetlist += mon1 M.groupsize += 1 var/newmon = rand(0,100) if(newmon >= 50) mon2 = pick(monsterlist) if(mon2 == "slime") mon2 = new/mob/monster/slime(locate(M.battlearea.x+2,M.battlearea.y,M.battlearea.z)) if(mon2 == "stagbeetle") mon2 = new/mob/monster/stagbeetle(locate(M.battlearea.x+2,M.battlearea.y,M.battlearea.z)) if(mon2 == "blackraven") mon2 = new/mob/monster/blackraven(locate(M.battlearea.x+2,M.battlearea.y,M.battlearea.z)) M.montargetlist += mon2 M.groupsize += 1 if(newmon >= 50) mon3 = pick(monsterlist) if(mon3 == "slime") mon3 = new/mob/monster/slime(locate(M.battlearea.x-2,M.battlearea.y,M.battlearea.z)) if(mon3 == "stagbeetle") mon3 = new/mob/monster/stagbeetle(locate(M.battlearea.x-2,M.battlearea.y,M.battlearea.z)) if(mon3 == "blackraven") mon3 = new/mob/monster/blackraven(locate(M.battlearea.x-2,M.battlearea.y,M.battlearea.z)) M.montargetlist += mon3 M.groupsize += 1
|
PS this is only like 5% of the code becoese its wat to exstensive to put in forums but you should be able to see the problem here
|
Firstly, learn how to use lists. They're extremely useful. No turn-based battle system is complete without at least one.
Secondly, use loops. A for() loop, especially, would simplify this piece of code no end.