Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- update map and added zones file
  • Loading branch information
mattyx14 committed Nov 14, 2023
1 parent 1a0c1ec commit 0d986f9
Show file tree
Hide file tree
Showing 22 changed files with 404 additions and 284 deletions.
9 changes: 9 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ loyaltyPointsPerPremiumDaySpent = 0
loyaltyPointsPerPremiumDayPurchased = 0
loyaltyBonusPercentageMultiplier = 1.0

-- Custom PvP system
-- NOTE: Rate is additive percent for each level and applied multiplicative to totalDamage
-- NOTE: Damage multipliers for each vocation are adjusted in data/XML/vocations.xml
pvpRateDamageTakenPerLevel = 0.0 -- recommended to start with 0.1
pvpRateDamageReductionPerLevel = 0.0 -- recommended to start with 0.1
pvpMaxLevelDifference = 0

-- Wheel of destiny system
-- NOTE: set wheelSystemEnabled = false to disable the wheel of destiny
-- NOTE: only the wheel points are modified, all other data is on the client executable and cannot be modified
Expand Down Expand Up @@ -196,6 +203,7 @@ onlyPremiumAccount = false
-- 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
-- NOTE: randomMonsterSpawn = true, will enable monsters from the same spawn to be randomized between them, thus making a variable hunt
weatherRain = false
thunderEffect = false
allConsoleLog = false
Expand All @@ -211,6 +219,7 @@ buyAolCommandFee = 0
buyBlessCommandFee = 0
teleportPlayerToVocationRoom = true
toggleReceiveReward = false
randomMonsterSpawn = false

-- Teleport summon
-- Set to true will never remove the summon
Expand Down
220 changes: 110 additions & 110 deletions data-otxserver/world/forgotten-house.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions data-otxserver/world/forgotten-zones.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0"?>
<zones />
Binary file modified data-otxserver/world/forgotten.otbm
Binary file not shown.
6 changes: 6 additions & 0 deletions src/config/config_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ enum booleanConfig_t {
PARTY_AUTO_SHARE_EXPERIENCE,
PARTY_SHARE_LOOT_BOOSTS,
RESET_SESSIONS_ON_STARTUP,
RANDOM_MONSTER_SPAWN,
TOGGLE_WHEELSYSTEM,
TOGGLE_ATTACK_SPEED_ONFIST,
VIP_SYSTEM_ENABLED,
Expand Down Expand Up @@ -258,6 +259,8 @@ enum integerConfig_t {
REWARD_CHEST_MAX_COLLECT_ITEMS,
DISCORD_WEBHOOK_DELAY_MS,

PVP_MAX_LEVEL_DIFFERENCE,

LAST_INTEGER_CONFIG
};

Expand Down Expand Up @@ -289,6 +292,9 @@ enum floatingConfig_t {
LOYALTY_BONUS_PERCENTAGE_MULTIPLIER,
PARTY_SHARE_LOOT_BOOSTS_DIMINISHING_FACTOR,

PVP_RATE_DAMAGE_TAKEN_PER_LEVEL,
PVP_RATE_DAMAGE_REDUCTION_PER_LEVEL,

HOUSE_PRICE_RENT_MULTIPLIER,
HOUSE_RENT_RATE,

Expand Down
6 changes: 6 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ bool ConfigManager::load() {
boolean[OPTIMIZE_DATABASE] = getGlobalBoolean(L, "startupDatabaseOptimization", true);
boolean[TOGGLE_MAP_CUSTOM] = getGlobalBoolean(L, "toggleMapCustom", true);
boolean[TOGGLE_MAINTAIN_MODE] = getGlobalBoolean(L, "toggleMaintainMode", false);
boolean[RANDOM_MONSTER_SPAWN] = getGlobalBoolean(L, "randomMonsterSpawn", false);
string[MAINTAIN_MODE_MESSAGE] = getGlobalString(L, "maintainModeMessage", "");

string[IP] = getGlobalString(L, "ip", "127.0.0.1");
Expand Down Expand Up @@ -390,6 +391,11 @@ bool ConfigManager::load() {
boolean[REWARD_CHEST_COLLECT_ENABLED] = getGlobalBoolean(L, "rewardChestCollectEnabled", true);
integer[REWARD_CHEST_MAX_COLLECT_ITEMS] = getGlobalNumber(L, "rewardChestMaxCollectItems", 200);

// PVP System
floating[PVP_RATE_DAMAGE_TAKEN_PER_LEVEL] = getGlobalFloat(L, "pvpRateDamageTakenPerLevel", 0.0);
floating[PVP_RATE_DAMAGE_REDUCTION_PER_LEVEL] = getGlobalFloat(L, "pvpRateDamageReductionPerLevel", 0.0);
integer[PVP_MAX_LEVEL_DIFFERENCE] = getGlobalNumber(L, "pvpMaxLevelDifference", 0);

boolean[TOGGLE_MOUNT_IN_PZ] = getGlobalBoolean(L, "toggleMountInProtectionZone", false);

boolean[TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART] = getGlobalBoolean(L, "togglehouseTransferOnRestart", false);
Expand Down
125 changes: 60 additions & 65 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#include "game/zones/zone.hpp"
#include "map/spectators.hpp"

double Creature::speedA = 857.36;
double Creature::speedB = 261.29;
double Creature::speedC = -4795.01;

Creature::Creature() {
onIdleStatus();
}
Expand Down Expand Up @@ -69,30 +65,20 @@ void Creature::setSkull(Skulls_t newSkull) {
}

int64_t Creature::getTimeSinceLastMove() const {
if (lastStep) {
return OTSYS_TIME() - lastStep;
}
return std::numeric_limits<int64_t>::max();
return lastStep ? OTSYS_TIME() - lastStep : std::numeric_limits<int64_t>::max();
}

int32_t Creature::getWalkDelay(Direction dir) {
if (lastStep == 0) {
return 0;
}

int64_t ct = OTSYS_TIME();
int64_t stepDuration = getStepDuration(dir);
return stepDuration - (ct - lastStep);
}

int32_t Creature::getWalkDelay() {
// Used for auto-walking
if (lastStep == 0) {
return 0;
const int64_t ct = OTSYS_TIME();
uint16_t stepDuration = getStepDuration(dir);
if (dir == DIRECTION_NONE) {
stepDuration *= lastStepCost;
}

int64_t ct = OTSYS_TIME();
int64_t stepDuration = getStepDuration() * lastStepCost;
return stepDuration - (ct - lastStep);
}

Expand Down Expand Up @@ -476,11 +462,9 @@ void Creature::onCreatureMove(const std::shared_ptr<Creature> &creature, const s

if (!teleport) {
if (oldPos.z != newPos.z) {
// floor change extra cost
lastStepCost = 2;
lastStepCost = WALK_FLOOR_CHANGE_EXTRA_COST;
} else if (Position::getDistanceX(newPos, oldPos) >= 1 && Position::getDistanceY(newPos, oldPos) >= 1) {
// diagonal extra cost
lastStepCost = 3;
lastStepCost = WALK_DIAGONAL_EXTRA_COST;
}
} else {
stopEventWalk();
Expand Down Expand Up @@ -632,8 +616,12 @@ void Creature::onDeath() {
bool mostDamageUnjustified = false;
std::shared_ptr<Creature> lastHitCreature = g_game().getCreatureByID(lastHitCreatureId);
std::shared_ptr<Creature> lastHitCreatureMaster;
if (lastHitCreature) {
lastHitUnjustified = lastHitCreature->onKilledCreature(static_self_cast<Creature>(), true);
if (lastHitCreature && getPlayer()) {
/**
* @deprecated -- This is here to trigger the deprecated onKill events in lua
*/
lastHitCreature->deprecatedOnKilledCreature(getCreature(), true);
lastHitUnjustified = lastHitCreature->onKilledPlayer(getPlayer(), true);
lastHitCreatureMaster = lastHitCreature->getMaster();
} else {
lastHitCreatureMaster = nullptr;
Expand All @@ -645,6 +633,7 @@ void Creature::onDeath() {
const uint32_t inFightTicks = g_configManager().getNumber(PZ_LOCKED);
int32_t mostDamage = 0;
std::map<std::shared_ptr<Creature>, uint64_t> experienceMap;
std::unordered_set<std::shared_ptr<Player>> killers;
for (const auto &it : damageMap) {
if (auto attacker = g_game().getCreatureByID(it.first)) {
CountBlock_t cb = it.second;
Expand All @@ -655,13 +644,20 @@ void Creature::onDeath() {

if (attacker != getCreature()) {
uint64_t gainExp = getGainedExperience(attacker);
if (auto attackerPlayer = attacker->getPlayer()) {
auto attackerMaster = attacker->getMaster() ? attacker->getMaster() : attacker;
if (auto attackerPlayer = attackerMaster->getPlayer()) {
attackerPlayer->removeAttacked(getPlayer());

auto party = attackerPlayer->getParty();
killers.insert(attackerPlayer);
if (party && party->getLeader() && party->isSharedExperienceActive() && party->isSharedExperienceEnabled()) {
attacker = party->getLeader();
killers.insert(party->getLeader());
mostDamageCreature = attacker;

for (const auto &partyMember : party->getMembers()) {
killers.insert(partyMember);
}
}
}

Expand All @@ -679,10 +675,22 @@ void Creature::onDeath() {
it.first->onGainExperience(it.second, getCreature());
}

if (mostDamageCreature && mostDamageCreature != lastHitCreature && mostDamageCreature != lastHitCreatureMaster) {
mostDamageCreature = mostDamageCreature && mostDamageCreature->getMaster() ? mostDamageCreature->getMaster() : mostDamageCreature;
for (const auto &killer : killers) {
if (auto monster = getMonster()) {
killer->onKilledMonster(monster);
} else if (auto player = getPlayer(); player && mostDamageCreature != killer) {
killer->onKilledPlayer(player, false);
}
}

/**
* @deprecated -- This is here to trigger the deprecated onKill events in lua
*/
if (mostDamageCreature && (mostDamageCreature != lastHitCreature || getMonster()) && mostDamageCreature != lastHitCreatureMaster) {
auto mostDamageCreatureMaster = mostDamageCreature->getMaster();
if (lastHitCreature != mostDamageCreatureMaster && (lastHitCreatureMaster == nullptr || mostDamageCreatureMaster != lastHitCreatureMaster)) {
mostDamageUnjustified = mostDamageCreature->onKilledCreature(static_self_cast<Creature>(), false);
mostDamageUnjustified = mostDamageCreature->deprecatedOnKilledCreature(getCreature(), false);
}
}

Expand Down Expand Up @@ -1014,14 +1022,16 @@ void Creature::goToFollowCreature() {
}
}

if (listDir.empty()) {
hasFollowPath = getPathTo(getFollowCreature()->getPosition(), listDir, fpp);
if (followCreature->getPlayer() && followCreature->getPlayer()->isDisconnected()) {
hasFollowPath = false;
} else if (listDir.empty()) {
hasFollowPath = getPathTo(followCreature->getPosition(), listDir, fpp);
}

startAutoWalk(listDir.data());

if (executeOnFollow) {
onFollowCreatureComplete(getFollowCreature());
onFollowCreatureComplete(followCreature);
}
}

Expand Down Expand Up @@ -1185,10 +1195,10 @@ void Creature::onAttackedCreatureKilled(std::shared_ptr<Creature> target) {
}
}

bool Creature::onKilledCreature(std::shared_ptr<Creature> target, bool lastHit) {
bool Creature::deprecatedOnKilledCreature(std::shared_ptr<Creature> target, bool lastHit) {
auto master = getMaster();
if (master) {
master->onKilledCreature(target, lastHit);
master->deprecatedOnKilledCreature(target, lastHit);
}

// scripting event - onKill
Expand Down Expand Up @@ -1428,52 +1438,35 @@ bool Creature::hasCondition(ConditionType_t type, uint32_t subId /* = 0*/) const
return false;
}

int64_t Creature::getStepDuration(Direction dir) {
int64_t stepDuration = getStepDuration();
if ((dir & DIRECTION_DIAGONAL_MASK) != 0) {
stepDuration *= 3;
}
return stepDuration;
}

int64_t Creature::getStepDuration() {
uint16_t Creature::getStepDuration(Direction dir) {
if (isRemoved()) {
return 0;
}

int32_t stepSpeed = getStepSpeed();
uint32_t calculatedStepSpeed = std::max<uint32_t>(floor((Creature::speedA * log(stepSpeed + Creature::speedB) + Creature::speedC) + 0.5), 1);
calculatedStepSpeed = (stepSpeed > -Creature::speedB) ? calculatedStepSpeed : 1;

uint32_t groundSpeed = 150;
auto tile = getTile();
if (tile && tile->getGround()) {
std::shared_ptr<Item> ground = tile->getGround();
const ItemType &it = Item::items[ground->getID()];
groundSpeed = it.speed > 0 ? it.speed : groundSpeed;
if (walk.needRecache()) {
auto duration = std::floor(1000 * walk.groundSpeed / walk.calculatedStepSpeed);
walk.duration = static_cast<uint16_t>(std::ceil(duration / SERVER_BEAT) * SERVER_BEAT);
}

double duration = std::floor(1000 * groundSpeed / calculatedStepSpeed);
int64_t stepDuration = std::ceil(duration / 50) * 50;

std::shared_ptr<Monster> monster = getMonster();
if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) {
stepDuration *= 2;
auto duration = walk.duration;
if ((dir & DIRECTION_DIAGONAL_MASK) != 0) {
duration *= WALK_DIAGONAL_EXTRA_COST;
} else if (const auto &monster = getMonster()) {
if (monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) {
duration *= WALK_TARGET_NEARBY_EXTRA_COST;
}
}

return stepDuration;
return duration;
}

int64_t Creature::getEventStepTicks(bool onlyDelay) {
int64_t ret = getWalkDelay();
if (ret <= 0) {
int64_t stepDuration = getStepDuration();
if (onlyDelay && stepDuration > 0) {
ret = 1;
} else {
ret = stepDuration * lastStepCost;
}
const uint16_t stepDuration = getStepDuration();
ret = onlyDelay && stepDuration > 0 ? 1 : stepDuration * lastStepCost;
}

return ret;
}

Expand All @@ -1496,6 +1489,8 @@ void Creature::setSpeed(int32_t varSpeedDelta) {
} else if (oldSpeed <= 0 && !listWalkDir.empty()) {
addEventWalk();
}

updateCalculatedStepSpeed();
}

void Creature::setCreatureLight(LightInfo lightInfo) {
Expand Down
Loading

0 comments on commit 0d986f9

Please sign in to comment.