新增队伍系统,攻击不会打给同队,剩一队时游戏就结束(目前允许0~6,0号为自由队,每个人分别算一队)
添加/group命令来选择队伍
This commit is contained in:
@@ -188,12 +188,22 @@ end
|
||||
|
||||
-- Royale mode
|
||||
function randomTarget(P)-- Return a random opponent for P
|
||||
if #PLY_ALIVE>1 then
|
||||
local R
|
||||
repeat
|
||||
R=PLY_ALIVE[rnd(#PLY_ALIVE)]
|
||||
until R~=P
|
||||
return R
|
||||
local l=TABLE.shift(PLY_ALIVE,0)
|
||||
local count=0
|
||||
for i=1,#l do
|
||||
if P.group==0 and l[i]~=P or P.group~=l[i].group then
|
||||
count=count+1
|
||||
end
|
||||
end
|
||||
if count==0 then return end
|
||||
count=rnd(count)
|
||||
for i=1,#l do
|
||||
if P.group==0 and l[i]~=P or P.group~=l[i].group then
|
||||
count=count-1
|
||||
if count==0 then
|
||||
return l[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function freshMostDangerous()
|
||||
|
||||
@@ -20,6 +20,16 @@ RANK_COLORS={
|
||||
{1,.5,.4},
|
||||
{.95,.5,.95},
|
||||
}
|
||||
GROUP_COLORS={
|
||||
[0]=COLOR.Z,
|
||||
[1]=COLOR.R,
|
||||
[2]=COLOR.G,
|
||||
[3]=COLOR.B,
|
||||
[4]=COLOR.Y,
|
||||
[5]=COLOR.M,
|
||||
[6]=COLOR.C,
|
||||
}
|
||||
|
||||
do-- SVG_TITLE_FILL, SVG_TITLE_LINE
|
||||
SVG_TITLE_FILL={
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ return{
|
||||
for i,p in next,L do
|
||||
if p.uid==USER.uid then
|
||||
if p.playMode=='Gamer' then
|
||||
PLY.newPlayer(1)
|
||||
PLY.newPlayer(1,false,p)
|
||||
N=2
|
||||
end
|
||||
table.remove(L,i)
|
||||
|
||||
@@ -689,7 +689,8 @@ function NET.wsCallBack.player_finish(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.wsCallBack.player_joinGroup(body)-- TODO
|
||||
function NET.wsCallBack.player_joinGroup(body)
|
||||
NETPLY.map[body.data.playerId].group=body.data.group
|
||||
end
|
||||
function NET.wsCallBack.player_setHost(body)
|
||||
if body.data.role=='Admin' then
|
||||
@@ -697,7 +698,7 @@ function NET.wsCallBack.player_setHost(body)
|
||||
end
|
||||
NETPLY.map[body.data.playerId].role=body.data.role
|
||||
end
|
||||
function NET.wsCallBack.player_setState(body)-- TODO (not used)
|
||||
function NET.wsCallBack.player_setState(body)-- not used
|
||||
end
|
||||
function NET.wsCallBack.player_stream(body)
|
||||
_pumpStream(body.data)
|
||||
@@ -716,7 +717,7 @@ function NET.wsCallBack.match_finish()
|
||||
TASK.unlock('netPlaying')
|
||||
end)
|
||||
end
|
||||
function NET.wsCallBack.match_ready()-- TODO
|
||||
function NET.wsCallBack.match_ready()-- not used
|
||||
end
|
||||
function NET.wsCallBack.match_start(body)
|
||||
TASK.lock('netPlaying')
|
||||
|
||||
@@ -6,16 +6,6 @@ local gc_stencil,gc_setStencilTest=gc.stencil,gc.setStencilTest
|
||||
local ins,rem=table.insert,table.remove
|
||||
local setFont=FONT.set
|
||||
|
||||
local groupColor={
|
||||
[0]=COLOR.Z,
|
||||
[1]=COLOR.R,
|
||||
[2]=COLOR.G,
|
||||
[3]=COLOR.B,
|
||||
[4]=COLOR.Y,
|
||||
[5]=COLOR.M,
|
||||
[6]=COLOR.C,
|
||||
}
|
||||
|
||||
local posLists={
|
||||
-- 1~5
|
||||
(function()
|
||||
@@ -207,7 +197,7 @@ function NETPLY.draw()
|
||||
gc_rectangle('fill',0,0,p.w,p.h)
|
||||
gc_setColor(COLOR.dH)
|
||||
end
|
||||
gc_setLineWidth(p.role=='Admin' and 4 or 2)
|
||||
gc_setLineWidth(p.role=='Admin' and 4 or 1)
|
||||
gc_rectangle('line',0,0,p.w,p.h)
|
||||
|
||||
-- Stencil
|
||||
@@ -236,7 +226,7 @@ function NETPLY.draw()
|
||||
end
|
||||
|
||||
-- UID & Username
|
||||
gc_setColor(groupColor[p.group] or COLOR.dH)
|
||||
gc_setColor(GROUP_COLORS[p.group] or COLOR.dH)
|
||||
if p.h>=47 then
|
||||
setFont(40)
|
||||
gc_print("#"..p.uid,50,-5)
|
||||
|
||||
@@ -721,7 +721,7 @@ function draw.norm(P,repMode)
|
||||
|
||||
-- Draw username
|
||||
setFont(30)
|
||||
gc_setColor(.97,.97,.97)
|
||||
gc_setColor(GROUP_COLORS[P.group])
|
||||
GC.mStr(P.username or USERS.getUsername(P.uid),300,-60)
|
||||
|
||||
-- Draw HUD
|
||||
|
||||
@@ -192,7 +192,7 @@ local function _loadGameEnv(P)-- Load gameEnv
|
||||
-- else
|
||||
-- print("default-"..k..":"..tostring(v))
|
||||
end
|
||||
if type(v)~='table' then -- Default setting
|
||||
if type(v)~='table' then -- Default setting
|
||||
ENV[k]=v
|
||||
else
|
||||
ENV[k]=TABLE.copy(v)
|
||||
@@ -219,11 +219,11 @@ local function _loadRemoteEnv(P,confStr)-- Load gameEnv
|
||||
if GAME.modeEnv[k]~=nil then
|
||||
v=GAME.modeEnv[k] -- Mode setting
|
||||
elseif confStr[k]~=nil then
|
||||
v=confStr[k] -- Game setting
|
||||
v=confStr[k] -- Game setting
|
||||
elseif SETTING[k]~=nil then
|
||||
v=SETTING[k] -- Global setting
|
||||
v=SETTING[k] -- Global setting
|
||||
end
|
||||
if type(v)~='table' then-- Default setting
|
||||
if type(v)~='table' then -- Default setting
|
||||
ENV[k]=v
|
||||
else
|
||||
ENV[k]=TABLE.copy(v)
|
||||
@@ -407,14 +407,25 @@ function PLY.newRemotePlayer(id,mini,p)
|
||||
|
||||
P.uid=p.uid
|
||||
P.sid=NET.uid_sid[p.uid]
|
||||
P.group=p.group
|
||||
if not (P.group%1==0 and P.group>=1 and P.group<=6) then P.group=0 end
|
||||
|
||||
_loadRemoteEnv(P,p.config)
|
||||
_applyGameEnv(P)
|
||||
end
|
||||
function PLY.newAIPlayer(id,AIdata,mini)
|
||||
function PLY.newAIPlayer(id,AIdata,mini,p)
|
||||
local P=_newEmptyPlayer(id,mini)
|
||||
P.type='computer'
|
||||
|
||||
local pData={
|
||||
uid=id,
|
||||
group=0,
|
||||
} if p then TABLE.coverR(p,pData) end
|
||||
P.username='BOT'..pData.uid
|
||||
P.sid=NET.uid_sid[pData.uid]
|
||||
P.group=pData.group
|
||||
if not (P.group%1==0 and P.group>=1 and P.group<=6) then P.group=0 end
|
||||
|
||||
_loadGameEnv(P)
|
||||
P.gameEnv.face={0,0,0,0,0,0,0}
|
||||
P.gameEnv.skin={1,7,11,3,14,4,9}
|
||||
@@ -422,13 +433,19 @@ function PLY.newAIPlayer(id,AIdata,mini)
|
||||
AIdata._20G=P._20G
|
||||
P:loadAI(AIdata)
|
||||
end
|
||||
function PLY.newPlayer(id,mini)
|
||||
function PLY.newPlayer(id,mini,p)
|
||||
local P=_newEmptyPlayer(id,mini)
|
||||
P.type='human'
|
||||
P.sound=true
|
||||
|
||||
P.uid=USER.uid
|
||||
P.sid=NET.uid_sid[USER.uid]
|
||||
local pData={
|
||||
uid=USER.uid,
|
||||
group=0,
|
||||
} if p then TABLE.coverR(p,pData) end
|
||||
P.uid=pData.uid
|
||||
P.sid=NET.uid_sid[pData.uid]
|
||||
P.group=pData.group
|
||||
if not (P.group%1==0 and P.group>=1 and P.group<=6) then P.group=0 end
|
||||
|
||||
_loadGameEnv(P)
|
||||
_applyGameEnv(P)
|
||||
|
||||
@@ -2845,15 +2845,33 @@ function Player:lose(force)
|
||||
gameOver()
|
||||
self:newTask(#PLAYERS>1 and task_lose or task_finish)
|
||||
if GAME.net and not NET.spectate then
|
||||
NET.player_finish({foo="-- TODO"})
|
||||
NET.player_finish({foo=""})
|
||||
else
|
||||
TASK.new(task_autoPause)
|
||||
end
|
||||
else
|
||||
self:newTask(task_lose)
|
||||
end
|
||||
if #PLY_ALIVE==1 then
|
||||
PLY_ALIVE[1]:win()
|
||||
|
||||
if #PLY_ALIVE>0 then
|
||||
local cur=PLY_ALIVE[1].group
|
||||
for i=2,#PLY_ALIVE do
|
||||
local g=PLY_ALIVE[i].group
|
||||
if cur==0 then
|
||||
if g==0 then-- Two team 0, not finished
|
||||
goto BREAK_notFinished
|
||||
else-- Remember this may-be-last team
|
||||
cur=g
|
||||
end
|
||||
elseif g==0 or cur~=g then-- Find another team, not finished
|
||||
goto BREAK_notFinished
|
||||
end
|
||||
end
|
||||
-- Only 1 team survived, all winner
|
||||
for i=1,#PLY_ALIVE do
|
||||
PLY_ALIVE[i]:win()
|
||||
end
|
||||
::BREAK_notFinished::
|
||||
end
|
||||
end
|
||||
--------------------------<\Event>--------------------------
|
||||
|
||||
@@ -142,6 +142,10 @@ function scene.keyDown(key,isRep)
|
||||
if tonumber(cmd[2]) then NET.room_kick(tonumber(cmd[2])) end
|
||||
elseif cmd[1]=='/host' then
|
||||
if tonumber(cmd[2]) then NET.player_setHost(tonumber(cmd[2])) end
|
||||
elseif cmd[1]=='/group' then
|
||||
if tonumber(cmd[2]) and tonumber(cmd[2])%1==0 and tonumber(cmd[2])>=0 and tonumber(cmd[2])<=6 then
|
||||
NET.player_joinGroup(tonumber(cmd[2]))
|
||||
end
|
||||
else
|
||||
NET.textBox:push{COLOR.R,'Invalid command'}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user