Skip to content

Commit 7a5608f

Browse files
Add files via upload
1 parent ceb6816 commit 7a5608f

File tree

6 files changed

+48
-38
lines changed

6 files changed

+48
-38
lines changed

main.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class Mod : GenericMod {
7878
game->PrintMessage(L"[Notification] Correctly recentered player region.\n", 0, 255, 0);
7979
return 1;
8080
}
81-
8281
return 0;
8382
}
8483

@@ -193,7 +192,16 @@ class Mod : GenericMod {
193192
if (player->id == attacker->id || player->pet_id == attacker->id)
194193
{
195194
FloatRGBA purple(0.65f, 0.40f, 1.0f, 1.0f);
196-
int xp_gain = GetCreatureLevel(creature) * (creature->entity_data.level + 1);
195+
196+
int xp_gain = 100;
197+
198+
if (player->entity_data.level > GetCreatureLevel(creature)) {
199+
xp_gain = (int)std::roundf(100 * (creature->entity_data.level + 1) * std::powf(0.8f, player->entity_data.level - GetCreatureLevel(creature)));
200+
}
201+
else {
202+
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));
203+
}
204+
197205

198206
if ((creature->entity_data.appearance.flags2 & (1 << (int)cube::Creature::AppearanceModifiers::IsBoss)) != 0)
199207
{
@@ -292,13 +300,13 @@ class Mod : GenericMod {
292300

293301
// ##### PLAYER ######
294302
// Defense
295-
m_PlayerScaling.insert_or_assign(STAT_TYPE::HEALTH, 5);
296-
m_PlayerScaling.insert_or_assign(STAT_TYPE::ARMOR, 1);
297-
m_PlayerScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 1);
303+
m_PlayerScaling.insert_or_assign(STAT_TYPE::HEALTH, 1);
304+
m_PlayerScaling.insert_or_assign(STAT_TYPE::ARMOR, 0.2);
305+
m_PlayerScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 0.2);
298306

299307
// Offense
300-
m_PlayerScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 1);
301-
m_PlayerScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 1);
308+
m_PlayerScaling.insert_or_assign(STAT_TYPE::ATK_POWER, 0.2);
309+
m_PlayerScaling.insert_or_assign(STAT_TYPE::SPELL_POWER, 0.2);
302310
m_PlayerScaling.insert_or_assign(STAT_TYPE::CRIT, 0.0001f);
303311
m_PlayerScaling.insert_or_assign(STAT_TYPE::HASTE, 0.0001f);
304312

@@ -308,7 +316,6 @@ class Mod : GenericMod {
308316

309317
// ##### CREATURE ######
310318
// Defense
311-
312319
m_CreatureScaling.insert_or_assign(STAT_TYPE::HEALTH, 0.9);
313320
m_CreatureScaling.insert_or_assign(STAT_TYPE::ARMOR, 0.7);
314321
m_CreatureScaling.insert_or_assign(STAT_TYPE::RESISTANCE, 0.7);
@@ -354,20 +361,19 @@ class Mod : GenericMod {
354361
if (creature->entity_data.hostility_type != cube::Creature::EntityBehaviour::Player &&
355362
creature->entity_data.hostility_type != cube::Creature::EntityBehaviour::Pet)
356363
{
357-
358364
*stat *= m_CreatureScaling.at(type) * 0.5 * std::pow(2.7183, 0.2 * GetCreatureLevel(creature)) / 1.21 * std::pow(0.99, 1 + 0.07 * GetCreatureLevel(creature) * GetCreatureLevel(creature));
359365

360366
}
361367
}
362368

369+
363370
virtual void OnCreatureArmorCalculated(cube::Creature* creature, float* armor) override {
364371
ApplyStatBuff(creature, armor, STAT_TYPE::ARMOR);
365372
ApplyCreatureBuff(creature, armor, STAT_TYPE::ARMOR);
366373
}
367374

368375
virtual void OnCreatureCriticalCalculated(cube::Creature* creature, float* critical) override {
369376
ApplyStatBuff(creature, critical, STAT_TYPE::CRIT);
370-
ApplyCreatureBuff(creature, critical, STAT_TYPE::CRIT);
371377
}
372378

373379
virtual void OnCreatureAttackPowerCalculated(cube::Creature* creature, float* power) override {
@@ -382,7 +388,6 @@ class Mod : GenericMod {
382388

383389
virtual void OnCreatureHasteCalculated(cube::Creature* creature, float* haste) override {
384390
ApplyStatBuff(creature, haste, STAT_TYPE::HASTE);
385-
ApplyCreatureBuff(creature, haste, STAT_TYPE::HASTE);
386391
}
387392

388393
virtual void OnCreatureHPCalculated(cube::Creature* creature, float* hp) override {
@@ -407,4 +412,4 @@ class Mod : GenericMod {
407412
// Export of the mod created in this file, so that the modloader can see and use it.
408413
EXPORT Mod* MakeMod() {
409414
return new Mod();
410-
}
415+
}

src/GearScalingOverWrite.h

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ extern "C" float GetGearScaling(cube::Item * item, cube::Creature* creature, int
3333
if (game && creature->entity_data.hostility_type == cube::Creature::EntityBehaviour::Player)
3434
{
3535
result *= 0.5 * std::pow(2.7183, 0.2 * GetItemLevel(item)) / 1.21 * std::pow(0.99, 1 + 0.07 * GetItemLevel(item) * GetItemLevel(item));
36-
3736
}
3837
return result;
3938
}
4039

41-
4240
extern "C" float GetOtherStatsRe(cube::Item * item, cube::Creature * creature)
4341
{
4442
IntVector2 region;
@@ -66,40 +64,37 @@ extern "C" float GetOtherStatsRe(cube::Item * item, cube::Creature * creature)
6664

6765
float result = std::powf(X, Y);
6866

69-
cube::Game* game = cube::GetGame();
70-
if (game && creature->entity_data.hostility_type == cube::Creature::EntityBehaviour::Player)
71-
{
72-
result *= 0.01f + 0.0016f * GetItemLevel(item);
73-
if (result > 0.2f) {
74-
result = std::log2f(result/0.2f)*0.2f + 0.2f;
75-
result *= randomizer;
76-
}
77-
}
78-
else {
79-
result = 0;
67+
68+
result *= 0.01f + 0.0016f * GetItemLevel(item);
69+
if (result > 0.2f) {
70+
result = std::log2f(result/0.2f)*0.2f + 0.2f;
71+
result *= randomizer;
8072
}
8173

8274

75+
8376
int category = item->category;
77+
8478
if (category < 3 || category > 9)
8579
{
8680
result *= 0;
8781
}
8882

83+
8984
return result;
9085
}
9186

9287

9388
extern "C" float GetHasteRe(cube::Item * item, cube::Creature * creature) {
94-
return GetOtherStatsRe(item, creature) * PyroRand(1 + item->modifier) / 32768;
89+
return GetOtherStatsRe(item, creature) * PyroRand(item->modifier + 0x157) / 32768;
9590
}
9691

9792
extern "C" float GetRegenRe(cube::Item * item, cube::Creature * creature) {
98-
return GetOtherStatsRe(item, creature) * PyroRand(2 + item->GetBuyingPrice()) / 32768;
93+
return GetOtherStatsRe(item, creature) * PyroRand(item->GetSellingPrice() + 0x159) / 32768;
9994
}
10095

10196
extern "C" float GetCritRe(cube::Item * item, cube::Creature * creature) {
102-
return GetOtherStatsRe(item, creature) * PyroRand(3 + item->GetSellingPrice()) / 32768;
97+
return GetOtherStatsRe(item, creature) * PyroRand(item->GetBuyingPrice() + 0x161) / 32768;
10398
}
10499

105100
extern "C" float GearScaling(float x, float y, cube::Item* item)
@@ -130,5 +125,4 @@ void Setup_GearScalingOverwrite() {
130125
WriteFarJMP(CWOffset(0x10A490), GetHasteRe); //haste
131126
WriteFarJMP(CWOffset(0x109F30), GetRegenRe); //regen
132127
WriteFarJMP(CWOffset(0x1090F0), GetCritRe); //critical
133-
134-
}
128+
}

src/LevelDisplayOverwrite.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ extern "C" void OverwriteItemName(cube::Item * item, std::wstring * string)
2929
{
3030
swprintf_s(buffer, 250, L"LV %.0f ", item_level);
3131
}
32-
3332
*string = buffer + *string;
3433
}
3534

3635
extern "C" void LevelDisplayOverwriteCreature(cube::Creature* creature, void* unk)
3736
{
3837
wchar_t buffer[250];
39-
4038
double item_level = GetCreatureLevel(creature);
4139

4240
if (item_level > 1e6)
@@ -51,7 +49,6 @@ extern "C" void LevelDisplayOverwriteCreature(cube::Creature* creature, void* un
5149
{
5250
swprintf_s(buffer, 250, L"LV %.0f ", item_level);
5351
}
54-
5552
PutText(unk, buffer);
5653
return;
5754
}

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)