-
Notifications
You must be signed in to change notification settings - Fork 8
/
dragon.php
313 lines (283 loc) · 12.8 KB
/
dragon.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
// addnews ready
// translator ready
// mail ready
require_once("common.php");
require_once("lib/fightnav.php");
require_once("lib/titles.php");
require_once("lib/http.php");
require_once("lib/buffs.php");
require_once("lib/taunt.php");
require_once("lib/names.php");
tlschema("dragon");
$battle = false;
page_header("The Green Dragon!");
$op = httpget('op');
if ($op==""){
if (!httpget('nointro')) {
output("`\$Fighting down every urge to flee, you cautiously enter the cave entrance, intent on catching the great green dragon sleeping, so that you might slay it with a minimum of pain.");
output("Sadly, this is not to be the case, for as you round a corner within the cave you discover the great beast sitting on its haunches on a huge pile of gold, picking its teeth with a rib.");
}
$badguy = array(
"creaturename"=>translate_inline("`@The Green Dragon`0"),
"creaturelevel"=>getsetting('maxlevel',15)+2,
"creatureweapon"=>translate_inline("Great Flaming Maw"),
"creatureattack"=>30+getsetting('maxlevel',15),
"creaturedefense"=>10+getsetting('maxlevel',15),
"creaturehealth"=>150+getsetting('maxlevel',15)*10,
"diddamage"=>0,
"type"=>"dragon");
//toughen up each consecutive dragon.
// First, find out how each dragonpoint has been spent and count those
// used on attack and defense.
// Coded by JT, based on collaboration with MightyE
restore_buff_fields();
$points = round(get_player_dragonkillmod(true)*0.75,0);
$atkflux = e_rand(0, $points);
$defflux = e_rand(0,$points-$atkflux);
$hpflux = ($points - ($atkflux+$defflux)) * 5;
debug("DEBUG: $points modification points total.`0`n");
debug("DEBUG: +$atkflux allocated to attack.`n");
debug("DEBUG: +$defflux allocated to defense.`n");
debug("DEBUG: +". ($hpflux/5) . "*5 to hitpoints.`0`n");
calculate_buff_fields();
$badguy['creatureattack']+=$atkflux;
$badguy['creaturedefense']+=$defflux;
$badguy['creaturehealth']+=$hpflux;
$badguy = modulehook("buffdragon", $badguy);
$session['user']['badguy']=createstring($badguy);
$battle=true;
}elseif($op=="prologue1"){
output("`@Victory!`n`n");
$flawless = (int)(httpget('flawless'));
if ($flawless) {
output("`b`c`&~~ Flawless Fight ~~`0`c`b`n`n");
}
output("`2Before you, the great dragon lies immobile, its heavy breathing like acid to your lungs.");
output("You are covered, head to toe, with the foul creature's thick black blood.");
output("The great beast begins to move its mouth. You spring back, angry at yourself for having been fooled by its ploy of death, and watch for its huge tail to come sweeping your way.");
output("But it does not.");
output("Instead the dragon begins to speak.`n`n");
output("\"`^Why have you come here mortal? What have I done to you?`2\" it says with obvious effort.");
output("\"`^Always my kind are sought out to be destroyed. Why? Because of stories from distant lands that tell of dragons preying on the weak? I tell you that these stories come only from misunderstanding of us, and not because we devour your children.`2\"");
output("The beast pauses, breathing heavily before continuing, \"`^I will tell you a secret. Behind me now are my eggs. They will hatch, and the young will battle each other. Only one will survive, but she will be the strongest. She will quickly grow, and be as powerful as me.`2\"");
output("Breath comes shorter and shallower for the great beast.`n`n");
output("\"`#Why do you tell me this? Don't you know that I will destroy your eggs?`2\" you ask.`n`n");
output("\"`^No, you will not, for I know of one more secret that you do not.`2\"`n`n");
output("\"`#Pray tell oh mighty beast!`2\"`n`n");
output("The great beast pauses, gathering the last of its energy. \"`^Your kind cannot tolerate the blood of my kind. Even if you survive, you will be a feeble creature, barely able to hold a weapon, your mind blank of all that you have learned. No, you are no threat to my children, for you are already dead!`2\"`n`n");
output("Realizing that already the edges of your vision are a little dim, you flee from the cave, bound to reach the healer's hut before it is too late.");
output("Somewhere along the way you lose your weapon, and finally you trip on a stone in a shallow stream, sight now limited to only a small circle that seems to float around your head.");
output("As you lay, staring up through the trees, you think that nearby you can hear the sounds of the village.");
output("Your final thought is that although you defeated the dragon, you reflect on the irony that it defeated you.`n`n");
output("As your vision winks out, far away in the dragon's lair, an egg shuffles to its side, and a small crack appears in its thick leathery skin.");
if ($flawless) {
output("`n`nYou fall forward, and remember at the last moment that you at least managed to grab some of the dragon's treasure, so maybe it wasn't all a total loss.");
}
addnav("It is a new day","news.php");
strip_all_buffs();
$sql = "DESCRIBE " . db_prefix("accounts");
$result = db_query($sql);
$dkpoints = 0;
foreach ($session['user']['dragonpoints'] as $val) {
if ($val=="hp") $dkpoints+=5;
}
restore_buff_fields();
$hpgain = array(
'total' => $session['user']['maxhitpoints'],
'dkpoints' => $dkpoints,
'extra' => $session['user']['maxhitpoints'] - $dkpoints -
($session['user']['level']*10),
'base' => $dkpoints + ($session['user']['level'] * 10),
);
$hpgain = modulehook("hprecalc", $hpgain);
calculate_buff_fields();
$nochange=array("acctid"=>1
,"name"=>1
,"sex"=>1
,"playername"=>1
,"strength"=>1
,"dexterity"=>1
,"intelligence"=>1
,"constitution"=>1
,"wisdom"=>1
,"password"=>1
,"marriedto"=>1
,"title"=>1
,"login"=>1
,"dragonkills"=>1
,"locked"=>1
,"loggedin"=>1
,"superuser"=>1
,"gems"=>1
,"hashorse"=>1
,"gentime"=>1
,"gentimecount"=>1
,"lastip"=>1
,"uniqueid"=>1
,"dragonpoints"=>1
,"laston"=>1
,"prefs"=>1
,"lastmotd"=>1
,"emailaddress"=>1
,"emailvalidation"=>1
,"gensize"=>1
,"bestdragonage"=>1
,"dragonage"=>1
,"donation"=>1
,"donationspent"=>1
,"donationconfig"=>1
,"bio"=>1
,"charm"=>1
,"banoverride"=>1
,"referer"=>1
,"refererawarded"=>1
,"ctitle"=>1
,"beta"=>1
,"clanid"=>1
,"clanrank"=>1
,"clanjoindate"=>1
,"translatorlanguages"=>1
,"replaceemail"=>1
,"forgottenpassword"=>1
);
$nochange = modulehook("dk-preserve", $nochange);
$badguys = $session['user']['badguy']; //needed for the dragons name later
$session['user']['dragonage'] = $session['user']['age'];
if ($session['user']['dragonage'] < $session['user']['bestdragonage'] ||
$session['user']['bestdragonage'] == 0) {
$session['user']['bestdragonage'] = $session['user']['dragonage'];
}
while ($row = db_fetch_assoc($result)) {
if (array_key_exists($row['Field'],$nochange) &&
$nochange[$row['Field']]){
}else{
$session['user'][$row['Field']] = $row["Default"];
}
}
$session['user']['gold'] = getsetting("newplayerstartgold",50);
$session['user']['location'] = getsetting('villagename', LOCATION_FIELDS);
$session['user']['armor'] = getsetting('startarmor','T-Shirt');
$session['user']['weapon'] = getsetting('startweapon','Fists');
$newtitle = get_dk_title($session['user']['dragonkills'], $session['user']['sex']);
$restartgold = $session['user']['gold'] +
getsetting("newplayerstartgold", 50)*$session['user']['dragonkills'];
$restartgems = 0;
if ($restartgold > getsetting("maxrestartgold", 300)) {
$restartgold = getsetting("maxrestartgold", 300);
$restartgems = max(0,($session['user']['dragonkills'] -
(getsetting("maxrestartgold", 300)/
getsetting("newplayerstartgold", 50)) - 1));
if ($restartgems > getsetting("maxrestartgems", 10)) {
$restartgems = getsetting("maxrestartgems", 10);
}
}
$session['user']['gold'] = $restartgold;
$session['user']['gems'] += $restartgems;
if ($flawless) {
$session['user']['gold'] += 3*getsetting("newplayerstartgold",50);
$session['user']['gems'] += 1;
}
$session['user']['maxhitpoints'] = 10 + $hpgain['dkpoints'] +
$hpgain['extra'];
$session['user']['hitpoints']=$session['user']['maxhitpoints'];
// Sanity check
if ($session['user']['maxhitpoints'] < 1) {
// Yes, this is a freaking hack.
die("ACK!! Somehow this user would end up perma-dead.. Not allowing DK to proceed! Notify admin and figure out why this would happen so that it can be fixed before DK can continue. Most likely, you have less than Level*10 Hitpoints when you kill the dragon. Let this fix and tell the admin that such a case should not happen. If necessary, bite her/his toes until she/he complies.");
exit();
}
// Set the new title.
$newname = change_player_title($newtitle);
$session['user']['title'] = $newtitle;
$session['user']['name'] = $newname;
foreach ($session['user']['dragonpoints'] as $val) {
switch ($val) {
//legacy support
case "at":
$session['user']['attack']++;
break;
case "de":
$session['user']['defense']++;
break;
}
}
$session['user']['laston']=date("Y-m-d H:i:s",strtotime("-1 day"));
if (!getsetting('pvpdragonoptout',0)) $session['user']['slaydragon'] = 1;
$companions = array();
$session['user']['companions'] = array();
output("`n`nYou wake up in the midst of some trees. Nearby you hear the sounds of a village.");
output("Dimly you remember that you are a new warrior, and something of a dangerous Green Dragon that is plaguing the area. You decide you would like to earn a name for yourself by perhaps some day confronting this vile creature.");
// allow explanative text as well.
modulehook("dragonkilltext");
$regname = get_player_basename();
//get the dragons name
$badguys = @unserialize ($badguys);
$badguy=array("creaturename"=>translate_inline("`@The Green Dragon`0"));
foreach ($badguys['enemies'] as $opponent) {
if ($opponent['type']=='dragon') {
//hit
$badguy=$opponent;
break;
}
}
$howoften=($session['user']['dragonkills']>1?"times":"time"); // no translation, we never know who is viewing...
addnews("`#%s`# has earned the title `&%s`# for having slain `@%s`& `^%s`# %s!",$regname,$session['user']['title'],$badguy['creaturename'],$session['user']['dragonkills'],$howoften);
output("`n`n`^You are now known as `&%s`^!!",$session['user']['name']);
output("`n`n`&Because you have slain %s`& %s %s, you start with some extras. You also keep additional permanent hitpoints you've earned.`n",$badguy['creaturename'],$session['user']['dragonkills'],$howoften);
$session['user']['charm']+=5;
output("`^You gain FIVE charm points for having defeated the dragon!`n");
debuglog("slew the dragon and starts with {$session['user']['gold']} gold and {$session['user']['gems']} gems");
// Moved this hear to make some things easier.
modulehook("dragonkill", array());
invalidatedatacache("list.php-warsonline");
}
if ($op=="run"){
output("The creature's tail blocks the only exit to its lair!");
$op="fight";
httpset('op', 'fight');
}
if ($op=="fight" || $op=="run"){
$battle=true;
}
if ($battle){
require_once("battle.php");
if ($victory){
$flawless = 0;
if (isset($badguy['diddamage']) && $badguy['diddamage'] != 1) $flawless = 1;
$session['user']['dragonkills']++;
output("`&With a mighty final blow, `@%s`& lets out a tremendous bellow and falls at your feet, dead at last.",$badguy['creaturename']);
addnews("`&%s has slain the hideous creature known as `@%s`&. All across the land, people rejoice!",$session['user']['name'],$badguy['creaturename']);
tlschema("nav");
addnav("Continue","dragon.php?op=prologue1&flawless=$flawless");
tlschema();
}else{
if($defeat){
tlschema("nav");
addnav("Daily news","news.php");
tlschema();
$taunt = select_taunt_array();
if ($session['user']['sex']){
addnews("`%%s`5 has been slain when she encountered `@%s`5!!! Her bones now litter the cave entrance, just like the bones of those who came before.`n%s",$session['user']['name'],$badguy['creaturename'],$taunt);
}else{
addnews("`%%s`5 has been slain when he encountered `@%s`5!!! His bones now litter the cave entrance, just like the bones of those who came before.`n%s",$session['user']['name'],$badguy['creaturename'],$taunt);
}
$session['user']['alive']=0;
debuglog("lost {$session['user']['gold']} gold when they were slain");
$session['user']['gold']=0;
$session['user']['hitpoints']=0;
output("`b`&You have been slain by `@%s`&!!!`n",$badguy['creaturename']);
output("`4All gold on hand has been lost!`n");
//grant modules a chance to exclusively hook in here and do worse things to the user =)
output_notl("`n");
modulehook("dragondeath",array());
output_notl("`n");
output("You may begin fighting again tomorrow.");
page_footer();
}else{
fightnav(true,false);
}
}
}
page_footer();
?>