Character Browser SoD HP/Mana/End Calculations
Reply
SoD HP/Mana/End Calculations
I posted a few changes to allow CharBrowser to use the new SoD client calculations. For some reason, I still can't get the code tags on this forum to show all of my code (it tends to cut off before -> or randomly at a $), so I submitted it there if anyone wants to use it.

http://www.eqemulator.org/forums/showpost.php?p=193814&postcount=2
Sat Oct 30, 2010 1:09 pm
Can you post the chunk that is causing errors on the boards, I'll look into it.
Sat Oct 30, 2010 1:53 pm
Project Lead
From my post on Bots, this is all that comes in for /searchbots.php. It cuts off everything before the arrow in $template->set_filenames(array()). I had this problem with any section that contained the -> in it.

php
More +
<php>set_filenames(array(
  'body' => 'searchbots_body.tpl')
);

$template->assign_vars(array(  
  'ORDER_LINK' => $baselink."&start=$start&direction=".(($direction=="ASC") ? "DESC":"ASC"),
  'PAGINATION' => generate_pagination("$baselink&orderby=$orderby&direction=$direction", $totalbots, $numToDisplay, $start, true),
  'L_RESULTS' => $language['SEARCH_RESULTS'],
  'L_NAME' => $language['SEARCH_NAME'],
  'L_LEVEL' => $language['SEARCH_LEVEL'],
  'L_CLASS' => $language['SEARCH_CLASS'],
  'L_DONE' => $language['BUTTON_DONE'],
  'CHARNAME' => $char,)
);

if(mysql_num_rows($results) > 0) {
  while($row = mysql_fetch_array($results)) {
    $template->assign_block_vars("characters", array(
      'CLASS' => $dbclassnames[$row["class"]],     
      'LEVEL' => $row["botlevel"],
      'NAME' => $row["name"],
      'CHARNAME' => $row["charname"],
      'GUILD_NAME' => (($row["guildname"]) ? "&lt;".$row["guildname"]."&gt;":"") )
    );
  }
}

$template->pparse('body');

//dump footer
include("include/footer.php");

?>


and in this submission, it cut out half of GetMaxHP, but everything else was fine:
php
More +

//function copied/converted from EQEMU sourcecode oct 26, 2010
function GetMaxHP($mlevel,$class,$sta,$ihp,$useSoDHPManaEnd)
{
        if($useSoDHPManaEnd == 1)
        {
                $SoDPost255 = 0;

                if((($sta- 255) / 2) > 0)
                        $SoDPost255 = (($sta- 255) / 2);
                else
                        $SoDPost255 = 0;

                $hp_factor = GetClassHPFactor($class);
               
                if ($mlevel < 41) {
                        $base_hp = (5 + ($mlevel * $hp_factor / 12) +
                                (($sta- $SoDPost255) * $level * $hp_factor / 3600));
                }
                **MISSING CODE GOES HERE**
                else if ($mlevel <81> 0)
                        $Post255 = ($sta-255)/2;
                else
                        $Post255 = 0;
               
                $base_hp = (5)+($mlevel*$lm/10) + ((($sta-$Post255)*$mlevel*$lm/3000)) + (($Post255*$mlevel)*$lm/6000);

                $base_hp += $ihp;
        }

        return floor($base_hp);
}


it cut this out:
else if ($mlevel < 81) {
$base_hp = (5 + (40 * hp_factor / 12) + (($mlevel - 40) * $hp_factor / 6) +
(($sta- $SoDPost255) * $hp_factor / 90) +
(($sta- $SoDPost255) * ($mlevel - 40) * $hp_factor / 1800));
}
else {
$base_hp = (5 + (80 * $hp_factor / 8) + (($mlevel - 80) * $hp_factor / 10) +
(($sta- $SoDPost255) * $hp_factor / 90) +
(($sta- $SoDPost255) * $hp_factor / 45));
}

$base_hp += $ihp;
}
else
{
$lm = GetClassLevelFactor($mlevel,$class);
$Post255 = 0;
Sat Oct 30, 2010 2:59 pm
I'll look in the DB when i get home and see if it's cutting it off during the posting or viewing. Hopefully I'll have it sorted out soon.
Sat Oct 30, 2010 3:15 pm
Project Lead
it's wrong in the database so its getting chopped off during posting, i'll do a quick walkthrough of the code to see if I can spot it


oh, in the top of your functions use

php
More +
global $useSoDHPManaEnd;


that will make the variable available at the function scope
Last edited by Maudigan on Sun Dec 05, 2010 8:54 pm; edited 2 times in total
Sun Oct 31, 2010 8:31 am
Project Lead
Fixed, I traced it back to the HTML parser. Something in the default regex was detecting the less than 81, and the greater than 0 a few lines lower as an html tag... it turned that whole chunk of code into <81>. Instead of jacking around with phpbb's default regex I just disabled HTML on the boards. The only tag that was available was <center>, I'll just add some bbcode to use [center] in the future.



Edit: i forgot to mention, this was something I had planned on adding so i may merge this in when I do gaeorns security patch.


php
More +
//function copied/converted from EQEMU sourcecode oct 26, 2010
function GetMaxHP($mlevel,$class,$sta,$ihp,$useSoDHPManaEnd)
{
        if($useSoDHPManaEnd == 1)
        {
                $SoDPost255 = 0;

                if((($sta- 255) / 2) > 0)
                        $SoDPost255 = (($sta- 255) / 2);
                else
                        $SoDPost255 = 0;

                $hp_factor = GetClassHPFactor($class);
               
                if ($mlevel < 41) {
                        $base_hp = (5 + ($mlevel * $hp_factor / 12) +
                                (($sta- $SoDPost255) * $level * $hp_factor / 3600));
                }
                else if ($mlevel < 81) {
                        $base_hp = (5 + (40 * hp_factor / 12) + (($mlevel - 40) * $hp_factor / 6) +
                                (($sta- $SoDPost255) * $hp_factor / 90) +
                                (($sta- $SoDPost255) * ($mlevel - 40) * $hp_factor / 1800));
                }
                else {
                        $base_hp = (5 + (80 * $hp_factor / 8) + (($mlevel - 80) * $hp_factor / 10) +
                                (($sta- $SoDPost255) * $hp_factor / 90) +
                                (($sta- $SoDPost255) * $hp_factor / 45));
                }

                $base_hp += $ihp;
        }
        else
        {
                $lm = GetClassLevelFactor($mlevel,$class);
                $Post255 = 0;
                if(($sta-255)/2 > 0)
                        $Post255 = ($sta-255)/2;
                else
                        $Post255 = 0;
               
                $base_hp = (5)+($mlevel*$lm/10) + ((($sta-$Post255)*$mlevel*$lm/3000)) + (($Post255*$mlevel)*$lm/6000);

                $base_hp += $ihp;
        }

        return floor($base_hp);
}
Last edited by Maudigan on Sun Dec 05, 2010 8:52 pm; edited 1 time in total
Sun Oct 31, 2010 9:35 am
Project Lead
Nice. Thanks for the info, and glad it was a pretty east fix.
Mon Nov 01, 2010 6:51 am
Character Browser SoD HP/Mana/End Calculations
Reply