Example #1
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;
  }
}
Example #2
0
void NpcTemplateElem::copyto( Clib::ConfigElem& elem ) const
{
  elem = _elem;
  elem.set_source( &_source );
}