View Single Post
  #2  
Old 05-07-2002, 03:05 AM
Wiz
Dragon
 
Join Date: Feb 2002
Posts: 583
Default

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.
Reply With Quote