- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCommon.lua
More file actions
Latest commit
96 lines (92 loc) · 3.37 KB
/
Copy pathtempCommon.lua
File metadata and controls
96 lines (92 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
-- todo: better sword check
isSword= {}
for_, vinipairs{'sword0', 'sword1', 'sword2', 'sword3', 'sword4'} do
isSword[v] =true
end
sword2color= {
sword0= {192/255, 192/255, 192/255},
sword1= {114/255, 114/255, 114/255},
sword2= {166/255, 97/255, 56/255},
sword3= {238/255, 50/255, 255/255},
sword4= {255/255, 255/255, 50/255}
}
slot2type= {'helmet', 'sword', 'chest', 'shield', 'accessory', 'pants', 'accessory'}
tile2id= {}
fori, vinipairs{'water', 'sand', 'grass', 'rock', 'path', 'floor', 'wall', 'platform', 'platform2'} do
tile2id[v] =i
end
-- todo: enemy inheritance
functionserverEnemyDamage(self, d, clientId)
self.hp=self.hp-d
ifself.hp<=0andnotself.destroyedthen
sound.play('scream')
server.addXP(clientId, math.random(3, 5))
localbagItems= {}
localchoices= {
none=20, apple=10, shield=5,
armor0Helmet=8, armor0Chest=8, armor0Pants=8,
armor1Helmet=8, armor1Chest=8, armor1Pants=8,
sword0=4, sword1=4, sword2=3, sword3=3, sword4=3
}
for_=1, 3do
choice=lume.weightedchoice(choices)
ifchoice~='none' then
localitemData= {imageId=choice}
ifchoice=='sword0' then
itemData.atk=math.max(5, math.floor(love.math.randomNormal()*2+10))
elseifchoice=='sword1' then
itemData.atk=math.max(5, math.floor(love.math.randomNormal()*2+12))
elseifchoice=='sword2' then
itemData.atk=math.max(5, math.floor(love.math.randomNormal()*2+14))
elseifchoice=='sword3' then
itemData.atk=math.max(5, math.floor(love.math.randomNormal()*2+16))
elseifchoice=='sword4' then
itemData.atk=math.max(5, math.floor(love.math.randomNormal()*2+18))
end
localitemId=items.server.newItem(itemData)
table.insert(bagItems, itemId)
end
end
localnumItems=#bagItems
ifnumItems~=0then
localtype=lume.randomchoice{'lootBag', 'lootBag1', 'lootBagFuse'}
lootBag.server:new{
realm=serverRealm,
x=self.x, y=self.y,
items=bagItems,
type=type,
life=30
}:spawn()
end
--if math.random() < 0.5 then portals.server.spawn{x=self.x, y=self.y, life=10} end
self:destroy()
else
sound.play('spider')
end
end
-- window to game canvas
functionwindow2game(x, y)
x=x- (ssx-gameScale*gsx)/2
x=x/gameScale
y=y- (ssy-gameScale*gsy)/2
y=y/gameScale
returnx, y
end
functionsetGameCanvas2x()
local_shader=love.graphics.getShader()
local_color= {love.graphics.getColor()}
love.graphics.setShader()
love.graphics.setCanvas(canvases.game2x)
love.graphics.setBlendMode('alpha', 'premultiplied')
love.graphics.setColor(1, 1, 1)
love.graphics.push()
love.graphics.origin()
love.graphics.draw(canvases.game, 0, 0, 0, 2, 2)
love.graphics.pop()
love.graphics.setCanvas(canvases.game)
love.graphics.setBlendMode('alpha')
love.graphics.clear()
love.graphics.setCanvas(canvases.game2x)
love.graphics.setShader(_shader)
love.graphics.setColor(_color)
end