Skip to content

Commit 8b11037

Browse files
Merge pull request #2 from denisolenison/master
Rebalancing
2 parents f9faafe + 13b84c5 commit 8b11037

File tree

5 files changed

+89
-23
lines changed

5 files changed

+89
-23
lines changed

main.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,16 @@ class Mod : GenericMod {
177177
if (player->id == attacker->id || player->pet_id == attacker->id)
178178
{
179179
FloatRGBA purple(0.65f, 0.40f, 1.0f, 1.0f);
180-
int xp_gain = GetCreatureLevel(creature) * (creature->entity_data.level + 1);
180+
181+
int xp_gain = 100;
182+
183+
if (player->entity_data.level > GetCreatureLevel(creature)) {
184+
xp_gain = (int)std::roundf(100 * (creature->entity_data.level + 1) * std::powf(0.8f, player->entity_data.level - GetCreatureLevel(creature)));
185+
}
186+
else {
187+
xp_gain = (int)std::roundf(100 * (creature->entity_data.level + 1) * (1 + 0.15f * (GetCreatureLevel(creature) - player->entity_data.level)) * std::powf(1.05f, GetCreatureLevel(creature) - player->entity_data.level));
188+
}
189+
181190

182191
if ((creature->entity_data.appearance.flags2 & (1 << (int)cube::Creature::AppearanceModifiers::IsBoss)) != 0)
183192
{
@@ -276,13 +285,13 @@ class Mod : GenericMod {
276285

277286
// ##### PLAYER ######
278287
// Defense
279-
m_PlayerScaling.insert_or_assign(STAT_TYPE::HEALTH, 5);
280-
m_PlayerScaling.insert_or_assign(STAT_TYPE::ARMOR, 1);
281-
m_PlayerScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 1);
288+
m_PlayerScaling.insert_or_assign(STAT_TYPE::HEALTH, 1);
289+
m_PlayerScaling.insert_or_assign(STAT_TYPE::ARMOR, 0.2);
290+
m_PlayerScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 0.2);
282291

283292
// Offense
284-
m_PlayerScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 1);
285-
m_PlayerScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 1);
293+
m_PlayerScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 0.2);
294+
m_PlayerScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 0.2);
286295
m_PlayerScaling.insert_or_assign(STAT_TYPE::CRIT, 0.0001f);
287296
m_PlayerScaling.insert_or_assign(STAT_TYPE::HASTE, 0.0001f);
288297

@@ -292,13 +301,13 @@ class Mod : GenericMod {
292301

293302
// ##### CREATURE ######
294303
// Defense
295-
m_CreatureScaling.insert_or_assign(STAT_TYPE::HEALTH, 20);
296-
m_CreatureScaling.insert_or_assign(STAT_TYPE::ARMOR, 0.1f);
297-
m_CreatureScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 0.1f);
304+
m_CreatureScaling.insert_or_assign(STAT_TYPE::HEALTH, 4);
305+
m_CreatureScaling.insert_or_assign(STAT_TYPE::ARMOR, 0.02f);
306+
m_CreatureScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 0.02f);
298307

299308
// Offense
300-
m_CreatureScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 1);
301-
m_CreatureScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 1);
309+
m_CreatureScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 0.2);
310+
m_CreatureScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 0.2);
302311
m_CreatureScaling.insert_or_assign(STAT_TYPE::CRIT, 0);
303312
m_CreatureScaling.insert_or_assign(STAT_TYPE::HASTE, 0);
304313

@@ -337,20 +346,20 @@ class Mod : GenericMod {
337346
if (creature->entity_data.hostility_type != cube::Creature::EntityBehaviour::Player &&
338347
creature->entity_data.hostility_type != cube::Creature::EntityBehaviour::Pet)
339348
{
340-
*stat /= creature->entity_data.level + 1;
341-
*stat += m_CreatureScaling.at(type) * (GetCreatureLevel(creature) - LEVELS_PER_REGION / 2);
342-
*stat *= creature->entity_data.level + 1;
349+
*stat *= 0.2 * std::pow(2.7183, 0.2 * GetCreatureLevel(creature)) / 1.21 * std::pow(0.99, 1 + 0.07 * GetCreatureLevel(creature) * GetCreatureLevel(creature));
350+
*stat += m_CreatureScaling.at(type) * GetCreatureLevel(creature);
351+
343352
}
344353
}
345354

355+
346356
virtual void OnCreatureArmorCalculated(cube::Creature* creature, float* armor) override {
347357
ApplyStatBuff(creature, armor, STAT_TYPE::ARMOR);
348358
ApplyCreatureBuff(creature, armor, STAT_TYPE::ARMOR);
349359
}
350360

351361
virtual void OnCreatureCriticalCalculated(cube::Creature* creature, float* critical) override {
352362
ApplyStatBuff(creature, critical, STAT_TYPE::CRIT);
353-
ApplyCreatureBuff(creature, critical, STAT_TYPE::CRIT);
354363
}
355364

356365
virtual void OnCreatureAttackPowerCalculated(cube::Creature* creature, float* power) override {
@@ -365,7 +374,6 @@ class Mod : GenericMod {
365374

366375
virtual void OnCreatureHasteCalculated(cube::Creature* creature, float* haste) override {
367376
ApplyStatBuff(creature, haste, STAT_TYPE::HASTE);
368-
ApplyCreatureBuff(creature, haste, STAT_TYPE::HASTE);
369377
}
370378

371379
virtual void OnCreatureHPCalculated(cube::Creature* creature, float* hp) override {

src/GearScalingOverWrite.h

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,60 @@ extern "C" float GetGearScaling(cube::Item * item, cube::Creature* creature, int
2424
float base_res = ((base * 0.5f) / (float)0x20);
2525
float mod_modifier = (mod3 / 0x10624DD3) / 7.0f;
2626

27-
float X = 2;
27+
float X = 1.37;
2828
float Y = base_res + effective_rarity + mod_modifier;
2929

3030
float result = std::powf(X, Y);
3131

3232
cube::Game* game = cube::GetGame();
3333
if (game && creature->entity_data.hostility_type == cube::Creature::EntityBehaviour::Player)
3434
{
35-
result *= 1 + 0.05f * GetItemLevel(item);
35+
result *= 0.2 * std::pow(2.7183, 0.2 * GetItemLevel(item)) / 1.21 * std::pow(0.99, 1 + 0.07 * GetItemLevel(item) * GetItemLevel(item));
3636
}
3737
return result;
3838
}
3939

40+
extern "C" float GetOtherStatsRe(cube::Item * item, cube::Creature * creature)
41+
{
42+
IntVector2 region;
43+
if (creature->entity_data.hostility_type == 0)
44+
{
45+
region = creature->entity_data.current_region;
46+
}
47+
else
48+
{
49+
region = item->region;
50+
}
51+
52+
int mod = item->modifier;
53+
54+
int mod1 = mod ^ (mod << 0x0D);
55+
int mod2 = mod1 ^ (mod1 >> 0x11);
56+
int mod3 = mod2 ^ (mod2 << 0x05);
57+
58+
int effective_rarity = item->GetEffectiveRarity(&region);
59+
float mod_modifier = (mod3 / 0x10624DD3) / 7.0f;
60+
61+
float X = 1.2;
62+
float Y = effective_rarity + mod_modifier;
63+
64+
float result = std::powf(X, Y);
65+
66+
cube::Game* game = cube::GetGame();
67+
if (game && creature->entity_data.hostility_type == cube::Creature::EntityBehaviour::Player)
68+
{
69+
result *= 0.005f + 0.0008f * GetItemLevel(item);
70+
if (result > 0.2f) {
71+
result = std::log2f(result/0.2f)*0.2f + 0.2f;
72+
}
73+
}
74+
else {
75+
result = 0.01f;
76+
}
77+
78+
return result;
79+
}
80+
4081
extern "C" float GearScaling(float x, float y, cube::Item* item)
4182
{
4283
float n = std::pow(x, y);
@@ -62,4 +103,7 @@ __attribute__((naked)) void ASM_OverwriteGearScaling() {
62103
void Setup_GearScalingOverwrite() {
63104
//WriteFarJMP(CWOffset(0x109D11), (void*)&ASM_OverwriteGearScaling);
64105
WriteFarJMP(CWOffset(0x109C50), GetGearScaling);
106+
WriteFarJMP(CWOffset(0x10A490), GetOtherStatsRe); //haste
107+
WriteFarJMP(CWOffset(0x109F30), GetOtherStatsRe); //regen
108+
WriteFarJMP(CWOffset(0x1090F0), GetOtherStatsRe); //critical
65109
}

src/XPOverwrite.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
extern "C" int XP_Overwrite(int level)
66
{
77
//return (1050 * level - 50) / (level + 19);
8-
return 50 * std::powf(level + 1, 1.3f);
8+
//return 50 * std::powf(level + 1, 1.3f);
9+
return 5000 + 400*level;
910
}
1011

1112
__attribute__((naked)) void ASM_XP_Overwrite() {

src/utility.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ int GetItemLevel(cube::Item* item)
2727
return item->rarity;
2828
}
2929

30-
return 1 + LEVELS_PER_REGION * GetRegionDistance(item->region) + GetLevelVariation(item->modifier, LEVELS_PER_REGION);
30+
int res = 1 + LEVELS_PER_REGION * GetRegionDistance(item->region) + GetLevelVariation(item->modifier, LEVELS_PER_REGION);
31+
32+
if (res > 333) {
33+
res = 333;
34+
}
35+
36+
return res;
3137
}
3238

3339
int GetCreatureLevel(cube::Creature* creature)
@@ -58,7 +64,14 @@ int GetCreatureLevel(cube::Creature* creature)
5864
default:
5965
// Variation where packs of creatures have the same level
6066
//return (1 + 5 * distance) + GetLevelVariation(creature->entity_data.race * distance, 5);
61-
return (1 + LEVELS_PER_REGION * distance) + GetLevelVariation(creature->id, LEVELS_PER_REGION);
67+
68+
int res = (1 + LEVELS_PER_REGION * distance) + GetLevelVariation(creature->id, LEVELS_PER_REGION);
69+
if (res > 333) {
70+
res = 333;
71+
}
72+
73+
74+
return res;
6275
}
6376
}
6477

src/utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22
#include "cwsdk.h"
33

4-
#define LEVELS_PER_REGION 10
5-
#define LEVEL_EQUIPMENT_CAP 5
4+
#define LEVELS_PER_REGION 3
5+
#define LEVEL_EQUIPMENT_CAP 0
66

77
int GetRegionDistance(IntVector2 region);
88
int GetItemLevel(cube::Item* item);

0 commit comments

Comments
 (0)