View Single Post
Old June 25, 2020, 07:09   #3
Celiend
Rookie
 
Join Date: Jun 2020
Posts: 8
Celiend is on a distinguished road
Quote:
I'd take a look at how the priest spell "dispel undead" works.
Perfect. It makes sense that what I'm trying to do is, in fact, exactly what "dispel undead" does.

Code:
spell:Dispel Undead:10:14:55:6
effect:PROJECT_LOS_AWARE:DISP_UNDEAD
dice:d$S
expr:S:PLAYER_LEVEL:* 3
desc:Inflicts unresistable damage on each undead monster within line of sight.
Code:
bool effect_handler_PROJECT_LOS_AWARE(effect_handler_context_t *context)
{
	int i;
	int dam = effect_calculate_value(context, context->other ? true : false);
	int typ = context->subtype;

	int flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;

	if (context->aware) flg |= PROJECT_AWARE;

	/* Affect all (nearby) monsters */
	for (i = 1; i < cave_monster_max(cave); i++) {
		struct monster *mon = cave_monster(cave, i);
		struct loc grid;

		/* Paranoia -- Skip dead monsters */
		if (!mon->race) continue;

		/* Location */
		grid = mon->grid;

		/* Require line of sight */
		if (!square_isview(cave, grid)) continue;

		/* Jump directly to the target monster */
		(void)project(source_player(), 0, grid, dam, typ, flg, 0, 0, context->obj);
		context->ident = true;
	}

	/* Result */
	return true;
}
There appears to be some "black magic" with respect to how the "context" gets defined; "int typ = context->subtype;" must be interpreted from what the parser reads?

Last edited by Celiend; June 25, 2020 at 08:08.
Celiend is offline   Reply With Quote