Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Push dead NPC Spell


Glowplug
 Share

Recommended Posts

As per my Nagasteim post I need the player to be able to push dead NPCs off a wharf into the water.
They will have limited time to perform this before the next enemy patrol emerge.

Telekinesis and pushActorAway do not work on dead NPC and temporary resurrection is messy.

I've tried calculating the coordinates to move the dead NPC to but ran into trouble.
To solve Z I had hoped to simply raise the NPC high enough to allow for whatever slope upwards.
The dead NPC hangs mid air instead of falling to ground - is there a solution for this?

It makes sense to use the player as origin so I started with...
newX = player.getPos X + moveDistance * Cos(player.getAngle Z)
newY = player.getPos Y - moveDistance * Sin(player.getAngle Z)
...but that goes the wrong direction no matter which angle I cast from.
I have not found suitable variation.

I've looked at the code behind Side's Sailing Ships but found myself overwhelmed.

Any help greatly appreciate,
Greg

Link to comment
Share on other sites

I've observed this behavior with NPCs also. They don't always Havok settle when you would expect them to. (I actually exploit this at one point for some eye-candy in Rathunas, although in a situation where if it *doesn't* behave that way, no harm done -- in general, relying on a game engine bug for anything critical isn't a great idea!)

 

I know you don't want to resurrect the dead, but you may find that you can resolve this by doing a resurrect() on one frame and then a kill() on the next. This is fairly easy to achieve in a GameMode block:

; Object script attached to the NPC that is to die and be moved

short wasKilled
short doRelocate

begin OnDeath
   set wasKilled to 1
end

begin GameMode

; We assume that external logic will set doRelocate when it is time to move the corpse

; If this NPC has been resurrected, re-kill them and enable.
; This might be replaced with just "if getDisabled", if there is no other occasion
; in which this reference would ever be disabled in your mod.
if getDead == 0 && wasKilled
   enable
   kill
endif

; This has to go *after* the preceding so its effects last through a frame transition
if wasKilled && doRelocate
   disable
   MoveTo my-new-location
   resurrect
   set doRelocate to 0
endif

end ; GameMode

You may (probably *will*) have to tinker with when the resurrect and kill calls happen. In particular, the kill may need to move down into the block right after the resurrect, rather than being in the next frame with the enable. Also, I'm not 100% sure how the timing of getDead behaves with respect to frame timing and the resurrection animation. In other words, here's a skeleton of an idea -- your mileage will vary. :-)

 

One other little tip: In my testing, I have found that NPC bodies do *not* behave properly with respect to an Enable Parent switching them on and off. I found that to reliably switch their rendering on and off, I needed to explicitly disable or enable each NPC reference. I haven't tested this with creatures, only humanoid NPCs.

 

Another possible approach, though more involved: Copy the NPC skeleton meshes to your own directory, and make a custom race that uses your copy of the skeleton meshes instead of the originals. You can use NIFskope to fine-tune the physics behavior of the meshes, setting their mass, damping coefficients, and so forth. I shudder to think of the unforseen side effects of this, but it might be workable if your NPCs are sufficiently generic and all of one race, and they don't have need of the default dialog.

 

Hope this helps.

Link to comment
Share on other sites

I've observed this behavior with NPCs also. They don't always Havok settle when you would expect them to. (I actually exploit this at one point for some eye-candy in Rathunas, although in a situation where if it *doesn't* behave that way, no harm done -- in general, relying on a game engine bug for anything critical isn't a great idea!)

 

I know you don't want to resurrect the dead, but you may find that you can resolve this by doing a resurrect() on one frame and then a kill() on the next. This is fairly easy to achieve in a GameMode block:

; Object script attached to the NPC that is to die and be moved

short wasKilled
short doRelocate

begin OnDeath
   set wasKilled to 1
end

begin GameMode

; We assume that external logic will set doRelocate when it is time to move the corpse

; If this NPC has been resurrected, re-kill them and enable.
; This might be replaced with just "if getDisabled", if there is no other occasion
; in which this reference would ever be disabled in your mod.
if getDead == 0 && wasKilled
   enable
   kill
endif

; This has to go *after* the preceding so its effects last through a frame transition
if wasKilled && doRelocate
   disable
   MoveTo my-new-location
   resurrect
   set doRelocate to 0
endif

end ; GameMode

You may (probably *will*) have to tinker with when the resurrect and kill calls happen. In particular, the kill may need to move down into the block right after the resurrect, rather than being in the next frame with the enable. Also, I'm not 100% sure how the timing of getDead behaves with respect to frame timing and the resurrection animation. In other words, here's a skeleton of an idea -- your mileage will vary. :-)

 

One other little tip: In my testing, I have found that NPC bodies do *not* behave properly with respect to an Enable Parent switching them on and off. I found that to reliably switch their rendering on and off, I needed to explicitly disable or enable each NPC reference. I haven't tested this with creatures, only humanoid NPCs.

 

Another possible approach, though more involved: Copy the NPC skeleton meshes to your own directory, and make a custom race that uses your copy of the skeleton meshes instead of the originals. You can use NIFskope to fine-tune the physics behavior of the meshes, setting their mass, damping coefficients, and so forth. I shudder to think of the unforseen side effects of this, but it might be workable if your NPCs are sufficiently generic and all of one race, and they don't have need of the default dialog.

 

Hope this helps.

Thank you for your time on this, you have saved me days or even giving up :)

Having got that going I was able to focus on getting the trigonometry right.

Thanks to Side's Sails for the Trig Z solution.

I was finally able to put it all on the Touch spell which solves a few other issues.

 

scn kvSpellPushDeadScript

ref refActor
float fAngle
float fX
float fY
int iWasDead
float fTimer

begin scriptEffectStart
    set refActor to getSelf
    set fTimer to 0
    set iWasDead to 0
    if refActor.getDead
        set iWasDead to 1
        set fAngle to player.getAngle z
        if fAngle < 90
            set fAngle to 90 - fAngle
        else
            set fAngle to 450 - fAngle
        endif
        set fX to player.getPos x + 512 * cos fAngle
        set fY to player.getPos y + 512 * sin fAngle
        refActor.setPos x fX
        refActor.setPos y fY
    endif
end

begin scriptEffectUpdate
    set fTimer to fTimer + getSecondsPassed
    if iWasDead == 1
        set iWasDead to 2
        refActor.resurrect 1
    elseif iWasDead == 2 && fTimer > 0.1
        set iWasDead to 0
        refActor.kill
        dispel kvSpellPushDead
    endif
end

Edited by Glowplug
Link to comment
Share on other sites

Great! Your little spell works a treat!

 

Have you considered separating the spell, perhaps with a smaller push distance, and offering that as a standalone mod for immersive RP and people who don't want to leave bodies of friendly NPCs just lying around randomly?

 

Thanks once again for your time.

Begin stand alone requires a bit more polish than I had planned but seems worth the effort.

Being similar to Telekinesis I put that first to give it a nice icon.

I've made it self leveling with Level: Magicka Cost, Distance Pushed...

Novice: 10, 180

Apprentice: 30, 270

Journeyman: 70, 360

Expert: 120, 450

Master: 200, 512

...any feedback on those settings greatly appreciated as I am now testing it.

I like the challenge of not changing anything on Oblivion.esm so I'll try making it a start game added travel scroll.

That can take the player somewhere to fight off n enemy to retrieve the spell tomb which intern sets them back where they cast the travel scroll.

I'll see how it goes.

 

Edit: I've changed the costs to 10, 20, 40, 80 and 120 respectively.

Testing on Master Mysticism with a robe enchanted with Fortify Magicka 30, Restore Magicka 25 it's just enough to get a dead actor a reasonable distance.

Edited by Glowplug
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...