changes
This commit is contained in:
@@ -29,13 +29,14 @@ function player.interface(actor, place)
|
|||||||
gui.menu_item("cb_dropscissor" ,"Drop Scissor")
|
gui.menu_item("cb_dropscissor" ,"Drop Scissor")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function player:cb_conjurerock() self.Count['r']=self.Count['r']+1 end
|
function player:cb_conjurerock() self.Count['r']=self.Count['r']+1 end
|
||||||
function player:cb_conjurepaper() self.Count['p']=self.Count['p']+1 end
|
function player:cb_conjurepaper() self.Count['p']=self.Count['p']+1 end
|
||||||
function player:cb_conjurescissor() self.Count['s']=self.Count['s']+1 end
|
function player:cb_conjurescissor() self.Count['s']=self.Count['s']+1 end
|
||||||
|
|
||||||
function army.interface(actor,place)
|
function army.interface(actor,place)
|
||||||
if place.owner==actor then gui_menu_item("cb_recruit","Recruit");
|
if place.owner==actor then gui_menu_item("cb_recruit","Recruit");
|
||||||
else gui.menu_item("cb_capture","Capture");
|
else gui.menu_item("cb_fight" ,"Fight");
|
||||||
end end
|
end end
|
||||||
|
|
||||||
-- Rock dulls Scissors 3
|
-- Rock dulls Scissors 3
|
||||||
@@ -84,20 +85,24 @@ function army.fight0(ak,ac,dk,dc) -- returns number of attacker casualties, defe
|
|||||||
|
|
||||||
function army.cb_fight(actor,place,dialog)
|
function army.cb_fight(actor,place,dialog)
|
||||||
for ak,ac in pairs(actor.Count) do -- Should randomize the order
|
for ak,ac in pairs(actor.Count) do -- Should randomize the order
|
||||||
local enemy
|
local enemyk, enemyc
|
||||||
local acas
|
local acas
|
||||||
local maxcas=-1
|
local maxcas=-1
|
||||||
|
local Loss0,Loss1
|
||||||
|
local whichdk, whichdc
|
||||||
for dk,dc in pairs(place.Count) do
|
for dk,dc in pairs(place.Count) do
|
||||||
local rem0,rem1=army.fight0(ak,ac,dk,dc)
|
local rem0,rem1=army.fight0(ak,ac,dk,dc)
|
||||||
local Loss0=ac-rem0
|
Loss0=ac-rem0
|
||||||
local Loss1=dk-rem1
|
Loss1=dc-rem1
|
||||||
|
print("When "..ac.." "..ak.." fight "..dc.." "..dk.." they kill "..Loss1.." and suffer "..Loss0)
|
||||||
if Loss1>maxcas then
|
if Loss1>maxcas then
|
||||||
enemy=dk
|
enemyk=dk
|
||||||
|
enemyc=dc
|
||||||
maxcas=Loss1
|
maxcas=Loss1
|
||||||
acas=Loss1
|
acas=Loss1
|
||||||
end end
|
end end
|
||||||
if enemy then
|
if enemyk then
|
||||||
print("Army "..ak.." kills "..maxcas.." "..dk.." and suffers "..Loss0)
|
print("Army of "..ac.." "..ak.." fights "..enemyc.." "..enemyk..", killing "..Loss1.." and suffering "..Loss0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -188,14 +193,13 @@ function player.cb_map(actor,place,dialog)
|
|||||||
local lis=tangible.near(actor,rad,true,false)
|
local lis=tangible.near(actor,rad,true,false)
|
||||||
pprint("cb_map ",lis)
|
pprint("cb_map ",lis)
|
||||||
for _,t in pairs(lis) do
|
for _,t in pairs(lis) do
|
||||||
|
if t~=actor then print(tangible.getclass(t)) end
|
||||||
local graphic,plane,x,y,z,facing = tangible.animstate(t)
|
local graphic,plane,x,y,z,facing = tangible.animstate(t)
|
||||||
local c=tangible.getclass(t)
|
local c=tangible.getclass(t)
|
||||||
local dx,dy=tangible.xyz(t)
|
local dx,dy=tangible.xyz(t)
|
||||||
local offset=(dy+rad)*(rad*2+1)+dx+rad
|
local offset=(dy+rad)*(rad*2+1)+dx+rad
|
||||||
local cl=tangible.getclass(t)
|
local cl=tangible.getclass(t)
|
||||||
local kind=t.kind or 'Nil'
|
local kind=t.kind or 'Nil'
|
||||||
pprint(t)
|
|
||||||
print("Offset of "..cl.." is "..offset.." kind is "..kind)
|
|
||||||
if not scratch[offset] then scratch[offset]={} end
|
if not scratch[offset] then scratch[offset]={} end
|
||||||
if not scratch[offset].count then scratch[offset].count={} end
|
if not scratch[offset].count then scratch[offset].count={} end
|
||||||
if not scratch[offset].count[kind] then scratch[offset].count[kind]=0 end
|
if not scratch[offset].count[kind] then scratch[offset].count[kind]=0 end
|
||||||
@@ -224,11 +228,11 @@ function player.cb_map(actor,place,dialog)
|
|||||||
for dx=-rad,rad do lbuf=lbuf.."----" end
|
for dx=-rad,rad do lbuf=lbuf.."----" end
|
||||||
lbuf=lbuf.."-"
|
lbuf=lbuf.."-"
|
||||||
print(lbuf)
|
print(lbuf)
|
||||||
print("In Player:")
|
print("In Player "..tangible.id(actor)..":")
|
||||||
for k,v in pairs(actor.Count) do print(" "..k.." "..v) end
|
for k,v in pairs(actor.Count) do print(" "..k.." "..v) end
|
||||||
local lis=tangible.near(actor,0,true,true)
|
local lis=tangible.near(actor,0,true,true)
|
||||||
for k,v in pairs(lis) do
|
for k,v in pairs(lis) do
|
||||||
print("Army:")
|
print("In Army "..tangible.id(v)..":")
|
||||||
for k2,v2 in pairs(v.Count) do print(" "..k2.." "..v2) end
|
for k2,v2 in pairs(v.Count) do print(" "..k2.." "..v2) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ function login.interface(actor, place)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function login.cb_becomeplayer(actor, place, dialog)
|
function login.cb_becomeplayer(actor, place, dialog)
|
||||||
|
actor.kind='P'
|
||||||
|
actor.Count={}
|
||||||
|
setmetatable(actor.Count,{jones=5,__index=function(t,k) return 0 end,__newindex=function(t,k,v) if v~=nil and v~=0 then rawset(t,k,v) end end})
|
||||||
tangible.setclass(actor, player)
|
tangible.setclass(actor, player)
|
||||||
tangible.animate(actor,{action="warp",plane="main",x=0,y=0,z=0})
|
tangible.animate(actor,{action="warp",plane="main",x=0,y=0,z=0})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
makeclass('player')
|
||||||
|
makeclass('buff')
|
||||||
|
|
||||||
|
function player.interface(actor,place)
|
||||||
|
gui.menu_item("cb_north","Go North")
|
||||||
|
gui.menu_item("cb_south","Go South")
|
||||||
|
gui.menu_item("cb_west" ,"Go West")
|
||||||
|
gui.menu_item("cb_east" ,"Go East")
|
||||||
|
gui.menu_item("cb_emit" ,"Emit Buff")
|
||||||
|
gui.menu_item("cb_map" ,"Where Am I?")
|
||||||
|
end
|
||||||
|
|
||||||
|
function player.cb_where(actor,place)
|
||||||
|
pprint(tangible.xyz(actor))
|
||||||
|
end
|
||||||
|
|
||||||
|
function player.cb_north(actor,place) tangible.animate(actor,{action="walk",dy= 1}) end
|
||||||
|
function player.cb_south(actor,place) tangible.animate(actor,{action="walk",dy=-1}) end
|
||||||
|
function player.cb_west (actor,place) tangible.animate(actor,{action="walk",dx=-1}) end
|
||||||
|
function player.cb_east (actor,place) tangible.animate(actor,{action="walk",dx= 1}) end
|
||||||
|
|
||||||
|
function player.cb_emit(actor,place)
|
||||||
|
tangible.build{class='buff',x=0,y=0,z=0,plane='main',graphic='Ring'}
|
||||||
|
end
|
||||||
|
|
||||||
|
function seq(a,b,c) return a<=b and b<=c or false end
|
||||||
|
|
||||||
|
function player.cb_map(actor,place)
|
||||||
|
local rad=2
|
||||||
|
local map={}
|
||||||
|
local lis=tangible.near(actor,rad,true,false)
|
||||||
|
local ax,ay=tangible.xyz(actor)
|
||||||
|
for _,t in ipairs(lis) do
|
||||||
|
local x,y=tangible.xyz(t)
|
||||||
|
local dx=ax-x
|
||||||
|
local dy=ay-y
|
||||||
|
local class=tangible.getclass(t)
|
||||||
|
if seq(-rad,dx,rad) and seq(-rad,dy,rad) then
|
||||||
|
local offset=(dy+rad)*(rad*2+1)+dx+rad
|
||||||
|
if not map[offset] then map[offset]={} end
|
||||||
|
if class=='buff' then map[offset].buff=true
|
||||||
|
elseif class=='player' then map[offset].player=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for dy=-rad,rad do for line=1,3 do
|
||||||
|
local str=""
|
||||||
|
for dx=-rad,rad do
|
||||||
|
local offset=(dy+rad)*(rad*2+1)+dx+rad
|
||||||
|
str=str.."---"
|
||||||
|
end
|
||||||
|
print(str)
|
||||||
|
end end
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user