Exemplo n.º 1
0
Arquivo: xtra1.c Projeto: jcubic/ToME
/*
 * Calculate the players current "state", taking into account
 * not only race/class intrinsics, but also objects being worn
 * and temporary spell effects.
 *
 * See also calc_mana() and calc_hitpoints().
 *
 * Take note of the new "speed code", in particular, a very strong
 * player will start slowing down as soon as he reaches 150 pounds,
 * but not until he reaches 450 pounds will he be half as fast as
 * a normal kobold.  This both hurts and helps the player, hurts
 * because in the old days a player could just avoid 300 pounds,
 * and helps because now carrying 300 pounds is not very painful.
 *
 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
 * damage, since that would affect non-combat things.  These values
 * are actually added in later, at the appropriate place.
 *
 * This function induces various "status" messages, unless silent is
 * TRUE.
 */
void calc_bonuses(bool silent)
{
	if (silent)
		call_lua("player.calc_bonuses", "(n)", "");
	else
		call_lua("player.calc_bonuses", "(b)", "", silent);
}
Exemplo n.º 2
0
static void activate_module()
{
	/* Initialize the module table */
	call_lua("assign_current_module", "(s)", "", game_module);

	/* Do misc inits  */
	call_lua("get_module_info", "(s)", "d", "max_plev", &max_plev);
	call_lua("get_module_info", "(s)", "d", "death_dungeon", &DUNGEON_DEATH);

	call_lua("get_module_info", "(s)", "d", "random_artifact_weapon_chance", &RANDART_WEAPON);
	call_lua("get_module_info", "(s)", "d", "random_artifact_armor_chance", &RANDART_ARMOR);
	call_lua("get_module_info", "(s)", "d", "random_artifact_jewelry_chance", &RANDART_JEWEL);

	call_lua("get_module_info", "(s,d)", "d", "version", 1, &VERSION_MAJOR);
	call_lua("get_module_info", "(s,d)", "d", "version", 2, &VERSION_MINOR);
	call_lua("get_module_info", "(s,d)", "d", "version", 3, &VERSION_PATCH);
	version_major = VERSION_MAJOR;
	version_minor = VERSION_MINOR;
	version_patch = VERSION_PATCH;

	/* Change window name if needed */
	if (strcmp(game_module, "ToME"))
	{
		strnfmt(angband_term_name[0], 79, "T-Engine: %s", game_module);
		Term_xtra(TERM_XTRA_RENAME_MAIN_WIN, 0);
	}

	/* Reprocess the player name, just in case */
	process_player_base();
}
Exemplo n.º 3
0
Arquivo: cmd4.c Projeto: jcubic/ToME
/*
 * Call upton options screen
 */
void do_cmd_options(char *what)
{
	if (what == NULL)
	{
		call_lua("option_display", "()", "");
	}
	else
	{
		call_lua("option_display", "(s)", "", what);
	}
}
Exemplo n.º 4
0
Arquivo: cmd4.c Projeto: jcubic/ToME
/*
 * Mention the current version
 */
void do_cmd_version(void)
{
	cptr author, email;
	s32b eM, em, ep;

	call_lua("get_module_info", "(s,d)", "s", "author", 1, &author);
	call_lua("get_module_info", "(s,d)", "s", "author", 2, &email);
	call_lua("get_engine_version", "()", "ddd", &eM, &em, &ep);

	/* Silly message */
	msg_format("You are playing %s %d.%d.%d made by %s (%s).", game_module, VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, author, email);
	msg_format("The T-Engine version is %d.%d.%d%s.", eM, em, ep, IS_CVS);
	call_lua("patchs_display", "()", "");
}
Exemplo n.º 5
0
Arquivo: melee1.c Projeto: jcubic/ToME
/*
 * Attack the player via physical attacks.
 */
bool make_attack_normal(s32b m_idx, byte divis)
{
	s32b ret;

	call_lua("monster_attack", "(d,d,d)", "d", m_idx, p_ptr->py, p_ptr->px, &ret);
	return ret;
}
Exemplo n.º 6
0
Arquivo: skills.c Projeto: jcubic/ToME
static s32b get_combat_num()
{
	s32b max;

	call_lua("get_combat_num", "()", "d", &max);
	return max;
}
Exemplo n.º 7
0
bool do_control_magic(void)
{
	s32b ret;

	call_lua("control_monster_force_casting", "()", "d", &ret);
	return ret;
}
Exemplo n.º 8
0
Arquivo: skills.c Projeto: jcubic/ToME
/* Do we meet the requirements */
bool can_learn_ability(s32b ab)
{
	ability_type *ab_ptr = &ab_info[ab];
	s32b i;

	if (ab_ptr->acquired)
		return FALSE;

	if (p_ptr->skill_points < ab_info[ab].cost)
		return FALSE;

	for (i = 0; i < 10; i++)
	{
		/* Must have skill level */
		if (ab_ptr->skills[i] > -1)
		{
			if (get_skill(ab_ptr->skills[i]) < ab_ptr->skill_levels[i])
				return FALSE;
		}

		/* Must have ability */
		if (ab_ptr->need_abilities[i] > -1)
		{
			if (!ab_info[ab_ptr->need_abilities[i]].acquired)
				return FALSE;
		}

		/* Must not have ability */
		if (ab_ptr->forbid_abilities[i] > -1)
		{
			if (ab_info[ab_ptr->forbid_abilities[i]].acquired)
				return FALSE;
		}
	}

	for (i = 0; i <= STATS_MAX; i++)
	{
		/* Must have stat */
		if (ab_ptr->stat[i] > -1)
		{
			if (get_stat(i, ind) < ab_ptr->stat[i] - 3)
				return FALSE;
		}
	}

	if (ab_ptr->allow != -1)
	{
		s32b ret;
		open_lua_functions_registry(get_lua_functions_registry_domain("ab_info"), ab_ptr->allow);
		call_lua(NULL, "(d)", "d", ab, &ret);
		close_lua_functions_registry();
		if (!ret) return FALSE;
	}

	/* Do the script allow us? */
	if (process_hooks(HOOK_LEARN_ABILITY, "(d)", ab))
		return FALSE;

	return TRUE;
}
Exemplo n.º 9
0
/*
 * Advance the skill point of the skill specified by i and
 * modify related skills
 */
void increase_skill(int i, s16b *invest)
{
	s32b max_skill_overage;

	/* No skill points to be allocated */
	if (!p_ptr->skill_points) return;

	/* The skill cannot be increased */
	if (!s_info[i].mod) return;

	/* The skill is already maxed */
	if (s_info[i].value >= SKILL_MAX) return;

	/* Cannot allocate more than player level + max_skill_overage levels */
	call_lua("get_module_info", "(s)", "d", "max_skill_overage", &max_skill_overage);
	if (((s_info[i].value + s_info[i].mod) / SKILL_STEP) >= (p_ptr->lev + max_skill_overage + 1))
	{
		int hgt, wid;

		Term_get_size(&wid, &hgt);
		msg_box(format("Cannot raise a skill value above %i + player level.", max_skill_overage), (int)(hgt / 2), (int)(wid / 2));
		return;
	}

	/* Spend an unallocated skill point */
	p_ptr->skill_points--;

	/* Increase the skill */
	s_info[i].value += s_info[i].mod;
	invest[i]++;
}
Exemplo n.º 10
0
/*
 * Has this object type been "sampled"?
 */
bool object_tried_p(object_type *o_ptr)
{
	bool ret;
	call_lua("is_tried", "(O)", "b", o_ptr, &ret);

	return ret;
}
Exemplo n.º 11
0
void callluascript::operator()( boost::property_tree::ptree message ) const
{
	load_lua();
	std::stringstream jsondata;
	boost::property_tree::json_parser::write_json(jsondata, message);

	call_lua(jsondata.str());
}
Exemplo n.º 12
0
/*
 * Is the player aware of the effects of the given object?
 */
bool object_aware_p(object_type *o_ptr)
{
	bool ret;

	call_lua("is_aware", "(O)", "b", o_ptr, &ret);

	return ret;
}
Exemplo n.º 13
0
/*
 * Attempt to make an object (normal or good/great)
 *
 * This routine plays nasty games to generate the "special artifacts".
 *
 * This routine uses "object_level" for the "generation level".
 *
 * We assume that the given object has been "wiped".
 *
 * To Watch: The allocation table caching is heavily relies on
 * an assumption that the SPECIAL_GENE objects should only be created
 * through the forge--object_prep()--apply_magic() sequence and
 * get_obj_num() should never be called for that purpose XXX XXX XXX
 */
object_type* make_object(bool good, bool great, flags_type* theme)
{
	object_type* obj = NULL;

	call_lua("rand_obj.make_object", "(b,b,F)", "O", good, great,
			 theme, &obj);

	return obj;
}
Exemplo n.º 14
0
/*
 * Apply special make code
 */
static void invoke_on_make(flags_type *flags, object_type *o_ptr, s32b power)
{
	if (flag_exists(flags, FLAG_ON_MAKE))
	{
		open_lua_functions_registry(flag_get(flags, FLAG_ON_MAKE), flag_get2(flags, FLAG_ON_MAKE));
		call_lua(NULL, "(O,d)", "", o_ptr, power);
		close_lua_functions_registry();
	}
}
Exemplo n.º 15
0
/*
 * Delete a dungeon object
 *
 * Handle "stacks" of objects correctly.
 */
void delete_object_idx(s32b o_idx)
{
	/* Any additional tasks */
	call_lua("__core_objects.delete_object_idx_notice", "(d)", "", o_idx);

	/* Excise */
	item_increase(o_idx, -255);
	item_optimize(o_idx);
}
Exemplo n.º 16
0
Arquivo: xtra1.c Projeto: jcubic/ToME
/*
 * Computes current weight limit.
 */
s32b weight_limit(void)
{
	s32b i = 0;

	call_lua("player.weight_limit", "()", "d", &i);

	/* Return the result */
	return i;
}
Exemplo n.º 17
0
Arquivo: skills.c Projeto: jcubic/ToME
/*
 * Advance the skill point of the skill specified by i and
 * modify related skills
 */
void increase_skill(s32b i, s16b *invest)
{
	s32b max_skill_overage, max_level;
	cptr error = NULL;

	/* No skill points to be allocated */
	if (!p_ptr->skill_points) return;

	/* The skill cannot be increased */
	if (!s_info[i].mod) return;

	/* The skill is already maxed */
	call_lua("get_module_info", "(s)", "d", "max_skill_level", &max_level);
	if (s_info[i].value >= max_level * SKILL_STEP) return;

	/* Cannot allocate more than player level + max_skill_overage levels */
	call_lua("get_module_info", "(s)", "d", "max_skill_overage", &max_skill_overage);
	if (((s_info[i].value + s_info[i].mod) / SKILL_STEP) >= (p_ptr->lev + max_skill_overage + 1))
	{
		s32b hgt, wid;

		Term_get_size(&wid, &hgt);
		msg_box(format("Cannot raise a skill value to or above %d until you get more experienced.", p_ptr->lev + max_skill_overage), (s32b)(hgt / 2), (s32b)(wid / 2));
		return;
	}

	/* More complex checking */
	call_lua("get_module_info", "(s,d)", "s", "allow_skill_raise", i, &error);
	if (error)
	{
		s32b hgt, wid;

		Term_get_size(&wid, &hgt);
		msg_box(error, (s32b)(hgt / 2), (s32b)(wid / 2));
		return;
	}

	/* Spend an unallocated skill point */
	p_ptr->skill_points--;

	/* Increase the skill */
	s_info[i].value += s_info[i].mod;
	invest[i]++;
}
Exemplo n.º 18
0
void callluascript::operator()(channel_identifier cid, avbotmsg msg, send_avchannel_message_t sender, boost::asio::yield_context yield_context) const
{
	load_lua();
	std::stringstream jsondata;
	auto json_msg = av_msg_make_json(cid, msg);
	json_msg.put("channel", channel_name_);
	boost::property_tree::json_parser::write_json(jsondata, json_msg);

	call_lua(jsondata.str());
}
Exemplo n.º 19
0
static void dump_modules(int sel, int max)
{
	int i;

	char buf[40], pre = ' ', post = ')';
	cptr name;

	char ind;


	for (i = 0; i < max; i++)
	{
		ind = I2A(i % 26);
		if (i >= 26) ind = toupper(ind);

		if (sel == i)
		{
			pre = '[';
			post = ']';
		}
		else
		{
			pre = ' ';
			post = ')';
		}

		call_lua("get_module_name", "(d)", "s", i, &name);
		strnfmt(buf, 40, "%c%c%c %s", pre, ind, post, name);

		if (sel == i)
		{
			call_lua("get_module_desc", "(d)", "s", i, &name);
			print_desc_aux(name, 5, 0);

			c_put_str(TERM_L_BLUE, buf, 10 + (i / 4), 20 * (i % 4));
		}
		else
			put_str(buf, 10 + (i / 4), 20 * (i % 4));
	}
}
Exemplo n.º 20
0
/*
 **************************** Monster AI **********************
 */
void set_monster_ai(monster_type *m_ptr, u32b ai)
{
	/*
	 * If we dont have a correct AI state for this new AI, make a default one
	 * NOTE: Really it's betetr to init the states with the correct parameters
	 */
//	if (!flag_exists(&m_ptr->ai_states, ai))
	{
		call_lua("ai.init", "(M,d)", "", m_ptr, ai);
	}

	m_ptr->ai = ai;
}
Exemplo n.º 21
0
static void
__reload_config(int signo)
{
	int ret, rvalue;
	
	ret = call_lua("reload_config", ">d", &rvalue);

	if (ret != 0) {
		log_debug("reload_config failed.");
	} else {
		log_debug("reload_config success.");
	}
}
Exemplo n.º 22
0
/*
 * Erase an inventory slot if it has no more items
 */
bool item_optimize(s32b item)
{
	object_type *o_ptr = get_object(item);

	/* Only optimize real items */
	if (!o_ptr) return (FALSE);

	/* Only optimize empty items */
	if (o_ptr->number) return (FALSE);

	call_lua("__core_objects.item_optimize", "(d,O)", "", item, o_ptr);

	return (TRUE);
}
Exemplo n.º 23
0
void lua_console::run()
{
    while( !done ) {
        draw();

        std::string input = get_input();

#ifdef LUA
        call_lua( input );

        read_stream( lua_output_stream, c_white );
        read_stream( lua_error_stream, c_red );
#else
        text_stack.push_back( {"This build does not support lua.", c_red} );
#endif // LUA
    }
}
Exemplo n.º 24
0
Arquivo: xtra1.c Projeto: jcubic/ToME
/*
 * Handle "p_ptr->window"
 */
void window_stuff(void)
{
	/* Character is not ready yet, no screen updates */
	if (!character_generated || character_icky) return;

	/* Nothing to do */
	if (!flag_used(&p_ptr->window)) return;

	/* Display monster list */
	if (flag_exists(&p_ptr->window, FLAG_PW_M_LIST) || flag_exists(&p_ptr->window, FLAG_PW_ALL))
	{
		fix_m_list();
	}

	/* Display overhead view */
	if (flag_exists(&p_ptr->window, FLAG_PW_MESSAGE) || flag_exists(&p_ptr->window, FLAG_PW_ALL))
	{
		fix_message();
	}

	/* Display monster recall */
	if (flag_exists(&p_ptr->window, FLAG_PW_MONSTER) || flag_exists(&p_ptr->window, FLAG_PW_ALL))
	{
		fix_monster();
	}

	/* Display object recall */
	if (flag_exists(&p_ptr->window, FLAG_PW_OBJECT) || flag_exists(&p_ptr->window, FLAG_PW_ALL))
	{
		fix_object();
	}

	call_lua("windows.display", "()", "");

	flag_empty(&p_ptr->window);
}
Exemplo n.º 25
0
void lua_callback(lua_State *, const char *callback_name)
{
    call_lua(std::string("mod_callback(\"") + std::string(callback_name) + "\")");
}
Exemplo n.º 26
0
int proc_options(char *s, int *moonphases, char **nat, char **relig,
					char **date_form, char **time_form, char **ev_form,
					char **todo_form, int *iftodo, int *ifevent,
					int *weekout, int *fdow, char **astro)
{
	FILE *fp; int holder;
	char *line = NULL; size_t len = 0; ssize_t read;
	int ind;

	if (strcmp(s,"-") == 0)
		return 0;
	if ((fp = fopen(s,"r")) == NULL) {
		fprintf(stderr,"dozcal:  unable to open file "
			"\"%s\", with this error:\n\t%d: "
			"%s\n",s,errno,strerror(errno));
		return 0;
	}
	while ((read = getline(&line, &len, fp)) != -1) {
		chomp(line);
		if (strstr(line,"PRINT_TODOS")) {
			*iftodo = 1;
			continue;
		} else if (strstr(line,"UTCTIME")) {
			utc = 1;
			continue;
		} else if (strstr(line,"NO_EVENT")) {
			*ifevent = 0;
			continue;
		} else if (strstr(line,"WEEKLY")) {
			*weekout = 1;
			continue;
		} else if (strstr(line,"NOCOLOR")) {
			allopts[NOCOLOR].colconst = -1;
			continue;
		}
		if (check_line(line) >= 1)
			continue;
		if (strstr(line,"MOON")) {
			if (strstr(line,"major"))
				*moonphases = 2;
			if (strstr(line,"all"))
				*moonphases = 1;
		} else if (strstr(line,"RELIG")) {
			holder = get_impstr(line);
			*relig = realloc(*relig,((strlen(line)+1) * sizeof(char)));
			strcpy(*relig,line+holder);
		} else if (strstr(line,"NATION")) {
			holder = get_impstr(line);
			*nat = realloc(*nat,((strlen(line)+1) * sizeof(char)));
			strcpy(*nat,line+holder);
		} else if (strstr(line,"ASTRON")) {
			holder = get_impstr(line);
			*astro = realloc(*astro,((strlen(line)+1) * sizeof(char)));
			strcpy(*astro,line+holder);
		} else if (strstr(line,"TIMEZONE")) {
			holder = get_impstr(line);
			tzoffset = doztodec(line+holder);
		} else if (strstr(line,"GEOG")) {
			holder = get_impstr(line);
			proc_geog(line+holder);
		} else if (strstr(line,"DATE_FORMAT")) {
			holder = get_impstr(line);
			*date_form = realloc(*date_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*date_form,line+holder);
		} else if (strstr(line,"TIME_FORMAT")) {
			holder = get_impstr(line);
			*time_form = realloc(*time_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*time_form,line+holder);
		} else if (strstr(line,"EVENT_FORMAT")) {
			holder = get_impstr(line);
			*ev_form = realloc(*ev_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*ev_form,line+holder);
		} else if (strstr(line,"TODO_FORMAT")) {
			holder = get_impstr(line);
			*todo_form = realloc(*todo_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*todo_form,line+holder);
		} else if (strstr(line,"INPUT")) {
			holder = get_impstr(line);
			process_file(line+holder);
		} else if (strstr(line,"SCRIPT")) {
			holder = get_impstr(line);
			call_lua(line+holder);
		} else if (strstr(line,"FIRST_DOW")) {
			holder = get_impstr(line);
			*fdow = first_dow(line+holder);
		} else if (strstr(line,"WHOLE_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CALENDAR_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EVENT_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_WEEK_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_WEEK_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_LINE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_LINE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_LINE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_LINE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"BOT_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"BOT_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WARNING_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WARNING_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"INACTIVE_BORDER_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"INACTIVE_BORDER_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"ACTIVE_BORDER_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"ACTIVE_BORDER_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WHOLE_EV_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WHOLE_TODO_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else {
			fprintf(stderr,"dozcal:  option \"%s\" is not "
				"recognized; skipping...\n",line);
		}
	}
	free(line);
	fclose(fp);
	return 0;
}
Exemplo n.º 27
0
Arquivo: skills.c Projeto: jcubic/ToME
void select_default_combat()
{
	call_lua("select_default_combat", "()", "");
}
Exemplo n.º 28
0
Arquivo: xtra1.c Projeto: jcubic/ToME
/*
 * Handle "p_ptr->update"
 */
void update_stuff(void)
{
	/* Update stuff */
	if (!p_ptr->update) return;


	if (p_ptr->update & (PU_BODY))
	{
		p_ptr->update &= ~(PU_BODY);
		calc_body();
	}

	if (p_ptr->update & (PU_BONUS))
	{
		p_ptr->update &= ~(PU_BONUS);
		calc_bonuses(FALSE);
	}

	if (p_ptr->update & (PU_TORCH))
	{
		p_ptr->update &= ~(PU_TORCH);
		calc_torch();
	}

	if (p_ptr->update & (PU_HP))
	{
		p_ptr->update &= ~(PU_HP);
		call_lua("player.calc_hitpoints", "()", "");
	}

	if (p_ptr->update & (PU_SANITY))
	{
		p_ptr->update &= ~(PU_SANITY);
		call_lua("player.calc_sanity", "()", "");
	}

	if (p_ptr->update & (PU_MANA))
	{
		p_ptr->update &= ~(PU_MANA);
		call_lua("player.calc_mana", "()", "");
	}

	/* Character is not ready yet, no screen updates */
	if (!character_generated) return;


	/* Character is in "icky" mode, no screen updates */
	if (character_icky) return;


	if (p_ptr->update & (PU_UN_VIEW))
	{
		p_ptr->update &= ~(PU_UN_VIEW);
		forget_view();
	}

	if (p_ptr->update & (PU_VIEW))
	{
		p_ptr->update &= ~(PU_VIEW);
		update_view();
	}

	if (p_ptr->update & (PU_DISTANCE))
	{
		p_ptr->update &= ~(PU_DISTANCE);
		p_ptr->update &= ~(PU_MONSTERS);
		update_monsters(TRUE);
	}

	if (p_ptr->update & (PU_MONSTERS))
	{
		p_ptr->update &= ~(PU_MONSTERS);
		update_monsters(FALSE);
	}

	if (p_ptr->update & (PU_MON_LITE))
	{
		p_ptr->update &= ~(PU_MON_LITE);
		if (monster_lite) update_mon_lite();
	}
}
Exemplo n.º 29
0
BOOL lcb_call(void *data, int idx, Str text, int persist) {
  LuaCallback *lcb = (LuaCallback*)data;
  return call_lua(lcb->L,lcb->callback,idx,text,persist);
}
Exemplo n.º 30
0
/* Display possible modules and select one */
bool select_module()
{
	s32b k, sel, max;

	/* Hack */
	use_color = TRUE;

	/* Init some lua */
	init_lua();

	/* Some ports need to separate the module scripts from the installed mods,
	   so we need to check for these in two different places */
	if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "mods_aux.lua", FALSE))
		tome_dofile_anywhere(ANGBAND_DIR_MODULES, "mods_aux.lua", TRUE);
	if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "modules.lua", FALSE))
		tome_dofile_anywhere(ANGBAND_DIR_MODULES, "modules.lua", TRUE);

	/* Grab the savefiles */
	call_lua("max_modules", "()", "d", &max);

	/* No need to bother the player if there is only one module */
	sel = -1;
	if (force_module)
		call_lua("find_module", "(s)", "d", force_module, &sel);
	if (max == 1)
		sel = 0;
	if (sel != -1)
	{
		cptr tmp;

		/* Process the module */
		call_lua("init_module", "(d)", "", sel);
		call_lua("get_module_name", "(d)", "s", sel, &tmp);
		game_module = string_make(tmp);

		activate_module();

		return FALSE;
	}

	sel = 0;

	/* Preprocess the basic prefs, we need them to have movement keys */
	process_pref_file("pref.prf");

	while (TRUE)
	{
		/* Clear screen */
		Term_clear();

		/* Let the user choose */
		c_put_str(TERM_YELLOW, "Welcome to ToME, you must select a module to play,", 1, 12);
		c_put_str(TERM_YELLOW, "either ToME official module or third party ones.", 2, 13);
		put_str("Press 8/2/4/6 to move, Return to select and Esc to quit.", 4, 3);

		dump_modules(sel, max);

		k = inkey();

		if (k == ESCAPE)
		{
			quit(NULL);
		}
		if (k == '6')
		{
			sel++;
			if (sel >= max) sel = 0;
			continue;
		}
		else if (k == '4')
		{
			sel--;
			if (sel < 0) sel = max - 1;
			continue;
		}
		else if (k == '2')
		{
			sel += 4;
			if (sel >= max) sel = sel % max;
			continue;
		}
		else if (k == '8')
		{
			sel -= 4;
			if (sel < 0) sel = (sel + max - 1) % max;
			continue;
		}
		else if (k == '\r')
		{
			if (sel < 26) k = I2A(sel);
			else k = toupper(I2A(sel));
		}

		{
			int x;
			cptr tmp;

			if (islower(k)) x = A2I(k);
			else x = A2I(tolower(k)) + 26;

			if ((x < 0) || (x >= max)) continue;

			/* Process the module */
			call_lua("init_module", "(d)", "", x);
			call_lua("get_module_name", "(d)", "s", x, &tmp);
			game_module = string_make(tmp);

			activate_module();

			return (FALSE);
		}
	}

	/* Shouldnt happen */
	return (FALSE);
}