Help on some PHP code for amory

Hello, i’m trying to modify an amory based on shadez (edited for azerothcore) to work without patching the core, for now i’m able to search for player and see what they equip, but i can’t see the base stats (they are all 0 because they are taken from the table that the server patch send to sql )

I find this piece of code : 

/**
     * Returns array with Strength value
     * @category Character class
     * @access   private
     * @return   array
     **/
    private function GetCharacterStrength() {
        $tmp_stats = array();
        $tmp_stats['bonus_strenght'] = Utils::GetFloatValue($this->GetDataField(UNIT_FIELD_POSSTAT0), 0);
        $tmp_stats['negative_strenght'] = Utils::GetFloatValue($this->GetDataField(UNIT_FIELD_NEGSTAT0), 0);
        $tmp_stats['effective'] = $this->GetDataField(UNIT_FIELD_STAT0);
        $tmp_stats['attack'] = Utils::GetAttackPowerForStat(STAT_STRENGTH, $tmp_stats['effective'], $this->class);
        $tmp_stats['base'] = $tmp_stats['effective'] - $tmp_stats['bonus_strenght'] - $tmp_stats['negative_strenght'];
        if(in_array($this->class, array(CLASS_WARRIOR, CLASS_PALADIN, CLASS_SHAMAN))) {
            $tmp_stats['block'] = max(0, $tmp_stats['effective'] * BLOCK_PER_STRENGTH - 10);
        }
        else {
            $tmp_stats['block'] = -1;
        }
        $player_stats = array(
            'attack'    => $tmp_stats['attack'],
            'base'      => $tmp_stats['base'],
            'block'     => $tmp_stats['block'],
            'effective' => $tmp_stats['effective']
        );
        unset($tmp_stats);
        return $player_stats;
    }

From what i understand this line $tmp_stats[‘effective’] = $this->GetDataField(UNIT_FIELD_STAT0); search for strength in the sql table i said before…

How can i make this function to “take” the strength data from the SQL database located in character_stats?

I tried something like $tmp_stats[‘effective’] = $this->db->select(“SELECT strength FROM character_stats WHERE guid=%d”, $this->guid); but it doesn’t work

P.S.

I AM NOT A CODER i am just able to read some basic code.

Thank you for your help  :)

I can help with TrinityCore armory, but not AzerothCore. They use a different database structure.

You could ask the AzerothCore community.

Thank you for your reply :slight_smile: i forgot to say that i’m using it with trinitycore :slight_smile: i “Adapted (i think :smiley: )” it for TC :slight_smile: as i said before i can see the equipped item but all the base stats are at 0 (Stamina agility strength etc.) :slight_smile:

I chose an armory made for azerothcore because it seem the most updated https://github.com/grimgravy/WoW-Armory

i really don’t understand why you need to patch your core when you have all the stats/numbers/achivments/talents etc on your database…mha… in fact this is what i’m trying to do remove the patch and take the most of the data from SQL TABLE in characters DB.

If you make this variable $tmp_stats[‘effective’] egual to a XXX number for example $tmp_stats[‘effective’] = 100; you will have in the strength stat 100 and the other stats on mouseover (like Attack power) corrected resolved.

The armory that I created is for 3.3.5a, I’m assuming that you can adapt the same concept with new introduced stats for Master.

However, I did not use Shadez wow armory, (that is literally so ancient). I started from scratch.

I don’t have the 3d models set up, but If I get time I can share a repo with an updated 3.3.5a armory. I had worked on playermapper for so long, I need to update the armory for 7.x

I don’t want to take advantage of you and your armory :slight_smile: feel free to share your work :slight_smile: 3D models for me aren’t necessary, yeah, they are good to see but they aren’t (for me) a priority… i just saw your playermapper, it is a very very very well done job congratulations :slight_smile:
anyway…in the meantime there is a chance for me to try to get a piece of code or some example on how to get that value from the code i wrote before? :slight_smile: i know shadez armory is really ancient, maybe 8years, and i don’t know if the azerothcore armory is just “adapted” to work or have some new code, but it works also with mangos and in my case with 2.4.3 core :slight_smile:

Thank you again for your help and time  :)

I managed to connect to character_stats data sql and “take” the base stats data (strength, intellect, stamina etc.) but how can i take for example hit rating or Attack speed?

I think there are some formula…

thx :slight_smile:

That’s pull by all the gear that the player is wearing, no real formula. I added the gear stats value and certain include certain stats changes for H.R. and Attack Speed depending on the talent the player uses.

I’m not home to look, but I remember pulling all gear value and talents.

is it possible to have an example of code? :slight_smile:

so I have hit rating, haste, defense, and mana regen. I will PM you the code details and you can dissect it. It’s a HUGE file with for loops and calls straight from the character table to html.

All in PhP.

Thank you so much for your kindness and your time… i Will see your code when i come back home :slight_smile:

Actually i’m interested on modifying TC code so that character_stats has more details, there are a ton of stats that I think that the core should be able to calc on it’s own.

I would like to help you but as i said before i’m not a coder ehhehe, i never studied it and i don’t know how i can understand some codes, for example i removed the part of code (from shadez-azerothcore armory) that don’t let you see the character’s items and stats giving you missing file… Yes i’m very slow, but maybe i can do it :stuck_out_tongue: i just have a lot of patience searching in the code and on google and have a lot of tries :stuck_out_tongue:

you need to find the function defined as ‘GetDataField’ should be some where in the controllers or modules depending on the structure or perhaps even somewhere in the same file your looking at, if you use a ide like netbeans it’ll list all the functions defined an will take you to the file location… but anyway from there you’ll need either to find what ever database differences to match what you need, or at least it’ll take you to next function that handles database requests. good luck and post back upon what you find :slight_smile:

from what i understand (i repeat im not a coder) that function and also (UNIT_FIELD_STAT0), take the data from the table “armory_character_stats”, if you known this armory need to patch the core, once you did it, the core save all the stats in the table “armory_character_stats”, if i remember well, mangos (and maybe TC also) did this some years ago, in fact at the first version of this armory you didn’t need to patch the core because the core save all the stats for you :slight_smile:

How ever it is in the same file :

			/**
		
	


			 
		
		
			* Returns value of $fieldNum field. Requires $this->guid or int $guid as second parameter!
		
	


			 
		
		
			* @category Characters class
		
	


			 
		
		
			* @access public
		
	


			 
		
		
			* @param int $fieldNum
		
	


			 
		
		
			* @param int $guid = null
		
	


			 
		
		
			* @return int
		
	


			 
		
		
			**/
		
	


			 
		
		
			public function GetDataField($fieldNum, $guid = null) {
		
	


			 
		
		
			if($guid == null && $this->guid > 0) {
		
	


			 
		
		
			$guid = $this->guid;
		
	


			 
		
		
			}
		
	


			 
		
		
			if(!$guid) {
		
	


			 
		
		
			Armory::Log()->writeError('%s : guid not provided', __METHOD__);
		
	


			 
		
		
			return false;
		
	


			 
		
		
			}
		
	


			 
		
		
			return (isset($this->char_data[$fieldNum])) ? $this->char_data[$fieldNum] : 0;
		
	


			 
		
		
			}

And here you can find the part about (UNIT_FIELD_STAT0) :slight_smile:

https://github.com/grimgravy/WoW-Armory/blob/master/includes/UpdateFields.php

UNIT_FIELD_POSSTAT0 and the rest like that are constants, not a function. https://secure.php.net/manual/en/function.defined.php

is anything being set in $guid or $this->guid? trying doing

var_dump($this); exit();

i can’t dump nothing :frowning: however, $guid is just the player guid : https://github.com/grimgravy/WoW-Armory/blob/master/includes/classes/class.characters.php#L40
you can find that $this anywhere in this file (and in other class.***.php files) i don’t understand what it does.

Is there anything out there that has a basic shell of an armory? I am just curious…

I really wish I had more time to write one up, like I did with playermapper. A basic shell (in php) that people could use and add onto and adapt. So far Iv’e noticed so many people downloading Shadez wow armory and it’s so outdated, even people pulling forks from what seems to a rough update of his armory down the line. 6 years ago I downloaded his armory and spent 2 days dissecting it. I ended up scrapping it and writing my own from scratch in 3 days.

It’s custom for my site, but I could write a basic armory shell if there is nothing out there and people wanted would get on board to add to the repo.

you are right, shadez armory is really old, in fact item tooltip don’t work with browser that aren’t Firefox (all the other tooltip works with all browsers), but this is the only one armory with code to the public :slight_smile: however it has a lot of functions as double spec talent, bank, arena, searching items in DB, talent calculator included and more… and can work with more realms and emulators (mangos and trinity) :slight_smile: i think is a really well done armory, yes it has his years, but maybe some coder can have a look at his code and “refresh” it :stuck_out_tongue: :slight_smile: