Skip to content

Commit 0821eee

Browse files
authored
[Client Feature] Forge System (Fiendish and Influenced Creatures from 12.80) (#543)
Implementation of the Forge New features: • Added talkactions for use in forge system; Talkactions "/adddusts, /removedusts, /getdusts, /setdusts" Talkaction to teleport to fiendish creature "/fiendish" and for influenced "/influenced" Talkaction to set monster fiendish "/setfiendish", need to look to monster direction and use talkaction Added in "/m" talkaction the param for create monster fiendish/influenced, example: "/m rat, 1" create an influenced Rat with level 1 (allowed is 1-5) "/m rat, fiendish" create a Rat with fiendish status Talkaction to open forge "/openforge" • Added spell to find fiendish "exiva moe res" NOTE: The system is, as far as possible, the same as the global one, there is still a lot of information about the system that nobody knows.
1 parent 6a90ee7 commit 0821eee

File tree

71 files changed

+4683
-715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4683
-715
lines changed

config.lua.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ taskHuntingFreeRerollTime = 20 * 60 * 60
8989

9090
-- Forge system
9191
forgeMaxItemTier = 10
92+
forgeCostOneSliver = 20
93+
forgeSliverAmount = 3
94+
forgeCoreCost = 50
95+
forgeMaxDust = 225
96+
forgeFusionCost = 100
97+
forgeTransferCost = 100
98+
forgeBaseSuccessRate = 50
99+
forgeBonusSuccessRate = 15
100+
forgeTierLossReduction = 50
101+
forgeMinSlivers = 3
102+
forgeMaxSlivers = 7
103+
forgeInfluencedLimit = 300
104+
forgeFiendishLimit = 3
105+
forgeFiendishIntervalType = "hour"
106+
forgeFiendishIntervalTime = "1"
92107

93108
-- NOTE: Access only for Premium Account
94109
onlyPremiumAccount = false
@@ -109,6 +124,7 @@ autoBank = false
109124
-- Teleport summon
110125
-- Set to true will never remove the summon
111126
teleportSummons = false
127+
112128
-- NOTE: true will allow the /reload command to be used
113129
-- NOTE: Using this script might cause unwanted changes
114130
-- This script forces a reload in the entire server, this means that everything that is stored in memory might stop to work properly and/or completely, this script should be used in test environments only

data-canary/monster/demons/demon.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ monster.light = {
7676
color = 0
7777
}
7878

79-
monster.summons = {
80-
{name = "fire elemental", chance = 10, interval = 2000}
79+
monster.summon = {
80+
maxSummons = 1,
81+
summons = {
82+
{name = "fire elemental", chance = 10, interval = 2000}
83+
}
8184
}
8285

8386
monster.voices = {

data-canary/monster/slimes/slime.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ monster.light = {
7575
color = 0
7676
}
7777

78-
monster.summons = {
79-
{name = "Slime", chance = 10, interval = 2000}
78+
monster.summon = {
79+
maxSummons = 1,
80+
summons = {
81+
{name = "Slime", chance = 10, interval = 2000}
82+
}
8083
}
8184

8285
monster.voices = {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
local forgeKill = CreatureEvent("ForgeSystemMonster")
2+
3+
function forgeKill.onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
4+
local targetMonster = creature:getMonster()
5+
if not targetMonster then
6+
return true
7+
end
8+
9+
return ForgeMonster:onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
10+
end
11+
12+
forgeKill:register()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
local forge = Action()
2+
3+
function forge.onUse(player, item, fromPosition, target, toPosition, isHotkey)
4+
player:openForge()
5+
return true
6+
end
7+
8+
forge:id(37122, 37128, 37129, 37131, 37132, 37133, 37153, 37157)
9+
forge:register()

data-canary/scripts/lib/register_monster_type.lua

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ registerMonsterType.health = function(mtype, mask)
8484
mtype:health(mask.health)
8585
end
8686
end
87-
registerMonsterType.maxSummons = function(mtype, mask)
88-
if mask.maxSummons then
89-
mtype:maxSummons(mask.maxSummons)
90-
end
91-
end
9287
registerMonsterType.race = function(mtype, mask)
9388
if mask.race then
9489
mtype:race(mask.race)
@@ -195,12 +190,16 @@ registerMonsterType.flags = function(mtype, mask)
195190
if mask.flags.isBlockable ~= nil then
196191
mtype:isBlockable(mask.flags.isBlockable)
197192
end
193+
if mask.flags.isForgeCreature ~= nil then
194+
mtype:isForgeCreature(mask.flags.isForgeCreature)
195+
end
198196
end
199197
end
200198
registerMonsterType.light = function(mtype, mask)
201199
if mask.light then
200+
local color = 0
202201
if mask.light.color then
203-
local color = mask.light.color
202+
color = mask.light.color
204203
end
205204
if mask.light.level then
206205
mtype:light(color, mask.light.level)
@@ -259,10 +258,15 @@ registerMonsterType.voices = function(mtype, mask)
259258
end
260259
end
261260
end
262-
registerMonsterType.summons = function(mtype, mask)
263-
if type(mask.summons) == "table" then
264-
for k, v in pairs(mask.summons) do
265-
mtype:addSummon(v.name, v.interval, v.chance)
261+
registerMonsterType.summon = function(mtype, mask)
262+
if mask.summon then
263+
if mask.summon.maxSummons then
264+
mtype:maxSummons(mask.summon.maxSummons)
265+
end
266+
if type(mask.summon.summons) == "table" then
267+
for k, v in pairs(mask.summon.summons) do
268+
mtype:addSummon(v.name, v.interval, v.chance, v.count)
269+
end
266270
end
267271
end
268272
end
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
local LEVEL_LOWER = 1
2+
local LEVEL_SAME = 2
3+
local LEVEL_HIGHER = 3
4+
5+
local DISTANCE_BESIDE = 1
6+
local DISTANCE_CLOSE = 2
7+
local DISTANCE_FAR = 3
8+
local DISTANCE_VERYFAR = 4
9+
10+
local directions = {
11+
[DIRECTION_NORTH] = "north",
12+
[DIRECTION_SOUTH] = "south",
13+
[DIRECTION_EAST] = "east",
14+
[DIRECTION_WEST] = "west",
15+
[DIRECTION_NORTHEAST] = "north-east",
16+
[DIRECTION_NORTHWEST] = "north-west",
17+
[DIRECTION_SOUTHEAST] = "south-east",
18+
[DIRECTION_SOUTHWEST] = "south-west"
19+
}
20+
21+
local messages = {
22+
[DISTANCE_BESIDE] = {
23+
[LEVEL_LOWER] = "is below you",
24+
[LEVEL_SAME] = "is standing next to you",
25+
[LEVEL_HIGHER] = "is above you"
26+
},
27+
[DISTANCE_CLOSE] = {
28+
[LEVEL_LOWER] = "is on a lower level to the",
29+
[LEVEL_SAME] = "is to the",
30+
[LEVEL_HIGHER] = "is on a higher level to the"
31+
},
32+
[DISTANCE_FAR] = "is far to the",
33+
[DISTANCE_VERYFAR] = "is very far to the"
34+
}
35+
36+
local spell = Spell("instant")
37+
38+
function spell.onCastSpell(creature, variant)
39+
local targetId = ForgeMonster:pickClosestFiendish(creature)
40+
if not targetId then
41+
creature:sendCancelMessage("No creatures around")
42+
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
43+
return false
44+
end
45+
local target = Creature(targetId)
46+
if not target then
47+
creature:sendCancelMessage("No creatures around")
48+
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
49+
return false
50+
end
51+
52+
local targetPosition = target:getPosition()
53+
local creaturePosition = creature:getPosition()
54+
local positionDifference = {
55+
x = creaturePosition.x - targetPosition.x,
56+
y = creaturePosition.y - targetPosition.y,
57+
z = creaturePosition.z - targetPosition.z
58+
}
59+
60+
local maxPositionDifference, direction = math.max(math.abs(positionDifference.x), math.abs(positionDifference.y))
61+
if maxPositionDifference >= 5 then
62+
local positionTangent = positionDifference.x ~= 0 and positionDifference.y / positionDifference.x or 10
63+
if math.abs(positionTangent) < 0.4142 then
64+
direction = positionDifference.x > 0 and DIRECTION_WEST or DIRECTION_EAST
65+
elseif math.abs(positionTangent) < 2.4142 then
66+
direction = positionTangent > 0 and
67+
(positionDifference.y > 0 and DIRECTION_NORTHWEST or DIRECTION_SOUTHEAST) or
68+
positionDifference.x > 0 and DIRECTION_SOUTHWEST or DIRECTION_NORTHEAST
69+
else
70+
direction = positionDifference.y > 0 and DIRECTION_NORTH or DIRECTION_SOUTH
71+
end
72+
end
73+
74+
local level = positionDifference.z > 0 and LEVEL_HIGHER or positionDifference.z < 0 and LEVEL_LOWER or LEVEL_SAME
75+
local distance = maxPositionDifference < 5 and DISTANCE_BESIDE or maxPositionDifference < 101 and DISTANCE_CLOSE or
76+
maxPositionDifference < 275 and DISTANCE_FAR or DISTANCE_VERYFAR
77+
local message = messages[distance][level] or messages[distance]
78+
if distance ~= DISTANCE_BESIDE then
79+
message = message .. " " .. directions[direction]
80+
end
81+
82+
local type = target:getType()
83+
local stringLevel = 'Unknown'
84+
if type then
85+
local bestiaryKillsAmount = type:BestiarytoKill()
86+
if bestiaryKillsAmount >= 5 and bestiaryKillsAmount <= 25 then
87+
stringLevel = 'Harmless'
88+
elseif bestiaryKillsAmount <= 250 then
89+
stringLevel = 'Trivial'
90+
elseif bestiaryKillsAmount <= 500 then
91+
stringLevel = 'Easy'
92+
elseif bestiaryKillsAmount <= 1000 then
93+
stringLevel = 'Medium'
94+
elseif bestiaryKillsAmount <= 2500 then
95+
stringLevel = 'Hard'
96+
elseif bestiaryKillsAmount <= 5000 then
97+
stringLevel = 'Challenging'
98+
end
99+
end
100+
101+
message = string.format("The monster " .. message .. ". Be prepared to find a creature of difficulty level \"" ..
102+
stringLevel .. "\".")
103+
local timeLeft = math.floor((target:getTimeToChangeFiendish() - os.time()) / 60)
104+
if (timeLeft <= 15) then
105+
message = string.format(message .. " " .. ForgeMonster:getTimeLeftToChangeMonster(target))
106+
end
107+
108+
creature:sendTextMessage(MESSAGE_INFO_DESCR, message)
109+
creaturePosition:sendMagicEffect(CONST_ME_MAGIC_BLUE)
110+
return true
111+
end
112+
113+
spell:name("Find Fiend")
114+
spell:words("exiva moe res")
115+
spell:group("support")
116+
spell:vocation("druid;true", "elder druid;true", "knight;true", "elite knight;true", "paladin;true",
117+
"royal paladin;true", "sorcerer;true", "master sorcerer;true")
118+
spell:id(20)
119+
spell:cooldown(2 * 1000)
120+
spell:groupCooldown(2 * 1000)
121+
spell:level(25)
122+
spell:mana(20)
123+
spell:isAggressive(false)
124+
spell:needLearn(false)
125+
spell:register()

0 commit comments

Comments
 (0)