-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlevel.cc
More file actions
214 lines (168 loc) · 6.17 KB
/
level.cc
File metadata and controls
214 lines (168 loc) · 6.17 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <sys/types.h>
#include <stdio.h>
#include <syslog.h>
#include "define.h"
#include "struct.h"
void do_level( char_data* ch, const char *argument )
{
if( is_confused_pet( ch ) )
return;
if( *argument ) {
int i;
if( !number_arg( argument, i ) )
send( ch, "Unknown syntax - see help level.\n\r" );
else if( i > LEVEL_HERO )
send( ch, "Gaining levels beyond %d via experience points is impossible.\n\r", LEVEL_HERO );
else if( i < 2 )
send( ch, "Levels below 2 do not require experience.\n\r" );
else
send( ch, "Gaining level %d costs %d experience points.\n\r",
i, exp_for_level( i-1 ) );
return;
}
if( is_mob( ch ) )
return;
const int level = ch->Level( );
send( ch, "You are level %d.\n\r", level );
if( ch->Level() <= LEVEL_HERO ) {
send( ch, "You have acquired %d experience point%s so far this level.\n\r",
ch->exp,
ch->exp == 1 ? "" : "s" );
}
if( ch->Level() < LEVEL_HERO ) {
bool regain = ( ch->pcdata->max_level != -1 );
int x = exp_for_level( ch ) - ch->exp;
if( x <= 0 ) {
send( ch, "You have enough experience points to %sgain level %d.\n\r", regain ? "re" : "", level + 1 );
if( !is_set( ch->pcdata->pfile->flags, PLR_APPROVED ) && ( ch->Level() >= 5 ) ) {
char buf [ TWO_LINES ];
convert_to_ansi( ch, TWO_LINES, "Perhaps you should read @ehelp approvals@n?\n\r", buf );
send( ch, buf );
}
} else {
send( ch, "You need %d experience point%s to %sgain level %d.\n\r", x, x == 1 ? "" : "s", regain ? "re" : "", level + 1 );
}
}
}
void advance_level( char_data* ch, bool message )
{
if( ch->species )
return;
char buf [ MAX_STRING_LENGTH ];
int clss = ch->pcdata->clss;
int add_hp;
int add_mana;
int add_move;
int pracs = 0;
++ch->shdata->level;
const bool regain = ( ch->pcdata->max_level != -1 );
if( message ) {
send( ch, "\n\r" );
send_color( ch, COLOR_MILD, "-=-= CONGRATULATIONS!!! =-=-" );
send( ch, "\n\r\n\r" );
send( ch, "You have %sgained level %d.\n\r", regain ? "re" : "", ch->Level() );
if( ch->Level() < LEVEL_HERO ) {
send( ch, "You need %d experience points for the next level.\n\r", exp_for_level( ch )-ch->exp );
} else {
send( ch, "\n\r" );
send_color( ch, COLOR_STRONG, "You have attained the maximum level available to mortals." );
send( ch, "\n\r" );
send_color( ch, COLOR_STRONG, "Please consider remorting... see help remort." );
send( ch, "\n\r\n\r" );
}
snprintf( buf, MAX_STRING_LENGTH, "%s has %sgained level %d.", ch->descr->name, regain ? "re" : "", ch->Level() );
info( 0, empty_string, 0, buf, IFLAG_LEVELS, regain ? 2 : 1, ch );
}
if( ch->pcdata->max_level == ch->Level() ) {
ch->pcdata->max_level = -1;
ch->base_hit = ch->pcdata->level_hit;
ch->base_mana = ch->pcdata->level_mana;
ch->base_move = ch->pcdata->level_move;
} else {
add_hp = number_range( clss_table[ clss ].hit_min, clss_table[ clss ].hit_max );
add_mana = number_range( clss_table[ clss ].mana_min, clss_table[ clss ].mana_max );
add_move = number_range( clss_table[ clss ].move_min, clss_table[ clss ].move_max );
ch->base_hit += add_hp;
ch->base_mana += add_mana;
ch->base_move += add_move;
int pracbonus = ( ch->Intelligence() - 10 ) / 2;
if( ch->pcdata->max_level == -1 ) {
if( ( pracs = ( 12 - ch->Level() + pracbonus ) ) <= 0 )
pracs = 1;
if( message ) {
send( ch, "\n\r" );
send_color( ch, COLOR_SKILL, ">> You gain %d practice point%s. <<", pracs, pracs == 1 ? "" : "s" );
send( ch, "\n\r\n\r" );
}
ch->pcdata->practice += pracs;
remove_bit( ch->pcdata->pfile->flags, PLR_FAMILIAR );
}
}
if( message ) { player_log( ch, "%sained level %d.", regain ? "Reg" : "G", ch->Level() ); }
ch->pcdata->pfile->level = ch->Level();
calc_resist( (player_data*)ch );
update_maxes( ch );
}
void lose_level( char_data* ch, bool message )
{
char tmp [ ONE_LINE ];
int add_hp;
int add_mana;
int add_move;
if( !ch->pcdata || ch->Level() < 2 )
return;
if( ch->pcdata->max_level == -1 ) {
ch->pcdata->max_level = ch->Level();
ch->pcdata->level_hit = ch->base_hit;
ch->pcdata->level_mana = ch->base_mana;
ch->pcdata->level_move = ch->base_move;
}
--ch->shdata->level;
ch->pcdata->pfile->level = ch->Level();
if( message && ch->Level() < LEVEL_BUILDER ) {
snprintf( tmp, ONE_LINE, "%s has lost a level.", ch->descr->name );
info( 0, empty_string, 0, tmp, IFLAG_LEVELS, 2, ch );
}
add_hp = ( ch->base_hit-20 )/( ch->Level() );
add_mana = ( ch->base_mana-50 )/( ch->Level() );
add_move = ( ch->base_move-100 )/( ch->Level() );
ch->base_hit -= add_hp;
ch->base_mana -= add_mana;
ch->base_move -= add_move;
calc_resist( (player_data*)ch );
update_maxes( ch );
if( message ) {
send( ch, "You have lost a level!\n\r" );
player_log( ch, "Lost level %d.", ch->Level( )+1 );
}
}
/*
* EXPECTED FUNCTIONS (PLAYER)
*/
double player_data :: Mean_Hp( ) const
{
return 20+(Level()-1)*(clss_table[ pcdata->clss ].hit_min + clss_table[ pcdata->clss ].hit_max)/2;
}
double player_data :: Mean_Mana( ) const
{
return 50+(Level()-1)*(clss_table[ pcdata->clss ].mana_min + clss_table[ pcdata->clss ].mana_max)/2;
}
double player_data :: Mean_Move( ) const
{
return 100+(Level()-1)*(clss_table[ pcdata->clss ].move_min + clss_table[ pcdata->clss ].move_max)/2;
}
/*
* EXPECTED FUNCTIONS (MOB)
*/
double Mob_Data :: Mean_Hp( ) const
{
return 0.0;
}
double Mob_Data :: Mean_Mana( ) const
{
return 0.0;
}
double Mob_Data :: Mean_Move( ) const
{
return 0.0;
}