static int create_random_girl(lua_State *L)
{
	

	int age		= 17;
	bool global	= false;	// set to true to add her to the pool
	bool undead	= false;	// unused by CreateRandomGirl
	bool slave	= false;	// set to true to create her as a slave
	bool inhuman	= false;	// set to true for a non-human girl
					// really should allow "both"
	bool kidnapped	= false;	// set to true to create an abductee
/*
 *	now - let's have an arg table
 */
 	int argtab = lua_gettop(L);
/*
 *	make sure it exists and is in fact a table
 */
	if(argtab == 0) {
		g_LogFile.ss() << "Warning: missing parameter for wm.add_cust_to_brothel";
		g_LogFile.ssend();
		return 1;
	}
	luaL_checktype(L, argtab, LUA_TTABLE);
/*
 *	OK - let's pull some parameters out of that table
 *	defaults are retained if a parameter is omitted
 */
	get_from_table(L, argtab, "age", age);
	get_from_table(L, argtab, "global", global);
	get_from_table(L, argtab, "undead", undead);
	get_from_table(L, argtab, "slave",  slave);
	get_from_table(L, argtab, "inhuman",  inhuman);
	get_from_table(L, argtab, "kidnapped",  kidnapped);
/*
 *	now create the girl
 */
	Girl *girl = g_Girls.CreateRandomGirl(
		age,		// age
		global,		// add to global girl list flag
		slave,		// create as slave flag
		undead,		// undead flag
		inhuman,	// true if non-humans are possible
		kidnapped	// true if kidnapped
	);
/*
 *	now create a lua table with the girl data
 */
	make_lua_girl(L, girl);
	return 1;
}
/*
 * take a girl object and update the corresponding Girl struct
 *
 * some use cases:
 *
 *	wm.girl:update()	-- updates wm.girl
 *	wm.girl.update()	-- updates wm.girl
 *	other_girl:update()	-- updates other_girl
 *
 * The one to watch out for will be
 *
 *	other_girl.update()	-- updates wm.girl
 *
 * which is a bit mental. Probably less hassle all around
 * if we just raise an error if the argument is nil
 */
static int update_girl(lua_State *L)
{
    std::string s;
	const char *pt;
	luaL_checktype(L, 1, LUA_TTABLE);
/*
 *	OK. the table is our lua girl object
 *	it should have a field called "pointer"
 */
 	int lua_girl = lua_gettop(L);
	lua_pushstring(L, "pointer");
	lua_gettable(L, lua_girl);
/*
 *	check for nil here. If there is no pointer,
 *	it's probably not a girl object
 */
 	if(lua_isnil(L, -1)) {
		return luaL_error(L,
			"girl.update: supplied object has no pointer"
		);
	}
	Girl *girl = (Girl *) lua_touserdata(L, -1);
/*
 *	set the stack back to the lua_girl
 */
 	lua_settop(L, lua_girl);
/*
 *	OK. let's look for differences with the version in memory
 *	and adjust as needed
 *
 *	There are probably good reasons to leave the name field alone
 *	so let's start with the real name
 */
	get_from_table(L, lua_girl, "real_name", s);
	if(s != girl->m_Realname) {
		girl->m_Realname = s;
	}
/*
 *	let's repeat that with the description. Be nice to have that
 *	evolve as the girl became accustomed to her new life
 */
	get_from_table(L, lua_girl, "desc", s);
	if(s != girl->m_Desc) {
		girl->m_Desc = s;
	}

/*
 *	next, we loop through the stats and check them
 */
	int lua_val, cpp_val;
	for(unsigned int i = 0; (pt = stats[i]); i++) {
		get_from_table(L, lua_girl, pt, lua_val);
		cpp_val = girl->get_stat(i);
/*
 *		skip it if there's no chance
 */
		int diff = lua_val - cpp_val;
 		if(diff == 0) {
			continue;
		}
		girl->upd_stat(i, diff);
	}
/*
 *	exact same thing with the skills
 */
	for(unsigned int i = 0; (pt = skills[i]); i++) {
		get_from_table(L, lua_girl, pt, lua_val);
		cpp_val = girl->get_skill(i);
/*
 *		skip it if there's no chance
 */
		int diff = lua_val - cpp_val;
 		if(diff == 0) {
			continue;
		}
		girl->upd_skill(i, diff);
	}
/*
 *	skip traits for now - I want to do them differently
 */
	return 0;
}
Example #3
0
zval* get_def_obj(const void* def) {
  return (zval*)get_from_table(upb_def_to_php_obj_map, def);
}
Example #4
0
zval* get_ce_obj(const void* ce) {
  return (zval*)get_from_table(ce_to_php_obj_map, ce);
}
Example #5
0
static int create_random_girl(lua_State *L)
{
	CLog log;

	int age			= 17;		// if age is less than 18, virgin is set to true and age gets reset to 18	// `J` Legal Note: 18 is the Legal Age of Majority for the USA where I live 
	bool global		= false;	// set to true to add her to the pool
	bool slave		= false;	// set to true to create her as a slave
	bool undead		= false;	// unused by CreateRandomGirl
	bool inhuman	= false;	// set to true for a non-human girl
	bool kidnapped	= false;	// set to true to create an abductee
	bool arena		= false;	// set to true for an arena girl
	bool daughter	= false;	// set to true if she will be player's daughter
	bool isdaughter	= false;	// set to true if is she a Canonical_Daughter of another girl?
	string name		= "";		// specific name search
	/*
 *	now - let's have an arg table
 */
 	int argtab = lua_gettop(L);
/*
 *	make sure it exists and is in fact a table
 */
	if(argtab == 0) {
		log.ss() << "Warning: missing parameter for wm.add_cust_to_brothel";
		log.ssend();
		return 1;
	}
	luaL_checktype(L, argtab, LUA_TTABLE);
/*
 *	OK - let's pull some parameters out of that table
 *	defaults are retained if a parameter is omitted
 */
	get_from_table(L, argtab, "age", age);
	get_from_table(L, argtab, "global", global);
	get_from_table(L, argtab, "slave",  slave);
	get_from_table(L, argtab, "undead", undead);
	get_from_table(L, argtab, "inhuman", inhuman);
	get_from_table(L, argtab, "kidnapped",  kidnapped);
	get_from_table(L, argtab, "arena", arena);
	get_from_table(L, argtab, "daughter", daughter);
	get_from_table(L, argtab, "isdaughter", isdaughter);

/*
 *	now create the girl
 */
	sGirl *girl = g_Girls.CreateRandomGirl(
		age,		// age
		global,		// add to global girl list flag
		slave,		// create as slave flag
		undead,		// undead flag
		inhuman,	// true if non-humans are possible
		kidnapped,	// true if kidnapped
		arena,		// is the girl from the arena
		daughter,	// is she going to be the player's daughter?
		isdaughter,	// is she a Canonical_Daughter of another girl?
		""			// used to find a specific rgirl by name
	);
/*
 *	now create a lua table with the girl data
 */
	make_lua_girl(L, girl);
	return 1;
}