Page 1 of 1

Player adventure class compare to item adventure

Posted: Mon Mar 27, 2017 6:10 pm
by Ememjr
so i am looking at the items table adventure_classes field from what i can tell it is some type of bitmap to represent what classes can use the item

i am looking to change the quests.cpp and of course test it but would like to know how to compare that field to the current players class and get either a boolean response

i see where to get the items adventure class (item->generic_info.adventure_classes) but i do not know where to get the players class

so something like this

if item->generic_info.adventure_classes incluses ??the playerclass(lets say the player picking up a quest)
do something here;

still learning how everthing works together in eq2emu

Re: Player adventure class compare to item adventure

Posted: Mon Mar 27, 2017 6:56 pm
by Jabantiz
player->GetAdventureClass() will return the id of the class.

If I remember right, has been a long time sense I actually worked with bitmaps, you need to convert the class id into its bitmap equivalent which would be

Code: Select all

int64 id = pow(2, GetAdventureClass() - 1);
and then you compare that value to the bitmask by doing an and

Code: Select all

if ((item->generic_info.adventure_classes & id) > 0) {
    // class is in the bitmask
}
Make sure to have the ( ) around the and operation or else it will cause logic errors.

Again it has been a while sense I worked with this stuff so some of it might be off.

Re: Player adventure class compare to item adventure

Posted: Tue Mar 28, 2017 4:37 am
by Ememjr
thanks a lot

i did have to modify a little, had to divide the item->generic_info.adventure_classes by 2 in order for the bits to line up correctly

Code: Select all

if ((id & (item->generic_info.adventure_classes / 2)) > 0) {
					// class in bit mask
				}

Re: Player adventure class compare to item adventure

Posted: Tue Mar 28, 2017 3:28 pm
by Jabantiz
Remember that it needs to be an unsigned int 64 for the id as that is what the adventure_classes should be. You should not modify the adventure_classes directly as that is just to store the bits, changing that value at all means the bits will shift around and no longer line up properly.