cast spell





PHPXRef 0.7 : NEABExplorer : /skills/cast_spell.php source









[ Index ]


PHP Cross Reference of NEABExplorer














if (gwGetCookie('xrefnav')=='off')
document.write('[ Show Explorer ]');
else
document.write('[ Hide Explorer ]');



[ Show Explorer ]
[ Hide Navbar ]





titleBody[close]
/skills/ -> cast_spell.php (source)

[Summary view]
[Print]
[Text view]


1 <?PHP
2 /**
3 * This page is used to calculate the effect of the spell casted by the player.
4 */
5
6 function calc_effect($base)
7 {
8 global $uservals;
9
10 $maxeffect=$base+ceil(($uservals["INTELLIGENCE"]/3+$uservals["INTMOD"]/4+$uservals["TEMP_INT"]/4));
11 return mt_rand(ceil($maxeffect*.8),$maxeffect);
12 }
13
14 $r=$db->Execute("SELECT COUNT(SPELLID) FROM SPELLBOOK WHERE SPELLID = $id AND USERID = $userid");
15 if($r->fields[0] == "1")
16 $ok=true;
17 else
18 $ok=false;
19 $r->Close();
20
21 $failed=false;
22 $otherschool=false;
23 if($ok)
24 {
25 $spell=read_db_entry($db,"SELECT * FROM SPELLS WHERE ID = $id");
26 if($spell["SCHOOL"] != "M" && $uservals["SCHOOL"] != $spell["SCHOOL"])
27 {
28 $spell["MININT"]*=10;
29 $spell["MINLEVEL"]*=3;
30 $otherschool=true;
31 }
32
33 $int=($uservals["INTMOD"]+$uservals["TEMP_INT"]+$uservals["INTELLIGENCE"])*4;
34 $pts=$spell["HEAL"]+$spell["ATTACK"]+$spell["FREEZE"]*20+$spell["PROTECTION"]+$spell["TAKEHP"]*2+$spell["TAKEMP"]*2;
35 $prob=mt_rand(0,$pts+$int);
36
37 if(($int/4) < ($spell["MININT"]+0))
38 {
39 if(isset($text))
40 $text.="As you try to cast the spell, your hands spark....but nothing happens!<BR>\nIt seems your int is too low to cast this spell.<BR>\n";
41 else
42 echo "As you try to cast the spell, your hands spark....but nothing happens!<BR>\nIt seems your int is too low to cast this spell.<BR>\n";
43 $failed=true;
44 }
45 else if(($uservals["LEVEL"]+0) < ($spell["MINLEVEL"]+0))
46 {
47 if(isset($text))
48 $text.="As you try to cast the spell, your hands spark....but nothing happens!<BR>\nIt seems your level is too low to cast this spell.<BR>\n";
49 else
50 echo "As you try to cast the spell, your hands spark....but nothing happens!<BR>\nIt seems your level is too low to cast this spell.<BR>\n";
51 $failed=true;
52 }
53 else if($prob > $int && ($uservals["MP"]+0) >= ($spell["MPCOST"]+0) && ($uservals["MONSTERCOMBAT"]+0) != 0 && $otherschool)
54 {
55 if(isset($text))
56 $text.="As you try to cast the spell, your hands spark....but nothing happens!<BR>\n";
57 else
58 echo "As you try to cast the spell, your hands spark....but nothing happens!<BR>\n";
59 $uservals["MP"]-=$spell["MPCOST"];
60 $db->Execute("UPDATE PLAYER SET MP={$uservals['MP']} WHERE ID=$userid");
61 $failed=true;
62 }
63 else if(($uservals["MP"]+0) >= ($spell["MPCOST"]+0))
64 {
65 if($spell["TYPE"] == 'G')
66 {
67 if(($spell["HEAL"]+0) > 0)
68 {
69 $hp=calc_effect($spell["HEAL"]);
70 $uservals["HP"]+=$hp;
71 if($uservals["HP"] > ($uservals["HPMOD"]+$uservals['MAXHP']+$uservals["TEMP_HP"]))
72 $uservals["HP"]=($uservals["HPMOD"]+$uservals['MAXHP']+$uservals["TEMP_HP"]);
73 $uservals["MP"]-=$spell["MPCOST"];
74 $db->Execute("UPDATE PLAYER SET HP={$uservals['HP']}, MP={$uservals['MP']} WHERE ID=$userid");
75 $msg=str_replace("\$HEAL",$hp,$spell["DISPLAY"]);
76 if(isset($text))
77 $text.="$msg<BR>\n";
78 else
79 echo "$msg<BR>\n";
80 }
81 }
82 else if($spell["TYPE"] == 'A')
83 {
84 $uservals["MP"]-=$spell["MPCOST"];
85 $db->Execute("UPDATE PLAYER SET MP={$uservals['MP']} WHERE ID=$userid");
86 $attack=calc_effect($spell["ATTACK"]);
87 $fattack=$attack;
88 $prot=calc_effect($spell["PROTECTION"]);
89 if($attack > 0)
90 {
91 $mpro=round(($monster["LEVEL"])*pow($monster["LEVEL"],0.25)*$monster["PRO"]/50);
92 $attack=ceil($attack-$mpro*.5);
93 if($attack <= 0)
94 $attack=0;
95 }
96 $msg=str_replace(array("\$DMG","\$PRO"),array($attack,$prot),$spell["DISPLAY"]);
97 if(isset($text))
98 $text.="$msg<BR>\n";
99 else
100 echo "$msg<BR>\n";
101 if(($spell["SELF"]+0) > 0)
102 {
103 $selfdmg=ceil($fattack*($spell["SELF"]/$spell["ATTACK"]));
104 if($selfdmg > 0)
105 {
106 $uservals["HP"]-=$selfdmg;
107 $db->Execute("UPDATE PLAYER SET HP = ".$uservals["HP"]." WHERE ID = $userid");
108 if(isset($text))
109 $text.="Your spell also produced $selfdmg to yourself.<BR>\n";
110 else
111 echo "Your spell also produced $selfdmg to yourself.<BR>\n";
112 }
113 }
114 if(($spell["FREEZE"]+0) > 0)
115 {
116 $dif=$monster["LEVEL"]-$uservals["LEVEL"];
117 $i=($uservals["INTELLIGENCE"]+$uservals["INTMOD"]+$uservals["TEMP_INT"]);
118 if($dif < 3 || mt_rand(0,ceil($dif+$i/4)) <= ceil($i/4))
119 {
120 $db->Execute("UPDATE PLAYER SET FREEZE=-".$spell["FREEZE"]." WHERE ID=$userid");
121 $uservals["FREEZE"]=-$spell["FREEZE"];
122 if(isset($text))
123 $text.="You froze your opponent for ".$spell["FREEZE"]." round.<BR>\n";
124 else
125 echo "You froze your opponent for ".$spell["FREEZE"]." round.<BR>\n";
126 }
127 else
128 {
129 if(isset($text))
130 $text.="Your opponent resisted your freeze spell.<BR>\n";
131 else
132 echo "Your opponent resisted your freeze spell.<BR>\n";
133 }
134 }
135 if(($spell["PROTECTION"]+0) > 0 && ($uservals["COMBATPROT"]+0) == 0)
136 {
137 $db->Execute("UPDATE PLAYER SET COMBATPROT=".$prot." WHERE ID=$userid");
138 $uservals["COMBATPROT"]=$prot;
139 if(isset($text))
140 $text.="You upgraded your protection by ".$prot." points, you now have ".($uservals["PROTECTION"]+$uservals["COMBATPROT"]).".<BR>\n";
141 else
142 echo "You upgraded your protection by ".$prot." points, you now have ".($uservals["PROTECTION"]+$uservals["COMBATPROT"]).".<BR>\n";
143 }
144 if(($spell["TAKEHP"]+0) > 0)
145 {
146 $heal=calc_effect($spell["TAKEHP"]);
147 if($heal > $attack)
148 $heal=$attack;
149 $uservals["HP"]+=$heal;
150 if($uservals["HP"] > ($uservals["HPMOD"]+$uservals['MAXHP']+$uservals["TEMP_HP"]))
151 $uservals["HP"]=($uservals["HPMOD"]+$uservals['MAXHP']+$uservals["TEMP_HP"]);
152 $db->Execute("UPDATE PLAYER SET HP=".$uservals["HP"]." WHERE ID=$userid");
153 if(isset($text))
154 $text.="You recovered $heal HP.<BR>\n";
155 else
156 echo "You recovered $heal HP.<BR>\n";
157 }
158 if(($spell["TAKEMP"]+0) > 0)
159 {
160 $heal=calc_effect($spell["TAKEMP"]);
161 if($heal > $attack)
162 $heal=$attack;
163 $uservals["MP"]+=$heal;
164 if($uservals["MP"] > ($uservals["MPMOD"]+$uservals['MAXMP']+$uservals["TEMP_MP"]))
165 $uservals["MP"]=($uservals["MPMOD"]+$uservals['MAXMP']+$uservals["TEMP_MP"]);
166 $db->Execute("UPDATE PLAYER SET MP=".$uservals["MP"]." WHERE ID=$userid");
167 if(isset($text))
168 $text.="You recovered $heal MP.<BR>\n";
169 else
170 echo "You recovered $heal MP.<BR>\n";
171 }
172 }
173 }
174 else
175 {
176 if(isset($text))
177 $text.="You do not have enough MP to cast this spell.<BR>\n";
178 else
179 echo "You do not have enough MP to cast this spell.<BR>\n";
180 }
181 }
182 ?>



FUNC_DATA={
'read_db_entry': ['read_db_entry', '', [['locations_modules/2dmap','minimap.php',10],['libs','misc_util.php',71]], 27],
'close': ['close', '', [['libs','db_conn_5.php',35],['libs','db_conn_5.php',87],['libs','db_conn_4.php',35],['libs','db_conn_4.php',87]], 380],
'execute': ['execute', '', [['libs','db_conn_5.php',37],['libs','db_conn_4.php',37]], 652],
'calc_effect': ['calc_effect', 'This page is used to calculate the effect of the spell casted by the player. ', [['skills','cast_spell.php',2]], 5],
'mt_rand': ['mt_rand', '', [], 102],
'count': ['count', '', [], 113],
'str_replace': ['str_replace', '', [], 44],
'ceil': ['ceil', '', [], 66],
'round': ['round', '', [], 19],
'pow': ['pow', '', [], 3]};
CLASS_DATA={
};
CONST_DATA={
};

titleDescriptionBody
titleDescriptionBody
titleDescriptionBody
titleBody



Generated: Sun Jul 8 18:11:25 2007
Cross-referenced by PHPXref 0.7





Wyszukiwarka

Podobne podstrony:
cast spell
cast spell
remove spell
P C and Kristin Cast Dom Nocy Ujawniona (Revealed) rozdział 18
Dragon Age Spell Grimoire
divine spell
P C Cast, Kristin Cast (Dom Nocy 01) Naznaczona [rozd 3,4,5]
Spell Sheet Exalted Deeds v3 5
Spell Bound Rozdział 31
Spell Sheet Wizard v3 5
Arcana Evolved Spell Treasury The Lost
spell checker
Spell Sheet Assassin v3 5
spell

więcej podobnych podstron