Beispiel #1
0
	Mobile::NPC* add_npc( const char* npctype, unsigned short x, unsigned short y, short z )
	{
	  Clib::ConfigFile cfile;
	  Clib::ConfigElem elem;
	  if ( !Core::FindNpcTemplate( npctype, cfile, elem ) )
	  {
          throw std::runtime_error(std::string("NPC template '") + npctype + "' not found");
	  }

	  auto  npc = new Mobile::NPC( elem.remove_ushort( "OBJTYPE" ), elem );
	  elem.clear_prop( "Serial" );
	  elem.clear_prop( "X" );
	  elem.clear_prop( "Y" );
	  elem.clear_prop( "Z" );

	  elem.add_prop( "Serial", GetNextSerialNumber() );
	  elem.add_prop( "X", x );
	  elem.add_prop( "Y", y );
	  elem.add_prop( "Z", z );
	  npc->readPropertiesForNewNPC( elem );

	  objStorageManager.objecthash.Insert( npc );

	  SetCharacterWorldPosition( npc, WorldChangeReason::NpcCreate );
	  return npc;
	}
Beispiel #2
0
	void Account::writeto( Clib::ConfigElem& elem ) const
	{
	  elem.add_prop( "Name", name_.c_str() );

	  //dave 6/5/3 don't write cleartext unless configured to
	  if ( Plib::systemstate.config.retain_cleartext_passwords && !password_.empty( ) )
		elem.add_prop( "Password", password_.c_str() );

	  elem.add_prop( "PasswordHash", passwordhash_.c_str() );

	  elem.add_prop( "Enabled", ( (unsigned int)( enabled_ ? 1 : 0 ) ) );
	  elem.add_prop( "Banned", ( (unsigned int)( banned_ ? 1 : 0 ) ) );

	  if ( !default_privs_.empty() )
	  {
		elem.add_prop( "DefaultPrivs", default_privs_.extract().c_str() );
	  }
	  if ( default_cmdlevel_ )
	  {
		elem.add_prop( "DefaultCmdLevel", Core::gamestate.cmdlevels[default_cmdlevel_].name.c_str( ) );
	  }
	  if ( uo_expansion_ )
	  {
		elem.add_prop( "UOExpansion", uo_expansion().c_str() );
	  }
	  props_.printProperties( elem );
	}
Beispiel #3
0
/// Creates a new intrinic shield for an NPC template and returns it
/// @param elem: The conig element defining the NPC
/// @param pkg: The package
/// @returns The created shield or NULL if none is defined in the template
UArmor* create_intrinsic_shield_from_npctemplate( Clib::ConfigElem& elem, const Plib::Package* pkg )
{
  std::string tmp;
  if ( elem.remove_prop( "Shield", &tmp ) )
  {
    // Construct an ArmorTemplate for this NPC template.
    Clib::ConfigElem shieldelem;
    shieldelem.set_rest( elem.rest() );
    shieldelem.set_source( elem );
    shieldelem.add_prop( "Objtype", "0xFFFF" );
    shieldelem.add_prop( "Graphic", "1" );
    shieldelem.add_prop( "SaveOnExit", "0" );
    shieldelem.add_prop( "AR", tmp.c_str() );

    if ( elem.remove_prop( "ShieldMaxHp", &tmp ) )
      shieldelem.add_prop( "MaxHP", tmp.c_str() );
    else
      shieldelem.add_prop( "MaxHP", "1" );

    if ( elem.remove_prop( "ShieldOnHitScript", &tmp ) )
      shieldelem.add_prop( "OnHitScript", tmp.c_str() );

    while ( elem.remove_prop("ShieldCProp", &tmp) )
      shieldelem.add_prop( "CProp", tmp.c_str() );

    return create_intrinsic_shield( elem.rest(), shieldelem, pkg );
  }
  else
  {
    return NULL;
  }
}