Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Feature/general improvements #59

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -9,7 +9,7 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(cotire)

add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)
add_compile_options(-Wall -pipe -fvisibility=hidden)

if (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-fno-strict-aliasing)
Expand Down
14 changes: 8 additions & 6 deletions data/XML/stages.xml
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<stages>
<config enabled="0"/>
<stage minlevel="1" maxlevel="8" multiplier="7"/>
<stage minlevel="9" maxlevel="20" multiplier="6"/>
<stage minlevel="21" maxlevel="50" multiplier="5"/>
<stage minlevel="51" maxlevel="100" multiplier="4"/>
<stage minlevel="101" multiplier="5"/>
<config enabled="1"/>
<stage minlevel="1" maxlevel="10" multiplier="20"/>
<stage minlevel="11" maxlevel="20" multiplier="15"/>
<stage minlevel="21" maxlevel="40" multiplier="10"/>
<stage minlevel="41" maxlevel="60" multiplier="8"/>
<stage minlevel="61" maxlevel="80" multiplier="6"/>
<stage minlevel="81" maxlevel="130" multiplier="3"/>
<stage minlevel="131" multiplier="2"/>
</stages>
1 change: 1 addition & 0 deletions data/spells/scripts/runes/intense healing.lua
Expand Up @@ -11,5 +11,6 @@ end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
doRemoveCondition(creature, CONDITION_PARALYZE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doRemoveCondition(creature, CONDITION_PARALYZE)

return combat:execute(creature, variant)
end
3 changes: 2 additions & 1 deletion data/spells/scripts/runes/ultimate healing.lua
Expand Up @@ -2,7 +2,7 @@ local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
-- combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

function onGetFormulaValues(player, level, maglevel)
Expand All @@ -12,5 +12,6 @@ end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant, isHotkey)
doRemoveCondition(creature, CONDITION_PARALYZE)
return combat:execute(creature, variant)
end
13 changes: 4 additions & 9 deletions data/spells/scripts/spells/heal friend.lua
Expand Up @@ -7,15 +7,10 @@ combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
function onGetFormulaValues(player, level, maglevel)
local base = 120
local variation = 40

local formula = 3 * maglevel + (2 * level)

if formula >= 101 then
formula = 100
end

local min = (formula * (base - variation)) / 100
local max = (formula * (base + variation)) / 100

local min = math.max((base - variation), ((3 * maglevel + 2 * level) * (base - variation) / 100))
local max = math.max((base + variation), ((3 * maglevel + 2 * level) * (base + variation) / 100))

return min, max
end

Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,26 @@
version: '3.7'
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: 'nostalrius'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'nostalrius'
# You can use whatever password you like
MYSQL_PASSWORD: '123123'
# Password for root access
MYSQL_ROOT_PASSWORD: '123123'
tty: true
ports:
# <Port exposed> : < MySQL Port running inside container>
- '7708:3306'
expose:
# Opens port 3306 on the container
- '3306'
# Where our data will be persisted
volumes:
- my-db:/var/lib/mysql
# Names our volume
volumes:
my-db:
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -65,7 +65,7 @@ set(tfs_SRC
${CMAKE_CURRENT_LIST_DIR}/tools.cpp
${CMAKE_CURRENT_LIST_DIR}/vocation.cpp
${CMAKE_CURRENT_LIST_DIR}/waitlist.cpp
${CMAKE_CURRENT_LIST_DIR}/weapons.cpp
#${CMAKE_CURRENT_LIST_DIR}/weapons.cpp
${CMAKE_CURRENT_LIST_DIR}/wildcardtree.cpp
)

85 changes: 79 additions & 6 deletions src/combat.cpp
Expand Up @@ -790,14 +790,56 @@ int32_t Combat::computeDamage(Creature* creature, int32_t strength, int32_t vari

if (creature) {
if (Player* player = creature->getPlayer()) {
int32_t formula = 3 * player->getMagicLevel() + 2 * player->getLevel();
int32_t formulaMin = 3.5 * player->getMagicLevel() + 2 * player->getLevel();
int32_t formulaMax = formulaMin * 2;
int32_t formula = rand() % formulaMax;
damage = formula * damage / 100;
}
}

return damage;
}

int32_t Combat::getKnightTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode)
{
int32_t damage = attackValue;

switch (fightMode) {
case FIGHTMODE_ATTACK:
damage += 2 * damage / 10;
break;
case FIGHTMODE_DEFENSE:
damage -= 4 * damage / 10;
break;
default: break;
}

int32_t formula = (5 * (attackSkill * 1.3) + 60) * (damage * 1);
int32_t randresult = rand() % 100 + (attackSkill / 2);
int32_t totalDamage = -(ceil(formula * ((rand() % 100 + randresult) / 2) / 10000.));
return totalDamage;
}

int32_t Combat::getPaladinTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode)
{
int32_t damage = attackValue;

switch (fightMode) {
case FIGHTMODE_ATTACK:
damage += 2 * damage / 10;
break;
case FIGHTMODE_DEFENSE:
damage -= 4 * damage / 10;
break;
default: break;
}

int32_t formula = (5 * (attackSkill * 1.3) + 60) * damage;
int32_t randresult = rand() % 100 + (attackSkill / 2.5);
int32_t totalDamage = -(ceil(formula * ((rand() % 100 + randresult) / 2) / 10000.));
return totalDamage;
}

int32_t Combat::getTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode)
{
int32_t damage = attackValue;
Expand Down Expand Up @@ -874,7 +916,14 @@ bool Combat::closeAttack(Creature* attacker, Creature* target, fightMode_t fight

CombatDamage combatDamage;
combatDamage.type = combatParams.combatType;
int32_t totalDamage = Combat::getTotalDamage(skillValue, attackValue, fightMode);
int32_t totalDamage = 0;
if (Player* player = attacker->getPlayer()) {
totalDamage = Combat::getKnightTotalDamage(skillValue, attackValue, fightMode);
} else {
totalDamage = Combat::getTotalDamage(skillValue, attackValue, fightMode);
}


combatDamage.value = totalDamage;

bool hit = Combat::doCombatHealth(attacker, target, combatDamage, combatParams);
Expand Down Expand Up @@ -990,7 +1039,15 @@ bool Combat::rangeAttack(Creature* attacker, Creature* target, fightMode_t fight

CombatDamage combatDamage;
combatDamage.type = combatParams.combatType;
combatDamage.value = Combat::getTotalDamage(skillValue, attackValue, fightMode);
int32_t totalDamage = 0;
if (Player* player = attacker->getPlayer()) {
totalDamage = Combat::getPaladinTotalDamage(skillValue, attackValue, fightMode);
} else {
totalDamage = Combat::getTotalDamage(skillValue, attackValue, fightMode);
}


combatDamage.value = totalDamage;

if (weapon) {
hitChance = 75; // throwables and such
Expand Down Expand Up @@ -1185,13 +1242,13 @@ void Combat::circleShapeSpell(Creature* attacker, const Position& toPos, int32_t
void Combat::getAttackValue(Creature* creature, uint32_t& attackValue, uint32_t& skillValue, uint8_t& skill, bool fist)
{
skill = SKILL_FIST;

if (Player* player = creature->getPlayer()) {
Item* weapon = player->getWeapon();
if (weapon && !fist) {
switch (weapon->getWeaponType()) {
case WEAPON_AXE: {
skill = SKILL_AXE;
skill = SKILL_AXE;
attackValue = weapon->getAttack();
break;
}
Expand Down Expand Up @@ -1221,8 +1278,24 @@ void Combat::getAttackValue(Creature* creature, uint32_t& attackValue, uint32_t&
attackValue = 7;
break;
}

skillValue = player->getSkillLevel(skill);
// initialValue = 0;
// if (skillValue >= 100) {
// initialValue = 6;
// } else if (skillValue >= 90) {
// initialValue = 5;
// } else if (skillValue >= 80) {
// initialValue = 4;
// } else if (skillValue >= 70) {
// initialValue = 3;
// } else if (skillValue >= 60) {
// initialValue = 2;
// } else if (skillValue >= 40) {
// initialValue = 1;
// }
// int32_t randPlusAttack = (skillValue / 2) ;
//attackValue = 5 + (attackValue * 0.021) * pow(skillValue, (5/4));
} else {
attackValue = 7;
skillValue = player->getSkillLevel(skill);
Expand Down
2 changes: 2 additions & 0 deletions src/combat.h
Expand Up @@ -283,6 +283,8 @@ class Combat

static int32_t computeDamage(Creature* creature, int32_t strength, int32_t variation);
static int32_t getTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode);
static int32_t getKnightTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode);
static int32_t getPaladinTotalDamage(int32_t attackSkill, int32_t attackValue, fightMode_t fightMode);

static bool attack(Creature* attacker, Creature* target);
static bool closeAttack(Creature* attacker, Creature* target, fightMode_t fightMode, bool fist = false);
Expand Down
3 changes: 3 additions & 0 deletions src/tile.cpp
Expand Up @@ -725,6 +725,8 @@ void Tile::addThing(int32_t, Thing* thing)
} else if (itemType.alwaysOnTop) {
if (itemType.isSplash() && items) {
//remove old splash if exists
SpectatorVec spectators;
g_game.map.getSpectators(spectators, getPosition(), true, true);
for (ItemVector::const_iterator it = items->getBeginTopItem(), end = items->getEndTopItem(); it != end; ++it) {
Item* oldSplash = *it;
if (!Item::items[oldSplash->getID()].isSplash()) {
Expand All @@ -735,6 +737,7 @@ void Tile::addThing(int32_t, Thing* thing)
oldSplash->setParent(nullptr);
g_game.ReleaseItem(oldSplash);
postRemoveNotification(oldSplash, nullptr, 0);
onUpdateTile(spectators);
break;
}
}
Expand Down
Binary file added tfs
Binary file not shown.