--=============================MISCMATCH======================================
--MISC hooks related to the player are here. Usually Match and damage hooks.
--=============================================================================

//Spawn Silver Rings and other drops on hit!
local function pkufling(z, s)
	z.target = s
	z.fuse = 415
	z.flags2 = $|MF2_DONTRESPAWN
	z.flags = $|MF_BOUNCE & ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT)
		
	if (z.type == MT_SMSSILVERRING)
		z.color = SKINCOLOR_BONE
		z.scale = z.target.scale*2
		z.fuse = 280
	end
	z.angle = (P_RandomRange(1, 359))*ANG1
	P_InstaThrust(z, z.angle, 4*z.target.scale)
	P_SetObjectMomZ(z, 4<<16)
end

//Recoil off enemies from tricks if you hit them! This needs to go BEFORE the transformation damage hook.
addHook("MobjDamage", function(s, i, so) if not s.player return end local p = s.player
	if p.hypermysticsonic and s.skin == "sms" return true end --What damage?
	--Don't get killed by what you're holding
	if p.smspickup and p.smspickup.valid and (i == p.smspickup or so == p.smspickup) return true end -- 
	
	if so and so.player and so.skin == "sms"
		if gametype == GT_COOP --Negate friendly damage!
		or G_GametypeHasTeams() and so.player.ctfteam == p.ctfteam
			if i and (i.type == MT_SMSFIREBLAST)	
				P_GivePlayerRings(p, 1)
				if p.boostmeter ~= nil
					p.boostmeter = $+18
				end
				if i.valid and i.health
					P_SpawnMobj(i.x, i.y, i.z, MT_SPARK)
					i.gzmd = P_SpawnGhostMobj(i)
					i.gzmd.destscale = 1
					P_HomingAttack(i.gzmd, s)
					S_StartSound(s, sfx_itemup)
					S_StartSound(s, sfx_s1c0)
					i.state = S_NULL
				end
			end
			return true --
		end
	end

	if s.skin != "sms" return end --Be SMS from here on out.
	
	--Crash with superarmor off some things that WOULD've hurt you!
	if p.footsweepanim 
	or (s.state == S_SMS_AIRBOOST) and (p.sms_didairboost > 1)
		if i 
			if SMS_ArmoredCrash(s, p, i) return true end --
		elseif SMS_ArmoredCrash(s, p, so)
			return true --
		end
	elseif i
		if p.smsdivetimer //If you've got a good dive going, don't let enemies stop your fun.
			if (p.smsdivetimer > 9) and i and (i.flags & (MF_ENEMY|MF_BOSS))
				return true --
			end
		end	
		if (p.sms_boostlevel > 64 and p.speed > 44*s.scale)
		or (s.state == S_SMS_AIRBOOST)
		or ((p.cmd.buttons & BT_CUSTOM1 or p.sms_autoboosthold) and p.speed > 88*s.scale and p.panim == PA_RUN)	
			--Negate damage once if you hit stuff with an airboost.	
			--Fling with momentum off stuff you're crashing into!
			if (i.flags & (MF_ENEMY|MF_BOSS|MF_PAIN))
			or (i.type == MT_DETON)
		
				if (so and so.player) --None of this from player-owned objects.
				or p.rings <= 0 and not p.powers[pw_shield] --You're about to die entirely at this rate.
					return
				end
				A_SMSquake(s, 65<<16, 4, 1500)
				s.momx,s.momy = $*2/3,$*2/3
				if (s.momz*P_MobjFlip(s) < 6*s.scale)
					P_SetObjectMomZ(s, 6<<16)
				else
					P_SetObjectMomZ(s, 2<<16, true)
				end
				if (i.type == MT_DETON)
					P_DamageMobj(i)	
				end
				if p.powers[pw_shield] --Recreate SRB2's damage behaviour ,but keep your speed.
					P_RemoveShield(p)
					S_StartSound(s, sfx_shldls)
				else
					P_PlayRinglossSound(s)
					if p.sms_transformstate == 1
						p.sms_transformstate = 2
						P_PlayerRingBurst(p, -1) 
						P_GivePlayerRings(p, p.rings/-2)
					else	
						P_PlayerRingBurst(p, -1)
						P_GivePlayerRings(p, p.rings*-1)
						if p.sms_transformstate == 2 or  p.sms_transformstate == 3
							s.state = S_PLAY_PAIN 
							p.panim = PA_PAIN
							A_SMSTOSONIC(s, true)
						end
					end
				end		
				s.SMS_CrashRoll = {timer = 27, extratime = false}			
				SMS_RagDoll(s)
				p.powers[pw_flashing] = max($,105)
				return true --
			end
		end
	end
/*	if (p.hometrickanim or  p.sms_stompanim)
	and not p.powers[pw_invulnerability]
		if (s.skin == "sms")
			if i and (i.flags & (MF_ENEMY|MF_BOSS))
				if p.hometrickanim
					s.state = S_PLAY_ROLL
				end
				p.pflags = $|PF_JUMPED
				p.hometrickanim = false
				return true	 --		
			end
		end
  	end */
 
  	if p.powers[pw_shield] return end -- //Don't drop stuff or detransform if you're shielded
	
	//Drop weapons for players when hit!
	
	if G_RingSlingerGametype() and not s.battlemodsms
		local ghs
		if s.sms_ringweapons --We copied p.ringweapons earlier. Should we drop any?
			if not (i and i.samusshot)
				if (s.sms_ringweapons & RW_SCATTER)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 33*s.scale, MT_SCATTERPICKUP)
					pkufling(ghs, s)
				end
				if (s.sms_ringweapons & RW_EXPLODE)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 33*s.scale, MT_EXPLODEPICKUP)
					ghs.target = s
					pkufling(ghs, s)
				end
				if (s.sms_ringweapons & RW_GRENADE)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 33*s.scale, MT_GRENADEPICKUP)
					pkufling(ghs, s)
				end
				if (s.sms_ringweapons & RW_AUTO)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 33*s.scale, MT_AUTOPICKUP)
					pkufling(ghs, s)
				end
				if (s.sms_ringweapons & RW_RAIL)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 33*s.scale, MT_RAILPICKUP)
					pkufling(ghs, s)
				end
			end
			s.sms_ringweapons = 0
		end
		if s.sms_infinityring --Augh, you special little shit.
			ghs = P_SpawnMobjFromMobj(s, 0,0, 35*s.scale, MT_INFINITYRING)
			pkufling(ghs, s)
			s.sms_infinityring= nil
		end
		if (p.rings > 78) --Drop excess rings in the form of silver rings.
			ghs = P_SpawnMobjFromMobj(s, 0,0, 54*s.scale, MT_SMSSILVERRING)
			pkufling(ghs, s)
			if (p.rings > 158)
				ghs = P_SpawnMobjFromMobj(s, 0,0, 58*s.scale, MT_SMSSILVERRING)
				pkufling(ghs, s)
				if (p.rings > 238)
					ghs = P_SpawnMobjFromMobj(s, 0,0, 62*s.scale, MT_SMSSILVERRING)
					pkufling(ghs, s)
				end				
			end			
		end
	end
	
	//SMS can take 2 hits when manually transformed before detransforming, not counting shields.
	//The first hit he has an extra 50% defense, only losing half of his rings.
	//pw_bouncering, pw_railring, pw_automaticring, pw_explosionring, pw_scatterring, and pw_grenadering 
	
	if not p.sms_transformstate return end --Next part is for transformstate damage!
	
	if (p.sms_transformstate == 1) and i
	and not ( (i.flags & MF_PAIN|MF_ENEMY|MF_BOSS) and ((p.sms_boostlevel > 64) or s.airboostimmune) )
	 
		if (p.rings > 49)
		
			P_DoPlayerPain(p)
			P_PlayerRingBurst(p, -1)
			P_PlayRinglossSound(s)
			p.sms_transformstate = 2
			P_GivePlayerRings(p, p.rings/-2)
			HMS_AuraStorm(s, nil, SKINCOLOR_RED)
			SMS_LightClash(s, SKINCOLOR_RED, s)	
			return true --
			
		elseif p.rings == 1
		
			S_StartSound(s, sfx_shldls)
			P_DoPlayerPain(p)
			P_PlayerRingBurst(p, 0)
			p.sms_transformstate = 2	
			HMS_AuraStorm(s, nil, SKINCOLOR_RED)
			SMS_LightClash(s, SKINCOLOR_RED, s)	
			return true --
			
		elseif p.rings == 0 //Block a death blow!
			P_DoPlayerPain(p)
		--	S_StartSound(s, sfx_shldls)
		
			local ghs = P_SpawnGhostMobj(s)
			ghs.destscale = $*99
			ghs.blendmode = AST_ADD
			ghs.colorized = true
			ghs.fuse = 13 ghs.tics = 99
			
			P_FlashPal(p, PAL_MIXUP, 4)
		--	S_StartSound(target, sfx_s3k4e)
			if p.presmsskin
				R_SetPlayerSkin(p, p.presmsskin)
				s.skin = p.presmsskin					
			else
				R_SetPlayerSkin(p, "sonic")
				s.skin = "sonic"
			end
			if not s.battlemodsms
				P_NukeEnemies(s, s, 350*s.scale)
			else --Give score bonus and send SMS flying
				s.lastbmrings = p.rings
				if s.supersmsrecoil and i
					P_SetObjectMomZ(s, 10<<16)				
					s.supersmsrecoil2ang = R_PointToAngle2(s.x, s.y, i.x, i.y)
					P_InstaThrust(s, s.supersmsrecoil2ang, -65*s.scale)
					s.supersmsrecoil2 = 17
					if so and so.player
						P_FlashPal(so.player, PAL_MIXUP, 4)
					end
				end
				if so and so.player and (so.skin != "sms")
					if s.supersmsrecoil
						so.player.score = $+50 //Slight score boost for hitting SMS!
						CONS_Printf(so.player, "\x82"+"Gained 50 score bonus for taking down SMS hard!")
					else
						so.player.score = $+25 //Slight score boost for hitting SMS!
						CONS_Printf(so.player, "\x82"+"Gained 25 score bonus for taking down SMS!")
					end
				end
			end
			if not (p.powers[pw_shield] & SH_FIREFLOWER)
			and not ((mariomode) and p.powers[pw_invulnerability])
				s.color = p.sms_originalcolor
			else
				s.color = SKINCOLOR_WHITE
			end
			p.skincolor = p.sms_originalcolor
			p.sms_transformstate = 0
			SMS_LightFlash(s, SKINCOLOR_RED)	
			SMS_LightningTrail(s, s)
			HMS_GigaJetBolt(s)
			SMS_AngledLightning(s, SKINCOLOR_RED, 23, 3-SMS_Graphix(s))
			P_PlayRinglossSound(s)
			S_StartSound(s, sfx_smscrt)
			S_StartSoundAtVolume(s, sfx_nerf, 120)
			S_StartSound(s, sfx_smscr2)		
			return true --
		else
			P_DoPlayerPain(p)
			P_PlayerRingBurst(p, p.rings/2)
			P_PlayRinglossSound(s)
			p.sms_transformstate = 2
			P_GivePlayerRings(p, p.rings/-2)
			return true --
		end
		
	elseif p.sms_transformstate == 2 or p.sms_transformstate == 3
	
		local ghs = P_SpawnGhostMobj(s)
		ghs.destscale = $*99
		ghs.blendmode = AST_ADD
		ghs.colorized = true
		ghs.fuse = 13 ghs.tics = 99
		P_FlashPal(p, PAL_MIXUP, 4)
	--	S_StartSound(s, sfx_s3k4e)
		if p.presmsskin
			R_SetPlayerSkin(p, p.presmsskin)
			s.skin = p.presmsskin					
		else
			R_SetPlayerSkin(p, "sonic")
			s.skin = "sonic"
		end
		if not s.battlemodsms
			P_NukeEnemies(s, s, 350*s.scale)
		else --Give score bonus and send SMS flying
			s.lastbmrings = p.rings
			if s.supersmsrecoil and i
				P_SetObjectMomZ(s, 10<<16)				
				s.supersmsrecoil2ang = R_PointToAngle2(s.x, s.y, i.x, i.y)
				P_InstaThrust(s, s.supersmsrecoil2ang, -65*s.scale)
				s.supersmsrecoil2 = 17
				S_StartSound(s, sfx_smscrt)
				S_StartSoundAtVolume(s, sfx_nerf, 110)
				S_StartSound(s, sfx_smscr2)
				if so and so.player
					P_FlashPal(so.player, PAL_MIXUP, 4)
				end
			end
			if so and so.player and (so.skin != "sms")
				if s.supersmsrecoil
					so.player.score = $+50 //Slight score boost for hitting SMS!
					CONS_Printf(so.player, "\x82"+"Gained 50 score bonus for taking down SMS hard!")
				else
					so.player.score = $+25 //Slight score boost for hitting SMS!
					CONS_Printf(so.player, "\x82"+"Gained 25 score bonus for taking down SMS!")
				end
			end
		end
		if not (p.powers[pw_shield] & SH_FIREFLOWER)
		and not ((mariomode) and p.powers[pw_invulnerability])
			s.color = p.sms_originalcolor
		else
			s.color = SKINCOLOR_WHITE
		end
		p.skincolor = p.sms_originalcolor
		p.sms_transformstate = 0
		S_StartSoundAtVolume(s, sfx_nerf, 77)
		S_StartSound(s, sfx_smscrt)
		SMS_LightFlash(s, SKINCOLOR_WHITE)
		SMS_AngledLightning(s, SKINCOLOR_SUPERSKY2, 23, 3-SMS_Graphix(s))
		SMS_LightningTrail(s, s)
		return --
	end
end, MT_PLAYER)

//SMS doesn't get hurt while dodging/ringbursting, unless it's a lava, acid, or electricity sector.
//Like a true cliche Matrix dodge, though, he can stylefully ignore lasers!
//This also merges every other ShouldDamage hook.
addHook("ShouldDamage", function(s, i, so)
	if not s.player return end --
	local p = s.player
	
	if p.hypermysticsonic and s.skin == "sms" --Undefeatable!
		return false --
	elseif p.smspickup and (p.smspickup == so) --Don't hit by your own item pickup!
		return false --
	end
	
	//Don't give rings in these cases.
		if (i and i.valid)	
			if G_GametypeHasTeams() and not (i.type == MT_SMSFIREBLAST)
				if so and so.player and (so.player.ctfteam == p.ctfteam)
					if ((i.type == MT_HMSFIREBLAST) or (i.type == MT_HMS_NAPALM_FLAMES))
						return false --
					end
					if (s.skin == "sms") and (i.flags & MF_MISSILE) and not (i.type == MT_REDRING)
						return false -- //Only allow red-rings so people can't feed you with autorings for an easy HMS transformation
					end
					if (so.skin == "sms") and not (i.type == MT_SMSFIREBLAST) //Fireblast ring-sharing only!
						return false --
					end
				end
			end	
			
			if s.ibethrownbysmshelp
				return false --	
			//Kids, don't kill friends and family with black holes
			elseif (i.type == MT_HMSBLACKHOLE)
				if (gametype == GT_COOP)
				or (i.target and i.target.player and (i.target.player.ctfteam == p.ctfteam))
					return false --
				end

		//Even though the walljump technically becomes a missile, it should NEVER hurt players.

			elseif (i.type == MT_SMSWALLJUMP)
					return false --
			elseif i.fusrodah //Ignore hits from enemies currently flying towards their death
				if (i.flags & MF_PAIN|MF_ENEMY|MF_BOSS)
					return false --
				end
			end
		end
		if (s.skin != "sms") or p.powers[pw_invulnerability] or (p.pflags & PF_GODMODE)	
			return -- Need to be SMS from now on, and have a source or inflictor.
		end
		
		--Invincibility?
		if (p.sms_dodging > 2)
		or p.sms_ringburstfly
		or p.sms_comethaymaker
		or p.mslightspeedattack
		or p.lightspeedchain
		or ((s.state >=  S_SMS_LIGHTDASH) and (s.state <= S_SMSCOMETHAYMAKER2))
			if s.battlemodsms --Don't get interrupted by people's jumps here.
				return false --
			end
			if not ( P_PlayerTouchingSectorSpecial(p, 1, 4) --You're not standing in death?
			or P_PlayerTouchingSectorSpecial(p, 1, 3)
			or P_PlayerTouchingSectorSpecial(p, 1, 2) )
				
			and not SMSSHIELD(p) == SH_ELEMENTAL --Or you are standing in death, but you have shield.
			and not (so and so.player and so.player.hypermysticsonic) --Unbypassable damage.
				return false --Dodge!
			end
			if (p.sms_dodging > 2) and (so and not so.player)
				SMS_InvincibleBurst(s, p)
			end
		end
		
		local RAGDOLL = 0
		
		if so and (so.type == MT_TNTBARREL)
		or i and (i.type == MT_TNTBARREL)
			if p.homing or s.SMS_HomingBolt or p.footsweepanim
			or (so and so.YOUKICKEDME and so.YOUKICKEDME == s)
			or (i and i.YOUKICKEDME and i.YOUKICKEDME == s)
				return false --Ignore barrels when kicked/homed into.
			else
				RAGDOLL = 2
			end
		end

		if not (i and i.valid)
		or p.powers[pw_flashing]
			if RAGDOLL != 0 SMS_RagDoll(s, RAGDOLL) end		
			return --
		end --Need inflictor at all points now.
			
		if p.lightspeedchain --You're invincible to conventional attacks during a lightspeed attack!
			return false --			
		elseif p.footsweepanim			
			if (i.flags & (MF_ENEMY|MF_BOSS)) --Don't get hurt by (most) enemies you're footsweeping!
			and not ((i.type == MT_GSNAPPER) or (i.type == MT_CRUSHCLAW) and p.footsweep01) 	
				return false
			end	
		end
end, MT_PLAYER)

--Pick up Silver Ring dropped by SMS in match?
local function SMS_SRCollide(s, v)
	if v and v.player and s.health
		if not P_CanPickupItem(v.player, s)
			return false --
		end
	end
end
addHook("MobjCollide", SMS_SRCollide, MT_SMSSILVERRING)
addHook("MobjMoveCollide", SMS_SRCollide, MT_SMSSILVERRING)

addHook("TouchSpecial", function(r, s)
	if s and s.player and r.health
		if not (r.z > s.z+s.height)
		and not (s.z > r.z+r.height)
			if P_CanPickupItem(s.player, r)
				S_StartSound(s, sfx_itemup)
				P_GivePlayerRings(s.player, 10)
				r.destscale = r.scale*4
				P_KillMobj(r, s, s)
			end
		end
	end
	return true --
end, MT_SMSSILVERRING)

addHook("MobjThinker", function(s)
	if not s.valid return end
	if not (s.target and s.target.player) --FIND one.
		A_FindTarget(s, MT_PLAYER, 0)
	end
	if (s.state == S_SMSTSPARK1)
	s.blendmode = AST_ADD
		if (s.target and s.target.player and s.target.player.elauracolors and s.target.skin == "sms")
		local p = s.target.player
			if (p.elauracolors < 100)
				s.color = SKINCOLOR_YELLOW 
			elseif (p.elauracolors >= 100 and p.elauracolors < 120)
				s.color = SKINCOLOR_PERIDOT //Greenish yellow
			elseif (p.elauracolors >= 120 and p.elauracolors < 140)
				s.color = SKINCOLOR_GREEN  
			elseif (p.elauracolors >= 140 and p.elauracolors < 160)
				s.color = SKINCOLOR_EMERALD //Neon G
			elseif (p.elauracolors >= 160 and p.elauracolors < 180)
				s.color = SKINCOLOR_PERIDOT//Greenish yellow
			elseif (p.elauracolors >= 180 and p.elauracolors < 200)
				s.color = SKINCOLOR_YELLOW 
			elseif (p.elauracolors >= 200 and p.elauracolors < 220)
				s.color = SKINCOLOR_GOLD //Gold
			elseif (p.elauracolors >= 220 and p.elauracolors < 240)
				s.color = SKINCOLOR_ORANGE //Orange
			elseif (p.elauracolors >= 240 and p.elauracolors < 260)
				s.color = SKINCOLOR_RED //Red
			else //if (p.elauracolors >= 260 and p.elauracolors < 281)
				s.color = SKINCOLOR_RUST //Pink
			end
		elseif not s.coverride
			s.color = SKINCOLOR_YELLOW
		end
	end
end, MT_SMSTSPARK)

addHook("MobjThinker", function(s)
	if s.valid
	and (s.state == S_SMSTSPARK1) and not s.coverride
		s.color = SKINCOLOR_YELLOW
	end
end, MT_NIGHTSPARKLE)


//SMS' various unique hurt messages!
--2020: A local function here would've done wonders here. Oh well. Live and learn!

--Are you dead? Kill Message.
local function SMS_hmdead(s)
	if not s.health and not s.player.powers[pw_shield]
		return true --
	end
end
addHook("HurtMsg", function(p, i, so)
	if (gametype == GT_COOP) or not (p.mo and p.mo.valid)
		return --
	end
	if not (so and so.skin == "sms" or i and i.skin == "sms") --We need either an SMS inflictor or source.
		return --
	end	
	if not i return end
	
	local s = p.mo	
	if (p and s.battlemodsms) 
	or (so and so.battlemodsms) --Don't bother for battlemod.
		return
	end
	
	local PNAME = "\x80"+p.name
	if p.ctfteam and G_GametypeHasTeams()
		if p.ctfteam == 1
			PNAME = "\x85"+p.name+"\x80"
		else--if p.ctfteam == 2
			PNAME = "\x84"+p.name+"\x80"
		end
	end
	
	local IP = i.player
	local IPNAME = IP and "\x80"+IP.name or
	i.target and i.target.player and "\x80"+i.target.playername
	or so and so.player and so.player.name
	
	if IPNAME
		if p.ctfteam and G_GametypeHasTeams()
			if p.ctfteam == 1
				IPNAME = "\x85"+IP.name+"\x80"
			else--if p.ctfteam == 2
				IPNAME = "\x84"+IP.name+"\x80"
			end
		end	
	else 
		IPNAME = "\x80"+"PLAYER"
	end
	
	if IP	
		if IP.footsweepanim
			if SMS_hmdead(s)
				print(IPNAME+" roundhoused "+PNAME+" with a footsweep attack!")
                return true
			else
				print(IPNAME+" spinkicked "+PNAME+".")
				return true
            end

		elseif IP.sms_ringburstfly
			if SMS_hmdead(s)
               print(IPNAME+" skewered "+PNAME+" to death with the ringburst!")
               return true
			else
				print(IPNAME+" pierced "+PNAME+" with the flight of ringburst!")
				return true
            end

		elseif ((i.state == S_HMSCOMETHAYMAKER2) or (i.state == S_SMSCOMETHAYMAKER2) or (i.state == S_SMSCOMETHAYMAKER1) or (i.state == S_HMSCOMETHAYMAKER1))
			if not s.health
				print(IPNAME+" smashed "+PNAME+" out of the stadium! Homerun!")
                return true
			else
				print(IPNAME+" sent "+PNAME+" flying with a Comet Haymaker!")
				return true
            end

		else
			if SMS_hmdead(s)
				print(IPNAME+" killed "+PNAME+"!")
                return true
			else
                print(IPNAME+" hit "+PNAME+".")
				return true
			end
		end
	elseif i.type == MT_SMMK
		if not SMS_hmdead(s)
			if i.smssmmk
				print(PNAME+" got killed by "+IPNAME+"'s stomp shockwave!")
                return true
			else
				print(IPNAME+" roundhoused "+PNAME+" with a footsweep attack!")
                return true
			end

		else
			if i.smssmmk
				print(IPNAME+" stomp shockwave hit "+PNAME+"!")
				return true
			else
				print(IPNAME+" spinkicked "+PNAME+".")
				return true
			end
        end

	elseif i.type == MT_SMSSPINFIRE
		if SMS_hmdead(s)
            print(PNAME+" died to "+IPNAME+"'s dashing flames!")
            return true
		else

			print(IPNAME+" left "+PNAME+" in the fiery dust!")
			return true
        end
	elseif i.type == MT_SMSDIVEBOMB
		if SMS_hmdead(s)
            print(IPNAME+" killed "+PNAME+" with an explosive divebomb!")
            return true
		else
			print(IPNAME+"'s explosive divebomb wounded "+PNAME+".")
			return true
        end
	elseif i.type == MT_SMSPOWERBOMB
		if SMS_hmdead(s)
             print(PNAME+" was vaporized by "+IPNAME+"'s powerbomb.")
             return true
		else
			print(IPNAME+" powerbombed "+PNAME+"!")
			return true
        end
	elseif i.type == MT_HMSPOWERBOMB	
		if SMS_hmdead(s)
			print(IPNAME+" completely obliterated "+PNAME+"!")
			return true
		else
			print(IPNAME+" nuked "+PNAME+" with an enormous explosion!")
			return true
        end
	elseif i.type == MT_CMPHRADIUS
		if not s.health
            print(IPNAME+" smashed "+PNAME+" out of the stadium! Homerun!")
            return true
		else
			print(IPNAME+" sent "+PNAME+" flying with a Comet Haymaker!")
			return true
        end
	elseif i.type == MT_HMSFIREBLAST
		if SMS_hmdead(s)
			print("Ding!"+PNAME+" was cooked alive by "+IPNAME+"'s flames! Enjoy while it's hot!")
			return true
		else
			print(PNAME+" was torched by "+IPNAME+".")
			return true
        end
	elseif ((i.type == MT_HMSFLAMEREST) or (i.type == MT_HMS_NAPALM_FLAMES))
		if SMS_hmdead(s)
             print(IPNAME+" 's inferno consumed "+PNAME+"'s life!")
             return true
		else
			print(IPNAME+" caught "+PNAME+" in the inferno!")
			return true
        end
	elseif i.type == MT_HMSNOVABLAST or (i.type == MT_HMSNOVABLASTHB)
		if SMS_hmdead(s)
			print(IPNAME+" annihilated "+PNAME+" with the Nova Blast!")
			return true --
		else
			print(IPNAME+" blew "+PNAME+" away with the Nova Blast!")
			return true --
        end
	elseif i.type == MT_HMSLIPILLAR
		if SMS_hmdead(s)
			print("RIP: "+PNAME+". You will be missed. But not by "+IPNAME+", who clearly hates you.")
			return true --
		else
			print(PNAME+" was blown away by "+IPNAME+"'s lightshow!")
			return true --
		end
	end
end)
