예제 #1
0
파일: nonplayer.c 프로젝트: ryjen/muddled
int load_npcs(Area *area)
{
    char buf[400];
    sql_stmt *stmt;
    int total = 0;
    int len = sprintf(buf,
                      "select * from character natural join nonplayer where areaId=%"
                      PRId64,
                      area->id);

    if (sql_query(buf, len, &stmt) != SQL_OK)
    {
        log_data("could not prepare statement");
        return 0;
    }

    while (sql_step(stmt) != SQL_DONE)
    {
        Character *ch = new_char();
        ch->npc = new_npc();
        ch->npc->area = area;
        load_npc_columns(ch, stmt);
        LINK(area->npcs, ch, next_in_area);
        LINK(first_character, ch, next);
        total++;
    }

    if (sql_finalize(stmt) != SQL_OK)
    {
        log_data("could not finalize statement");
    }
    return total;
}
예제 #2
0
static D_MOBILE *load_mobile( lua_State *L )
{
   D_MOBILE *m;
   
   if( !L )
      return NULL;
   
   if( ( m = new_npc() ) == NULL )
      return NULL;
   
   lua_pushstring( L, "name" );
   lua_gettable( L, -2 );
   m->name = strdup( luaL_checkstring( L, -1 ) );
   lua_pop( L, 1 );
   
   lua_pushstring( L, "gender" );
   lua_gettable( L, -2 );
   m->gender = (int)luaL_checknumber( L, -1 ) == 0 ? FEMALE : MALE;
   lua_pop( L, 1 );
   
   lua_pushstring( L, "level" );
   lua_gettable( L, -2 );
   m->level = (int)luaL_checknumber( L, -1 );
   lua_pop( L, 1 );
   
   lua_pushstring( L, "vnum" );
   lua_gettable( L, -2 );
   m->npc_data->vnum = (int)luaL_checknumber( L, -1 );
   lua_pop( L, 1 );
   
   return m;
}
예제 #3
0
파일: nonplayer.c 프로젝트: ryjen/muddled
Character *load_npc(identifier_t id)
{
    char buf[400];
    sql_stmt *stmt;
    Character *ch = 0;
    int len = sprintf(buf,
                      "select * from character join nonplayer on nonplayerId=characterId where charId=%"
                      PRId64,
                      id);

    if (sql_query(buf, len, &stmt) != SQL_OK)
    {
        log_data("could not prepare statement");
        return 0;
    }

    if (sql_step(stmt) != SQL_DONE)
    {
        ch = new_char();
        ch->npc = new_npc();
        load_npc_columns(ch, stmt);
        LINK(ch->npc->area->npcs, ch, next_in_area);
        LINK(first_character, ch, next);
    }

    if (sql_finalize(stmt) != SQL_OK)
    {
        log_data("could not finalize statement");
    }
    return ch;
}
예제 #4
0
//----------------------------------------------------------------------
// Public Methods
//
inline int
MimicShow::create_model()
{
	npc_ = new_npc("", 0xFEB4DA, 0, 0);
	if ( npc_ ) {
		enter_map(npc_, game_mapid, 0,0);

		set_npc_init_pos();
		change_dress_event(npc_);
		return 0;
	}

	ERROR_RETURN( ("MimicShow: Failed to Create Model NPC"), -1);
}