Jump to content

HELP - Playing sound script


FranktheFragger

Recommended Posts

Hi!

 

I am currently in the making of a version 1.1 of my only upload to the Fallout: New Vegas Nexus, "HEV Mark IV", and need a bit of help with the scripting of the sounds.

You can find the .esp here: http://www.nexusmods.com/newvegas/mods/51021/?

 

Not a very popular/amazing modification, but it does what it's made for.

 

Currently, this is where the script currently stands//

 

scn hev42SCRIPT
short bEquipped
short iPlayOnce
float fHPBase
float fHPLast
float fHPCurrent
float fHPRatio
begin OnUnequip player
set bEquipped to 0
end
begin OnEquip player
set fHPBase to player.GetBaseActorValue Health
set fHPLast to player.GetActorValue Health
set iPlayOnce to 0
set bEquipped to 1
end
begin GameMode
if bEquipped
if player.GetDead
set bEquipped to 0
PlaySound hevdead
else
set fHPCurrent to player.GetActorValue Health
if fHPLast != fHPCurrent
set fHPRatio to fHPCurrent / fHPBase
if fHPRatio <= 0.10
if iPlayOnce != 4
set iPlayOnce to 4
PlaySound hev101
endif
elseif fHPRatio <= 0.25
if iPlayOnce != 3
set iPlayOnce to 3
PlaySound hev251
endif
elseif fHPRatio <= 0.50
if iPlayOnce != 2
set iPlayOnce to 2
PlaySound hev501
endif
elseif fHPRatio <= 0.75
if iPlayOnce != 1
set iPlayOnce to 1
PlaySound hev751
endif
elseif iPlayOnce
set iPlayOnce to 0
endif
set fHPLast to fHPCurrent
endif
endif
endif
end
\\
I need help adding the following functions to the script, while being able to keep those already included.
This includes -
- Playing a sound when 200 radiation level is hit
- Playing a sound when poisoned
- Playing a sound ammo is depleted
I appreciate any and all help you can give me, this community has been very supportive in the past and I expect it will remain that way!
If you need more information, I would be more than happy to provide!
Thank you all so very much!
Link to comment
Share on other sites

Here ya go:

scn	hev42SCRIPT

short	bEquipped
short	iPlayOnceHP
float	fHPBase
float	fHPLast
float	fHPCurrent
float	fHPRatio
short	bPlayOnceRads
short	bPlayOncePoison
ref	rWeapon
ref	rAmmo
short	bPlayOnceAmmo

begin OnUnequip

	set bEquipped to 0

end

begin OnEquip player

	set fHPBase to player.GetBaseActorValue Health
	set fHPLast to player.GetActorValue Health
	set iPlayOnceHP to 0
	set bPlayOnceRads to 0
	set bPlayOncePoisoned to 0
	set rWeapon to 0
	set bEquipped to 1

end

begin GameMode

	if bEquipped
		if player.GetDead
			set bEquipped to 0
			PlaySound hevdead
		else
			set fHPCurrent to player.GetActorValue Health
			if fHPLast != fHPCurrent
				set fHPRatio to fHPCurrent / fHPBase
				if fHPRatio <= 0.1
					if iPlayOnceHP != 4
						set iPlayOnceHP to 4
						PlaySound hev101
					endif
				elseif fHPRatio <= 0.25
					if iPlayOnceHP != 3
						set iPlayOnceHP to 3
						PlaySound hev251
					endif
				elseif fHPRatio <= 0.5
					if iPlayOnceHP != 2
						set iPlayOnceHP to 2
						PlaySound hev501
					endif
				elseif fHPRatio <= 0.75
					if iPlayOnceHP != 1
						set iPlayOnceHP to 1
						PlaySound hev751
					endif
				elseif iPlayOnceHP
					set iPlayOnceHP to 0
				endif
				set fHPLast to fHPCurrent
			endif
			if bPlayOnceRads != (player.GetActorValue RadiationRads >= 200)
				set bPlayOnceRads to (bPlayOnceRads == 0)
				if bPlayOnceRads
					PlaySound hevRads
				endif
			endif
			if bPlayOncePoison != (player.IsSpellTarget BarkScorpionPoison || player.IsSpellTarget CazadorPoison || player.IsSpellTarget NightstalkerPoison || player.IsSpellTarget RadScorpion1Poison || player.IsSpellTarget RadScorpion2Poison)
				set bPlayOncePoison to (bPlayOncePoison == 0)
				if bPlayOncePoison
					PlaySound hevPoison
				endif
			endif
			; BEGIN low-ammo alert
			if rWeapon != player.GetEquippedObject 5
				set rWeapon to player.GetEquippedObject 5
				set rAmmo to GetWeaponAmmo rWeapon
				set bPlayOnceAmmo to 0
			elseif rAmmo
				if bPlayOnceAmmo != (player.GetItemCount rAmmo < 30)
					set bPlayOnceAmmo to (bPlayOnceAmmo == 0)
					if bPlayOnceAmmo
						PlaySound hevAmmo
					endif
				endif
			endif
			; END low-ammo alert
		endif
	endif

end

Note that the ammo part requires NVSE, so remove that segment if you don't want your mod to rely on NVSE.

Moreover, for the script to compile, you need to launch the GECK via the NVSE loader, as explained here (2nd paragraph under 'Installation').

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...