Skip to content

Commit

Permalink
Nokturno's fix and onAttack missiles (instead of onHit)
Browse files Browse the repository at this point in the history
Now if more than one ITEM_SLOT_TYPE add skills it won't bug. Also onHit events wasn't working well, because of this, I decided to switch to onAttack method and works well (already tested).
  • Loading branch information
ralke23 committed Oct 4, 2023
1 parent 828c5cc commit f72b792
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 53 deletions.
60 changes: 30 additions & 30 deletions scripts/UpgradeSystem/config.lua
Expand Up @@ -179,98 +179,98 @@ US_ENCHANTMENTS = {
},

[7] = {
name = "Flame Strike on Hit",
name = "Flame Strike on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_FIRE)
doTargetCombatHealth(attacker:getId(), target, COMBAT_FIREDAMAGE, 1, damage, CONST_ME_FIREATTACK, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Flame Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Flame Strike on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE + US_ITEM_TYPES.WEAPON_MELEE + US_ITEM_TYPES.WEAPON_WAND
},
[8] = {
name = "Ice Strike on Hit",
name = "Ice Strike on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_SMALLICE)
doTargetCombatHealth(attacker:getId(), target, COMBAT_ICEDAMAGE, 1, damage, CONST_ME_ICEATTACK, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Ice Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Ice Strike on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE + US_ITEM_TYPES.WEAPON_WAND
},
[9] = {
name = "Terra Strike on Hit",
name = "Terra Strike on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_SMALLEARTH)
doTargetCombatHealth(attacker:getId(), target, COMBAT_EARTHDAMAGE, 1, damage, CONST_ME_CARNIPHILA, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Terra Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Terra Strike on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE + US_ITEM_TYPES.WEAPON_WAND
},
[10] = {
name = "Death Strike on Hit",
name = "Death Strike on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_DEATH)
doTargetCombatHealth(attacker:getId(), target, COMBAT_DEATHDAMAGE, 1, damage, CONST_ME_MORTAREA, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Death Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Death Strike on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE + US_ITEM_TYPES.WEAPON_WAND
},
[11] = {
name = "Divine Missile on Hit",
name = "Divine Missile on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_SMALLHOLY)
doTargetCombatHealth(attacker:getId(), target, COMBAT_HOLYDAMAGE, 1, damage, CONST_ME_HOLYDAMAGE, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Divine Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Divine Missile on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.WEAPON_DISTANCE
},
[12] = {
name = "Energy Strike on Hit",
name = "Energy Strike on Attack",
combatType = US_TYPES.TRIGGER,
triggerType = US_TRIGGERS.HIT,
VALUES_PER_LEVEL = 1,
triggerType = US_TRIGGERS.ATTACK,
VALUES_PER_LEVEL = 2.5,
execute = function(attacker, target, damage)
if math.random(100) < 25 then
if math.random(100) < 100 then
attacker:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_ENERGY)
doTargetCombatHealth(attacker:getId(), target, COMBAT_ENERGYDAMAGE, 1, damage, CONST_ME_ENERGYAREA, ORIGIN_CONDITION)
end
end,
format = function(value)
return "25%% chance to reflect or cast Energy Hit dealing 1-" .. value .. " damage on combat"
return "20%% to cast Energy Strike on Attack dealing 1-" .. value .. " damage"
end,
itemType = US_ITEM_TYPES.RING + US_ITEM_TYPES.NECKLACE + US_ITEM_TYPES.WEAPON_WAND
},
Expand Down
45 changes: 22 additions & 23 deletions scripts/UpgradeSystem/core.lua
Expand Up @@ -4,7 +4,7 @@ print(">> Loading upgrade system v" .. UPGRADE_SYSTEM_VERSION)
US_CONDITIONS = {}
US_BUFFS = {}

local US_SUBID = {}
US_SUBID = {}

local TargetCombatEvent = EventCallback
TargetCombatEvent.onTargetCombat = function(creature, target)
Expand Down Expand Up @@ -98,6 +98,12 @@ function us_onEquip(cid, iuid, slot)
end
end
end
addEvent(function(pid)
local player = Player(pid)
if player then
us_onLogin(player)
end
end, 10, player:getId())
end

local MoveItemEvent = EventCallback
Expand Down Expand Up @@ -126,12 +132,9 @@ MoveItemEvent.onMoveItem = function(player, item, count, fromPosition, toPositio
end
end

if toPosition.y <= CONST_SLOT_AMMO then
if toPosition.y ~= CONST_SLOT_BACKPACK then
if fromPosition.y >= 64 or fromPosition.x ~= CONTAINER_POSITION then
-- remove old
local oldItem = player:getSlotItem(toPosition.y)
if oldItem then
for slotItem=CONST_SLOT_HEAD, CONST_SLOT_AMMO do
local oldItem = player:getSlotItem(slotItem)
if oldItem then
if oldItem:getType():isUpgradable() then
local oldBonuses = oldItem:getBonusAttributes()
if oldBonuses then
Expand All @@ -152,22 +155,18 @@ MoveItemEvent.onMoveItem = function(player, item, count, fromPosition, toPositio
end
end
end
end
end
end
end
end
-- apply new
if item:getType():isUpgradable() then
local newBonuses = item:getBonusAttributes()
if newBonuses then
addEvent(us_onEquip, 10, player:getId(), item:getUniqueId(), toPosition.y)
end
end
end
end
end

end
end
end
end
end
end
addEvent(function(pid)
local player = Player(pid)
if player then
us_onLogin(player)
end
end, 10, player:getId())
return true
end
MoveItemEvent:register()
Expand Down

0 comments on commit f72b792

Please sign in to comment.