forked from AlexJezior/TheFallenImmortals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attackdemon.php
134 lines (124 loc) · 9.81 KB
/
attackdemon.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
<?php
session_name("icsession");
session_start();
include('db.php');
$getchar = mysqli_query($conn, "SELECT * FROM characters WHERE id='".$_SESSION['userid']."'") or die(mysqli_error());
$char = mysqli_fetch_assoc($getchar);
if(isset($_POST['demonid'])){
$findDemon = mysqli_query($conn, "SELECT * FROM demons WHERE id='".$_POST['demonid']."'");
if(mysqli_num_rows($findDemon) >= "1"){
$demon = mysqli_fetch_assoc($findDemon);
if($char['level'] >= "10000" && $demon['power'] == "1"){
die("alert('After level 10,000, you may only kill Overlord Demons.');");
}
if($demon['xpos'] != $char['posx'] || $demon['ypos'] != $char['posy']){
print("alert('This demon is located at (".$demon['xpos'].", ".$demon['ypos'].").');");
die();
}
$demonRel = explode(', ', $demon['relativeLoc']);
$charRel = explode(', ', $char['relativeLoc']);
$demonXtop = $demonRel[0]+32;
$demonXbottom = $demonRel[0]-32;
$demonYtop = $demonRel[1]+32;
$demonYbottom = $demonRel[1]-32;
if(($demonXtop >= $charRel[0] && $demonXbottom <= $charRel[0]) && ($demonYtop >= $charRel[1] && $demonYbottom <= $charRel[1])){
}else{
die("alert('You must move closer to the demon to attack it!');");
}
$characterChance = mt_rand(1, 3);
if($characterChance == "1" && $demon['health'] > "0"){ //Character attacks demon
if($char['class'] == "Mage" || $char['class'] == "Mage II" || $char['class'] == "Mage III" || $char['class'] == "Mage IV" || $char['class'] == "Mage V" || $char['class'] == "Sorcerer" || $char['class'] == "Sorcerer II" || $char['class'] == "Sorcerer III" || $char['class'] == "Sorcerer IV" || $char['class'] == "Sorcerer V" || $char['class'] == "Elemental"){
$damagemin = floor($charint * "0.4");
$damagemax = floor($charint * "0.5");
}else{
$damagemin = floor($charstr * "0.4");
$damagemax = floor($charstr * "0.5");
}
$damageval = mt_rand($damagemin, $damagemax);
$demonNewHealth = $demon['health'] - $damageval;
$hurtdemon = mysqli_query($conn, "UPDATE demons SET health=health-'".$damageval."' WHERE id='".$demon['id']."'");
$data .= "You hit ".$demon['name']." for ".number_format($damageval)." damage!<br />";
$data .= "".$demon['name']." has ".number_format($demonNewHealth)." left!<br />";
if($demon['health'] <= "0" || $demonNewHealth <= "0"){
$data .= "You killed ".$demon['name']."!<br />";
if($demon['name'] == "Barbatos"){
$reward = mysqli_query($conn, "UPDATE characters SET stats=stats+'250' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 250 Stat Points in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 250 Stat Points!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Barbatos Overlord"){
$reward = mysqli_query($conn, "UPDATE characters SET stats=stats+'1000' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 1,000 Stat Points in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 1,000 Stat Points!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Incubus"){
$reward = mysqli_query($conn, "UPDATE characters SET gold=gold+'1500000' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 1,500,000 Gold in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 1,500,000 Gold!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Incubus Overlord"){
$reward = mysqli_query($conn, "UPDATE characters SET gold=gold+'10000000' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 10,000,000 Gold in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 10,000,000 Gold!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Eurynome"){
$reward = mysqli_query($conn, "UPDATE characters SET blood=blood+'300' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 300 oz. of Blood in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 300 oz. of Blood!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Eurynome Overlord"){
$reward = mysqli_query($conn, "UPDATE characters SET blood=blood+'1200' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 1,200 oz. of Blood in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 1,200 oz. of Blood!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Gula"){
$reward = mysqli_query($conn, "UPDATE characters SET cash=cash+'1' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 1 Cash in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 1 Cash!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}elseif($demon['name'] == "Gula Overlord"){
$reward = mysqli_query($conn, "UPDATE characters SET cash=cash+'3' WHERE id='".$_SESSION['userid']."'");
$data .= "You gain 3 Cash in your success!<br />";
$messagechat = "<strong><font color=\'#FF0000\'>".$char['username']." killed ".$demon['name']." and gained 3 Cash!</font></strong><br />";
$query = mysqli_query($conn, "INSERT INTO chatroom (`date`, `userlevel`, `username`, `message`, `to`) VALUES ('".$date."', '3', '".$char['username']."', '".$messagechat."', 'Chatroom')");
}
}else{
$demondamsmall = floor($demon['power'] * "500000");
$demondambig = floor($demon['power'] * "5000000");
$demondamage = mt_rand($demondamsmall, $demondambig);
$data .= "".$demon['name']." hits you for ".number_format($demondamage)." damage!<br />";
$data .= "".$demon['name']." has ".number_format($demon['health'])." left!<br />";
$updateCharHealth = mysqli_query($conn, "UPDATE characters SET life=life-'".$demondamage."' WHERE id='".$_SESSION['userid']."'");
$charhealth = $char['life'] - $demondamage;
if($char['life'] <= "0" || $charhealth <= "0"){
$data .= "<font color=\'#FF0000\'>You have died, but the fierce will to defeat this demon has brought you back to life!</font><br />";
$killplayer = mysqli_query($conn, "UPDATE characters SET life='".$char['endurance']."' WHERE id='".$_SESSION['userid']."' ");
$data .= "</center>";
}else{
$data .= "</center>";
}
}
}elseif($demon['health'] > "0"){ //Character misses demon
$data .= "You fail to hit ".$demon['name']."!<br />";
$demondamsmall = floor($demon['power'] * "500000");
$demondambig = floor($demon['power'] * "5000000");
$demondamage = mt_rand($demondamsmall, $demondambig);
$data .= "".$demon['name']." hits you for ".number_format($demondamage)." damage!<br />";
$data .= "".$demon['name']." has ".number_format($demon['health'])." left!<br />";
$charhealth = $char['life'] - $demondamage;
if($char['life'] <= "0" || $charhealth <= "0"){
$data .= "<font color=\'#FF0000\'>You have died, but the fierce will to defeat this demon has brought you back to life!</font><br />";
$killplayer = mysqli_query($conn, "UPDATE characters SET life='".$char['endurance']."' WHERE id='".$_SESSION['userid']."' ");
$data .= "</center>";
}else{
}
}else{
$data .= "The demon is dead!<br />";
}
}else{
$data .= "The demon is dead!<br />";
}
}
print("fillDiv('travelDesc','".$data."');");
include('updatestats.php');
?>