Script needed - reduce a creatures speed when below 'X' heal

Post » Mon Jun 18, 2012 6:23 pm

Hi there,

for a mod I'm working on, I've had a request to add in a feature that makes animals run more slowly when they have been wounded. However, I don't know the first thing about scripting... I'll see what I can do if no one can help, but I figured I'd try the generosity of the community first! :-)

I would be intensly appreciative if someone could help make a script that creates the following effect:

When a creature is reduced to 50% health, its speed is modified by -20%. When it is reduced to -80%, its speed is reduced by -40%.

This should be able to be dropped into the creatures stats in the ck, and from then on just do it's own thing. The simpler the better!

Anyone interested in helping? Happy to accept the nessessary tutoring, or the script directly.

Thanks in advance!

Nedius
User avatar
Makenna Nomad
 
Posts: 3391
Joined: Tue Aug 29, 2006 10:05 pm

Post » Mon Jun 18, 2012 8:05 am

I originally wrote up:

Scriptname HPSlow extends Actorfloat hppEvent onLoad()If (!self.isDead())  registerForUpdate(1)endIfendEventEvent onUpdate()hpp = self.getActorValue("Health")/self.getBaseActorValue("Health")if hpp < 20  self.setActorValue("SpeedMult", 60)elseif hpp < 50  self.setActorValue("SpeedMult", 80)endifendEventEvent onDeath(Actor akKiller)UnregisterForUpdate()endEvent

but it seems that the SpeedMult doesn't do anything when modified. Has anyone gotten this to work?
User avatar
Nomee
 
Posts: 3382
Joined: Thu May 24, 2007 5:18 pm

Post » Mon Jun 18, 2012 11:18 pm

Usually when you change speedmult you have to either change movement modes (e.g. sprint/walk/crouch) or change inventory weight for it to take effect. I usually just add like 0.01 to inventory weight, but i usually use spells.
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Mon Jun 18, 2012 2:12 pm

COuld you find out how they do the stagger effect for human enemies on low health, and copy that, changing a couple of variables so that it affects beasts, and the efect it does?
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Mon Jun 18, 2012 10:39 am

Usually when you change speedmult you have to either change movement modes (e.g. sprint/walk/crouch) or change inventory weight for it to take effect. I usually just add like 0.01 to inventory weight, but i usually use spells.

Hmm...would using AddItem and RemoveItem work in this case?
User avatar
Kim Bradley
 
Posts: 3427
Joined: Sat Aug 18, 2007 6:00 am

Post » Mon Jun 18, 2012 12:11 pm

I originally wrote up:

Scriptname HPSlow extends Actorfloat hppEvent onLoad()If (!self.isDead())  registerForUpdate(1)endIfendEventEvent onUpdate()hpp = self.getActorValue("Health")/self.getBaseActorValue("Health")if hpp < 20  self.setActorValue("SpeedMult", 60)elseif hpp < 50  self.setActorValue("SpeedMult", 80)endifendEventEvent onDeath(Actor akKiller)UnregisterForUpdate()endEvent

but it seems that the SpeedMult doesn't do anything when modified. Has anyone gotten this to work?


So this script doesn't actually slow them down? They just keep on running at the same speed? If Nitor is correct and they need to change travelling mode, would it work if they were instructed to change to the stagger animation, and then they try to run on from that?

This is looking more complicated than I'd hoped!
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm

Post » Mon Jun 18, 2012 8:01 pm

Hmm...would using AddItem and RemoveItem work in this case?

Haven't tried it, but my guess is yes.
User avatar
Raymond J. Ramirez
 
Posts: 3390
Joined: Sun Oct 14, 2007 8:28 am


Return to V - Skyrim