[REQ] FaceTarget() stops visual_state

Old bugs stored here for reference.
Locked
User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

[REQ] FaceTarget() stops visual_state

Post by John Adams » Wed Oct 08, 2008 10:33 pm

When you Hail an NPC and they are doing something visually (menders for example are smithing), the NPC should turn to face the player and stop what they are doing until the player ignores them for a duration and FaceTarget() expires - then put the NPC back into it's original visual_state.
An example is a mender that is banging out iron, turns to face the player, still banging, says their PlayFlavor (yes, still banging) but sneaks in a bow or smile or wink emote, then immediately goes back to banging iron, spraying sparks and shards of metal all over the players nice magic robes. ;)

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

Post by Jabantiz » Thu Oct 09, 2008 9:41 am

I attempted to code this as well, in a coding mood today I guess, and again this works for me. Not sure if this is the best way or correct way to do it but have yet to crash or screw up my server with this code.
In Entity.cpp around line 341 find:

Code: Select all

if(GetHP() > 0 && target->IsPlayer() && !EngagedInCombat())
		GetZone()->AddHeadingTimer(this);
And replace with this:

Code: Select all

if(GetHP() > 0 && target->IsPlayer() && !EngagedInCombat()){
		GetZone()->AddHeadingTimer(this);
		SetTempVisualState(GetVisualState());
		SetVisualState(0);
	}
In ZoneServer.cpp around line 1509 find:

Code: Select all

if(itr->second->Check(false)){
				itr->first->SetHeading(itr->first->GetSpawnOrigHeading());
Right after it add this:

Code: Select all

itr->first->SetVisualState(itr->first->GetTempVisualState());
itr->first->SetTempVisualState(0);
I know these are rather small things but I hope it is helpful, and the correct way of doing this stuff.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Thu Oct 09, 2008 10:47 am

Hey man, every small thing adds to the completion of the emulator. Nice work! Can I ask you to create "patches" though instead of find/replace?
If you use TortoiseSVN, you can right-click on your checked out code and drill down to Create Patch, and it will compare your modified code with what is current SVN, and save to a *.patch file. Then all we have to do is apply that patch rather than hunt and peck for where the changes go.
Keep up the good work. I wish I could code, but I have yet to find that rosetta stone =)

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

Post by Jabantiz » Thu Oct 09, 2008 11:04 am

Is this what you need? Never did this stuff before.
ZoneServer.patch

Code: Select all

Index: zoneserver.cpp
===================================================================
--- zoneserver.cpp	(revision 151)
+++ zoneserver.cpp	(working copy)
@@ -1507,6 +1507,8 @@
 		for(itr = heading_timers.begin(); itr != heading_timers.end(); itr++){
 			if(itr->second->Check(false)){
 				itr->first->SetHeading(itr->first->GetSpawnOrigHeading());
+				itr->first->SetVisualState(itr->first->GetTempVisualState());
+				itr->first->SetTempVisualState(0);
 				safe_delete(itr->second);
 				heading_timers.erase(itr);
 				break;
Entity.patch

Code: Select all

Index: Entity.cpp
===================================================================
--- Entity.cpp	(revision 151)
+++ Entity.cpp	(working copy)
@@ -338,8 +338,11 @@
 	if(!target)
 		return;
 	FaceTarget(target->GetX(), target->GetZ());
-	if(GetHP() > 0 && target->IsPlayer() && !EngagedInCombat())
+	if(GetHP() > 0 && target->IsPlayer() && !EngagedInCombat()){
 		GetZone()->AddHeadingTimer(this);
+		SetTempVisualState(GetVisualState());
+		SetVisualState(0);
+	}
 }
 
 void Entity::SetHPRegen(int16 new_val){
Provided links incase you need the actual files. If this is what you needed I will do the same for my other post.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Thu Oct 09, 2008 12:12 pm

Yup, that's it. What you can do though (sorry I wasn't clear) right-click on the World folder itself, and all changes will be included into a single patch file.
This is good though, just FYI for future patching. I'll give your code a try! Thanks again.

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

Post by Jabantiz » Thu Oct 09, 2008 12:18 pm

Yea I noticed you could do that but figured I should post only the changes relative to this topic, will post links for the other changes I made in its respective post. Also I didn't want to group it all together in case I screwed up on one of them.
**EDIT**
Edited my last post in the Race vs Race_Type thread and added the patch files.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sat Oct 11, 2008 6:20 am

Added to code as slightly different than your implementation, but the same general concept. Great work though :)

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Tue Oct 14, 2008 12:53 am

LE, should this code be working on the Dev SVN? If so, it's not. Ajarn, the Shieldsmith in Nettleville still hammering away when he's talking to me.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Tue Oct 14, 2008 2:32 pm

Did you have him face you first?

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Tue Oct 14, 2008 2:43 pm

FaceTarget() is always our first command.
He does appear to stop for a moment while performing ihs emote, but soon as the emote expires, he's back to pounding.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Tue Oct 14, 2008 3:11 pm

Ahh, because it is an action state, not a visual state. I'll have to fix it.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Tue Oct 14, 2008 3:21 pm

I'm sorry, that was my mistake. It is action_state, not visual_state. Oops =) I guess I knew that, just typed the wrong thing... doh.
Thanks

Locked

Who is online

Users browsing this forum: No registered users and 0 guests