PDA

View Full Version : On Guard Behavior


Malevolent
04-27-2002, 07:32 AM
Some fun guard behavior tweaks:

Random animations and sayings. I've attached a sample script file that I use in rivervale and the complete changed over wesquests that i've been using.

You'll need to tweak npc.h

/************************************************** ****
Mob based questing and other goodies
************************************************** ****/
void CheckQuests(char* zonename, char * message, int32 npc_id, int32 item_id = 0, bool IsDoorScript = false);
bool IsEnd(char* string);
bool IsCommented(char* string);
char * rmnl(char* nstring);
char * strreplace(char* searchstring, char* searchquery, char* replacement);


And add in this to npc::process

/****************************************
Guards fun anim
****************************************/

#define GUARD_ANIMATION_FREQ 500
if (rand()%GUARD_ANIMATION_FREQ==2)
if (!IsEngaged() && !ismovinghome) //what are all the guard names?

if (strstr(GetName(), "Guard")
|| strstr(GetName(), "Sentinel")
|| strstr(GetName(), "Sentry")
|| strstr(GetName(), "Dragoon") ) {
switch (rand()%12) {
case 1: DoSocialAnimation(72); break;
case 2: DoSocialAnimation(55); break;
case 3: DoSocialAnimation(72); break;
case 4: DoSocialAnimation(31); break;
case 5: DoSocialAnimation(34); break;
case 6: DoSocialAnimation(35); break;
case 7: DoSocialAnimation(72); break;
case 8: DoSocialAnimation(61); break;
case 9: DoSocialAnimation(72); break;
case 10: DoSocialAnimation(55); break;

case 11:
if (rand()%50==2)
this->CheckQuests(zone->GetShortName(), "RANDOM_GUARD", this->GetNPCTypeID());
default:
DoSocialAnimation(60);
break;

}
}


DoSocialAnimations is
/
*************************************
NPC Social Animation
*************************************/
void NPC::DoSocialAnimation(int num){
this->CastToMob()->DoAnim(num);
}


You'll need to have that signature in npc.h (void DoSocialAnimation(int num);

By changing 'name' in the quest file, you could also have town criers, etc.

--MV

theCoder
04-27-2002, 08:26 AM
That's cool! I think I'm going to have to log onto your server some time just to see all the neat things you're doing :)

The one comment I have is that it might be better to add a function isGaurd() to the NPC class. This function would just do what your if clause does right now (strstr(getName(), "Gaurd") || ...), but could be easily modified in the future if a gaurd field is added or something.