PLAYERS.alive拿出来作为单独变量
This commit is contained in:
@@ -205,7 +205,7 @@ local function noDevkeyPressed(key)
|
|||||||
LOG.print(string.format("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s",SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
|
LOG.print(string.format("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s",SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
|
||||||
elseif key=="f3"then
|
elseif key=="f3"then
|
||||||
for _=1,8 do
|
for _=1,8 do
|
||||||
local P=PLAYERS.alive[rnd(#PLAYERS.alive)]
|
local P=PLY_ALIVE[rnd(#PLY_ALIVE)]
|
||||||
if P~=PLAYERS[1]then
|
if P~=PLAYERS[1]then
|
||||||
P.lastRecv=PLAYERS[1]
|
P.lastRecv=PLAYERS[1]
|
||||||
P:lose()
|
P:lose()
|
||||||
|
|||||||
@@ -271,10 +271,10 @@ end
|
|||||||
|
|
||||||
--Royale mode
|
--Royale mode
|
||||||
function randomTarget(P)--Return a random opponent for P
|
function randomTarget(P)--Return a random opponent for P
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
local R
|
local R
|
||||||
repeat
|
repeat
|
||||||
R=PLAYERS.alive[rnd(#PLAYERS.alive)]
|
R=PLY_ALIVE[rnd(#PLY_ALIVE)]
|
||||||
until R~=P
|
until R~=P
|
||||||
return R
|
return R
|
||||||
end
|
end
|
||||||
@@ -282,28 +282,28 @@ end
|
|||||||
function freshMostDangerous()
|
function freshMostDangerous()
|
||||||
GAME.mostDangerous,GAME.secDangerous=false,false
|
GAME.mostDangerous,GAME.secDangerous=false,false
|
||||||
local m,m2=0,0
|
local m,m2=0,0
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
local h=#PLAYERS.alive[i].field
|
local h=#PLY_ALIVE[i].field
|
||||||
if h>=m then
|
if h>=m then
|
||||||
GAME.mostDangerous,GAME.secDangerous=PLAYERS.alive[i],GAME.mostDangerous
|
GAME.mostDangerous,GAME.secDangerous=PLY_ALIVE[i],GAME.mostDangerous
|
||||||
m,m2=h,m
|
m,m2=h,m
|
||||||
elseif h>=m2 then
|
elseif h>=m2 then
|
||||||
GAME.secDangerous=PLAYERS.alive[i]
|
GAME.secDangerous=PLY_ALIVE[i]
|
||||||
m2=h
|
m2=h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
if PLAYERS.alive[i].atkMode==3 then
|
if PLY_ALIVE[i].atkMode==3 then
|
||||||
PLAYERS.alive[i]:freshTarget()
|
PLY_ALIVE[i]:freshTarget()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function freshMostBadge()
|
function freshMostBadge()
|
||||||
GAME.mostBadge,GAME.secBadge=false,false
|
GAME.mostBadge,GAME.secBadge=false,false
|
||||||
local m,m2=0,0
|
local m,m2=0,0
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
local P=PLAYERS.alive[i]
|
local P=PLY_ALIVE[i]
|
||||||
local b=P.badge
|
local b=P.badge
|
||||||
if b>=m then
|
if b>=m then
|
||||||
GAME.mostBadge,GAME.secBadge=P,GAME.mostBadge
|
GAME.mostBadge,GAME.secBadge=P,GAME.mostBadge
|
||||||
@@ -314,44 +314,44 @@ function freshMostBadge()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
if PLAYERS.alive[i].atkMode==4 then
|
if PLY_ALIVE[i].atkMode==4 then
|
||||||
PLAYERS.alive[i]:freshTarget()
|
PLY_ALIVE[i]:freshTarget()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function royaleLevelup()
|
function royaleLevelup()
|
||||||
GAME.stage=GAME.stage+1
|
GAME.stage=GAME.stage+1
|
||||||
local spd
|
local spd
|
||||||
TEXT.show(text.royale_remain:gsub("$1",#PLAYERS.alive),640,200,40,"beat",.3)
|
TEXT.show(text.royale_remain:gsub("$1",#PLY_ALIVE),640,200,40,"beat",.3)
|
||||||
if GAME.stage==2 then
|
if GAME.stage==2 then
|
||||||
spd=30
|
spd=30
|
||||||
elseif GAME.stage==3 then
|
elseif GAME.stage==3 then
|
||||||
spd=15
|
spd=15
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLY_ALIVE do
|
||||||
P.gameEnv.garbageSpeed=.6
|
P.gameEnv.garbageSpeed=.6
|
||||||
end
|
end
|
||||||
if PLAYERS[1].alive then BGM.play("cruelty")end
|
if PLAYERS[1].alive then BGM.play("cruelty")end
|
||||||
elseif GAME.stage==4 then
|
elseif GAME.stage==4 then
|
||||||
spd=10
|
spd=10
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLY_ALIVE do
|
||||||
P.gameEnv.pushSpeed=3
|
P.gameEnv.pushSpeed=3
|
||||||
end
|
end
|
||||||
elseif GAME.stage==5 then
|
elseif GAME.stage==5 then
|
||||||
spd=5
|
spd=5
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLY_ALIVE do
|
||||||
P.gameEnv.garbageSpeed=1
|
P.gameEnv.garbageSpeed=1
|
||||||
end
|
end
|
||||||
elseif GAME.stage==6 then
|
elseif GAME.stage==6 then
|
||||||
spd=3
|
spd=3
|
||||||
if PLAYERS[1].alive then BGM.play("final")end
|
if PLAYERS[1].alive then BGM.play("final")end
|
||||||
end
|
end
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLY_ALIVE do
|
||||||
P.gameEnv.drop=spd
|
P.gameEnv.drop=spd
|
||||||
end
|
end
|
||||||
if GAME.curMode.name:find("_u")then
|
if GAME.curMode.name:find("_u")then
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
local P=PLAYERS.alive[i]
|
local P=PLY_ALIVE[i]
|
||||||
P.gameEnv.drop=int(P.gameEnv.drop*.3)
|
P.gameEnv.drop=int(P.gameEnv.drop*.3)
|
||||||
if P.gameEnv.drop==0 then
|
if P.gameEnv.drop==0 then
|
||||||
P.curY=P.ghoY
|
P.curY=P.ghoY
|
||||||
@@ -537,8 +537,8 @@ function destroyPlayers()--Destroy all player objects, restore freerows and free
|
|||||||
end
|
end
|
||||||
PLAYERS[i]=nil
|
PLAYERS[i]=nil
|
||||||
end
|
end
|
||||||
for i=#PLAYERS.alive,1,-1 do
|
for i=#PLY_ALIVE,1,-1 do
|
||||||
PLAYERS.alive[i]=nil
|
PLY_ALIVE[i]=nil
|
||||||
end
|
end
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
end
|
end
|
||||||
@@ -611,7 +611,7 @@ function loadGame(M,ifQuickPlay,ifNet)--Load a mode and go to game scene
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function initPlayerPosition(sudden)--Set initial position for every player
|
function initPlayerPosition(sudden)--Set initial position for every player
|
||||||
local L=PLAYERS.alive
|
local L=PLY_ALIVE
|
||||||
if not sudden then
|
if not sudden then
|
||||||
for i=1,#L do
|
for i=1,#L do
|
||||||
L[i]:setPosition(640,#L<=5 and 360 or -62,0)
|
L[i]:setPosition(640,#L<=5 and 360 or -62,0)
|
||||||
|
|||||||
@@ -142,7 +142,8 @@ for i=1,#MODOPT do
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Game tables
|
--Game tables
|
||||||
PLAYERS={alive={}}--Players data
|
PLAYERS={}--Players data
|
||||||
|
PLY_ALIVE={}
|
||||||
FIELD={}--Field(s) for custom game
|
FIELD={}--Field(s) for custom game
|
||||||
BAG={}--Sequence for custom game
|
BAG={}--Sequence for custom game
|
||||||
MISSION={}--Clearing mission for custom game
|
MISSION={}--Clearing mission for custom game
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ return{
|
|||||||
PLY.newAIPlayer(2,AIBUILDER("CC",2*AIlevel-1,math.floor(AIlevel*.5+1),true,20000+5000*AIlevel))
|
PLY.newAIPlayer(2,AIBUILDER("CC",2*AIlevel-1,math.floor(AIlevel*.5+1),true,20000+5000*AIlevel))
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,P in next,PLAYERS.alive do
|
for _,P in next,PLY_ALIVE do
|
||||||
setField(P,1)
|
setField(P,1)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function update_round(P)
|
local function update_round(P)
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
P.control=false
|
P.control=false
|
||||||
local ID=P.id
|
local ID=P.id
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function update_round(P)
|
local function update_round(P)
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
P.control=false
|
P.control=false
|
||||||
local ID=P.id
|
local ID=P.id
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function update_round(P)
|
local function update_round(P)
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
P.control=false
|
P.control=false
|
||||||
local ID=P.id
|
local ID=P.id
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function update_round(P)
|
local function update_round(P)
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
P.control=false
|
P.control=false
|
||||||
local ID=P.id
|
local ID=P.id
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local function update_round(P)
|
local function update_round(P)
|
||||||
if #PLAYERS.alive>1 then
|
if #PLY_ALIVE>1 then
|
||||||
P.control=false
|
P.control=false
|
||||||
local ID=P.id
|
local ID=P.id
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/49",69,175)
|
mStr(#PLY_ALIVE.."/49",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/49",69,175)
|
mStr(#PLY_ALIVE.."/49",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/49",69,175)
|
mStr(#PLY_ALIVE.."/49",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/99",69,175)
|
mStr(#PLY_ALIVE.."/99",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/99",69,175)
|
mStr(#PLY_ALIVE.."/99",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ return{
|
|||||||
end,
|
end,
|
||||||
mesDisp=function(P)
|
mesDisp=function(P)
|
||||||
setFont(35)
|
setFont(35)
|
||||||
mStr(#PLAYERS.alive.."/99",69,175)
|
mStr(#PLY_ALIVE.."/99",69,175)
|
||||||
mStr(P.modeData.ko,80,215)
|
mStr(P.modeData.ko,80,215)
|
||||||
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
gc.draw(drawableText.ko,60-drawableText.ko:getWidth(),222)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ end
|
|||||||
local function newEmptyPlayer(id,mini)
|
local function newEmptyPlayer(id,mini)
|
||||||
local P={id=id}
|
local P={id=id}
|
||||||
PLAYERS[id]=P
|
PLAYERS[id]=P
|
||||||
PLAYERS.alive[id]=P
|
PLY_ALIVE[id]=P
|
||||||
|
|
||||||
--Inherit functions of Player class
|
--Inherit functions of Player class
|
||||||
for k,v in next,Player do P[k]=v end
|
for k,v in next,Player do P[k]=v end
|
||||||
|
|||||||
@@ -1333,7 +1333,7 @@ do--Player.drop(self)--Place piece
|
|||||||
T=self.atking
|
T=self.atking
|
||||||
self:freshTarget()
|
self:freshTarget()
|
||||||
end
|
end
|
||||||
elseif #PLAYERS.alive>1 then
|
elseif #PLY_ALIVE>1 then
|
||||||
T=randomTarget(self)
|
T=randomTarget(self)
|
||||||
end
|
end
|
||||||
if T then
|
if T then
|
||||||
@@ -1753,16 +1753,16 @@ function Player:lose(force)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self:die()
|
self:die()
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
if PLAYERS.alive[i]==self then
|
if PLY_ALIVE[i]==self then
|
||||||
rem(PLAYERS.alive,i)
|
rem(PLY_ALIVE,i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.result="K.O."
|
self.result="K.O."
|
||||||
if GAME.modeEnv.royaleMode then
|
if GAME.modeEnv.royaleMode then
|
||||||
self:changeAtk()
|
self:changeAtk()
|
||||||
self.modeData.place=#PLAYERS.alive+1
|
self.modeData.place=#PLY_ALIVE+1
|
||||||
self.strength=0
|
self.strength=0
|
||||||
if self.lastRecv then
|
if self.lastRecv then
|
||||||
local A,i=self,0
|
local A,i=self,0
|
||||||
@@ -1791,7 +1791,7 @@ function Player:lose(force)
|
|||||||
|
|
||||||
freshMostBadge()
|
freshMostBadge()
|
||||||
freshMostDangerous()
|
freshMostDangerous()
|
||||||
if #PLAYERS.alive==royaleData.stage[GAME.stage]then
|
if #PLY_ALIVE==royaleData.stage[GAME.stage]then
|
||||||
royaleLevelup()
|
royaleLevelup()
|
||||||
end
|
end
|
||||||
self:showTextF(self.modeData.place,0,120,60,"appear",.26,.9)
|
self:showTextF(self.modeData.place,0,120,60,"appear",.26,.9)
|
||||||
@@ -1819,8 +1819,8 @@ function Player:lose(force)
|
|||||||
else
|
else
|
||||||
self:newTask(tick_lose)
|
self:newTask(tick_lose)
|
||||||
end
|
end
|
||||||
if #PLAYERS.alive==1 then
|
if #PLY_ALIVE==1 then
|
||||||
PLAYERS.alive[1]:win()
|
PLY_ALIVE[1]:win()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--------------------------<\Events>--------------------------
|
--------------------------<\Events>--------------------------
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ function update.remote_alive(P,dt)
|
|||||||
local amount=int(event/0x100)%0x100
|
local amount=int(event/0x100)%0x100
|
||||||
local time=int(event/0x10000)%0x10000
|
local time=int(event/0x10000)%0x10000
|
||||||
local line=int(event/0x100000000)%0x10000
|
local line=int(event/0x100000000)%0x10000
|
||||||
local L=PLAYERS.alive
|
local L=PLY_ALIVE
|
||||||
for i=1,#L do
|
for i=1,#L do
|
||||||
if L[i].subID==sid then
|
if L[i].subID==sid then
|
||||||
P:attack(L[i],amount,time,line,true)
|
P:attack(L[i],amount,time,line,true)
|
||||||
@@ -409,7 +409,7 @@ function update.remote_alive(P,dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif event>0x1000000000000 then--Receiving lines
|
elseif event>0x1000000000000 then--Receiving lines
|
||||||
local L=PLAYERS.alive
|
local L=PLY_ALIVE
|
||||||
local sid=tostring(event%0x100)
|
local sid=tostring(event%0x100)
|
||||||
for i=1,#L do
|
for i=1,#L do
|
||||||
if L[i].subID==sid then
|
if L[i].subID==sid then
|
||||||
|
|||||||
@@ -185,9 +185,9 @@ function scene.socketRead(mes)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i=1,#PLAYERS.alive do
|
for i=1,#PLY_ALIVE do
|
||||||
if PLAYERS.alive[i].userID==args[2]then
|
if PLY_ALIVE[i].userID==args[2]then
|
||||||
rem(PLAYERS.alive,i)
|
rem(PLY_ALIVE,i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -225,7 +225,7 @@ function scene.socketRead(mes)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif cmd=="R"then
|
elseif cmd=="R"then
|
||||||
local L=PLAYERS.alive
|
local L=PLY_ALIVE
|
||||||
for i=1,#L do
|
for i=1,#L do
|
||||||
if L[i].subID==args[1]then
|
if L[i].subID==args[1]then
|
||||||
L[i].ready=true
|
L[i].ready=true
|
||||||
|
|||||||
Reference in New Issue
Block a user