-
Notifications
You must be signed in to change notification settings - Fork 9
/
train.php
283 lines (264 loc) · 12.7 KB
/
train.php
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?php
//addnews ready
// mail ready
// translator ready
require_once("common.php");
require_once("lib/systemmail.php");
require_once("lib/increment_specialty.php");
require_once("lib/fightnav.php");
require_once("lib/http.php");
require_once("lib/taunt.php");
require_once("lib/substitute.php");
require_once("lib/villagenav.php");
require_once("lib/experience.php");
tlschema("train");
page_header("Bluspring's Warrior Training");
$battle = false;
$victory = false;
$defeat = false;
$point=getsetting('moneydecimalpoint',".");
$sep=getsetting('moneythousandssep',",");
output("`b`cBluspring's Warrior Training`c`b");
$mid = httpget("master");
if ($mid) {
$sql = "SELECT * FROM " . db_prefix("masters") . " WHERE creatureid=$mid";
} else {
$sql = "SELECT max(creaturelevel) as level FROM " . db_prefix("masters") . " WHERE creaturelevel <= " . $session['user']['level'];
$res = db_query($sql);
$row = db_fetch_assoc($res);
$l = (int)$row['level'];
$sql = "SELECT * FROM " . db_prefix("masters") . " WHERE creaturelevel=$l ORDER BY RAND(".e_rand().") LIMIT 1";
}
$result = db_query($sql);
if (db_num_rows($result) > 0 && $session['user']['level'] < getsetting('maxlevel',15)){
$master = db_fetch_assoc($result);
$mid = $master['creatureid'];
$master['creaturename'] = stripslashes($master['creaturename']);
$master['creaturewin'] = stripslashes($master['creaturewin']);
$master['creaturelose'] = stripslashes($master['creaturelose']);
$master['creatureweapon'] = stripslashes($master['creatureweapon']);
//this is a piece of old work I will leave in, if you don't have Gadriel, then well...
if ($master['creaturename'] == "Gadriel the Elven Ranger" &&
$session['user']['race'] == "Elf") {
$master['creaturewin'] = "You call yourself an Elf?? Maybe Half-Elf! Come back when you've been better trained.";
$master['creaturelose'] = "It is only fitting that another Elf should best me. You make good progress.";
}
//end of old piece
$level = $session['user']['level'];
$dks = $session['user']['dragonkills'];
$exprequired=exp_for_next_level($level, $dks);
$op = httpget('op');
if ($op==""){
checkday();
output("The sound of conflict surrounds you. The clang of weapons in grisly battle inspires your warrior heart. ");
output("`n`n`^%s stands ready to evaluate you.`0",
$master['creaturename']);
addnav("Navigation");
villagenav();
addnav("Actions");
addnav("Question Master","train.php?op=question&master=$mid");
addnav("M?Challenge Master","train.php?op=challenge&master=$mid");
if ($session['user']['superuser'] & SU_DEVELOPER) {
addnav("Superuser Gain level","train.php?op=challenge&victory=1&master=$mid");
}
}else if($op=="challenge"){
if (httpget('victory')) {
$victory=true;
$defeat=false;
if ($session['user']['experience'] < $exprequired)
$session['user']['experience'] = $exprequired;
$session['user']['seenmaster'] = 0;
}
if ($session['user']['seenmaster']){
output("You think that, perhaps, you've seen enough of your master for today, the lessons you learned earlier prevent you from so willingly subjecting yourself to that sort of humiliation again.");
addnav("Navigation");
villagenav();
addnav("Actions");
}else{
/* OK, let's fix the multimaster thing */
$session['user']['seenmaster'] = 1;
debuglog("Challenged master, setting seenmaster to 1");
if ($session['user']['experience']>=$exprequired){
restore_buff_fields();
$dk = round(get_player_dragonkillmod(true)*0.33,0);
$atkflux = e_rand(0, $dk);
$atkflux = min($atkflux, round($dk*.25));
$defflux = e_rand(0, ($dk-$atkflux));
$defflux = min($defflux, round($dk*.25));
$hpflux = ($dk - ($atkflux+$defflux)) * 5;
debug("DEBUG: $dk modification points total.`n");
debug("DEBUG: +$atkflux allocated to attack.`n");
debug("DEBUG: +$defflux allocated to defense.`n");
debug("DEBUG: +".($hpflux/5)."*5 to hitpoints`n");
calculate_buff_fields();
$master['creatureattack']+=$atkflux;
$master['creaturedefense']+=$defflux;
$master['creaturehealth']+=$hpflux;
$attackstack['enemies'][0] = $master;
$attackstack['options']['type'] = 'train';
$session['user']['badguy']=createstring($attackstack);
$battle=true;
if ($victory) {
$badguy = unserialize($session['user']['badguy']);
output("With a flurry of blows you dispatch your master.`n");
}
}else{
output("You ready your %s`0 and %s`0 and approach `^%s`0.`n`n",$session['user']['weapon'],$session['user']['armor'],$master['creaturename']);
output("A small crowd of onlookers has gathered, and you briefly notice the smiles on their faces, but you feel confident. ");
output("You bow before `^%s`0, and execute a perfect spin-attack, only to realize that you are holding NOTHING!", $master['creaturename']);
output("`^%s`0 stands before you holding your weapon.",$master['creaturename']);
output("Meekly you retrieve your %s, and slink out of the training grounds to the sound of boisterous guffaws.",$session['user']['weapon']);
addnav("Navigation");
villagenav();
addnav("Actions");
}
}
}else if($op=="question"){
checkday();
addnav("Navigation");
villagenav();
addnav("Actions");
output("You approach `^%s`0 timidly and inquire as to your standing in the class.",$master['creaturename']);
if($session['user']['experience']>=$exprequired){
output("`n`n`^%s`0 says, \"Gee, your muscles are getting bigger than mine...\"",$master['creaturename']);
}else{
output("`n`n`^%s`0 states that you will need `%%s`0 more experience before you are ready to challenge him in battle.",$master['creaturename'],number_format($exprequired-$session['user']['experience'],0,$point,$sep));
}
addnav("Question Master","train.php?op=question&master=$mid");
addnav("M?Challenge Master","train.php?op=challenge&master=$mid");
if ($session['user']['superuser'] & SU_DEVELOPER) {
addnav("Superuser Gain level","train.php?op=challenge&victory=1&master=$mid");
}
}else if($op=="autochallenge"){
addnav("Fight Your Master","train.php?op=challenge&master=$mid");
output("`^%s`0 has heard of your prowess as a warrior, and heard of rumors that you think you are so much more powerful than he that you don't even need to fight him to prove anything. ",$master['creaturename']);
output("His ego is understandably bruised, and so he has come to find you.");
output("`^%s`0 demands an immediate battle from you, and your own pride prevents you from refusing the demand.",$master['creaturename']);
if ($session['user']['hitpoints']<$session['user']['maxhitpoints']){
output("`n`nBeing a fair person, your master gives you a healing potion before the fight begins.");
$session['user']['hitpoints']=$session['user']['maxhitpoints'];
}
modulehook("master-autochallenge");
if (getsetting('displaymasternews',1)) addnews("`3%s`3 was hunted down by their master, `^%s`3, for being truant.",$session['user']['name'],$master['creaturename']);
}
if ($op=="fight"){
$battle=true;
}
if ($op=="run"){
output("`\$Your pride prevents you from running from this conflict!`0");
$op="fight";
$battle=true;
}
if($battle){
require_once("lib/battle-skills.php");
require_once("lib/extended-battle.php");
suspend_buffs('allowintrain', "`&Your pride prevents you from using extra abilities during the fight!`0`n");
suspend_companions("allowintrain");
if (!$victory) {
require_once("battle.php");
}
if ($victory){
$badguy['creaturelose']=substitute_array($badguy['creaturelose']);
output_notl("`b`&");
output($badguy['creaturelose']);
output_notl("`0`b`n");
output("`b`\$You have defeated %s!`0`b`n",$badguy['creaturename']);
$session['user']['level']++;
$session['user']['maxhitpoints']+=10;
$session['user']['soulpoints']+=5;
$session['user']['attack']++;
$session['user']['defense']++;
// Fix the multimaster bug
if (getsetting("multimaster", 1) == 1) {
$session['user']['seenmaster']=0;
debuglog("Defeated master, setting seenmaster to 0");
}
output("`#You advance to level `^%s`#!`n",$session['user']['level']);
output("Your maximum hitpoints are now `^%s`#!`n",$session['user']['maxhitpoints']);
output("You gain an attack point!`n");
output("You gain a defense point!`n");
if ($session['user']['level']<15){
output("You have a new master.`n");
}else{
output("None in the land are mightier than you!`n");
}
if ($session['user']['referer']>0 && ($session['user']['level']>=getsetting("referminlevel",4) || $session['user']['dragonkills'] > 0) && $session['user']['refererawarded']<1){
$sql = "UPDATE " . db_prefix("accounts") . " SET donation=donation+".getsetting("refereraward",25)." WHERE acctid={$session['user']['referer']}";
db_query($sql);
$session['user']['refererawarded']=1;
$subj=array("`%One of your referrals advanced!`0");
$body=array("`&%s`# has advanced to level `^%s`#, and so you have earned `^%s`# points!", $session['user']['name'], $session['user']['level'], getsetting("refereraward", 25));
systemmail($session['user']['referer'],$subj,$body);
}
increment_specialty("`^");
// Level-Up companions
// We only get one level per pageload. So we just add the per-level-values.
// No need to multiply and/or substract anything.
if (getsetting("companionslevelup", 1) == true) {
$newcompanions = $companions;
foreach ($companions as $name => $companion) {
$companion['attack'] = $companion['attack'] + (isset($companion['attackperlevel'])?$companion['attackperlevel']:0);
$companion['defense'] = $companion['defense'] + (isset($companion['defenseperlevel'])?$companion['defenseperlevel']:0);
$companion['maxhitpoints'] = $companion['maxhitpoints'] + (isset($companion['maxhitpointsperlevel'])?$companion['maxhitpointsperlevel']:0);
$companion['hitpoints'] = $companion['maxhitpoints'];
$newcompanions[$name] = $companion;
}
}
invalidatedatacache("list.php-warsonline");
addnav("Navigation");
villagenav();
addnav("Actions");
addnav("Question Master","train.php?op=question");
addnav("M?Challenge Master","train.php?op=challenge");
if ($session['user']['superuser'] & SU_DEVELOPER) {
addnav("Superuser Gain level","train.php?op=challenge&victory=1");
}
if ($session['user']['age'] == 1) {
if (getsetting('displaymasternews',1)) addnews("`%%s`3 has defeated ".($session['user']['sex']?"her":"his")." master, `%%s`3 to advance to level `^%s`3 after `^1`3 day!!", $session['user']['name'],$badguy['creaturename'],$session['user']['level']);
} else {
if (getsetting('displaymasternews',1)) addnews("`%%s`3 has defeated ".($session['user']['sex']?"her":"his")." master, `%%s`3 to advance to level `^%s`3 after `^%s`3 days!!", $session['user']['name'],$badguy['creaturename'],$session['user']['level'],$session['user']['age']);
}
if ($session['user']['hitpoints'] < $session['user']['maxhitpoints'])
$session['user']['hitpoints'] = $session['user']['maxhitpoints'];
modulehook("training-victory", $badguy);
}elseif($defeat){
$taunt = select_taunt_array();
if (getsetting('displaymasternews',1)) addnews("`%%s`5 has challenged their master, %s and lost!`n%s",$session['user']['name'],$badguy['creaturename'],$taunt);
$session['user']['hitpoints']=$session['user']['maxhitpoints'];
output("`&`bYou have been defeated by `%%s`&!`b`n",$badguy['creaturename']);
output("`%%s`\$ halts just before delivering the final blow, and instead extends a hand to help you to your feet, and hands you a complementary healing potion.`n",$badguy['creaturename']);
$badguy['creaturewin']=substitute_array($badguy['creaturewin']);
output_notl("`^`b");
output($badguy['creaturewin']);
output_notl("`b`0`n");
addnav("Navigation");
villagenav();
addnav("Actions");
addnav("Question Master","train.php?op=question&master=$mid");
addnav("M?Challenge Master","train.php?op=challenge&master=$mid");
if ($session['user']['superuser'] & SU_DEVELOPER) {
addnav("Superuser Gain level","train.php?op=challenge&victory=1&master=$mid");
}
modulehook("training-defeat", $badguy);
}else{
fightnav(false,false, "train.php?master=$mid");
}
if ($victory || $defeat) {
unsuspend_buffs('allowintrain', "`&You now feel free to make use of your buffs again!`0`n");
unsuspend_companions("allowintrain");
}
}
}else{
checkday();
output("You stroll into the battle grounds.");
output("Younger warriors huddle together and point as you pass by.");
output("You know this place well.");
output("Bluspring hails you, and you grasp her hand firmly.");
output("There is nothing left for you here but memories.");
output("You remain a moment longer, and look at the warriors in training before you turn to return to the village.");
addnav("Navigation");
villagenav();
addnav("Actions");
}
page_footer();
?>