Skip to content

Commit

Permalink
Merge branch 'main' into fix/improvement-creature-events
Browse files Browse the repository at this point in the history
  • Loading branch information
luan authored Oct 16, 2023
2 parents e342c8a + 7ce2982 commit 8589f71
Show file tree
Hide file tree
Showing 61 changed files with 426 additions and 249 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ source of the Canary, so that it will be the first repository to use this engine
To connect to the server and to take a stable experience, you can
use [mehah's otclient](https://github.com/mehah/otclient)
or [tibia client](https://github.com/dudantas/tibia-client/releases/latest) and if you want to edit something, check
our [customized tools](https://docs.opentibiabr.com/others/downloads/tools).
our [customized tools](https://docs.opentibiabr.com/opentibiabr/downloads/tools).

If you want edit the map, use the [own remere's map editor](https://github.com/opentibiabr/remeres-map-editor/).

Expand Down
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ onlyPremiumAccount = false
-- NOTE: buyAolCommandFee will add fee when player buy aol by command (!aol), active changing value more than 0 (fee value. ex: 1 = 1gp aol will be 50001)
-- NOTE: buyBlessCommandFee will add fee when player buy bless by command (!bless), active changing value between 1 and 100 (fee percent. ex: 3 = 3%, 30 = 30%)
-- NOTE: teleportPlayerToVocationRoom will enable oressa to teleport player to his/her room vocation
-- NOTE: toggleReceiveReward = true, will enable players to choose one of reward exercise weapon by command !reward
weatherRain = false
thunderEffect = false
allConsoleLog = false
Expand All @@ -200,6 +201,7 @@ toggleTravelsFree = false
buyAolCommandFee = 0
buyBlessCommandFee = 0
teleportPlayerToVocationRoom = true
toggleReceiveReward = false

-- Teleport summon
-- Set to true will never remove the summon
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Storage = {
PremiumAccount = 30058,
BattleAxeQuest = 30059,
ShrineEntrance = 30060,

PlayerWeaponReward = 30061,
--[[
Old storages
Over time, this will be dropped and replaced by the table above
Expand Down
110 changes: 110 additions & 0 deletions data-otservbr-global/monster/bosses/doctor_marrow.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
local mType = Game.createMonsterType("Doctor Marrow")
local monster = {}

monster.description = "Doctor Marrow"
monster.experience = 0
monster.outfit = {
lookType = 1611,
lookHead = 57,
lookBody = 0,
lookLegs = 0,
lookFeet = 95,
lookAddons = 0,
lookMount = 0,
}

monster.health = 1800
monster.maxHealth = 1800
monster.race = "blood"
monster.corpse = 18074
monster.speed = 125
monster.manaCost = 0

monster.changeTarget = {
interval = 4000,
chance = 10,
}

monster.strategiesTarget = {
nearest = 80,
health = 10,
damage = 10,
}

monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
critChance = 10,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true,
}

monster.light = {
level = 0,
color = 0,
}

monster.voices = {
interval = 5000,
chance = 10,
{ text = "You can't stop the future!", yell = false },
}

monster.attacks = {
{ name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -2800 },
}

monster.defenses = {
defense = 54,
armor = 59,
mitigation = 3.7,
}

monster.elements = {
{ type = COMBAT_PHYSICALDAMAGE, percent = 0 },
{ type = COMBAT_ENERGYDAMAGE, percent = 0 },
{ type = COMBAT_EARTHDAMAGE, percent = 0 },
{ type = COMBAT_FIREDAMAGE, percent = 0 },
{ type = COMBAT_LIFEDRAIN, percent = 0 },
{ type = COMBAT_MANADRAIN, percent = 0 },
{ type = COMBAT_DROWNDAMAGE, percent = 0 },
{ type = COMBAT_ICEDAMAGE, percent = 0 },
{ type = COMBAT_HOLYDAMAGE, percent = 0 },
{ type = COMBAT_DEATHDAMAGE, percent = 0 },
}

monster.immunities = {
{ type = "paralyze", condition = true },
{ type = "outfit", condition = false },
{ type = "invisible", condition = true },
{ type = "bleed", condition = false },
}

mType.onThink = function(monster, interval) end

mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end

mType.onDisappear = function(monster, creature) end

mType.onMove = function(monster, creature, fromPosition, toPosition) end

mType.onSay = function(monster, creature, type, message) end

mType:register(monster)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local winReward = CreatureEvent("WinReward")

function winReward.onLogin(player)
if configManager.getBoolean(configKeys.TOGGLE_RECEIVE_REWARD) and player:getTown():getId() >= TOWNS_LIST.AB_DENDRIEL then
-- check user won exercise weapon and send message
if player:getStorageValue(tonumber(Storage.PlayerWeaponReward)) ~= 1 then
player:sendTextMessage(MESSAGE_LOGIN, "You can receive an exercise weapon using command !reward")
end
end
return true
end

winReward:register()
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function theirmastersvoice.onStartup()
if item then
local slimeChance = math.random(100)
if slimeChance <= 30 then
item:transform(math.random(13585, 13589))
item:transform(math.random(12059, 12063))
position:sendMagicEffect(CONST_ME_YELLOW_RINGS)
end
end
Expand Down
3 changes: 3 additions & 0 deletions data-otservbr-global/scripts/lib/register_monster_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ registerMonsterType.flags = function(mtype, mask)
if mask.flags.canPushCreatures ~= nil then
mtype:canPushCreatures(mask.flags.canPushCreatures)
end
if mask.flags.critChance ~= nil then
mtype:critChance(mask.flags.critChance)
end
if mask.flags.targetDistance then
mtype:targetDistance(math.max(1, mask.flags.targetDistance))
end
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified data-otservbr-global/world/world_changes/fury_gates/carlin.otbm
Binary file not shown.
Binary file not shown.
Binary file modified data-otservbr-global/world/world_changes/fury_gates/edron.otbm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified data-otservbr-global/world/world_changes/fury_gates/thais.otbm
Binary file not shown.
Binary file modified data-otservbr-global/world/world_changes/fury_gates/venore.otbm
Binary file not shown.
7 changes: 5 additions & 2 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ function Player:onMoveCreature(creature, fromPosition, toPosition)
end

local function hasPendingReport(name, targetName, reportType)
name = self:getName():gsub("%s+", "_")
FS.mkdir_p(string.format("%s/reports/players/%s", CORE_DIRECTORY, name))
local file = io.open(string.format("%s/reports/players/%s-%s-%d.txt", CORE_DIRECTORY, name, targetName, reportType), "r")
if file then
io.close(file)
Expand All @@ -407,7 +409,7 @@ local function hasPendingReport(name, targetName, reportType)
end

function Player:onReportRuleViolation(targetName, reportType, reportReason, comment, translation)
local name = self:getName()
name = self:getName()
if hasPendingReport(name, targetName, reportType) then
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your report is being processed.")
return
Expand Down Expand Up @@ -444,7 +446,8 @@ function Player:onReportRuleViolation(targetName, reportType, reportReason, comm
end

function Player:onReportBug(message, position, category)
local name = self:getName()
local name = self:getName():gsub("%s+", "_")
FS.mkdir_p(string.format("%s/reports/bugs/%s", CORE_DIRECTORY, name))
local file = io.open(string.format("%s/reports/bugs/%s/report.txt", CORE_DIRECTORY, name), "a")

if not file then
Expand Down
1 change: 0 additions & 1 deletion data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15098,7 +15098,6 @@
</item>
<item fromid="6116" toid="6117" name="electric sparks">
<attribute key="primarytype" value="walls"/>
<attribute key="blocking" value="1"/>
<attribute key="blockProjectile" value="1"/>
</item>
<item id="6118" article="a" name="treasure map">
Expand Down
32 changes: 32 additions & 0 deletions data/libs/functions/fs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FS = {}

function FS.exists(path)
local file = io.open(path, "r")
if file then
file:close()
return true
end
return false
end

function FS.mkdir(path)
if FS.exists(path) then
return true
end
local success, err = os.execute('mkdir "' .. path .. '"')
if not success then
return false, err
end
return true
end

function FS.mkdir_p(path)
if path == "" then
return true
end
if FS.exists(path) then
return true
end
FS.mkdir_p(path:match("(.*[/\\])"))
return FS.mkdir(path)
end
1 change: 1 addition & 0 deletions data/libs/functions/load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dofile(CORE_DIRECTORY .. "/libs/functions/constants.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/container.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/creature.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/functions.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/fs.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/game.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/item.lua")
dofile(CORE_DIRECTORY .. "/libs/functions/itemtype.lua")
Expand Down
65 changes: 65 additions & 0 deletions data/scripts/talkactions/player/reward.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
local config = {
items = {
{ id = 35284, charges = 64000 },
{ id = 35279, charges = 64000 },
{ id = 35281, charges = 64000 },
{ id = 35283, charges = 64000 },
{ id = 35282, charges = 64000 },
{ id = 35280, charges = 64000 },
},
storage = tonumber(Storage.PlayerWeaponReward), -- storage key, player can only win once
}

local function sendExerciseRewardModal(player)
local window = ModalWindow({
title = "Exercise Reward",
message = "choose a item",
})
for _, it in pairs(config.items) do
local iType = ItemType(it.id)
if iType then
window:addChoice(iType:getName(), function(player, button, choice)
if button.name ~= "Select" then
return true
end

local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
if inbox and inbox:getEmptySlots() > 0 then
local item = inbox:addItem(it.id, it.charges)
if item then
item:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
else
player:sendTextMessage(MESSAGE_LOOK, "You need to have capacity and empty slots to receive.")
return
end
player:sendTextMessage(MESSAGE_LOOK, string.format("Congratulations, you received a %s with %i charges in your store inbox.", iType:getName(), it.charges))
player:setStorageValue(config.storage, 1)
else
player:sendTextMessage(MESSAGE_LOOK, "You need to have capacity and empty slots to receive.")
end
end)
end
end
window:addButton("Select")
window:addButton("Close")
window:setDefaultEnterButton(0)
window:setDefaultEscapeButton(1)
window:sendToPlayer(player)
end

local exerciseRewardModal = TalkAction("!reward")
function exerciseRewardModal.onSay(player, words, param)
if not configManager.getBoolean(configKeys.TOGGLE_RECEIVE_REWARD) or player:getTown():getId() < TOWNS_LIST.AB_DENDRIEL then
return true
end
if player:getStorageValue(config.storage) > 0 then
player:sendTextMessage(MESSAGE_LOOK, "You already received your exercise weapon reward!")
return true
end
sendExerciseRewardModal(player)
return true
end

exerciseRewardModal:separator(" ")
exerciseRewardModal:groupType("normal")
exerciseRewardModal:register()
2 changes: 2 additions & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ enum booleanConfig_t {
TOGGLE_MOUNT_IN_PZ,
TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART,

TOGGLE_RECEIVE_REWARD,

LAST_BOOLEAN_CONFIG
};

Expand Down
3 changes: 2 additions & 1 deletion src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "config/configmanager.hpp"
#include "declarations.hpp"
#include "game/game.hpp"
#include "lua/scripts/luajit_sync.hpp"
#include "server/network/webhook/webhook.hpp"

#if LUA_VERSION_NUM >= 502
Expand Down Expand Up @@ -393,6 +392,8 @@ bool ConfigManager::load() {

boolean[TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART] = getGlobalBoolean(L, "togglehouseTransferOnRestart", false);

boolean[TOGGLE_RECEIVE_REWARD] = getGlobalBoolean(L, "toggleReceiveReward", false);

loaded = true;
lua_close(L);
return true;
Expand Down
Loading

0 comments on commit 8589f71

Please sign in to comment.