Skip to content

Commit

Permalink
[Fix] Bestiary unlocked creature (#438)
Browse files Browse the repository at this point in the history
Before, the bestiary did not unlock or account for a creature due to the lack of the script in creaturescripts for its functioning.
  • Loading branch information
beats-dh authored Jul 19, 2022
1 parent 0d9d3a1 commit e033f83
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
42 changes: 21 additions & 21 deletions data/scripts/bestiary/charms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ local charms = {
of its initial hit points as physical damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_PHYSICALDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You wounded the monster.",
messageServerLog = "[Wound charm]",
effect = CONST_ME_HITAREA,
Expand All @@ -20,8 +20,8 @@ local charms = {
of its initial hit points as fire damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_FIREDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You enflamed the monster.",
messageServerLog = "[Enflame charm]",
effect = CONST_ME_HITBYFIRE,
Expand All @@ -34,8 +34,8 @@ local charms = {
of its initial hit points as earth damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_EARTHDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You poisoned the monster.",
messageServerLog = "[Poison charm]",
effect = CONST_ME_GREEN_RINGS,
Expand All @@ -48,8 +48,8 @@ local charms = {
of its initial hit points as ice damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_ICEDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You frozen the monster.",
messageServerLog = "[Freeze charm]",
effect = CONST_ME_ICEATTACK,
Expand All @@ -62,8 +62,8 @@ local charms = {
of its initial hit points as energy damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_ENERGYDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You eletrocuted the monster.",
messageServerLog = "[Zap charm]",
effect = CONST_ME_ENERGYHIT,
Expand All @@ -76,8 +76,8 @@ local charms = {
of its initial hit points as death damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_DEATHDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You curse the monster.",
messageServerLog = "[Curse charm]",
effect = CONST_ME_SMALLCLOUDS,
Expand All @@ -88,7 +88,7 @@ local charms = {
name = "Cripple",
description = "Cripples the creature with a certain chance and paralyzes it for 10 seconds.",
type = CHARM_OFFENSIVE,
chance = 10,
chance = 20,
messageCancel = "You cripple the monster.",
points = 500
},
Expand All @@ -109,7 +109,7 @@ local charms = {
name = "Dodge",
description = "Dodges an attack with a certain chance without taking any damage at all.",
type = CHARM_DEFENSIVE,
chance = 10,
chance = 20,
messageCancel = "You dodge the attack.",
effect = CONST_ME_POFF,
points = 600
Expand All @@ -120,7 +120,7 @@ local charms = {
description = "Bursts of adrenaline enhance your reflexes with a certain chance \z
after you get hit and let you move faster for 10 seconds.",
type = CHARM_DEFENSIVE,
chance = 10,
chance = 20,
messageCancel = "Your movements where bursted.",
points = 500
},
Expand All @@ -129,7 +129,7 @@ local charms = {
name = "Numb",
description = "Numbs the creature with a certain chance after its attack and paralyzes the creature for 10 seconds.",
type = CHARM_DEFENSIVE,
chance = 10,
chance = 20,
messageCancel = "You numb the monster.",
points = 500
},
Expand All @@ -139,7 +139,7 @@ local charms = {
description = "Cleanses you from within with a certain chance after you get hit and \z
removes one random active negative status effect and temporarily makes you immune against it.",
type = CHARM_DEFENSIVE,
chance = 10,
chance = 20,
messageCancel = "You purified the attack.",
points = 700
},
Expand All @@ -148,7 +148,7 @@ local charms = {
name = "Bless",
description = "Blesses you and reduces skill and xp loss by 10% when killed by the chosen creature.",
type = CHARM_PASSIVE,
percent = 5,
percent = 10,
chance = 100,
points = 800
},
Expand All @@ -157,7 +157,7 @@ local charms = {
name = "Scavenge",
description = "Enhances your chances to successfully skin/dust a skinnable/dustable creature.",
type = CHARM_PASSIVE,
percent = 25,
percent = 10,
points = 800
},
-- Gut charm
Expand All @@ -184,8 +184,8 @@ local charms = {
of its initial hit points as holy damage once.",
type = CHARM_OFFENSIVE,
damageType = COMBAT_HOLYDAMAGE,
percent = 5,
chance = 10,
percent = 10,
chance = 20,
messageCancel = "You divine the monster.",
messageServerLog = "[Divine charm]",
effect = CONST_ME_HOLYDAMAGE,
Expand Down
27 changes: 27 additions & 0 deletions data/scripts/creaturescripts/bestiary_kill.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local bestiaryOnKill = CreatureEvent("BestiaryOnKill")

function bestiaryOnKill.onKill(player, creature, lastHit)
if not player:isPlayer() or not creature:isMonster() or creature:hasBeenSummoned() or creature:isPlayer() then
return true
end

for cid, damage in pairs(creature:getDamageMap()) do
local participant = Player(cid)
if participant and participant:isPlayer() then
participant:addBestiaryKill(creature:getName())
end
end

return true
end

bestiaryOnKill:register()

local loginBestiaryPlayer = CreatureEvent("loginBestiaryPlayer")

function loginBestiaryPlayer.onLogin(player)
player:registerEvent("BestiaryOnKill")
return true
end

loginBestiaryPlayer:register()

0 comments on commit e033f83

Please sign in to comment.