Jump to content

[LE] Help working on this script please?


Recommended Posts

Right, so I'm trying to polish out this code. It's based on an abandoned mod that the author has said anyone can try to work on. So I decided a year after I made my first mod that maybe I'd give it a shot.

scriptName _SDT_DeathProtectionScript extends ActiveMagicEffect

Actor property PlayerRef auto
EffectShader property DragonPowerAbsorbFXS auto
GlobalVariable property _SDT_HardcoreEnabled auto
GlobalVariable property _SDT_ReviveCost auto
GlobalVariable property _SDT_SuperEnabled auto
MagicEffect Property _SDT_HardcoreCooldownEffect  Auto  
Sound property NPCDragonDeathSequenceWind auto
Spell Property _SDT_DragonAspect1 auto
Spell Property _SDT_DragonAspect2 auto
Spell Property _SDT_DragonAspect3 auto
Spell Property _SDT_EtherealSpell auto
Spell Property _SDT_ExplosionSpell auto
SPELL Property _SDT_HardcoreCooldownSpell  Auto  
VisualEffect Property FXAlduinSoulEscapeEffect auto

function OnEffectStart(actor akTarget, actor akCaster)

	akTarget.GetActorBase().SetEssential(true)
endFunction

function OnEffectFinish(actor akTarget, actor akCaster)

	akTarget.GetActorBase().SetEssential(false)
endFunction

function OnEnterBleedout()

	Int SDT_SoulCount = PlayerRef.GetActorValue("DragonSouls") as Int
	Int SDT_SoulDump = _SDT_ReviveCost.GetValueInt()
	Int SDT_HardcoreSwitch = _SDT_HardcoreEnabled.GetValueInt()
	Int SDT_SuperSwitch = _SDT_SuperEnabled.GetValueInt()
	if SDT_SoulCount >= SDT_SoulDump
		if PlayerRef.HasMagicEffect(_SDT_HardcoreCooldownEffect)
			PlayerRef.KillEssential(none)
		else
			utility.Wait(3.00000)
			_SDT_EtherealSpell.Cast(PlayerRef)
			DragonPowerAbsorbFXS.Play(PlayerRef, 7.00000)
			FXAlduinSoulEscapeEffect.Play(PlayerRef, 7.00000, PlayerRef)
			NPCDragonDeathSequenceWind.Play(PlayerRef)
			utility.Wait(5.00000)
						
			;Dragon Aspect on revival
			if SDT_SuperSwitch >= 1
				if SDT_SoulCount >=10 && SDT_SoulCount < 20
					_SDT_DragonAspect1.Cast(PlayerRef)
					_SDT_ExplosionSpell.Cast(PlayerRef)
					PlayerRef.ResetHealthAndLimbs()
				else
				endIf
				if SDT_SoulCount >= 20 && SDT_SoulCount < 30
					_SDT_DragonAspect2.Cast(PlayerRef)
					_SDT_ExplosionSpell.Cast(PlayerRef)
					PlayerRef.ResetHealthAndLimbs()
				else
				endIf
				if SDT_SoulCount >= 30
					_SDT_DragonAspect3.Cast(PlayerRef)
					_SDT_ExplosionSpell.Cast(PlayerRef)
					PlayerRef.ResetHealthAndLimbs()
				else
				endif
			else
				PlayerRef.ResetHealthAndLimbs()
			endif
			
			;Reduce Dragon Souls according to cost
			PlayerRef.ModActorValue("DragonSouls", (-SDT_SoulDump) as Float)
				if SDT_HardcoreSwitch == 2		
					debug.Notification("Lost " + SDT_SoulCount as String + 1 as String + " Dragon Souls!")
					PlayerRef.ForceActorValue("DragonSouls", 0 as Float)
					_SDT_HardcoreCooldownSpell.Cast(PlayerRef)
				elseIf SDT_HardcoreSwitch == 1		
					debug.Notification("Lost " + (SDT_SoulCount / 2) as String + " Dragon Souls!")
					PlayerRef.ForceActorValue("DragonSouls", (SDT_SoulCount / 2) as Float)
				endIf
		endIf
	else
			PlayerRef.KillEssential(none)
	endIf
endFunction



 

So if you guys can read it, what I'm trying to accomplish is:

 

1. On bleedout, the mod waits 3 seconds, turns the player ethereal as they hulk up, and then revives the player.

2. If the global _SDT_SuperEnabled is set to 1, then Dragon Aspect is cast.

3. Depending on the global setting _SDT_HardcoreEnabled, remaining number of dragon souls is reduced. _SDT_HardcoreEnabled set to 1 gives the revival a cooldown period. Set to 2, it just outright removes all souls.

 

But I'm running into a few problems.

 

First time entering bleedout state at 100 Dragon Souls _SDT_HardcoreEnabled set to 1: ethereal effect doesn't play. Player hulks up, art effects play. Dragon aspect casts. Explosion casts. Player revives.

 

Second time entering bleedout state at 50 Dragon Souls _SDT_HardcoreEnabled set to 2: Cooldown effects turns out wasn't applied. Ethereal effect plays. Player instantly resets health and limbs. Art effects play. Dragon Aspect casts. Explosion casts.

 

I'm new to scripting so I can't see what the problem is. Can anyone help me?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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