重构next和hold系统,支持多next

This commit is contained in:
MrZ626
2020-11-18 15:16:19 +08:00
parent ccf47c3c2f
commit e3f2a9c803
27 changed files with 386 additions and 302 deletions

View File

@@ -29,6 +29,11 @@ love.keyboard.setKeyRepeat(true)
love.keyboard.setTextInput(false)
love.mouse.setVisible(false)
MODOPT={
-- nextStartPos=2,
-- drop=0,
-- lock=0,
}
CUSTOMENV={
--Basic
drop=60,
@@ -36,8 +41,9 @@ CUSTOMENV={
wait=0,
fall=0,
next=6,
hold=true,
nextCount=6,
nextStartPos=1,
holdCount=1,
oncehold=true,
--Visual

View File

@@ -3,8 +3,8 @@ return function(type,speedLV,next,hold,node)
if type=="CC"then
return{
type="CC",
next=next,
hold=hold,
nextCount=next,
hold=hold>0,
delta=AISpeed[speedLV],
node=node,
}

View File

@@ -66,19 +66,21 @@ if _CC then
CC.setNode(opt,P.AIdata.node)
P.AI_bot=CC.new(opt,wei)
CC.free(opt)CC.free(wei)
for i=1,P.AIdata.next do
CC.addNext(P.AI_bot,CCblockID[P.next[i].id])
for i=1,P.AIdata.nextCount do
CC.addNext(P.AI_bot,CCblockID[P.nextQueue[i].id])
end
CC.updateField(P)
P.hd=nil
P.holded=false
P.cur=rem(P.next,1)
while P.holdQueue[1]do rem(P.holdQueue)end
P.holdTime=P.gameEnv.holdCount
P.cur=rem(P.nextQueue,1)
P.sc,P.dir=spinCenters[P.cur.id][0],0
P.r,P.c=#P.cur.bk,#P.cur.bk[1]
P.curX,P.curY=blockPos[P.cur.id],21+ceil(P.fieldBeneath/30)-P.r+min(int(#P.field*.2),2)
P:newNext()
local id=CCblockID[P.next[P.AIdata.next].id]
local id=CCblockID[P.nextQueue[P.AIdata.nextCount].id]
if id then
CC.addNext(P.AI_bot,id)
end
@@ -204,13 +206,13 @@ return{
end
end
for ifhold=0,P.gameEnv.hold and 1 or 0 do
for ifhold=0,P.gameEnv.holdCount>0 and 1 or 0 do
--Get block id
local bn
if ifhold==0 then
bn=P.cur and P.cur.id
else
bn=P.hd and P.hd.id or P.next[1]and P.next[1].id
bn=P.holdQueue[1]and P.holdQueue[1].id or P.nextQueue[1]and P.nextQueue[1].id
end
if not bn then goto CTN end

View File

@@ -56,7 +56,7 @@ function restoreVirtualKey()
B.isDown=false
B.pressTime=0
end
if not modeEnv.Fkey then
if not MODEENV.Fkey then
virtualkey[9].ava=false
end
end
@@ -64,7 +64,7 @@ end
function copyQuestArgs()
local ENV=CUSTOMENV
local str=""..
(ENV.hold and"H"or"Z")..
(ENV.hold>0 and"H"or"Z")..
(ENV.ospin and"O"or"Z")..
(ENV.missionKill and"M"or"Z")..
ENV.sequence
@@ -72,7 +72,7 @@ function copyQuestArgs()
end
function pasteQuestArgs(str)
local ENV=CUSTOMENV
ENV.hold= byte(str,1)~=90
ENV.holdCount= byte(str,1)~=90 and 1 or 0
ENV.ospin= byte(str,2)~=90
ENV.missionKill= byte(str,3)~=90
ENV.sequence= sub(str,4)
@@ -451,19 +451,19 @@ function resetGameData()
GAME.seed=rnd(261046101471026)
destroyPlayers()
modeEnv=CURMODE.env
MODEENV=CURMODE.env
restoreVirtualKey()
CURMODE.load()
if modeEnv.task then
if MODEENV.task then
for i=1,#PLAYERS do
PLAYERS[i]:newTask(modeEnv.task)
PLAYERS[i]:newTask(MODEENV.task)
end
end
BG.set(modeEnv.bg)
BGM.play(modeEnv.bgm)
BG.set(MODEENV.bg)
BGM.play(MODEENV.bgm)
TEXT.clear()
if modeEnv.royaleMode then
if MODEENV.royaleMode then
for i=1,#PLAYERS do
PLAYERS[i]:changeAtk(randomTarget(PLAYERS[i]))
end
@@ -508,19 +508,19 @@ function resetPartGameData(replaying)
end
destroyPlayers()
modeEnv=CURMODE.env
MODEENV=CURMODE.env
restoreVirtualKey()
CURMODE.load()
if modeEnv.task then
if MODEENV.task then
for i=1,#PLAYERS do
PLAYERS[i]:newTask(modeEnv.task)
PLAYERS[i]:newTask(MODEENV.task)
end
end
BG.set(modeEnv.bg)
BGM.play(modeEnv.bgm)
BG.set(MODEENV.bg)
BGM.play(MODEENV.bgm)
TEXT.clear()
if modeEnv.royaleMode then
if MODEENV.royaleMode then
for i=1,#PLAYERS do
PLAYERS[i]:changeAtk(randomTarget(PLAYERS[i]))
end

View File

@@ -18,7 +18,7 @@ return{
minarr=1,
drop=0,lock=15,
wait=15,fall=6,
next=3,
nextCount=3,
visible="fast",
freshLimit=15,
dropPiece=score,

View File

@@ -5,7 +5,7 @@ return{
color=COLOR.red,
env={
drop=30,lock=60,
next=1,
nextCount=1,
block=false,center=0,ghost=0,
dropFX=0,lockFX=0,
visible="none",

View File

@@ -24,7 +24,7 @@ return{
irs=false,ims=false,
center=0,ghost=0,
drop=3,lock=3,wait=10,fall=25,
next=1,hold=false,
nextCount=1,hold=false,
sequence="rnd",
RS="Classic",
freshLimit=0,

View File

@@ -50,41 +50,41 @@ return{
env={},
load=function()
for k,v in next,CUSTOMENV do
modeEnv[k]=v
MODEENV[k]=v
end
if BAG[1]then
modeEnv.bag=BAG
MODEENV.bag=BAG
else
modeEnv.bag=nil
MODEENV.bag=nil
end
if MISSION[1]then
modeEnv.mission=MISSION
MODEENV.mission=MISSION
else
modeEnv.mission=nil
MODEENV.mission=nil
end
modeEnv.dropPiece=PLY.check_lineReach
MODEENV.dropPiece=PLY.check_lineReach
for y=1,20 do
if notAir(FIELD[1][y])then
--Switch clear mode on
modeEnv.dropPiece=checkClear
MODEENV.dropPiece=checkClear
break
end
end
PLY.newPlayer(1,340,15)
local L=modeEnv.opponent
local L=MODEENV.opponent
if L~=0 then
modeEnv.target=nil
MODEENV.target=nil
if L<6 then
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("9S",2*L))
else
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("CC",2*L-11,int(L*.5-1.5),MODEENV.hold,4000*L))
end
end
for _,P in next,PLAYERS.alive do
setField(P,1)
end
modeEnv.bg=CUSTOMENV.bg
modeEnv.bgm=CUSTOMENV.bgm
MODEENV.bg=CUSTOMENV.bg
MODEENV.bgm=CUSTOMENV.bgm
end,
mesDisp=function(P)
setFont(55)

View File

@@ -39,30 +39,30 @@ return{
},
load=function()
for k,v in next,CUSTOMENV do
modeEnv[k]=v
MODEENV[k]=v
end
if BAG[1]then
modeEnv.bag=BAG
MODEENV.bag=BAG
else
modeEnv.bag=nil
MODEENV.bag=nil
end
if MISSION[1]then
modeEnv.mission=MISSION
MODEENV.mission=MISSION
else
modeEnv.mission=nil
MODEENV.mission=nil
end
PLY.newPlayer(1,340,15)
local L=modeEnv.opponent
local L=MODEENV.opponent
if L~=0 then
modeEnv.target=nil
MODEENV.target=nil
if L<6 then
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("9S",2*L))
else
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("CC",2*L-11,int(L*.5-1.5),modeEnv.hold,4000*L))
PLY.newAIPlayer(2,965,360,.5,AIBUILDER("CC",2*L-11,int(L*.5-1.5),MODEENV.hold,4000*L))
end
end
modeEnv.bg=CUSTOMENV.bg
modeEnv.bgm=CUSTOMENV.bgm
MODEENV.bg=CUSTOMENV.bg
MODEENV.bgm=CUSTOMENV.bgm
end,
mesDisp=function(P)
local dx,dy=P.fieldOff.x,P.fieldOff.y

View File

@@ -4,7 +4,7 @@ return{
env={
drop=5,lock=60,
fall=6,
next=3,
nextCount=3,
freshLimit=15,
pushSpeed=2,
task=function(P)

View File

@@ -4,7 +4,7 @@ return{
env={
drop=30,lock=60,
fall=10,
next=3,
nextCount=3,
freshLimit=15,
pushSpeed=1,
task=function(P)

View File

@@ -7,7 +7,7 @@ return{
for _=1,3 do P:getNext(7)end
end,
freshMethod=function(P)
if not P.next[1] then
if not P.nextQueue[1] then
local height=FREEROW.get(0)
local max=#P.field
if max>0 then
@@ -92,7 +92,7 @@ return{
end
end,
target=100,dropPiece=PLY.check_lineReach,
next=1,hold=false,
nextCount=1,hold=false,
ospin=false,
freshLimit=15,
bg="glow",bgm="reason",

View File

@@ -6,7 +6,7 @@ return{
sequence="bag",
bag={1,1,2,2,3,3,4,4,5,5,6,6},
target=100,dropPiece=PLY.check_lineReach,
next=3,
nextCount=3,
ospin=false,
freshLimit=15,
bg="glow",bgm="reason",

View File

@@ -20,7 +20,7 @@ local function check_LVup(P)
ENV.target=26
SFX.play("reach")
elseif T==26 then--Stage 3: dig to bottom
if not P.hd then P.life=P.life+1 end--1 up if ban hold
if not P.holdQueue[1]then P.life=P.life+1 end--1 up if ban hold
P.waiting=45
ENV.skin[1],ENV.skin[2]=ENV.skin[2],ENV.skin[1]
ENV.skin[3],ENV.skin[4]=ENV.skin[4],ENV.skin[3]
@@ -135,7 +135,7 @@ return{
das=5,arr=1,
drop=0,lock=15,
wait=10,fall=10,
next=2,
nextCount=2,
sequence="his4",
target=12,dropPiece=check_LVup,
mission={4,4,4,64},

View File

@@ -49,7 +49,7 @@ end
return{
color=COLOR.red,
env={
next=4,
nextCount=4,
hold=false,
drop=60,lock=60,
fall=20,

View File

@@ -42,7 +42,7 @@ end
return{
color=COLOR.green,
env={
next=4,
nextCount=4,
hold=false,
drop=120,lock=180,
fall=20,

View File

@@ -2,7 +2,7 @@ return{
color=COLOR.green,
env={
drop=60,lock=60,
next=0,hold=false,
nextCount=0,hold=false,
sequence="rnd",
target=40,dropPiece=PLY.check_lineReach,
bg="aura",bgm="waterfall",

View File

@@ -156,18 +156,121 @@ local function drawNextPreview(P,B)
end
end end
end
local function drawHold(P,clr)
local B=P.hd.bk
local texture=SKIN.curText
for i=1,#B do for j=1,#B[1]do
if B[i][j]then
Draw(texture[clr],30*(j+2.06-#B[1]*.5)-30,-30*(i+1.36-#B*.5))-- drawCell(i+1.36-#B*.5,j+2.06-#B[1]*.5,clr)
end
end end
end
local draw={}
function draw.drawNext_norm(P)
local ENV=P.gameEnv
local N=ENV.nextCount*72
local texture=SKIN.curText
gc.push("transform")
gc.translate(316,116)
gc.setColor(0,0,0,.4)gc.rectangle("fill",0,-80,124,N+8)
gc.setColor(1,1,1)gc.rectangle("line",0,-80,124,N+8)
mText(drawableText.next,62,-131)
N=1
while N<=ENV.nextCount and P.nextQueue[N]do
local bk,clr=P.nextQueue[N].bk,P.nextQueue[N].color
for i=1,#bk do for j=1,#bk[1] do
if bk[i][j]then
Draw(texture[clr],30*(j+2.06-#bk[1]*.5)-30,-30*(i+3.76-2.4*N-#bk*.5))-- drawCell(i-2.4*N-#bk*.5,j+12.6-#bk[1]*.5,clr)
end
end end
N=N+1
end
if ENV.bagLine then
local L=ENV.bagLen
local C=-P.pieceCount%L--Phase
gc.setColor(.8,.5,.5)
for i=C,N-1,L do
local y=72*i-77
gc.line(2+P.fieldOff.x,y,120,y)
end
end
gc.pop()
end
function draw.drawNext_hidden(P)
local ENV=P.gameEnv
local N=ENV.nextCount*72
local texture=SKIN.curText
gc.push("transform")
gc.translate(316,116)
gc.setColor(.5,0,0,.4)gc.rectangle("fill",0,-80,124,N+8)
gc.setColor(1,1,1)gc.rectangle("line",0,-80,124,N+8)
mText(drawableText.next,62,-131)
N=min(ENV.nextStartPos,P.pieceCount+1)
while N<=ENV.nextCount and P.nextQueue[N]do
local bk,clr=P.nextQueue[N].bk,P.nextQueue[N].color
for i=1,#bk do for j=1,#bk[1] do
if bk[i][j]then
Draw(texture[clr],30*(j+2.06-#bk[1]*.5)-30,-30*(i+3.76-2.4*N-#bk*.5))-- drawCell(i-2.4*N-#bk*.5,j+12.6-#bk[1]*.5,clr)
end
end end
N=N+1
end
if ENV.bagLine then
local L=ENV.bagLen
local C=-P.pieceCount%L--Phase
gc.setColor(.8,.5,.5)
for i=C,N-1,L do
local y=72*i-77
gc.line(2+P.fieldOff.x,y,120,y)
end
end
gc.pop()
end
function draw.drawHold_norm(P)
local texture=SKIN.curText
gc.push("transform")
gc.translate(-140,116)
gc.setColor(0,0,0,.4)gc.rectangle("fill",0,-80,124,80)
gc.setColor(1,1,1)gc.rectangle("line",0,-80,124,80)
if P.holdTime==0 then gc.setColor(.6,.4,.4)end
mText(drawableText.hold,62,-131)
local B=P.holdQueue[1]
if B then
local bk,clr=B.bk,B.color
for i=1,#bk do for j=1,#bk[1]do
if bk[i][j]then
Draw(texture[clr],30*(j+2.06-#bk[1]*.5)-30,-30*(i+3.76-2.4*1-#bk*.5))-- drawCell(i+1.36-#B*.5,j+2.06-#B[1]*.5,clr)
end
end end
end
gc.pop()
end
function draw.drawHold_multi(P)
local ENV=P.gameEnv
local N=ENV.holdCount*72
local texture=SKIN.curText
gc.push("transform")
gc.translate(-140,116)
gc.setColor(0,0,0,.4)gc.rectangle("fill",0,-80,124,N+8)
gc.setColor(1,1,1)gc.rectangle("line",0,-80,124,N+8)
if P.holdTime==0 then gc.setColor(.6,.4,.4)end
mText(drawableText.hold,62,-131)
gc.setColor(1,1,1)
if P.holdQueue[ENV.holdCount]then
N=P.holdTime+1
else
N=1
end
for n=1,#P.holdQueue do
if n==N then gc.setColor(.6,.4,.4)end
local bk,clr=P.holdQueue[n].bk,P.holdQueue[n].color
for i=1,#bk do for j=1,#bk[1]do
if bk[i][j]then
Draw(texture[clr],30*(j+2.06-#bk[1]*.5)-30,-30*(i+3.76-2.4*n-#bk*.5))-- drawCell(i+1.36-#B*.5,j+2.06-#B[1]*.5,clr)
end
end end
end
gc.pop()
end
function draw.drawTargetLine(P,r)
if r<21+(P.fieldBeneath+P.fieldUp)/30 and r>0 then
gc.setLineWidth(4)
@@ -273,8 +376,8 @@ function draw.norm(P)
end
--Draw next preview
if ENV.nextPos and P.next[1]then
drawNextPreview(P,P.next[1].bk)
if ENV.nextPos and P.nextQueue[1]then
drawNextPreview(P,P.nextQueue[1].bk)
end
gc.setScissor()
@@ -346,49 +449,13 @@ function draw.norm(P)
end
--Draw Hold
if ENV.hold then
gc.push("transform")
gc.translate(-140,116)
gc.setColor(0,0,0,.4)gc.rectangle("fill",0,-80,124,80)
gc.setColor(1,1,1)gc.rectangle("line",0,-80,124,80)
if P.holded then gc.setColor(.6,.4,.4)end
mText(drawableText.hold,62,-131)
if P.hd then drawHold(P,P.hd.color)end
gc.pop()
end
P:drawHold()
--Draw Next(s)
local N=ENV.next*72
if ENV.next>0 then
gc.setColor(0,0,0,.4)gc.rectangle("fill",316,36,124,N)
gc.setColor(1,1,1)gc.rectangle("line",316,36,124,N)
mText(drawableText.next,378,-15)
N=1
local texture=SKIN.curText
while N<=ENV.next and P.next[N]do
local bk,clr=P.next[N].bk,P.next[N].color
for i=1,#bk do for j=1,#bk[1] do
if bk[i][j]then
Draw(texture[clr],30*(j+12.6-#bk[1]*.5)-30,-30*(i-2.4*N-#bk*.5))-- drawCell(i-2.4*N-#bk*.5,j+12.6-#bk[1]*.5,clr)
end
end end
N=N+1
end
end
--Draw Bagline(s)
if ENV.bagLine then
local L=ENV.bagLen
local C=-P.pieceCount%L--Phase
gc.setColor(.8,.5,.5)
for i=C,N-1,L do
local y=72*i+36
gc.line(318+P.fieldOff.x,y,438,y)
end
end
P:drawNext()
--Draw target selecting pad
if modeEnv.royaleMode then
if MODEENV.royaleMode then
if P.atkMode then
gc.setColor(1,.8,0,P.swappingAtkMode*.02)
gc.rectangle("fill",RCPB[2*P.atkMode-1],RCPB[2*P.atkMode],90,35,8,4)
@@ -539,7 +606,7 @@ function draw.small(P)
end
--Draw badge
if modeEnv.royaleMode then
if MODEENV.royaleMode then
gc.setColor(1,1,1)
for i=1,P.strength do
gc.draw(IMG.badgeIcon,12*i-7,4,nil,.5)
@@ -598,20 +665,22 @@ function draw.demo(P)
end
gc.pop()
--Draw hold
local blockImg=TEXTURE.miniBlock
if P.hd then
local id=P.hd.id
--Draw hold
local N=1
while P.holdQueue[N]do
local id=P.holdQueue[N].id
_=P.color[id]
gc.setColor(_[1],_[2],_[3],.3)
_=blockImg[id]
gc.draw(_,15,30,nil,16,nil,0,_:getHeight()*.5)
gc.draw(_,15,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5)
N=N+1
end
--Draw next
local N=1
while N<=ENV.next and P.next[N]do
local id=P.next[N].id
N=1
while N<=ENV.nextCount and P.nextQueue[N]do
local id=P.nextQueue[N].id
_=P.color[id]
gc.setColor(_[1],_[2],_[3],.3)
_=blockImg[id]

View File

@@ -1,6 +1,11 @@
return{
das=10,arr=2,sddas=2,sdarr=2,
ihs=true,irs=true,ims=true,
das=10,
arr=2,
sddas=2,
sdarr=2,
ihs=true,
irs=true,
ims=true,
swap=true,
ghost=.3,center=1,
@@ -20,8 +25,8 @@ return{
drop=60,lock=60,
wait=0,fall=0,
bone=false,
next=6,
hold=true,oncehold=true,
nextCount=6,nextStartPos=1,
holdCount=1,oncehold=true,
ospin=true,
RS="TRS",
sequence="bag",

View File

@@ -72,99 +72,12 @@ local function releaseKey_Rec(P,keyID)
end
P.keyPressing[keyID]=false
end
local function loadGameEnv(P)--Load gameEnv
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
--Load game settings
for k,v in next,gameEnv0 do
if modeEnv[k]~=nil then
v=modeEnv[k] --Mode setting
-- DBP("mode-"..k..":"..tostring(v))
elseif GAME.setting[k]~=nil then
v=GAME.setting[k] --Game setting
-- DBP("game-"..k..":"..tostring(v))
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
-- DBP("global-"..k..":"..tostring(v))
-- else
-- DBP("default-"..k..":"..tostring(v))
end
if type(v)~="table"then--Default setting
ENV[k]=v
else
ENV[k]=copyTable(v)
end
end
end
local function applyGameEnv(P)--Finish gameEnv processing
local ENV=P.gameEnv
P._20G=ENV.drop==0
P.dropDelay=ENV.drop
P.lockDelay=ENV.lock
P.color={}
for _=1,7 do
P.color[_]=SKIN.libColor[ENV.skin[_]]
end
P.life=ENV.life
P.keyAvailable={true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}
if ENV.noTele then
for i=11,20 do
if i~=14 then
P.keyAvailable[i]=false
virtualkey[i].ava=false
end
end
end
for _,v in next,ENV.keyCancel do
P.keyAvailable[v]=false
virtualkey[v].ava=false
end
P:setInvisible(
ENV.visible=="show"and -1 or
ENV.visible=="time"and 300 or
ENV.visible=="fast"and 20 or
ENV.visible=="none"and 0
)
P:set20G(P._20G)
P:setHold(ENV.hold)
P:setRS(ENV.RS)
if type(ENV.mission)=="table"then
P.curMission=1
end
ENV.das=max(ENV.das,ENV.mindas)
ENV.arr=max(ENV.arr,ENV.minarr)
ENV.sdarr=max(ENV.sdarr,ENV.minsdarr)
ENV.next=min(ENV.next,SETTING.maxNext)
if ENV.sequence~="bag"and ENV.sequence~="loop"then
ENV.bagLine=false
else
ENV.bagLen=#ENV.bag
end
if ENV.next==0 then ENV.nextPos=false end
if ENV.lockFX==0 then ENV.lockFX=nil end
if ENV.dropFX==0 then ENV.dropFX=nil end
if ENV.moveFX==0 then ENV.moveFX=nil end
if ENV.clearFX==0 then ENV.clearFX=nil end
if ENV.shakeFX==0 then ENV.shakeFX=nil end
if ENV.ghost==0 then ENV.ghost=nil end
if ENV.center==0 then ENV.center=nil end
end
local function newEmptyPlayer(id,x,y,size)
local P={id=id}
PLAYERS[id]=P
PLAYERS.alive[id]=P
--Inherit functions of player class
--Inherit functions of Player class
for k,v in next,Player do P[k]=v end
if P.id==1 and GAME.recording then
@@ -224,10 +137,10 @@ local function newEmptyPlayer(id,x,y,size)
--P.cur={bk=matrix[2], id=shapeID, color=colorID, name=nameID}
--P.sc,P.dir={0,0},0--SpinCenterCoord, direction
--P.r,P.c=0,0--row, col
--P.hd={...},same as P.cur
-- P.curX,P.curY,P.imgY,P.minY=0,0,0,0--x,y,ghostY
P.holded=false
P.next={}
P.holdQueue={}
P.holdTime=0
P.nextQueue={}
P.seqData={}
P.freshTime=0
@@ -276,6 +189,100 @@ local function newEmptyPlayer(id,x,y,size)
return P
end
local function loadGameEnv(P)--Load gameEnv
P.gameEnv={}--Current game setting environment
local ENV=P.gameEnv
local MODOPT=MODOPT
local GAME=GAME
local SETTING=SETTING
--Load game settings
for k,v in next,gameEnv0 do
if MODOPT[k]~=nil then
v=MODOPT[k] --Mod setting
-- DBP("mod-"..k..":"..tostring(v))
elseif MODEENV[k]~=nil then
v=MODEENV[k] --Mode setting
-- DBP("mode-"..k..":"..tostring(v))
elseif GAME.setting[k]~=nil then
v=GAME.setting[k] --Game setting
-- DBP("game-"..k..":"..tostring(v))
elseif SETTING[k]~=nil then
v=SETTING[k] --Global setting
-- DBP("global-"..k..":"..tostring(v))
-- else
-- DBP("default-"..k..":"..tostring(v))
end
if type(v)~="table"then--Default setting
ENV[k]=v
else
ENV[k]=copyTable(v)
end
end
end
local function applyGameEnv(P)--Finish gameEnv processing
local ENV=P.gameEnv
P._20G=ENV.drop==0
P.dropDelay=ENV.drop
P.lockDelay=ENV.lock
P.color={}
for _=1,7 do
P.color[_]=SKIN.libColor[ENV.skin[_]]
end
P.life=ENV.life
P.keyAvailable={true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true}
if ENV.noTele then
for i=11,20 do
if i~=14 then
P.keyAvailable[i]=false
virtualkey[i].ava=false
end
end
end
for _,v in next,ENV.keyCancel do
P.keyAvailable[v]=false
virtualkey[v].ava=false
end
P:setInvisible(
ENV.visible=="show"and -1 or
ENV.visible=="time"and 300 or
ENV.visible=="fast"and 20 or
ENV.visible=="none"and 0
)
P:set20G(P._20G)
P:setHold(ENV.holdCount)
P:setNext(ENV.nextCount,ENV.nextStartPos>1)
P:setRS(ENV.RS)
if type(ENV.mission)=="table"then
P.curMission=1
end
ENV.das=max(ENV.das,ENV.mindas)
ENV.arr=max(ENV.arr,ENV.minarr)
ENV.sdarr=max(ENV.sdarr,ENV.minsdarr)
ENV.nextCount=min(ENV.nextCount,SETTING.maxNext)
if ENV.sequence~="bag"and ENV.sequence~="loop"then
ENV.bagLine=false
else
ENV.bagLen=#ENV.bag
end
if ENV.nextCount==0 then ENV.nextPos=false end
if ENV.lockFX==0 then ENV.lockFX=nil end
if ENV.dropFX==0 then ENV.dropFX=nil end
if ENV.moveFX==0 then ENV.moveFX=nil end
if ENV.clearFX==0 then ENV.clearFX=nil end
if ENV.shakeFX==0 then ENV.shakeFX=nil end
if ENV.ghost==0 then ENV.ghost=nil end
if ENV.center==0 then ENV.center=nil end
end
--------------------------</Lib Func>--------------------------
--------------------------<Public>--------------------------
@@ -303,48 +310,16 @@ function PLY.newDemoPlayer(id,x,y,size)
P.control=true
P.gameEnv={
das=10,arr=2,sddas=2,sdarr=2,
swap=true,
ghost=SETTING.ghost,
center=SETTING.center,
smooth=SETTING.smooth,
grid=SETTING.grid,
text=SETTING.text,
score=SETTING.score,
lockFX=SETTING.lockFX,
dropFX=SETTING.dropFX,
moveFX=SETTING.moveFX,
clearFX=SETTING.clearFX,
shakeFX=SETTING.shakeFX,
drop=1e99,lock=1e99,
wait=10,fall=20,
bone=false,
next=6,
hold=true,oncehold=true,
ospin=true,
RS="TRS",
sequence="bag",
bag={1,2,3,4,5,6,7},
face={0,0,0,0,0,0,0},
skin=copyTable(SETTING.skin),
mission=false,
life=1e99,
pushSpeed=3,
block=true,
noTele=false,
visible="show",
freshLimit=1e99,easyFresh=true,
keyCancel={},
mindas=0,minarr=0,minsdarr=0,
}
loadGameEnv(P)
applyGameEnv(P)
prepareSequence(P)
P:loadAI({
type="CC",
next=5,
nextCount=5,
hold=true,
delay=30,
delta=4,

View File

@@ -96,7 +96,7 @@ function Player.createBeam(P,R,send,color)
local r,g,b=unpack(SKIN.libColor[color])
r,g,b=r*2,g*2,b*2
local a=modeEnv.royaleMode and not(P.human or R.human)and .2 or 1
local a=MODEENV.royaleMode and not(P.human or R.human)and .2 or 1
SYSFX.newAttack(1-SETTING.atkFX*.1,x1,y1,x2,y2,wid,r,g,b,a*(SETTING.atkFX+2)*.0626)
end
--------------------------</FX>--------------------------
@@ -113,16 +113,34 @@ function Player.set20G(P,if20g,init)
virtualkey[7].ava=not if20g
if init and if20g and P.AI_mode=="CC"then CC.switch20G(P)end
end
function Player.setHold(P,ifhold)
P.gameEnv.hold=ifhold
P.keyAvailable[8]=ifhold
virtualkey[8].ava=ifhold
if not ifhold then
P.hd=nil
function Player.setHold(P,count)
if not count then
count=0
elseif count==true then
count=1
end
P.gameEnv.holdCount=count
P.holdTime=count
P.keyAvailable[8]=count>0
virtualkey[8].ava=count>0
if count==0 then
P.drawHold=NULL
while P.holdQueue[1]do rem(P.holdQueue)end
elseif count==1 then
P.drawHold=PLY.draw.drawHold_norm
else
P.drawHold=PLY.draw.drawHold_multi
end
end
function Player.setNext(P,next)
P.gameEnv.next=next
function Player.setNext(P,next,hidden)
P.gameEnv.nextCount=next
if next==0 then
P.drawNext=NULL
elseif not hidden then
P.drawNext=PLY.draw.drawNext_norm
else
P.drawNext=PLY.draw.drawNext_hidden
end
end
function Player.setInvisible(P,time)
if time<0 then
@@ -510,8 +528,9 @@ function Player.spin(P,d,ifpre)
end
end
function Player.hold(P,ifpre)
if not P.holded and (ifpre or P.waiting==-1) and P.gameEnv.hold then
local H,C=P.hd,P.cur
if P.holdTime>0 and(ifpre or P.waiting==-1)then
local N=#P.holdQueue<P.gameEnv.holdCount and #P.holdQueue+1 or 1
local H,C=P.holdQueue[N],P.cur
if not(H or C)then return end
--Finesse check
@@ -524,31 +543,33 @@ function Player.hold(P,ifpre)
P.spinLast=false
P.spinSeq=0
P.cur,P.hd=H,C--Swap hold
H,C=P.hd,P.cur
P.cur,P.holdQueue[N]=H,C--Swap hold
H,C=P.holdQueue[N],P.cur
if P.next[1]or C then--Make hold available in fixed sequence
P.holded=P.gameEnv.oncehold
if P.nextQueue[1]or C then--Make hold available in fixed sequence
if P.gameEnv.oncehold then
P.holdTime=P.holdTime-1
end
end
if H then
local hid=P.hd.id
P.hd.bk=BLOCKS[hid][P.gameEnv.face[hid]]
local hid=P.holdQueue[N].id
P.holdQueue[N].bk=BLOCKS[hid][P.gameEnv.face[hid]]
end
if not C then
C=rem(P.next,1)
C=rem(P.nextQueue,1)
P:newNext()
if C then
P.cur=C
P.pieceCount=P.pieceCount+1
if P.AI_mode=="CC"then
local next=P.next[P.AIdata.next]
local next=P.nextQueue[P.AIdata.nextCount]
if next then
CC.addNext(P.AI_bot,next.id)
end
end
else
P.holded=false
P.holdTime=0
end
end
if C then
@@ -556,10 +577,14 @@ function Player.hold(P,ifpre)
P:freshBlock(false,true)
P.dropDelay=P.gameEnv.drop
P.lockDelay=P.gameEnv.lock
P.freshTime=max(P.freshTime-5,0)
P.freshTime=max(P.freshTime-5,int(P.gameEnv.freshLimit*(P.gameEnv.holdCount-P.holdTime)/P.gameEnv.holdCount))
if P:ifoverlap(P.cur.bk,P.curX,P.curY)then P:lock()P:lose()end
end
if #P.holdQueue==P.gameEnv.holdCount then
ins(P.holdQueue,rem(P.holdQueue,1))
end
if P.sound then
SFX.play(ifpre and"prehold"or"hold")
end
@@ -569,20 +594,20 @@ end
function Player.getNext(P,n)
local E=P.gameEnv
ins(P.next,{bk=BLOCKS[n][E.face[n]],id=n,color=E.bone and 17 or E.skin[n],name=n})
ins(P.nextQueue,{bk=BLOCKS[n][E.face[n]],id=n,color=E.bone and 17 or E.skin[n],name=n})
end
function Player.popNext(P)--Pop next queue to hand
P.holded=false
P.holdTime=P.gameEnv.holdCount
P.spinLast=false
P.spinSeq=0
P.ctrlCount=0
P.cur=rem(P.next,1)
P.cur=rem(P.nextQueue,1)
P:newNext()
if P.cur then
P.pieceCount=P.pieceCount+1
if P.AI_mode=="CC"then
local next=P.next[P.AIdata.next]
local next=P.nextQueue[P.AIdata.nextCount]
if next then
CC.addNext(P.AI_bot,next.id)
end
@@ -873,9 +898,9 @@ do--player:drop()--Place piece
end
piece.finePts=finePts
P.stat.finesseRate=P.stat.finesseRate+finePts
STAT.finesseRate=STAT.finesseRate+finePts
if finePts<5 then
P.stat.extraPiece=P.stat.extraPiece+1
STAT.extraPiece=STAT.extraPiece+1
if ENV.fineKill then
P:lose()
end
@@ -1036,7 +1061,7 @@ do--player:drop()--Place piece
if P.b2b>1200 then P.b2b=1200 end
--Bonus atk/def when focused
if modeEnv.royaleMode then
if MODEENV.royaleMode then
local i=min(#P.atker,9)
if i>1 then
atk=atk+reAtk[i]
@@ -1061,7 +1086,7 @@ do--player:drop()--Place piece
off=off+_
if send>0 then
local T
if modeEnv.royaleMode then
if MODEENV.royaleMode then
if P.atkMode==4 then
local M=#P.atker
if M>0 then
@@ -1218,7 +1243,7 @@ function Player.loadAI(P,AIdata)--Load AI params
delay=AIdata.delay,
delta=AIdata.delta,
next=AIdata.next,
nextCount=AIdata.nextCount,
hold=AIdata.hold,
_20G=P._20G,
bag=AIdata.bag,
@@ -1229,6 +1254,7 @@ function Player.loadAI(P,AIdata)--Load AI params
P.AI_delay0=int(P.AI_delay0*.26)
end
if P.AI_mode=="CC"then
P:setHold(1)
P:setRS("SRS")
local opt,wei=CC.getConf()
CC.fastWeights(wei)
@@ -1238,10 +1264,11 @@ function Player.loadAI(P,AIdata)--Load AI params
CC.setNode(opt,P.AIdata.node)
P.AI_bot=CC.new(opt,wei)
CC.free(opt)CC.free(wei)
for i=1,AIdata.next do
CC.addNext(P.AI_bot,P.next[i].id)
for i=1,AIdata.nextCount do
CC.addNext(P.AI_bot,P.nextQueue[i].id)
end
else
P:setHold(1)
P:setRS("TRS")
end
end
@@ -1323,7 +1350,7 @@ function Player.win(P,result)
if P.result then return end
P:die()
P.result="WIN"
if modeEnv.royaleMode then
if MODEENV.royaleMode then
P.modeData.event=1
P:changeAtk()
end
@@ -1331,7 +1358,7 @@ function Player.win(P,result)
GAME.result=result or"win"
SFX.play("win")
VOC.play("win")
if modeEnv.royaleMode then
if MODEENV.royaleMode then
BGM.play("8-bit happiness")
end
end
@@ -1362,7 +1389,7 @@ function Player.lose(P,force)
if P.AI_mode=="CC"then
CC.destroy(P.AI_bot)
P.hd=nil
while P.holdQueue[1]do rem(P.holdQueue)end
P:loadAI(P.AIdata)
end
@@ -1398,7 +1425,7 @@ function Player.lose(P,force)
end
end
P.result="K.O."
if modeEnv.royaleMode then
if MODEENV.royaleMode then
P:changeAtk()
P.modeData.event=#PLAYERS.alive+1
P.strength=0
@@ -1440,7 +1467,7 @@ function Player.lose(P,force)
GAME.result="gameover"
SFX.play("fail")
VOC.play("lose")
if modeEnv.royaleMode then
if MODEENV.royaleMode then
if P.modeData.event==2 then
BGM.play("hay what kind of feeling")
else

View File

@@ -14,7 +14,7 @@ local freshPrepare={
for i=1,L do
P.seqData[i]=bag[L+1-i]
end
while #P.next<6 do
while #P.nextQueue<6 do
if P.seqData[1]then
P:getNext(rem(P.seqData))
else
@@ -27,7 +27,7 @@ freshMethod={
none=NULL,
bag=function(P)
local bag=P.seqData
while #P.next<6 do
while #P.nextQueue<6 do
if #bag==0 then--Copy a new bag
local bag0=P.gameEnv.bag
for i=1,#bag0 do bag[i]=bag0[i]end
@@ -36,7 +36,7 @@ freshMethod={
end
end,
his4=function(P)
while #P.next<6 do
while #P.nextQueue<6 do
local bag=P.gameEnv.bag
local L=#bag
for n=1,4 do
@@ -51,7 +51,7 @@ freshMethod={
end
end,
rnd=function(P)
while #P.next<6 do
while #P.nextQueue<6 do
local bag=P.gameEnv.bag
local L=#bag
for i=1,4 do
@@ -59,14 +59,14 @@ freshMethod={
repeat
i=bag[P:RND(L)]
count=count+1
until i~=P.next[#P.next].id or count>=L
until i~=P.nextQueue[#P.nextQueue].id or count>=L
P:getNext(i)
end
end
end,
reverb=function(P)
local seq=P.seqData
while #P.next<6 do
while #P.nextQueue<6 do
if #seq==0 then
local bag0=P.gameEnv.bag
for i=1,#bag0 do seq[i]=bag0[i]end
@@ -87,7 +87,7 @@ freshMethod={
end
end,
loop=function(P)
while #P.next<6 do
while #P.nextQueue<6 do
if #P.seqData==0 then
local bag=P.gameEnv.bag
local L=#bag
@@ -99,11 +99,11 @@ freshMethod={
end
end,
fixed=function(P)
while #P.next<6 do
while #P.nextQueue<6 do
if P.seqData[1]then
P:getNext(rem(P.seqData))
else
if not(P.cur or P.hd)then P:lose(true)end
if not(P.cur or P.holdQueue[1])then P:lose(true)end
return
end
end

View File

@@ -113,7 +113,7 @@ function update.alive(P,dt)
for i=2,10 do v=v+i*(i-1)*7.2/(_-P.dropTime[i])end
P.dropSpeed=P.dropSpeed*.99+v*.1
if modeEnv.royaleMode then
if MODEENV.royaleMode then
if P.keyPressing[9]then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
else
@@ -313,7 +313,7 @@ function update.dead(P,dt)
P.keySpeed=P.keySpeed*.96+P.stat.key/P.stat.time*60*.04
P.dropSpeed=P.dropSpeed*.96+P.stat.piece/P.stat.time*60*.04
--Final average speeds
if modeEnv.royaleMode then
if MODEENV.royaleMode then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
end
end

View File

@@ -13,7 +13,7 @@ WIDGET.init("custom_advance",{
WIDGET.newSwitch({name="bone", x=1190, y=550, disp=WIDGET.lnk_CUSval("bone"), code=WIDGET.lnk_CUSrev("bone")}),
--Control
WIDGET.newSlider({name="next", x=130, y=410,w=200,unit=6, disp=WIDGET.lnk_CUSval("next"), code=WIDGET.lnk_CUSsto("next")}),
WIDGET.newSlider({name="next", x=130, y=410,w=200,unit=6, disp=WIDGET.lnk_CUSval("nextCount"),code=WIDGET.lnk_CUSsto("nextCount")}),
WIDGET.newSwitch({name="hold", x=260, y=480, disp=WIDGET.lnk_CUSval("hold"), code=WIDGET.lnk_CUSrev("hold")}),
WIDGET.newSwitch({name="oncehold", x=260, y=560, disp=WIDGET.lnk_CUSval("oncehold"), code=WIDGET.lnk_CUSrev("oncehold"),hide=function()return not CUSTOMENV.hold end}),

View File

@@ -6,7 +6,7 @@ function sceneInit.main()
}
BG.set("space")
modeEnv=NONE
MODEENV=NONE
--Create demo player
destroyPlayers()
GAME.frame=0

View File

@@ -216,7 +216,7 @@ function Tmr.play(dt)
end
--Fresh royale target
if modeEnv.royaleMode and GAME.frame%120==0 then
if MODEENV.royaleMode and GAME.frame%120==0 then
freshMostDangerous()
end
@@ -308,7 +308,7 @@ function Pnt.play()
gc.setColor(1,1,1)
if SETTING.VKSwitch then drawVirtualkey()end
if modeEnv.royaleMode then
if MODEENV.royaleMode then
local P=PLAYERS[1]
gc.setLineWidth(5)
gc.setColor(.8,1,0,.2)

View File

@@ -34,7 +34,7 @@ function Tick.lose(P)
return true
end
end
if not modeEnv.royaleMode and #PLAYERS>1 then
if not MODEENV.royaleMode and #PLAYERS>1 then
P.y=P.y+P.endCounter*.26
P.absFieldY=P.absFieldY+P.endCounter*.26
end