Player adventure class compare to item adventure

EQ2Emulator Development forum.

Moderator: Team Members

Post Reply
User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Player adventure class compare to item adventure

Post by Ememjr » Mon Mar 27, 2017 6:10 pm

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

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Player adventure class compare to item adventure

Post by Jabantiz » Mon Mar 27, 2017 6:56 pm

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.

User avatar
Ememjr
Team Member
Posts: 975
Joined: Wed Mar 15, 2017 9:41 am
EQ2Emu Server: Perseverance

Re: Player adventure class compare to item adventure

Post by Ememjr » Tue Mar 28, 2017 4:37 am

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
				}

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Player adventure class compare to item adventure

Post by Jabantiz » Tue Mar 28, 2017 3:28 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests