-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathspells.php
187 lines (140 loc) · 8.2 KB
/
spells.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
<?php // spells.php :: functions for spells.
// Dragon Scourge
//
// Program authors: Jamin Blount
// Copyright (C) 2007 by renderse7en
// Script Version 1.0 Beta 5 Build 20
// You may not distribute this program in any manner, modified or
// otherwise, without the express, written consent from
// renderse7en.
//
// You may make modifications, but only for your own use and
// within the confines of the Dragon Scourge License Agreement
// (see our website for that).
function heal($id) {
global $userrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
$userrow["currenthp"] += $spells[$id]["value"];
$userrow["currentmp"] -= $spells[$id]["mp"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $userrow["currenthp"] = $userrow["maxhp"]; }
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " and gains " . $spells[$id]["value"] . " HP.<br />";
}
return($return);
}
function hurt($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
$userrow["currentmp"] -= $spells[$id]["mp"];
$magichit = ceil(rand($spells[$id]["value"]*.75, $spells[$id]["value"]));
$magicblock = ceil(rand($monsterrow["magicdefense"]*.75, $monsterrow["magicdefense"]) / 5);
$fightrow["playermagicdamage"] = max($magichit - $magicblock, 0);
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " for " . $fightrow["playermagicdamage"] . " damage.<br />";
}
return($return);
}
function fire($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
$userrow["currentmp"] -= $spells[$id]["mp"];
$magichit = ceil(rand($spells[$id]["value"]*.75, $spells[$id]["value"]));
$magicblock = ceil(rand($monsterrow["firedefense"]*.75, $monsterrow["firedefense"]) / 5);
$fightrow["playerfiredamage"] = max($magichit - $magicblock, 0);
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " for " . $fightrow["playerfiredamage"] . " damage.<br />";
}
return($return);
}
function light($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
$userrow["currentmp"] -= $spells[$id]["mp"];
$magichit = ceil(rand($spells[$id]["value"]*.75, $spells[$id]["value"]));
$magicblock = ceil(rand($monsterrow["lightdefense"]*.75, $monsterrow["lightdefense"]) / 5);
$fightrow["playerlightdamage"] = max($magichit - $magicblock, 0);
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " for " . $fightrow["playerlightdamage"] . " damage.<br />";
}
return($return);
}
function prism($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
$userrow["currentmp"] -= $spells[$id]["mp"];
$magichit = ceil(rand($spells[$id]["value"]*.75, $spells[$id]["value"]));
$magicblock = ceil(rand($monsterrow["lightdefense"]*.75, $monsterrow["lightdefense"]) / 5);
$fightrow["playerlightdamage"] = max($magichit - $magicblock, 0);
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . " for " . $fightrow["playerlightdamage"] . " damage.<br />";
}
return($return);
}
// Mad crazy ninja love to Anman for writing this spell. I've cleaned it up a bit to match the format of the rest of the code, but it's his spell.
function blessedstrike($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed == 0) {
//now define the power of the spell. you can stack these spells, but the more you try to stack it the harder it will be to get a decent number out of the stack. Now, this spell is more of a bonus to a player compared to the defence spell. So for this reason, the ratio of stacking has been decreased from 100 to 90 and the minimum % to take of the spell is now 10% instead of 20%.
$userrow["currentmp"] -= $spells[$id]["mp"];
if ($userrow["bonusattack"] == 0) {
$userrow["bonusattack"] = $spells[$id]["value"];
} else {
//if a more powerful inc attack spell is cast, replace the old value with the new one
if ($userrow["bonusattack"] < $spells[$id]["value"]) {
$userrow["bonusattack"] = $spells[$id]["value"];
} else {
//if the same or a weaker spell is cast, determine the maximum stack number and then apply..
$newattmax = ((90 - $userrow["bonusattack"])+1) / 90;
if ($newattmax < 0.1) { $newattmax = 0.1;}
$newattmax = $spells[$id]["value"] * $newattmax;
$newattmax = floor($newattmax);
if ($newattmax < 1) { $newattmax = 1;}
if ($spells[$id]["value"] > $newattmax) {$spells[$id]["value"] = $newattmax;}
$userrow["bonusattack"] = $userrow["bonusattack"] + $spells[$id]["value"];
}
if ($userrow["bonusattack"] > 200) { $userrow["bonusattack"] = 200; }
// *2 damage delt will never go above 50% chance. *1.75 damage will always be 50%
}
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . ". Future attacks will be more powerful!<br />";
}
return($return);
}
// Mad crazy ninja love to Anman for writing this spell. I've cleaned it up a bit to match the format of the rest of the code, but it's his spell.
function stoneskin($id) {
global $userrow, $monsterrow, $fightrow, $spells;
$failed = 0;
if ($userrow["currentmp"] < $spells[$id]["mp"]) { $return = "<span class=\"red\"><b>Spell Failed:</b> You do not have enough MP to cast that spell.</span><br />"; $failed = 1; }
if ($failed ==0 ) {
//now define the power of the spell. you can stack these spells, but the more you try to stack it the harder it will be to get a decent number out of the stack. The max will always be 100. This is because the spell works with percentages and 100 will always be the highest.
$userrow["currentmp"] -= $spells[$id]["mp"];
if ($userrow["bonusdefense"] == 0) {
$userrow["bonusdefense"] = $spells[$id]["value"];
} else {
//if a more powerful defense spell is cast, replace the old value with the new one
if ($userrow["bonusdefense"] < $spells[$id]["value"]) {
$userrow["bonusdefense"] = $spells[$id]["value"];
} else {
//if the same or a weaker spell is cast, determine the maximum stack number and then apply..
$newdefmax = ((100 - $userrow["bonusdefense"])+1) / 100;
if ($newdefmax < 0.2) { $newdefmax = 0.2;}
$newdefmax = $spells[$id]["value"] * $newdefmax;
$newdefmax = floor($newdefmax);
if ($newdefmax < 1) { $newdefmax = 1;}
if ($spells[$id]["value"] > $newdefmax) {$spells[$id]["value"] = $newdefmax;}
$userrow["bonusdefense"] = $userrow["bonusdefense"] + $spells[$id]["value"];
}
if ($userrow["bonusdefense"] > 200) { $userrow["bonusdefense"] = 200;}
// all damage will never go above 50% chance. 0.25% damage will always be 50%
}
$return = $userrow["charname"] . " casts " . $spells[$id]["name"] . ". Damage taken will be reduced!<br />";
}
return($return);
}
?>