Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed May 1, 2024
1 parent ebae39d commit e0e0e56
Show file tree
Hide file tree
Showing 31 changed files with 932 additions and 99 deletions.
3 changes: 2 additions & 1 deletion data-otxserver/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,8 @@ Storage = {
WarriorSkeleton = 52146,
DragonCounter = 52147,
},
QuestLine = 52148,
TheLostBrother = 52149,
},
DreamersChallenge = {
-- Reserved storage from 52160 - 52199
Expand Down Expand Up @@ -2534,7 +2536,6 @@ Storage = {
NightmareTeddy = {},
PoacherCavesMiniWorldChange = {},
TheGreatDragonHunt = {},
TheLostBrother = {},
TheTaintedSouls = {},
},
U10_90 = { -- update 10.90 - Reserved Storages 45201 - 45350
Expand Down
17 changes: 17 additions & 0 deletions data-otxserver/scripts/creaturescripts/others/login.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
local playerLogin = CreatureEvent("PlayerLogin")

function playerLogin.onLogin(player)
-- Premium Ends, change addon (citizen) houseless
if not player:isPremium() then
player:sendTextMessage(MESSAGE_FAILURE, "Your premium time has expired.")

if sex == 1 then
player:setOutfit({ lookType = 128, lookFeet = 114, lookLegs = 134, lookHead = 114, lookAddons = 0 })
elseif sex == 0 then
player:setOutfit({ lookType = 136, lookFeet = 114, lookLegs = 134, lookHead = 114, lookAddons = 0 })
end

if home and not player:isPremium() then
setHouseOwner(home, 0)
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "You've lost your house because you are not premium anymore.")
player:sendTextMessage(MESSAGE_GAME_HIGHLIGHT, "Your items from house are send to your inbox.")
end
end

-- Open channels
if table.contains({ TOWNS_LIST.DAWNPORT, TOWNS_LIST.DAWNPORT_TUTORIAL }, player:getTown():getId()) then
player:openChannel(3) -- World chat
Expand Down
36 changes: 22 additions & 14 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ local function useStaminaXpBoost(player)
return false
end

local staminaMinutes = player:getExpBoostStamina() / 60
if staminaMinutes == 0 then
local xpBoostMinutes = player:getXpBoostTime() / 60
if xpBoostMinutes == 0 then
return
end

Expand All @@ -156,18 +156,26 @@ local function useStaminaXpBoost(player)
return
end

local xpBoostLeftMinutesByDailyReward = player:kv():get("daily-reward-xp-boost") or 0
if timePassed > 60 then
if staminaMinutes > 2 then
staminaMinutes = staminaMinutes - 2
if xpBoostMinutes > 2 then
xpBoostMinutes = xpBoostMinutes - 2
if xpBoostLeftMinutesByDailyReward > 2 then
player:kv():set("daily-reward-xp-boost", xpBoostLeftMinutesByDailyReward - 2)
end
else
staminaMinutes = 0
xpBoostMinutes = 0
player:kv():remove("daily-reward-xp-boost")
end
_G.NextUseXpStamina[playerId] = currentTime + 120
else
staminaMinutes = staminaMinutes - 1
xpBoostMinutes = xpBoostMinutes - 1
if xpBoostLeftMinutesByDailyReward > 0 then
player:kv():set("daily-reward-xp-boost", xpBoostLeftMinutesByDailyReward - 1)
end
_G.NextUseXpStamina[playerId] = currentTime + 60
end
player:setExpBoostStamina(staminaMinutes * 60)
player:setXpBoostTime(xpBoostMinutes * 60)
end

local function useConcoctionTime(player)
Expand Down Expand Up @@ -483,14 +491,14 @@ function Player:onGainExperience(target, exp, rawExp)
self:addCondition(soulCondition)
end

-- Store Bonus
useStaminaXpBoost(self) -- Use store boost stamina
-- XP Boost Bonus
useStaminaXpBoost(self) -- Use stamina XP boost (store or daily reward)

local Boost = self:getExpBoostStamina()
local stillHasBoost = Boost > 0
local storeXpBoostAmount = stillHasBoost and self:getStoreXpBoost() or 0
local xpBoostTimeLeft = self:getXpBoostTime()
local stillHasXpBoost = xpBoostTimeLeft > 0
local xpBoostPercent = stillHasXpBoost and self:getXpBoostPercent() or 0

self:setStoreXpBoost(storeXpBoostAmount)
self:setXpBoostPercent(xpBoostPercent)

-- Stamina Bonus
local staminaBonusXp = 1
Expand Down Expand Up @@ -528,7 +536,7 @@ function Player:onGainExperience(target, exp, rawExp)
local lowLevelBonuxExp = self:getFinalLowLevelBonus()
local baseRate = self:getFinalBaseRateExperience()

return (exp + (exp * (storeXpBoostAmount / 100) + (exp * (lowLevelBonuxExp / 100)))) * staminaBonusXp * baseRate
return (exp + (exp * (xpBoostPercent / 100) + (exp * (lowLevelBonuxExp / 100)))) * staminaBonusXp * baseRate
end

function Player:onLoseExperience(exp)
Expand Down
15 changes: 13 additions & 2 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,38 @@ end

function getTimeInWords(secsParam)
local secs = tonumber(secsParam)
local days = math.floor(secs / (24 * 3600))
secs = secs - (days * 24 * 3600)
local hours, minutes, seconds = getHours(secs), getMinutes(secs), getSeconds(secs)
local timeStr = ""

if days > 0 then
timeStr = days .. (days > 1 and " days" or " day")
end

if hours > 0 then
timeStr = hours .. (hours > 1 and " hours" or " hour")
if timeStr ~= "" then
timeStr = timeStr .. ", "
end

timeStr = timeStr .. hours .. (hours > 1 and " hours" or " hour")
end

if minutes > 0 then
if timeStr ~= "" then
timeStr = timeStr .. ", "
end

timeStr = timeStr .. minutes .. (minutes > 1 and " minutes" or " minute")
end

if seconds > 0 then
if timeStr ~= "" then
timeStr = timeStr .. " and "
end

timeStr = timeStr .. seconds .. (seconds > 1 and " seconds" or " second")
end

return timeStr
end

Expand Down
11 changes: 9 additions & 2 deletions data/modules/scripts/daily_reward/daily_reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,15 @@ function Player.selectDailyReward(self, msg)
end
dailyRewardMessage = "Picked items: " .. description
elseif dailyTable.type == DAILY_REWARD_TYPE_XP_BOOST then
self:setExpBoostStamina(self:getExpBoostStamina() + (rewardCount * 60))
self:setStoreXpBoost(50)
local rewardCountReviewed = rewardCount
local xpBoostLeftMinutes = self:kv():get("daily-reward-xp-boost") or 0
if xpBoostLeftMinutes > 0 then
rewardCountReviewed = rewardCountReviewed - xpBoostLeftMinutes
end

self:setXpBoostTime(self:getXpBoostTime() + (rewardCountReviewed * 60))
self:kv():set("daily-reward-xp-boost", rewardCount)
self:setXpBoostPercent(50)
dailyRewardMessage = "Picked reward: XP Bonus for " .. rewardCount .. " minutes."
elseif dailyTable.type == DAILY_REWARD_TYPE_PREY_REROLL then
self:addPreyCards(rewardCount)
Expand Down
12 changes: 6 additions & 6 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function parseBuyStoreOffer(playerId, msg)
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_SEXCHANGE then
GameStore.processSexChangePurchase(player)
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_EXPBOOST then
GameStore.processExpBoostPuchase(player)
GameStore.processExpBoostPurchase(player)
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_HUNTINGSLOT then
GameStore.processTaskHuntingThirdSlot(player)
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_PREYSLOT then
Expand Down Expand Up @@ -732,7 +732,7 @@ function Player.canBuyOffer(self, offer)
disabled = 1
disabledReason = "You can't buy XP Boost for today."
end
if self:getExpBoostStamina() > 0 then
if self:getXpBoostTime() > 0 then
disabled = 1
disabledReason = "You already have an active XP boost."
end
Expand Down Expand Up @@ -1742,12 +1742,12 @@ function GameStore.processSexChangePurchase(player)
player:toggleSex()
end

function GameStore.processExpBoostPuchase(player)
local currentExpBoostTime = player:getExpBoostStamina()
function GameStore.processExpBoostPurchase(player)
local currentXpBoostTime = player:getXpBoostTime()
local expBoostCount = player:getStorageValue(GameStore.Storages.expBoostCount)

player:setStoreXpBoost(50)
player:setExpBoostStamina(currentExpBoostTime + 3600)
player:setXpBoostPercent(50)
player:setXpBoostTime(currentXpBoostTime + 3600)

if expBoostCount == -1 or expBoostCount == 6 then
expBoostCount = 1
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/actions/items/exercise_training_weapons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ end
local exerciseTraining = Action()

function exerciseTraining.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:getId() then
if not target or type(target) == "table" or not target:getId() then
return true
end

Expand Down
8 changes: 8 additions & 0 deletions data/scripts/spells/house/kick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ function spell.onCastSpell(player, variant)
local targetPlayer = Player(variant:getString()) or player
local guest = targetPlayer:getTile():getHouse()
local owner = player:getTile():getHouse()

-- Owner kick yourself from house
if targetPlayer == player then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:teleportTo(owner:getExitPosition())
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end

if not owner:canEditAccessList(GUEST_LIST, player) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

if not owner or not guest or not guest:kickPlayer(player, targetPlayer) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
Expand Down
11 changes: 11 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vcproj/
tests/
docs/
docker/

sonar-project.properties
*.md
Jenkinsfile
.*
gdb_debug
client_assertions.txt
25 changes: 25 additions & 0 deletions docker/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Mariadb
MYSQL_DATABASE=otservbr-global
MYSQL_USER=otxserver
MYSQL_PASSWORD=otxserver
MYSQL_ROOT_PASSWORD=root

# Login
LOGIN_HTTP_PORT=8080
LOGIN_GRPC_PORT=9090
MYSQL_HOST=database
MYSQL_PORT=3306
MYSQL_DBNAME=otservbr-global
MYSQL_USER=otxserver
MYSQL_PASS=otxserver
SERVER_NAME=OTServBR-Global
SERVER_IP=127.0.0.1
SERVER_PORT=7172
SERVER_LOCATION=BRA
RATE_LIMITER_RATE=2
RATE_LIMITER_BURST=5

# Server
toggleDownloadMap=false
statusProtocolPort=7171
gameProtocolPort=7172
37 changes: 37 additions & 0 deletions docker/DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Getting Started with docker

## - Requirements
- Docker 19 and docker-compose 1.17
- Execute the script root directory /docker/data/download-myaac.sh
- To use global ip change the login.py on world to use that ip and
also change in config.lua.dist
- Client pointing to http://<ip>:8080/login.php

### Default Values (docker-compose.yml)
- Ports: 7171, 7172, 80(web), 3306, 8080(login)
- Database Server: database
- Database Name/User/Password: otserver

### - Commands
To compile and start database, webserver and otserver just run
```
$ docker-compose up -d
```
Sometimes the server will not start due to database take too long to start
so you can restart it
```
docker-compose restart otserver
or
docker-compose stop otserver
docker-compose start otserver
```

To compile your changes in otserver, just stop and start
```
$ docker-compose up -d --build otserver
```

### - Observations
- The data folder persist db and webserver data;
55 changes: 55 additions & 0 deletions docker/Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Stage 1: Download all dependencies
FROM ubuntu:23.04 AS dependencies

RUN apt-get update && apt-get install -y --no-install-recommends cmake git \
unzip build-essential ca-certificates curl zip unzip tar \
pkg-config ninja-build autoconf automake libtool libluajit-5.1-dev libluajit-5.1-common \
python3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt
COPY vcpkg.json /opt
RUN vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') \
&& echo "vcpkg commit ID: $vcpkgCommitId" \
&& git clone https://github.com/Microsoft/vcpkg.git \
&& cd vcpkg \
&& git checkout $vcpkgCommitId \
&& ./bootstrap-vcpkg.sh

WORKDIR /opt/vcpkg
COPY vcpkg.json /opt/vcpkg/
RUN VCPKG_FORCE_SYSTEM_BINARIES=1 /opt/vcpkg/vcpkg --feature-flags=binarycaching,manifests,versions install

# Stage 2: create build
FROM dependencies AS build

COPY . /srv/
WORKDIR /srv

RUN export VCPKG_ROOT=/opt/vcpkg/ && VCPKG_FORCE_SYSTEM_BINARIES=1 cmake --preset linux-release && cmake --build --preset linux-release

# Stage 3: load data and execute
FROM ubuntu:23.04

VOLUME [ "/data" ]

COPY --from=build /srv/build/linux-release/bin/otxserver /bin/otxserver
COPY LICENSE *.sql key.pem /otxserver/
COPY data /otxserver/data
COPY data-otxserver /otxserver/data-otxserver
COPY data-otservbr-global /otxserver/data-otservbr-global
COPY config.lua.dist /otxserver/config.lua

WORKDIR /otxserver

RUN apt-get update && apt-get install -y --no-install-recommends \
mariadb-client libluajit-5.1-dev libluajit-5.1-common wget curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY docker/data/01-test_account.sql 01-test_account.sql
COPY docker/data/02-test_account_players.sql 02-test_account_players.sql
COPY docker/data/start.sh start.sh

ENTRYPOINT ["/otxserver/start.sh"]
Loading

0 comments on commit e0e0e56

Please sign in to comment.