2 // all of these stats are the total "points" an object has
3 // points are converted into efficiency = log(points/pointscale+1)*percentscale+100
4 // efficiency is by default 100% and rises logarithmically from that, according to the two scale vars, which are set in script
5 // efficiency is used with a base value, i.e. a sword that does 10 damage used by a player with 150% melee efficiency does 15 damage
7 // with this define, we can uses these names to define vars, strings, functions etc
9 // see rpg.html for detailed explanation as to their meaning
11 #define RPGSTATNAMES \
35 #define RPGATTRNAMES \
57 #define RPGNAMES RPGSTATNAMES RPGATTRNAMES
63 #define N(n) static int pointscale_##n, percentscale_##n; \
64 static void def_##n(int a, int b) { pointscale_##n = a; percentscale_##n = b; } \
65 int eff_##n() { return int(logf(s_##n/pointscale_##n+1)*percentscale_##n)+100; }
68 #define N(n) int s_##n;
74 stats() : statupdatetime(0)
77 #define N(n) s_##n = 0;
84 #define N(n) s_##n = 0;
89 void st_accumulate(rpgobj
&o
)
91 #define N(n) s_##n += o.s_##n;
96 void st_show(g3d_gui
&g
)
98 #define N(n) if(s_##n) { s_sprintfd(s)(#n ": %d => %d%%", s_##n, eff_##n()); g.text(s, 0xFFFFFF, "info"); }
101 #define N(n) if(s_##n) { s_sprintfd(s)(#n ": %d", s_##n); g.text(s, 0xFFAAAA, "info"); }
109 s_mana
= eff_maxmana();
112 void st_respawn() // player only
117 void st_update(int lastmillis
)
119 if(lastmillis
-statupdatetime
>1000)
121 statupdatetime
+= 1000;
122 const int base_hp_regen_rate
= 2, base_mana_regen_rate
= 3; // in script?
123 s_hp
+= eff_hpregen() *base_hp_regen_rate
/100;
124 s_mana
+= eff_manaregen()*base_mana_regen_rate
/100;
125 if(s_hp
>eff_maxhp()) s_hp
= eff_maxhp();
126 if(s_mana
>eff_maxmana()) s_mana
= eff_maxmana();