EQEmulator Forums

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

Wiz 05-06-2002 12:47 PM

Basic Feign Death code
 
After around eight hours of struggling with this, it's complete. It's very crude right now, has no "remember" factor and will only work if you're top on aggro.

Next version should have both of these fixed. :)

Insert into client_process.cpp:

Where the code for standing up is:
Code:

                                                        if (sa->parameter == 0x64)
                                                        {
//                                                                cout << "Client " << name << " standing" << endl;
                                                                appearance = 0;
                                                                this->SetFeigned(0);
                                                        }

Among skills code:
Code:

                                        case OP_FeignDeath:
                                        {
                                                int feignchance = GetSkill(FEIGN_DEATH);
                                                int primfeign = GetSkill(FEIGN_DEATH);
                                                if (primfeign > 100) {
                                                        primfeign = 100;
                                                }
                                                int secfeign = GetSkill(FEIGN_DEATH);
                                                if (secfeign < 101) {
                                                        secfeign = 0;
                                                }
                                                else {
                                                        secfeign = secfeign - 100;
                                                        secfeign = secfeign / 2;
                                                }
                                                int totalfeign = primfeign + secfeign;
                                                if (rand()%160 > (totalfeign)) {
                                                        Message(0,"You have fallen to the ground");
                                                        this->SetFeigned(0);
                                                        appearance = 3;
                                                }
                                                else {
                                                        this->SetFeigned(1);
                                                        appearance = 3;
                                                }
                                                if (rand()%210 > feignchance && rand()%3 == 1 && GetSkill(FEIGN_DEATH) < 200 && GetSkill(FEIGN_DEATH) < this->GetLevel()*5+5 ) {
                                                    this->SetSkill(25,++pp.skills[25]);
                                                        UpdateWho();
                                                }
                                                break;
                                        }

Client.cpp

Insert to bottom of Client:Client (below isgrouped=false)
Code:

        feigned = 0;
Insert to bottom of client.cpp
Code:

void Client::SetFeigned(int8 in_feigned) {
        feigned=in_feigned;
 }

client.h

Insert below bool GetPVP() { return pp.pvp; }
Code:

        void        SetFeigned(int8 in_feigned);
        int8    GetFeigned()        { return feigned; }

Insert at bottom of client.h, just above
};
#endif

Code:

        int8 feigned;
npcAI.cpp

Replace if (!sender->IsEngaged()) with:

Code:

if (!sender->IsEngaged() && currentmob->CastToClient()>GetFeigned() != 1)
npc.cpp

And finally, just above if (target->GetID() != this->ownerid && attack_timer->Check()) (line 334) add:

Code:

if (hate_list.GetTop()->CastToClient()->GetFeigned() == 1) {
                                RemoveFromHateList(GetHateTop());
                        }

There it is :)

Wiz 05-07-2002 03:05 AM

Version 2.0:

- Fixed a couple crash bugs
- Added basic spell breaks feign support
- Added basic memory code (NPC's can only remember one person right now, and if it returns to spawn point, memory list is wiped)

npc.cpp:

At the top of the script, just below extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; add:

Code:

int feigntimer = 0;
int forgetchance = 0;

Remove the old hate_list code, add this one instead, right above return true; on line 505 (above summon code):

Code:

        if (IsEngaged()) {
                if (hate_list.GetTop()->CastToClient()->GetFeigned() == 1) {
                                char* the_id = hate_list.GetTop()->CastToClient()->GetName();
                                if (this->GetLevel() > 34) {
                                        this->SetFeignMemory(the_id);
                                }
                                RemoveFromHateList(GetHateTop());
                        }
        }

Then add this right below what you just added in:

Code:

        if (this->GetFeignMemory() != "0") {
                Client* remember_client = entity_list.GetClientByName(this->GetFeignMemory());
                if (remember_client) {
                        if (remember_client->CastToClient()->GetFeigned()==0) {
                                AddToHateList(remember_client,1);
                                this->SetFeignMemory("0");
                                forgetchance = 0;
                        }
                        else if (feigntimer > 0) {
                                feigntimer = feigntimer - 1;
                        }
                        else if (rand()%100 <= forgetchance && feigntimer == 0) {
                                this->SetFeignMemory("0");
                                feigntimer = 100;
                                forgetchance = 0;
                        }
                        else if (feigntimer == 0) {
                                feigntimer = 100;
                                forgetchance = forgetchance + 4;
                        }
                }
                else {
                        this->SetFeignMemory("0");
                }
        }

Now, go into mob.cpp. In mob::mob right below invisible = false; add:

Code:

        feign_memory = "0";
Add this to the very bottom of mob.cpp:

Code:

void Mob::SetFeignMemory(char* in_feign_memory) {
        feign_memory=in_feign_memory;
 }

Then go into mob.h. Right below int16 d_meele_texture2; add:

Code:

        char*    feign_memory;
Then in the main function array, for example under void CheckPet(); add:

Code:

        void        SetFeignMemory(char* in_feign_memory);
        char*    GetFeignMemory()        { return feign_memory; }

Then, in spells.cpp, on whatever spell formulas you want to break feign:

Code:

                        if (this->CastToClient()->GetFeigned()==1) {
                                this->Message(0,"You are no longer feigning death because a spell hit you!");
                                this->CastToClient()->SetFeigned(0);
                        }

There. Current functions of my feign code:

- Skill gain, success and failure.
- All mobs will stop attacking you on success, if you are top of their aggro list.
- Mobs will not aggro a feigned person.
- Mobs above level 34, if they haven't returned to their spawn point, will remember one feigned person (last person who feigned). Every few seconds they have a chance to forget him. If he stands up while on memory list, they'll reaggro.
- Spells will interrupt feign.

Wiz 05-07-2002 03:10 AM

Also, a little todo list:

- Replace getting top aggro with cycling through aggro list.
- Support for larger memory lists.
- Spell FD with skill checks against abjure.

Wiz 05-07-2002 04:02 AM

Edited version 2.0 post with a couple tweaks and a bug fix.

Maniac 05-07-2002 09:56 AM

when adding something like this, you complile this and all the other source files together as your zone program right? Bit new to this =)

Wiz 05-07-2002 11:09 AM

Right, Maniac.

Maniac 05-07-2002 01:20 PM

Ok i spent like 20 mins adding all the files
to a project to find it wouldn't compile.
Is there a certain compiler i need?

Wiz 05-07-2002 01:34 PM

What are you using? Virtual C++?

Maniac 05-07-2002 01:35 PM

Dev C++ , a free one i found a while back. Open to suggestions for a better one to use =)

Wiz 05-07-2002 01:43 PM

Well, what are the compilation problems? You should just have to open the zone.dsw and compile.

Maniac 05-08-2002 11:50 AM

The fact i don't seem to have zone.dsw could be a start =P

Wiz 05-08-2002 12:40 PM

Redownload the 0.3.1.1 source.

Maniac 05-09-2002 08:41 AM

just did but only contained server, world, and client .dsw ...sorry to take up so much space with posts hehe =)

Wiz 05-09-2002 01:18 PM

Well yeah, use server.dsw then, and compile the Zone... paste any errors here.


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

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