Jump to content
ℹ️ Download History temporarily unavailable ×

Trouble with PC death script


kromey

Recommended Posts

Well, I'm stuck. I've been hacking at the "lich death" script for my Lichdom mod for the last... 5 hours? Really?? Damn...

 

Anyway, I'm stuck. I can get the player into either one of two states:

1) No different -- player just dies

2) Player is immortal

 

What I'm trying to do (and apparently failing miserably at) is to write a script such that when the player would be killed, if they are a lich, their health is recovered and they get downgraded to a nether lich; if they are a nether lich already, they actually die.

 

My closest attempt thus far uses the following scripts (snipped for clarity/brevity, all properties are properly defined and assigned in the CK):

On the player (via a quest alias):

Scriptname Lich_DeathScript extends ReferenceAlias  

Event OnEnterBleedout()
Debug.Notification("We're dying!")

(LichStatus as Lich_StatusScript).LichDeath()
EndEvent

And the quest script function being called:

Scriptname Lich_StatusScript extends Quest  

;For all intents and purposes, think of CurrentStage as an int that is initially 20

Function LichDeath()
If CurrentStage == 10
	Debug.Notification("Nether lich death -- die!")
	;Player is already a nether lich -- time to die!
	CurrentStage = 0 ;Not a lich no more
	;PlayerREF.GetActorBase().SetEssential(false)
	PlayerREF.KillEssential()
ElseIf CurrentStage == 20
	Debug.Notification("Lich death -- become nether lich!")
	;Heal the player up
	PlayerREF.ModAV("health", PlayerREF.GetBaseAV("health"))
	
	;Make the player a nether lich
	MakeNetherLich()
ElseIf CurrentStage != 0
	;Bwuh???
	Debug.Notification("Unknown lich state!")
	;Failsafe -- just make 'em a lich
	MakeLich()
Else
	;"Lich state" is 0, which means not a lich -- do nothing
EndIf
EndFunction

All the debug notifications appear as I would expect, which means this code is doing what I want it to, except that the player never actually dies. The player is made essential via the quest alias, but the KillEssential() function should be overriding that; instead it appears to be triggering the OnEnterBleedout event. Trying to make the player be not essential doesn't change anything either.

 

I've tried also not making the player essential, and using the OnDying event instead; that one just seems to never fire at all for the player! At least, I'm not getting any notifications on my screen.

 

What's really weird is that the following script, which is attached to a potion, works (also snipped for brevity):

Scriptname Lich_ElixirEndlessNightScript extends activemagiceffect  

Event OnEffectStart(Actor Target, Actor Caster)
Target.GetActorBase().SetEssential() ;Make the victim essential

Target.Kill(Caster) ;Send the victim into bleedout...
Utility.Wait(deathDelay) ;...wait a bit...
Target.KillEssential(Caster) ;...then kill him for good
EndEvent

So obviously KillEssential() works even on the player (tested by quaffing the potion, which despite its fatal nature I've made sure to make it not a poison). The only difference is that with the potion the player is made essential by the same script that kills him/her, but with the "lich death" script a quest alias is used with the Essential checkbox ticked.

 

Anyone have any ideas? I'm fresh out.

Link to comment
Share on other sites

I think the problem is the alias. You may need to find an alternative method to apply your script. My advice would be to put a version of your script on an ability that you give to the player and run everything from that ability; therefore negating the need for the alias. (Unless, of course, it's just something simple like ticking the Allow Dead checkbox on the alias form, but I avoid aliases if I can because they seem to behave illogically to me.)
Link to comment
Share on other sites

Hm... I haven't had any issues with aliases myself, but then again I haven't scripted on many aliases.

 

How would I use an ability to capture these events? MagicEffect doesn't have them; can I use a script that extends ActorReference in an ability? I was using the alias because that's the only way I know of to get these events...

Link to comment
Share on other sites

Actually, I can't not use the alias, as it's the only way to add a keyword to the player at a scripted point (start the quest, the player becomes undead by gaining the ActorTypeUndead keyword).

 

But if I could find a way to work it such that the player doesn't have to be made essential...

 

Hm... does the OnHit event trigger before or after damage is applied to the character? If before, is there a way to find out how much damage it will do? That might be an option...

 

Really, I just need a way to detect when the player would die, and prevent that from happening.

Link to comment
Share on other sites

Once the ActorTypeUndead keyword is added, you no longer need the Alias, as the keyword will persist, just like other changes put into effect on the player by the alias (abilities, factions, &tc).

Yes, you can put an Actor script on the player via an ability, but ActiveMagicEffects will also receive events from the Actor they are attached to:- so, there should be no problem.

Link to comment
Share on other sites

That is some good information, I had no idea that changes made via an alias would persist, nor that ActiveMagicEffect scripts received their actor's events! I think it's time to get back in the hotseat and see if I can't make a functional "lich death" script now -- kudos to you! :thumbsup:
Link to comment
Share on other sites

I ended up going a different route: Still using the alias on the player (and still attaching the script via the alias), but the alias no longer makes the player essential. Instead, MakeLich() makes the player essential via script:

PlayerREF.GetActorBase().SetEssential(True)

 

Then, MakeNetherLich() un-makes the player essential (er, makes the player non-essential :whistling: ):

PlayerREF.GetActorBase().SetEssential(False)

 

With a touch of semi-clever scripting, this actually produces a somewhat interesting mini-scene when the player is transformed into a nether lich! It's not perfect, it's got a few flaws, but it's more than serviceable for now.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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