Jump to content

Scripting Problem; adjusting the weight of a target character


ZeroCore

Recommended Posts

Okay, I'll be brief: I'm trying to make a mod that essentially allows you to modify your character slightly as a sort of "plastic surgery" mod. The idea is this; it contains 3 spells. One opens the face sculpting menu that was introduced in dawnguard, and the other two, when cast, allow you to change your character's weight (the idea is that the spell would increment the weight value of a character by 1 point per casting).

 

The spell to open the face sculpting menu works fine, but I can't figure out how to use SKSE's "getweight" and "setweight" functions correctly. The first attempt compiled, but did nothing in game.

 

It looked something like this:

 

Scriptname AAAWeightIncreaseScript extends ActiveMagicEffect

EVENT onEffectStart(Actor akTarget, Actor akCaster)
float weight = akTarget.GetWeight()
akTarget.SetWeight(weight + 1)
akTarget.QueueNiNodeUpdate()
ENDEVENT

 

 

And then there was its inverse for the opposite effect:

 

 

Scriptname AAAWeightDecreaseScript extends ActiveMagicEffect

EVENT onEffectStart(Actor akTarget, Actor akCaster)
float weight = akTarget.GetWeight()
akTarget.SetWeight(weight - 1)
akTarget.QueueNiNodeUpdate()
ENDEVENT

 

Neither of these worked.

 

The reason why I tried using the spell's target instead of the player actor is so that I could use the same script in a projectile spell, or a spell with a radius perhaps, to change the weight of NPC's (just for the lulz).

 

Now, I am not familiar with SKSE's functions, and I don't think the vanilla command of "setNPCWeight" will work outside of the in-game debug console.

 

If anyone could please help me with this, I'd appreciate it.

Link to comment
Share on other sites

Try casting the Actor into ActorBase first.

 

I.E.

EVENT onEffectStart(Actor akTarget, Actor akCaster)
ActorBase akAB = akTarget.GetActorBase()
float weight = akAB.GetWeight()
akAB.SetWeight(weight + 1)
ENDEVENT

Also you should not need the QueueNiNodeUpdate because SetWeight does not change any HeadParts or ArmorAddons.

Link to comment
Share on other sites

  On 1/19/2016 at 3:11 AM, IsharaMeradin said:

Try casting the Actor into ActorBase first.

 

I.E.

EVENT onEffectStart(Actor akTarget, Actor akCaster)
ActorBase akAB = akTarget.GetActorBase()
float weight = akAB.GetWeight()
akAB.SetWeight(weight + 1)
ENDEVENT

Also you should not need the QueueNiNodeUpdate because SetWeight does not change any HeadParts or ArmorAddons.

As it turns out, this worked.

 

Thanks for the help.

 

The thing of it is though is that it doesn't actually become noticeable until after you alter your character's outfit. I cast the spell a few times on my character and nothing really seemed to happen. Then I changed from one armor to another and only then did the change become apparent.

Edited by ZeroCore
Link to comment
Share on other sites

  • Recently Browsing   0 members

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