View Single Post
Old June 25, 2020, 07:37   #6
Celiend
Rookie
 
Join Date: Jun 2020
Posts: 8
Celiend is on a distinguished road
Nick's suggested solution works as intended, as well!

This is neat!!!

Thank you again for responding, wobbly and Nick!

This code is too ugly for me to attempt to submit it as part of a 'pull request'; and mechanically, the playerbase would probably object to the affect this behavior would have on the balance of the Necromancer... so it may be odious from those grounds.

I've exerted some direct control over the Vanilla Angband code-base! I am practically squeeking with joy, atm!

Code:
bool effect_handler_TAP_UNLIFE(effect_handler_context_t *context)
{
	int amount = effect_calculate_value(context, false);
	struct loc target;
	struct monster *mon = NULL;
	char m_name[80];
        
        // Hardcoded to affect Undead?
        int typ = 40;
        
        int flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;

	if (context->aware) flg |= PROJECT_AWARE;
        
	int drain = 0;
	bool fear = false;
	bool dead = false;
        
        msg("XXXCalled Tap Unlife:  amount: %i.",amount);

	context->ident = true;

	/* Closest living monster */
	if (!target_set_closest(TARGET_KILL, monster_is_undead)) {
		return false;
	}
	target_get(&target);
	mon = target_get_monster();
        
        struct loc origin = origin_get_loc(context->origin);
        
        int i = 0;
        
        for (i = 1; i < cave_monster_max(cave); i++) {
            
            struct monster *mon = cave_monster(cave, i);

            struct loc grid;

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

	    /* Require line of sight */
            if (!los(cave, origin, mon->grid)) continue;

	    /* Jump directly to the monster */
            	/* Hurt the monster */
            
            
            if(monster_is_undead(mon))
            {
                monster_desc(m_name, sizeof(m_name), mon, MDESC_TARG);
                msg("You draw power from the %s.", m_name);
                drain = MIN(mon->hp, amount) / 4;
                dead = mon_take_hit(mon, amount, &fear, " is destroyed!");        
            } 
            
            //(void)project(source_player(), 0, grid, amount, typ, flg, 0, 0, context->obj);
	    
            context->ident = true;
	}

	/* Hurt the monster */
        /*
        monster_desc(m_name, sizeof(m_name), mon, MDESC_TARG);
	msg("You draw power from the %s.", m_name);
	drain = MIN(mon->hp, amount) / 4;
	dead = mon_take_hit(mon, amount, &fear, " is destroyed!"); 
         */
	
	/* Gain mana */
	effect_simple(EF_RESTORE_MANA, context->origin, format("%d", drain), 0, 0,
				  0, 0, 0, NULL);

	/* Handle fear for surviving monsters */
        /*
        if (!dead && monster_is_visible(mon)) {
		message_pain(mon, amount);
		if (fear) {
			add_monster_message(mon, MON_MSG_FLEE_IN_TERROR, true);
		}
	} 
         */
	

	return true;
}
Celiend is offline   Reply With Quote