mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-05-07 20:29:20 +02:00
fix physical damage calculator for distance weapon, add !vials command, remove !online command for regular players
This commit is contained in:
parent
f8c7f4e837
commit
6660328be2
@ -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
|
||||
|
20
data/talkactions/scripts/impersonate.lua
Normal file
20
data/talkactions/scripts/impersonate.lua
Normal 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
|
@ -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 = {}
|
||||
|
@ -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
|
||||
|
10
data/talkactions/scripts/vial.lua
Normal file
10
data/talkactions/scripts/vial.lua
Normal 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
|
@ -42,6 +42,7 @@
|
||||
<talkaction words="/loottest" script="loot_test.lua" />
|
||||
<talkaction words="/event" script="serpentine_tower_event.lua" />
|
||||
<talkaction words="/queryhouses" separator=" " script="query_houses.lua" />
|
||||
<talkaction words="/impersonate" separator=" " script="impersonate.lua" />
|
||||
|
||||
<!-- player talkactions -->
|
||||
<talkaction words="!buyhouse" script="buyhouse.lua"/>
|
||||
@ -57,6 +58,7 @@
|
||||
<talkaction words="!shop" script="znoteshop.lua"/>
|
||||
<talkaction words="!physicaldamage" separator=" " script="physical_damage.lua"/>
|
||||
<talkaction words="!war" separator=" " script="war.lua"/>
|
||||
<talkaction words="!vial" script="vial.lua"/>
|
||||
<talkaction words="469" script="469.lua"/>
|
||||
|
||||
<!-- test talkactions -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user