forked from jewalky/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmagic_resist_limits.cpp
64 lines (58 loc) · 1.47 KB
/
magic_resist_limits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "srvmgr.h"
#include "utils.h"
#include "config_new.h"
int getLimit(T_UNIT* unit, int magic_ind)
{
bool warrior = IsWarrior(unit);
bool female = IsFemale(unit);
MainCharacterParameters* params = NULL;
if (female)
{
if (warrior)
params = &Config::WarriorFemaleMaxParameters;
else
params = &Config::MageFemaleMaxParameters;
}
else
{
if (warrior)
params = &Config::WarriorMaleMaxParameters;
else
params = &Config::MageMaleMaxParameters;
}
if (params)
{
switch (magic_ind)
{
case 1: return params->ResistFire;
case 2: return params->ResistWater;
case 3: return params->ResistAir;
case 4: return params->ResistEarth;
case 5: return params->ResistAstral;
}
}
log_format("[ERR] getLimit(%X, %d){params=%X}->Error\n", unit, magic_ind, params);
return 100;
}
int __stdcall imp_limit_magic_resist(T_UNIT* unit, int magic_ind, int resist)
{
int limit = getLimit(unit, magic_ind);
return resist < limit ? resist: limit;
}
int __declspec(naked) imp_limit_magic_resist_wrapper()
{ // 00532243
__asm
{
push eax
push ecx
push edx
push eax
push ecx
call imp_limit_magic_resist
mov edx, eax
pop ecx
pop eax
mov [ecx+eax*2+0C2h], dx
ret
}
}