Jump to content

Recommended Posts

Hey a friend of mine gave me a function to help me make a new one can someone Add some comments and or make it better in the coding part,

Heres the Function:

<?php
function getStrikeAction($user){
global $conf;
$num=0;
$trainedCount=$user->trainedAttackSold+$user->trainedAttackMerc;
$untrainedCount=$user->untrainedMerc+$user->untrainedSold;
$weaponA1=getUserWeapon($user);
if (!count($weaponA1)&&!$trainedCount) return 0;
/*$k=0;
for ($i=0;$i<count($weaponA1);$i++){
	for ($j=0; $j<$weaponA1[$i]->weaponCount ;$j++){
		$weaponA[$k]=$weaponA1[$i];
		$k++;
	}
}*/
$weaponA=getWeaponArray($weaponA1);
if ($weaponA){
	$wepAlloc=getWeaponAllocation($user,$weaponA,$trainedCount,$untrainedCount);
	$wI=0;
	for ($i=0; $i<$wepAlloc["trainedW"];$i++,$wI++){
		$num+=$weaponA[$wI]->weaponStrength*5;
	}
	for ($i=0; $i<$wepAlloc["untrainedW"];$i++,$wI++){
		$num+=$weaponA[$wI]->weaponStrength*4;
	}
}else{
	$wepAlloc["trainedUnW"]=$trainedCount;
	$wepAlloc["untrainedUnW"]=$untrainedCount;
}
$num+=$wepAlloc["trainedUnW"]*5;
$num+=$wepAlloc["untrainedUnW"]*4;
for ($i=0; $i<=$user->siegeLevel;$i++){
	if ($conf["race"][$user->race]["siege"][$i]["attack"]){
		$num+=round(($num*$conf["race"][$user->race]["siege"][$i]["attack"])/100);
	}
}

if ($conf["race"][$user->race]["attack"]){
	$num+=round(($num*$conf["race"][$user->race]["attack"])/100);
}
return $num;
}?>

 

Thanx ~Dethman

We'd need to see the script as a whole to really give an honest effort into making it "better." (Please don't post your whole script here).  If you're really serious about making it "better," I suggest hiring someone.  That way they can take a look at your setup/files/code as a whole and evaluate the situation. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.