View Single Post
  #1  
Old 05-14-2011, 04:14 PM
Sikkun
Sarnak
 
Join Date: Apr 2011
Posts: 30
Default Mounted Out of Combat Regeneration

Hello,
I was unable to find a fix for this (sorry if there is a known one) so here is the code I added to enable Mounted OOC Like on live.

Orginal:
horse.cpp

Code:
void Client::SummonHorse(int16 spell_id) {
	if (GetHorseId() != 0) {
		Message(13,"You already have a Horse.  Get off, Fatbutt!");
		return;
	}
	if(!Horse::IsHorseSpell(spell_id)) {
		LogFile->write(EQEMuLog::Error, "%s tried to summon an unknown horse, spell id %d", GetName(), spell_id);
		return;
	}
	
	// No Horse, lets get them one.
	
	Horse* horse = new Horse(this, spell_id, GetX(), GetY(), GetZ(), GetHeading());
	
	//we want to manage the spawn packet ourself.
	//another reason is we dont want quests executing on it.
	entity_list.AddNPC(horse, false);
	
	// Okay, lets say they have a horse now.
	
	
	EQApplicationPacket outapp;
	horse->CreateHorseSpawnPacket(&outapp, GetName(), GetID());
/*	// Doodman: Kludged in here instead of adding a field to PCType. FIXME!
	NewSpawn_Struct* ns=(NewSpawn_Struct*)outapp->pBuffer;
	ns->spawn.texture=mount_color;
	ns->spawn.pet_owner_id=0;
	ns->spawn.walkspeed=npc_type->walkspeed;
	ns->spawn.runspeed=npc_type->runspeed;
*/
	entity_list.QueueClients(horse, &outapp);
	
	
	int16 tmpID = horse->GetID();
	SetHorseId(tID);
}
New: (one line at the end)

Code:
void Client::SummonHorse(int16 spell_id) {
	if (GetHorseId() != 0) {
		Message(13,"You already have a Horse.  Get off, Fatbutt!");
		return;
	}
	if(!Horse::IsHorseSpell(spell_id)) {
		LogFile->write(EQEMuLog::Error, "%s tried to summon an unknown horse, spell id %d", GetName(), spell_id);
		return;
	}
	
	// No Horse, lets get them one.
	
	Horse* horse = new Horse(this, spell_id, GetX(), GetY(), GetZ(), GetHeading());
	
	//we want to manage the spawn packet ourself.
	//another reason is we dont want quests executing on it.
	entity_list.AddNPC(horse, false);
	
	// Okay, lets say they have a horse now.
	
	
	EQApplicationPacket outapp;
	horse->CreateHorseSpawnPacket(&outapp, GetName(), GetID());
/*	// Doodman: Kludged in here instead of adding a field to PCType. FIXME!
	NewSpawn_Struct* ns=(NewSpawn_Struct*)outapp->pBuffer;
	ns->spawn.texture=mount_color;
	ns->spawn.pet_owner_id=0;
	ns->spawn.walkspeed=npc_type->walkspeed;
	ns->spawn.runspeed=npc_type->runspeed;
*/
	entity_list.QueueClients(horse, &outapp);
	
	
	int16 tmpID = horse->GetID();
	SetHorseId(tmpID);

	//Sets Player action to Sit
	playeraction = 1;

}
And to make the OOC stop when not mounted

Orginal:
Code:
void Client::SetHorseId(int16 horseid_in) {
	//if its the same, do nothing
	if(horseId == horseid_in)
		return;
	
	//otherwise it changed.
	//if we have a horse, get rid of it no matter what.
	if(horseId) {
		Mob *horse = entity_list.GetMob(horseId);
		if(horse != NULL)
		horse->Depop();
	}
	
	//now we take whatever they gave us.
	horseId = horseid_in;
}
New (just one line again)

Code:
void Client::SetHorseId(int16 horseid_in) {
	//if its the same, do nothing
	if(horseId == horseid_in)
		return;
	
	//otherwise it changed.
	//if we have a horse, get rid of it no matter what.
	if(horseId) {
		Mob *horse = entity_list.GetMob(horseId);
		if(horse != NULL)
		{
			horse->Depop();
                                         //Sets player action to stand
			playeraction = 0;
		}
	}
	
	//now we take whatever they gave us.
	horseId = horseid_in;
}
Sikkun
Reply With Quote