The codes arguments are: Damage, Life Given, dontrandomise
[spoiler]
Code: Select all
//============================================================================
//
// A_LifeDrainPunch
//
//============================================================================
void A_LifeDrainPunch (AActor *self)
{
	AActor *pmo;
	int index=CheckIndex(2);
	if (index<0) return;
	int damage=EvalExpressionI (StateParameters[index], self);
	int newLife=EvalExpressionI (StateParameters[index+1], self);
	bool norandom=!!EvalExpressionI (StateParameters[index+2], self);
	if (!norandom) damage *= (pr_punch()%8+1);
	angle_t angle;
	int slope;
	int i;
	player_t *player;
	if (NULL == (player = self->player))
	{
		return;
	}
	AWeapon *weapon = self->player->ReadyWeapon;
	pmo = player->mo;
	for (i = 0; i < 3; i++)
	{
		angle = pmo->angle+i*(ANG45/16);
		slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE));
		if (linetarget)
		{
			P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, MOD_HIT, RUNTIME_CLASS(ABulletPuff));
			pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, 
				linetarget->x, linetarget->y);
			S_SoundID (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
			if ((linetarget->player || linetarget->flags3&MF3_ISMONSTER)
				&& (!(linetarget->flags2&(MF2_DORMANT+MF2_INVULNERABLE))))
			{
				newLife = player->health+(damage>>3);
				newLife = newLife > 100 ? 100 : newLife;
				if (newLife > player->health)
				{
					pmo->health = player->health = newLife;
				}
			}
			if (weapon != NULL)
			{
				weapon->DepleteAmmo (weapon->bAltFire, false);
			}
			break;
		}
		angle = pmo->angle-i*(ANG45/16);
		slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE));
		if (linetarget)
		{
			P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, MOD_HIT, RUNTIME_CLASS(ABulletPuff));
			pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, 
				linetarget->x, linetarget->y);
			if (linetarget->player || linetarget->flags3&MF3_ISMONSTER)
			{
				newLife = player->health+(damage>>4);
				newLife = newLife > 100 ? 100 : newLife;
				pmo->health = player->health = newLife;
			}
			weapon->DepleteAmmo (weapon->bAltFire, false);
			break;
		}
	}
}EDIT: Forgot a description, its a custom punch that when on contact, transfers the set amount of health to you. Simple, eh?
