hero update

This commit is contained in:
Shadow
2014-03-18 07:35:37 +02:00
parent 6e62f2232f
commit 7cfa82a18d
24 changed files with 652 additions and 10 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
## Filename addTroops.php ##
## Developed by: Dzoki & Advocatie ##
## License: TravianZ Project ##
## Reworks by: ronix ##
## Copyright: TravianZ (c) 2010-2014. All rights reserved. ##
## ##
#################################################################################
if(!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../Database.php");
$status="&ce=1";
if(isset($_POST['id'])) {
$_POST['hname'] = trim(stripslashes($_POST['hname']));
if ($_POST['hname']=="") {
header("Location: ../../../Admin/admin.php?p=editHero&uid=".$_POST['id']."&e=1");
exit;
}
include_once("../../Data/hero_full.php");
$id = $_POST['id'];
$q = "UPDATE ".TB_PREFIX."hero SET unit=".$_POST['hunit'].", name='".$_POST['hname']."', level=".$_POST['hlvl'].", points=".$_POST['exp'].", experience=".$hero_levels[$_POST['hlvl']].", health=".$_POST['hhealth'].",
attack=".$_POST['hatk'].", defence=".$_POST['hdef'].", attackbonus=".$_POST['hob'].", defencebonus=".$_POST['hdb'].", regeneration=".$_POST['hrege']." WHERE uid = ".$id;
$return=$database->query($q);
if($return) {
$database->query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed hero info',".time().")");
$status="&cs=1";
}
}
header("Location: ../../../Admin/admin.php?p=player&uid=".$id.$status);
?>
+38
View File
@@ -70,6 +70,44 @@ class funct {
case "logout":
$this->LogOut();
break;
case "killHero":
$varray = $database->getProfileVillages($get['uid']);
$killhero=false;
$error="";
for ($i = 0; $i <= count($varray)-1; $i++) {
$killhero=$database->FindHeroInVil($varray[$i]['wref']);
if ($killhero) break;
$killhero=$database->FindHeroInDef($varray[$i]['wref']);
if ($killhero) break;
$killhero=$database->FindHeroInMovement($varray[$i]['wref']);
if ($killhero) break;
}
if (!$killhero){
$killhero=$database->FindHeroInOasis($get['uid']);
}
if ($killhero) {
$database->KillMyHero($get['uid']);
$error="&kc=1";
}else $error="&e=1";
header("Location: admin.php?p=player&uid=".$get['uid'].$error);
exit;
case "reviveHero":
$result=$database->query("SELECT * FROM ".TB_PREFIX."hero WHERE uid='".$get['uid']."'");
$hdata=mysql_fetch_array($result);
$database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".$hdata['wref']);
$database->query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".time()." WHERE `uid` = '".$get['uid']."'");
header("Location: admin.php?p=player&uid=".$get['uid']."&rc=1");
exit;
case "addHero":
$user = $database->getUserArray($get['uid'],1);
$vilarray=$database->getVrefCapital($get['uid']);
$database->query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`,
`experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`,
`intraining`) VALUES ('".$get['uid']."', '" . $vilarray['wref'] . "', '0', '".$get['u']."', '".addslashes($user['username'])."',
'0', '5', '0', '0', '100', '0', '0', '0', '0', '".time()."', '50', '0')");
header("Location: admin.php?p=player&uid=".$get['uid']."&ac=1");
exit;
}
if($get['action'] == 'logout'){
header("Location: admin.php");
+86 -4
View File
@@ -3657,10 +3657,10 @@ References:
}
}
/*****************************************
Function to vacation mode - by advocaite
References:
*****************************************/
/*****************************************
Function to vacation mode - by advocaite
References:
*****************************************/
/***************************
Function to get Hero Dead
@@ -3731,6 +3731,88 @@ References:
$q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id;
return mysql_query($q, $this->connection);
}
/***************************
Function to find Hero place
Made by: ronix
***************************/
function FindHeroInVil($wid) {
$result = $this->query("SELECT * FROM ".TB_PREFIX."units WHERE hero>0 AND vref='".$wid."'");
if (!empty($result)) {
$dbarray = mysql_fetch_array($result);
if(isset($dbarray['hero'])) {
$this->query("UPDATE ".TB_PREFIX."units SET hero=0 WHERE vref='".$wid."'");
unset($dbarray);
return true;
}
}
return false;
}
function FindHeroInDef($wid) {
$delDef=true;
$result = $this->query_return("SELECT * FROM ".TB_PREFIX."enforcement WHERE hero>0 AND `from` = ".$wid);
if (!empty($result)) {
$dbarray = mysql_fetch_array($result);
if(isset($dbarray['hero'])) {
$this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$wid);
for ($i=0;$i<50;$i++) {
if($dbarray['u'.$i]>0) {
$delDef=false;
break;
}
}
if ($delDef) $this->deleteReinf($wid);
unset($dbarray);
return true;
}
}
return false;
}
function FindHeroInOasis($uid) {
$delDef=true;
$dbarray = $this->query_return("SELECT e.*,o.conqured,o.owner FROM ".TB_PREFIX."enforcement as e LEFT JOIN ".TB_PREFIX."odata as o ON e.vref=o.wref where o.owner=".$uid." AND e.hero>0");
if(!empty($dbarray)) {
foreach($dbarray as $defoasis) {
if($defoasis['hero']>0) {
$this->query("UPDATE ".TB_PREFIX."enforcement SET hero=0 WHERE `from` = ".$defoasis['from']);
for ($i=0;$i<50;$i++) {
if($dbarray['u'.$i]>0) {
$delDef=false;
break;
}
}
if ($delDef) $this->deleteReinf($defoasis['from']);
unset($dbarray);
return true;
}
}
}
return 0;
}
function FindHeroInMovement($wid) {
$outgoingarray = $this->getMovement(3, $wid, 0);
if(!empty($outgoingarray)) {
foreach($outgoingarray as $out) {
if ($out['t11']>0) {
$dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$out['ref']);
return true;
break;
}
}
}
$returningarray = $this->getMovement(4, $wid, 1);
if(!empty($returningarray)) {
foreach($returningarray as $ret) {
if($ret['attack_type'] != 1 && $ret['t11']>0) {
$dbarray = $this->query("UPDATE ".TB_PREFIX."attacks SET t11=0 WHERE `id` = ".$ret['ref']);
return true;
break;
}
}
}
return false;
}
/***************************
Function checkAttack
+1 -1
View File
@@ -845,7 +845,7 @@ The construction plans are conquerable immediately when they appear to the serve
There will be a countdown in game, showing the exact time of the release, 5 days prior to the launch. ");
//planos
//Building Plans
define("PLAN","Ancient Construction Plan");
define("PLANVILLAGE","WW Buildingplan");
define("PLAN_DESC","With this ancient construction plan you will able to build World Wonder to level 50. to build further, your alliance must hold at least two plans.");
+2 -2
View File
@@ -704,9 +704,9 @@ header("Location: banned.php");
}
}
public function Hero($uid) {
public function Hero($uid,$all=0) {
global $database;
$heroarray = $database->getHero($uid);
$heroarray = $database->getHero($uid,$all);
$herodata = $GLOBALS["h".$heroarray[0]['unit']];
$h_atk = $herodata['atk'] + 5 * floor($heroarray[0]['attack'] * $herodata['atkp'] / 5);