/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@falcon.mercer.peachnet.edu
MUD++ development mailing list mudpp-list@spice.com
------------------------------------------------------------------------------
npc.cc
*/
#include "string.h"
#include "llist.h"
#include "room.h"
#include "indexable.h"
#include "repop.h"
#include "area.h"
#include "npc.h"
#include "global.h"
const bitType npc_bit_list[] =
{
{"undefined", NPC_UNDEFINED },
{"unused-bit1", NPC_UNUSED1 },
{"wimpy", NPC_WIMPY },
{"aggressive", NPC_AGGRESSIVE },
{"sentinel", NPC_SENTINEL },
{"stayzone", NPC_STAY_ZONE },
{"scavenger", NPC_SCAVENGER },
{"friendly", NPC_FRIENDLY },
{"tame", NPC_TAME },
{"charmed", NPC_CHARMED },
{"banker", NPC_BANKER },
{"trainer", NPC_TRAINER },
{"guildmaster", NPC_PRACTICER },
{0, 0}
};
NPC::~NPC()
{
if( repop )
repop->setPtr( 0 );
}
void NPC::out( const char * )
{
}
void NPC::fromWorld()
{
npcs.remove( this );
}
void NPC::toWorld()
{
npcs.add( this );
}
// will change to readProtoFrom
int NPC::readFrom( InFile &in )
{
char buf[ BUF ];
if( *in.getword( buf ) != '{' )
in.error("NPC::readFrom() - expected '{'" );
// index = in.getword( buf );
setName( in.getstring( buf ) );
setShort( in.getstring( buf ) );
setLong( in.getstring( buf ) );
/*obj_flags = */ in.getnum();
/*char_flags = */ in.getnum();
/*mob_flags =*/ in.getnum();
weight = in.getnum();
exp = in.getnum();
gold = in.getnum();
silver = in.getnum();
copper = in.getnum();
hp = max_hp = in.getnum();
mana = max_mana = in.getnum();
/* */ in.getnum();
if( *in.getword( buf ) != '}' )
in.error("NPC::readFrom() - expected '}'" );
return 1;
}
// will change to writeProtoTo
int NPC::writeTo( OutFile &out ) const
{
out << '{' << endl;
// out << index << endl;
out << name << TERM_CHAR << endl;
out << shortdesc << TERM_CHAR << endl;
out << longdesc << TERM_CHAR << endl;
out << 0 <<' '<< char_bits[0] <<' '<< npc_bits[0] <<' ';
out << weight <<' '<< exp <<' '<< gold <<' '<< silver <<' '<< copper << endl;
out << max_hp <<' '<< max_mana <<' '<< 0 << endl;
out << '}' << endl;
return 1;
}
void NPC::look( Object * )
{
}
void NPC::look( Char * )
{
}
void NPC::pulse()
{
}
NPC * lookupNPC( const Index & x )
{
NPC *npc;
Area *area;
LList<Area> tlist = areas;
tlist.reset();
while( ( area = tlist.peek() ) )
{
tlist.next();
if( !x.getScope() )
if( ( npc = area->lookupNPC( x ) ) )
return npc;
if( area->getKey() == x.getScope() )
break;
}
if( area )
return area->lookupNPC( x );
return 0;
}
NPC * lookupNPC( const String & x )
{
return lookupNPC( Index( x ) );
}
NPC * lookupNPC( const char * x )
{
return lookupNPC( Index( x ) );
}