-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshared.lua
69 lines (60 loc) · 1.86 KB
/
shared.lua
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
shared = {}
shared.hidden = true
function getHouse(player)
local role = player:getRole()
if role == "lord" or role == "loyalist" then
return "lord"
elseif role == "renegade" then
return "renegade"
else
return "rebel"
end
end
function shared:isFriend(p1, p2)
return getHouse(p1) == getHouse(p2)
end
function shared:killAllRenegades(room)
for _, alive in sgs.qlist(room:getAlivePlayers()) do
local role = alive:getRole()
if role == "renegade" then
room:killPlayer(alive)
end
end
end
shared.fuyin = sgs.CreateTriggerSkill {
name = "shared_fuyin",
frequency = sgs.Skill_Compulsory,
events = {sgs.Death},
on_trigger = function(self, event, player, data)
if player:getRole() ~= "rebel" then
return false
end
local room = player:getRoom()
local death = data:toDeath()
local deadman = death.who
if deadman:getRole() ~= "rebel" then
return false
end
local nLoyalist = 0
local nRebel = 0
for _, alive in sgs.qlist(room:getAlivePlayers()) do
local role = alive:getRole()
if role == "loyalist" then
nLoyalist = nLoyalist + 1
elseif role == "rebel" then
nRebel = nRebel + 1
end
end
if (nLoyalist >= nRebel or deadman:objectName() == player:objectName()) and nLoyalist > 0 then
shared:killAllRenegades(room)
end
end,
can_trigger = function(self, target)
return target:hasSkill(self:objectName())
end
}
sgs.LoadTranslationTable {
["shared_fuyin"] = "福音",
[":shared_fuyin"] = "<b>反贼技,锁定技,</b>每当你或另一名反贼死亡时,若此时存活的忠臣数不少于反贼数,则内奸立即死亡。",
}
return shared