fix physical damage calculator for distance weapon, add !vials command, remove !online command for regular players

This commit is contained in:
ErikasKontenis 2021-05-07 22:34:28 +03:00
parent f8c7f4e837
commit 6660328be2
6 changed files with 64 additions and 13 deletions

View File

@ -80,7 +80,12 @@ function onUse(player, item, fromPosition, target, toPosition)
else else
target:say("Gulp.", TALKTYPE_MONSTER_SAY) target:say("Gulp.", TALKTYPE_MONSTER_SAY)
end end
item:transform(item:getId(), FLUID_NONE)
if player:getStorageValue(17742) ~= 1 then
item:transform(item:getId(), FLUID_NONE)
else
item:remove()
end
end end
else else
if toPosition.x == CONTAINER_POSITION then if toPosition.x == CONTAINER_POSITION then

View File

@ -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

View File

@ -1,6 +1,14 @@
local maxPlayersPerMessage = 10 local maxPlayersPerMessage = 10
function onSay(player, words, param) 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 hasAccess = player:getGroup():getAccess()
local players = Game.getPlayers() local players = Game.getPlayers()
local onlineList = {} local onlineList = {}

View File

@ -92,7 +92,6 @@ end
local function getDefense(creature, random1, random2) local function getDefense(creature, random1, random2)
local totalDefense = creature:getType():getDefense() + 1 local totalDefense = creature:getType():getDefense() + 1
local defenseSkill = creature:getType():getSkill() local defenseSkill = creature:getType():getSkill()
local formula = math.floor((5 * (defenseSkill) + 50) * totalDefense) local formula = math.floor((5 * (defenseSkill) + 50) * totalDefense)
local randresult = math.floor(random1 % 100) local randresult = math.floor(random1 % 100)
@ -112,13 +111,15 @@ local function getArmor(creature, rand)
return armor return armor
end 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 if bit.band(creature:getType():getCombatImmunities(), COMBAT_PHYSICALDAMAGE) == COMBAT_PHYSICALDAMAGE then
return 0 return 0
end end
damage = damage + getDefense(creature, random1, random2) if isCloseRange then
damage = damage + getDefense(creature, random1, random2)
end
if damage >= 0 then if damage >= 0 then
return 0 return 0
end end
@ -134,7 +135,7 @@ local function setPhysicalDamageBlock(creature, damage, random1, random2, random
end end
local function isThrowableHit(weapon, ammunition, skillValue, rand) 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 local hitChance = 75 -- throwables and such
if weapon:getAmmoType() ~= 0 then 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 weapon ~= nil and weapon:getWeaponType() == WEAPON_DISTANCE then
if isThrowableHit(weapon, ammunition, skillValue, os.rand()) 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 else
damage = 0 damage = 0
end end
minDamage = 0 minDamage = 0
if isThrowableHit(weapon, ammunition, skillValue, 0) then if isThrowableHit(weapon, ammunition, skillValue, 0) then
maxDamage = setPhysicalDamageBlock(creature, maxDamage, 0, 0, 0) maxDamage = setPhysicalDamageBlock(creature, false, maxDamage, 0, 0, 0)
else else
maxDamage = 0 maxDamage = 0
end end
else else
damage = setPhysicalDamageBlock(creature, damage, os.rand(), os.rand(), os.rand()) damage = setPhysicalDamageBlock(creature, true, damage, os.rand(), os.rand(), os.rand())
minDamage = setPhysicalDamageBlock(creature, minDamage, 99, 99, rshift(creature:getType():getArmor(), 1) + 1) minDamage = setPhysicalDamageBlock(creature, true, minDamage, 99, 99, rshift(creature:getType():getArmor(), 1) + 1)
maxDamage = setPhysicalDamageBlock(creature, maxDamage, 0, 0, 0) maxDamage = setPhysicalDamageBlock(creature, true, maxDamage, 0, 0, 0)
end end
local container = {} local container = {}
@ -235,7 +236,12 @@ function onSay(player, words, param)
local skillValue = player:getSkillLevel(skillType) local skillValue = player:getSkillLevel(skillType)
if skillValueNumber ~= nil then if skillValueNumber ~= nil then
if tonumber(skillValueNumber) > 0 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 else
player:sendCancelMessage("The skill value has to be a number and greater than zero.") player:sendCancelMessage("The skill value has to be a number and greater than zero.")
return false return false

View File

@ -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

View File

@ -42,6 +42,7 @@
<talkaction words="/loottest" script="loot_test.lua" /> <talkaction words="/loottest" script="loot_test.lua" />
<talkaction words="/event" script="serpentine_tower_event.lua" /> <talkaction words="/event" script="serpentine_tower_event.lua" />
<talkaction words="/queryhouses" separator=" " script="query_houses.lua" /> <talkaction words="/queryhouses" separator=" " script="query_houses.lua" />
<talkaction words="/impersonate" separator=" " script="impersonate.lua" />
<!-- player talkactions --> <!-- player talkactions -->
<talkaction words="!buyhouse" script="buyhouse.lua"/> <talkaction words="!buyhouse" script="buyhouse.lua"/>
@ -57,6 +58,7 @@
<talkaction words="!shop" script="znoteshop.lua"/> <talkaction words="!shop" script="znoteshop.lua"/>
<talkaction words="!physicaldamage" separator=" " script="physical_damage.lua"/> <talkaction words="!physicaldamage" separator=" " script="physical_damage.lua"/>
<talkaction words="!war" separator=" " script="war.lua"/> <talkaction words="!war" separator=" " script="war.lua"/>
<talkaction words="!vial" script="vial.lua"/>
<talkaction words="469" script="469.lua"/> <talkaction words="469" script="469.lua"/>
<!-- test talkactions --> <!-- test talkactions -->