From 6660328be2609cc1148c9c888c03c33c3764004d Mon Sep 17 00:00:00 2001 From: ErikasKontenis Date: Fri, 7 May 2021 22:34:28 +0300 Subject: [PATCH] fix physical damage calculator for distance weapon, add !vials command, remove !online command for regular players --- data/actions/scripts/misc/fluids.lua | 7 ++++- data/talkactions/scripts/impersonate.lua | 20 +++++++++++++ data/talkactions/scripts/online.lua | 8 ++++++ data/talkactions/scripts/physical_damage.lua | 30 ++++++++++++-------- data/talkactions/scripts/vial.lua | 10 +++++++ data/talkactions/talkactions.xml | 2 ++ 6 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 data/talkactions/scripts/impersonate.lua create mode 100644 data/talkactions/scripts/vial.lua diff --git a/data/actions/scripts/misc/fluids.lua b/data/actions/scripts/misc/fluids.lua index 9a7b45b..744ae10 100644 --- a/data/actions/scripts/misc/fluids.lua +++ b/data/actions/scripts/misc/fluids.lua @@ -80,7 +80,12 @@ function onUse(player, item, fromPosition, target, toPosition) else target:say("Gulp.", TALKTYPE_MONSTER_SAY) end - item:transform(item:getId(), FLUID_NONE) + + if player:getStorageValue(17742) ~= 1 then + item:transform(item:getId(), FLUID_NONE) + else + item:remove() + end end else if toPosition.x == CONTAINER_POSITION then diff --git a/data/talkactions/scripts/impersonate.lua b/data/talkactions/scripts/impersonate.lua new file mode 100644 index 0000000..67b3593 --- /dev/null +++ b/data/talkactions/scripts/impersonate.lua @@ -0,0 +1,20 @@ +function onSay(player, words, param) + if not player:getGroup():getAccess() then + return true + end + + local split = param:split(",") + local target = Player(split[1]) + if target == nil then + player:sendCancelMessage("Player not found.") + return false + end + + if target:getGroup():getAccess() then + player:sendCancelMessage("You cannot impersonate this player.") + return false + end + + target:say(split[2], TALKTYPE_SAY) + return false +end diff --git a/data/talkactions/scripts/online.lua b/data/talkactions/scripts/online.lua index 705bbb3..f9b0656 100644 --- a/data/talkactions/scripts/online.lua +++ b/data/talkactions/scripts/online.lua @@ -1,6 +1,14 @@ local maxPlayersPerMessage = 10 function onSay(player, words, param) + if not player:getGroup():getAccess() then + return true + end + + if player:getAccountType() < ACCOUNT_TYPE_GOD then + return false + end + local hasAccess = player:getGroup():getAccess() local players = Game.getPlayers() local onlineList = {} diff --git a/data/talkactions/scripts/physical_damage.lua b/data/talkactions/scripts/physical_damage.lua index 5fe8ba9..02733ef 100644 --- a/data/talkactions/scripts/physical_damage.lua +++ b/data/talkactions/scripts/physical_damage.lua @@ -92,7 +92,6 @@ end local function getDefense(creature, random1, random2) local totalDefense = creature:getType():getDefense() + 1 local defenseSkill = creature:getType():getSkill() - local formula = math.floor((5 * (defenseSkill) + 50) * totalDefense) local randresult = math.floor(random1 % 100) @@ -112,13 +111,15 @@ local function getArmor(creature, rand) return armor end -local function setPhysicalDamageBlock(creature, damage, random1, random2, randomArmor) +local function setPhysicalDamageBlock(creature, isCloseRange, damage, random1, random2, randomArmor) if bit.band(creature:getType():getCombatImmunities(), COMBAT_PHYSICALDAMAGE) == COMBAT_PHYSICALDAMAGE then return 0 end - - damage = damage + getDefense(creature, random1, random2) - + + if isCloseRange then + damage = damage + getDefense(creature, random1, random2) + end + if damage >= 0 then return 0 end @@ -134,7 +135,7 @@ local function setPhysicalDamageBlock(creature, damage, random1, random2, random end local function isThrowableHit(weapon, ammunition, skillValue, rand) - local distance = 15 -- we consider distance is always the best + local distance = 75 -- we consider distance is always the best local hitChance = 75 -- throwables and such if weapon:getAmmoType() ~= 0 then @@ -158,20 +159,20 @@ local function getTotalDamage(creature, weapon, ammunition, vocation, attack, sk if weapon ~= nil and weapon:getWeaponType() == WEAPON_DISTANCE then if isThrowableHit(weapon, ammunition, skillValue, os.rand()) then - damage = setPhysicalDamageBlock(creature, damage, os.rand(), os.rand(), os.rand()) + damage = setPhysicalDamageBlock(creature, false, damage, os.rand(), os.rand(), os.rand()) else damage = 0 end minDamage = 0 if isThrowableHit(weapon, ammunition, skillValue, 0) then - maxDamage = setPhysicalDamageBlock(creature, maxDamage, 0, 0, 0) + maxDamage = setPhysicalDamageBlock(creature, false, maxDamage, 0, 0, 0) else maxDamage = 0 end else - damage = setPhysicalDamageBlock(creature, damage, os.rand(), os.rand(), os.rand()) - minDamage = setPhysicalDamageBlock(creature, minDamage, 99, 99, rshift(creature:getType():getArmor(), 1) + 1) - maxDamage = setPhysicalDamageBlock(creature, maxDamage, 0, 0, 0) + damage = setPhysicalDamageBlock(creature, true, damage, os.rand(), os.rand(), os.rand()) + minDamage = setPhysicalDamageBlock(creature, true, minDamage, 99, 99, rshift(creature:getType():getArmor(), 1) + 1) + maxDamage = setPhysicalDamageBlock(creature, true, maxDamage, 0, 0, 0) end local container = {} @@ -235,7 +236,12 @@ function onSay(player, words, param) local skillValue = player:getSkillLevel(skillType) if skillValueNumber ~= nil then if tonumber(skillValueNumber) > 0 then - skillValue = tonumber(skillValueNumber) + if tonumber(skillValueNumber) <= 300 then + skillValue = tonumber(skillValueNumber) + else + player:sendCancelMessage("The skill value has to be no bigger than 300.") + return false + end else player:sendCancelMessage("The skill value has to be a number and greater than zero.") return false diff --git a/data/talkactions/scripts/vial.lua b/data/talkactions/scripts/vial.lua new file mode 100644 index 0000000..817fcd1 --- /dev/null +++ b/data/talkactions/scripts/vial.lua @@ -0,0 +1,10 @@ +function onSay(player, words, param) + if player:getStorageValue(17742) ~= 1 then + player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Vials auto removing enabled.") + player:setStorageValue(17742, 1) + else + player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Vials auto removing disabled.") + player:setStorageValue(17742, 0) + end + return false +end diff --git a/data/talkactions/talkactions.xml b/data/talkactions/talkactions.xml index 163bf8d..f4eeb38 100644 --- a/data/talkactions/talkactions.xml +++ b/data/talkactions/talkactions.xml @@ -42,6 +42,7 @@ + @@ -57,6 +58,7 @@ +