EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   Inspect code (https://www.eqemulator.org/forums/showthread.php?t=668)

Merkur 03-09-2002 10:33 AM

Inspect code
 
Just some lines for inspect. Hope you can need it.

client_process.cpp:

case OP_InspectRequest: { // 03/09 - Merkur
Inspect_Struct* ins = (Inspect_Struct*) app->pBuffer;
Mob* tmp = entity_list.GetMob(ins->TargetID);
tmp->CastToClient()->QueuePacket(app); // Send request to target
break;
}
// OP_InspectAnswer is 0xb620 (add to eq_opcodes.h)
case OP_InspectAnswer: {
Inspect_Struct* ins = (Inspect_Struct*) app->pBuffer;
Mob* tmp = entity_list.GetMob(ins->TargetID);
tmp->CastToClient()->QueuePacket(app); // Send answer to requester
break;
}


eq_packets_struct.h:
//Inspect
struct Inspect_Struct {
int16 TargetID;
int16 PlayerID;
};


Works fine ;)

Merkur 03-09-2002 02:58 PM

Some more lines :) Consider works pretty good this way - not 100% perfect but pretty close to EQ Live.

Code:

case OP_Consider:    //03/09  -Merkur
        {
                Consider_Struct* conin = (Consider_Struct*)app->pBuffer;
                if (conin->targetid == GetID())
                        break;                // don't consider yourself
               
                APPLAYER* outapp = new APPLAYER(OP_Consider, sizeof(Consider_Struct));
                Consider_Struct* con = (Consider_Struct*)outapp->pBuffer;
                con->playerid = GetID();
                con->targetid = conin->targetid;
                con->faction = GetFactionLevel(character_id,entity_list.GetMob(conin->targetid)->GetNPCTypeID(), race, class_, DEITY_AGNOSTIC); // rembrant, Dec. 20, 2001; TODO: Send the players proper deity                                               
                sint8 tmp = entity_list.GetMob(conin->targetid)->GetLevel() - this->GetLevel();
               
                int32 conlevel;
                if (GetLevel() <= 12)
                {
                        conlevel =  (tmp <= -4) ? 0x02:                        //green
                (tmp >=-3 && tmp <= -1) ? 0x04://blue
                (tmp == 0) ? 0x00:                                //white
                (tmp >= 1 && tmp <= 2) ?0x0F:    //yellow
                0x0D;                                                        //red
                }
                else if (GetLevel() >= 13 && GetLevel() <= 24)
                {
                        conlevel =  (tmp <= -6) ? 0x02:                        //green
                (tmp >=-5 && tmp <= -4) ? 0x12: //blue2
                (tmp >=-3 && tmp <= -1) ? 0x04://blue
                (tmp == 0) ? 0x00:                                //white
                (tmp >= 1 && tmp <= 2) ?0x0F:    //yellow
                0x0D;                                                        //red
                }
                else if (GetLevel() >= 25 && GetLevel() <= 40)
                {
                        conlevel =  (tmp <= -11) ? 0x02:                        //green
                (tmp >=-10 && tmp <= -8) ? 0x04://blue
                (tmp == 0) ? 0x00:                                //white
                (tmp >= 1 && tmp <= 2) ?0x0F:    //yellow
                0x0D;                                                        //red
                }
                else if (GetLevel() >= 41 && GetLevel() <= 48)
                {
                        conlevel =  (tmp <= -12) ? 0x02:                        //green
                (tmp >=-11 && tmp <= -1) ? 0x04://blue
                (tmp == 0) ? 0x00:                                //white
                (tmp >= 1 && tmp <= 2) ?0x0F:    //yellow
                0x0D;                                                        //red
                }
                else if (GetLevel() >= 50)
                {
                        conlevel =  (tmp <= -14) ? 0x02:                        //green
                (tmp >=-13 && tmp <= -1) ? 0x04://blue
                (tmp == 0) ? 0x00:                                //white
                (tmp >= 1 && tmp <= 2) ?0x0F:    //yellow
                0x0D;                                                        //red
                };
                con->level = conlevel;
                //  These values are only used if you con PCs (i think), but i see no reason...
                //        con->cur_hp = target->GetHP(); // rembrant, Dec. 20, 2001
                //        con->max_hp = target->GetMaxHP(); // rembrant, Dec. 20, 2001
                QueuePacket(outapp);
                delete outapp;                       
                break;
        }

edit: fixed a small error in this code (used wrong id for faction)

DeletedUser 03-10-2002 11:53 AM

Currently our CVS is down, but I will merge this soon (tm). What source version did you use to create it?:)

Merkur 03-10-2002 12:06 PM

I used the current Version 0.2.4.5

btw: in my version, i put these conlevel thing in a newfunction because i needed it for other things (i.e. determinate npc aggroradius) too.

theCoder 03-10-2002 04:49 PM

function in Mob?
 
I'm still trying to learn how the EMU code works (mostly be looking at it when I can and lurking on the dev board :)), so this may have implications I don't understand. But the OO side of me thinks that it would be easier to put the consider code into a function on the Mob class. Something like

int Mob::consider(Mob* target)
{
// Merkur's code here
}

Then in the processing function, replace most of the code with
con->level = this->consider(entity_list.GetMob(conin->targetid));

This wouldn't add any functionality, but it might make the code a little easier to manage (especially since the Client::Process function is over 2000 lines long already)

Merkur 03-10-2002 09:43 PM

Yup, it would be better (and like i wrote i did it), but its easier to post this way :)

T7g 03-11-2002 09:49 AM

/auction wtb good coders to work on emu, /tell one of the devs

theCoder 03-11-2002 10:52 AM

Heh, I'd love to, but I barely have the time to keep up to date on the boards. I still haven't even extracted the 0.2.4-preX stuff yet...

but I can try to offer insight every once and a while :)


All times are GMT -4. The time now is 02:32 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.