forked from opentibiabr/canary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hazard system (opentibiabr#1091)
This modification introduces the implementation of the Hazard System. The Hazard System is an advanced game mechanic that offers players the opportunity to increase the difficulty and rewards of their hunts in Gnomprona. The system allows players to increase the hazard level of a hunt, which both increases the damage dealt by monsters and the amount of loot and experience rewards received. The hazard level is adjusted individually by players, but in a team, it's the lowest hazard level among the players that counts for the whole team. The benefits of increasing the hazard level include greater loot and experience, as well as a higher chance of spawning a Plunder Patriarch when killing a monster. However, with a higher hazard level, all damage dealt by monsters increases, as does the chance for monsters to land critical hits and dodge attacks. Furthermore, the chance of generating Primal Pods when killing a creature increases with a higher hazard level. Additionally, this modification also implements the mechanic associated with the "Primal Ordeal" quest, where players must defeat the boss "The Primal Menace" to increase hazard qualification. The recommended combat strategy includes focusing on the Primal Pack Beasts, and dealing with the threats of Primal Pods that can transform into the powerful Fungosaurus creature.
- Loading branch information
Showing
23 changed files
with
448 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
local hazardSystemStepPod = MoveEvent() | ||
|
||
function hazardSystemStepPod.onStepIn(creature, item, position, fromPosition) | ||
if not configManager.getBoolean(configKeys.TOGGLE_HAZARDSYSTEM) then | ||
item:remove() | ||
return | ||
end | ||
|
||
local player = creature:getPlayer() | ||
if not player then | ||
return | ||
end | ||
|
||
local timer = item:getCustomAttribute("HazardSystem_PodTimer") | ||
if timer then | ||
local timeMs = os.time() * 1000 | ||
timer = timeMs - timer | ||
if timer >= configManager.getNumber(configKeys.HAZARD_PODS_TIME_TO_DAMAGE) and timer < configManager.getNumber(configKeys.HAZARD_PODS_TIME_TO_SPAWN) then | ||
player:sendCancelMessage("You stepped too late on the primal pod and it explodes.") | ||
player:getPosition():sendMagicEffect(CONST_ME_ENERGYHIT) | ||
local damage = math.ceil((player:getMaxHealth() * configManager.getNumber(configKeys.HAZARD_PODS_DAMAGE)) / 100) | ||
local points = player:getHazardSystemPoints() | ||
if points ~= 0 then | ||
damage = math.ceil((damage * (100 + points)) / 100) | ||
end | ||
damage = damage + 500 | ||
doTargetCombatHealth(0, player, COMBAT_LIFEDRAIN, -damage, -damage, CONST_ME_DRAWBLOOD) | ||
end | ||
end | ||
|
||
item:remove() | ||
return true | ||
end | ||
|
||
hazardSystemStepPod:id(ITEM_PRIMAL_POD) | ||
hazardSystemStepPod:register() | ||
|
||
local SpawnHazardSystemFungosaurus = function(position) | ||
local tile = Tile(position) | ||
if tile then | ||
local podItem = tile:getItemById(ITEM_PRIMAL_POD) | ||
if podItem then | ||
local monster = Game.createMonster("Fungosaurus", position, false, true) | ||
if monster then | ||
monster:say("The primal pod explode and wild emerges from it.") | ||
end | ||
podItem:remove() | ||
end | ||
end | ||
end | ||
|
||
local hazardSystemSpawnPod = CreatureEvent("HazardSystemCombat") | ||
|
||
function hazardSystemSpawnPod.onKill(player, creature, lastHit) | ||
if not configManager.getBoolean(configKeys.TOGGLE_HAZARDSYSTEM) then | ||
return true | ||
end | ||
|
||
local monster = creature:getMonster() | ||
if not creature or not monster or not monster:isOnHazardSystem() then | ||
return true | ||
end | ||
|
||
local points = player:getHazardSystemPoints() | ||
if points > 0 then | ||
local party = player:getParty() | ||
if party then | ||
for _, member in ipairs(party:getMembers()) do | ||
if member and member:getHazardSystemPoints() < points then | ||
points = member:getHazardSystemPoints() | ||
end | ||
end | ||
|
||
local leader = party:getLeader() | ||
if leader and leader:getHazardSystemPoints() < points then | ||
points = leader:getHazardSystemPoints() | ||
end | ||
end | ||
end | ||
|
||
if points == 0 then | ||
return true | ||
end | ||
|
||
local chanceTo = math.random(1, 10000) | ||
if chanceTo <= (points * configManager.getNumber(configKeys.HAZARD_PODS_DROP_MULTIPLIER)) then | ||
local closesestPosition = player:getClosestFreePosition(monster:getPosition(), 4, true) | ||
local primalPod = Game.createItem(ITEM_PRIMAL_POD, 1, closesestPosition.x == 0 and monster:getPosition() or closesestPosition) | ||
if primalPod then | ||
primalPod:setCustomAttribute("HazardSystem_PodTimer", os.time() * 1000) | ||
local podPos = primalPod:getPosition() | ||
addEvent(SpawnHazardSystemFungosaurus, configManager.getNumber(configKeys.HAZARD_PODS_TIME_TO_SPAWN), podPos) | ||
end | ||
return true | ||
end | ||
|
||
chanceTo = math.random(1, 10000) | ||
if chanceTo <= (points * configManager.getNumber(configKeys.HAZARDSYSTEM_SPAWN_PLUNDER_MULTIPLIER)) then | ||
local closesestPosition = player:getClosestFreePosition(monster:getPosition(), 4, true) | ||
local monster = Game.createMonster("Plunder Patriarch", closesestPosition.x == 0 and monster:getPosition() or closesestPosition, false, true) | ||
if monster then | ||
monster:say("The Plunder Patriarch rises from the ashes.") | ||
end | ||
return true | ||
end | ||
|
||
return true | ||
end | ||
|
||
hazardSystemSpawnPod:register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.