Add crazy fancy damage/exp formulas
This commit is contained in:
parent
e3dd24565b
commit
be5a7e80f9
@ -15,11 +15,15 @@ if ($place['teamid'] == $user['teamid']) {
|
|||||||
sendError("Don't attack your own kind!", true);
|
sendError("Don't attack your own kind!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The underwhelming damage formulas :P
|
// The damage formulas
|
||||||
require_once 'type_grid.php';
|
require_once 'type_grid.php';
|
||||||
$userdrain = 5 * floor($user['level']);
|
$userdrain = pow(floor($user['level']), 0.5) * 5;
|
||||||
$damage = 2 * $userdrain * $TYPE_GRID[$user['teamid']][$place['teamid']];
|
$type_mod = $TYPE_GRID[$user['teamid']][$place['teamid']];
|
||||||
|
if ($type_mod == 0.5) {
|
||||||
|
$type_mod = 0.8;
|
||||||
|
}
|
||||||
|
$damage = pow(floor($user['level']), 0.5) * 4 * $type_mod;
|
||||||
|
//$damage = 2 * $userdrain * $TYPE_GRID[$user['teamid']][$place['teamid']];
|
||||||
// Check if action possible
|
// Check if action possible
|
||||||
if ($user['energy'] < $userdrain) {
|
if ($user['energy'] < $userdrain) {
|
||||||
sendError("Not enough life left!", true);
|
sendError("Not enough life left!", true);
|
||||||
@ -36,9 +40,18 @@ if ($placehp < 0) {
|
|||||||
$placehp = 0;
|
$placehp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the user's health
|
// Update the user's health and level
|
||||||
// TODO: calculate XP and add to decimal portion of level
|
$exp = pow(pow(floor($user['level']) + 1, 2), -0.9);
|
||||||
$database->update('players', ['energy' => $userhp], ['uuid' => $_SESSION['uuid']]);
|
$userlevel = $user['level'] + $exp;
|
||||||
|
// If the new level is a whole int bigger than the current
|
||||||
|
$dolevelup = false;
|
||||||
|
if (floor($userlevel) > floor($user['level'])) {
|
||||||
|
$dolevelup = true;
|
||||||
|
$newmaxhp = floor($userlevel) * 100;
|
||||||
|
$database->update('players', ['energy' => $newmaxhp, 'maxenergy' => $newmaxhp, 'level' => $userlevel], ['uuid' => $_SESSION['uuid']]);
|
||||||
|
} else {
|
||||||
|
$database->update('players', ['energy' => $userhp, 'level' => $userlevel], ['uuid' => $_SESSION['uuid']]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($placehp == 0) {
|
if ($placehp == 0) {
|
||||||
// It's dead
|
// It's dead
|
||||||
@ -48,4 +61,4 @@ if ($placehp == 0) {
|
|||||||
$database->update('locations', ['currentlife' => $placehp], ['locationid' => $VARS['locationid']]);
|
$database->update('locations', ['currentlife' => $placehp], ['locationid' => $VARS['locationid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendOK("Success!");
|
sendOK(($dolevelup ? "Level up!" : "Success!"));
|
||||||
|
@ -28,11 +28,20 @@ if ($userhp < 0) {
|
|||||||
sendError("Not enough life left!", true);
|
sendError("Not enough life left!", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the user's health
|
// Update the user's health and level
|
||||||
// TODO: calculate XP and add to decimal portion of level
|
$exp = pow(pow(floor($user['level']) + 1, 2), -0.9);
|
||||||
$database->update('players', ['energy' => $userhp], ['uuid' => $_SESSION['uuid']]);
|
$userlevel = $user['level'] + $exp;
|
||||||
|
// If the new level is a whole int bigger than the current
|
||||||
|
$dolevelup = false;
|
||||||
|
if (floor($userlevel) > floor($user['level'])) {
|
||||||
|
$dolevelup = true;
|
||||||
|
$newmaxhp = floor($userlevel) * 100;
|
||||||
|
$database->update('players', ['energy' => $newmaxhp, 'maxenergy' => $newmaxhp, 'level' => $userlevel], ['uuid' => $_SESSION['uuid']]);
|
||||||
|
} else {
|
||||||
|
$database->update('players', ['energy' => $userhp, 'level' => $userlevel], ['uuid' => $_SESSION['uuid']]);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the place
|
// Update the place
|
||||||
$database->update('locations', ['currentlife' => 100, 'maxlife' => 100, 'owneruuid' => $_SESSION['uuid'], 'teamid' => $user['teamid']], ['locationid' => $VARS['locationid']]);
|
$database->update('locations', ['currentlife' => 100, 'maxlife' => 100, 'owneruuid' => $_SESSION['uuid'], 'teamid' => $user['teamid']], ['locationid' => $VARS['locationid']]);
|
||||||
|
|
||||||
sendOK("Success!");
|
sendOK(($dolevelup ? "Level up!" : "Success!"));
|
||||||
|
Reference in New Issue
Block a user