using a script to change actor size up or down

Post » Sat Nov 17, 2012 11:39 pm

Is there a simple script using a loop that would bring an actors size up to a max setting or bring it down to a min setting or last but most important bring it back to the original setting.

I am not great with math so would like someone with script and math skills to see if they can show me how this can be done. The script would run on the actor.
User avatar
koumba
 
Posts: 3394
Joined: Thu Mar 22, 2007 8:39 pm

Post » Sun Nov 18, 2012 6:57 am

If by size you mean that, size, you could use setscale. All objects and actors have the same scale. 1. so, in theory you shouldn't need to store any value, simply start changing it in one direction and then in the other one, depending on the purpose. If on the oher hand, by size you mean how muscular is, there is no script function for that. It can be done by console though and maybe there is a SKSE function doing that.
User avatar
Lynne Hinton
 
Posts: 3388
Joined: Wed Nov 15, 2006 4:24 am

Post » Sun Nov 18, 2012 1:07 am

I do mean setscale but what is the math loop I need to bring the scale up or down or back to its original value ?
User avatar
Chloe Yarnall
 
Posts: 3461
Joined: Sun Oct 08, 2006 3:26 am

Post » Sat Nov 17, 2012 5:01 pm

I don't understand what you mean by a "math loop", but wouldn't you just need to do a setScale(1) to bring it back to normal?

- Hypno
User avatar
Richard Thompson
 
Posts: 3302
Joined: Mon Jun 04, 2007 3:49 am

Post » Sun Nov 18, 2012 4:29 am

Paraphrasing from memory....

Declare a property for the object that you wish to change.

Use a float value for size.

MyObject.Setscale(0.5) makes the object 1/2 size.
MyObject.Setscale(1.0) returns it to normal.
MyObject.SetScale(2.0) makes it twice normal size.
User avatar
Anne marie
 
Posts: 3454
Joined: Tue Jul 11, 2006 1:05 pm

Post » Sun Nov 18, 2012 7:01 am

As I understand, you want to make the target grow or diminish gradually. If so, there is not much mistery. Just change the scale like 1.1, 1.2, 1.3 untill the npc is a gian or 0.9, 0.8, 0.7 untill it has the size of a squirrel, and make the oppossite when you want to undone it. If you want to make the npc real big, once it reach 2 scale double the increase to 2.2, 2,4... at 3 go to 0.5 increases and at 5 use whole unit increasses.

You don't need ot use multipliers, as the scale of every vanilla object is 1 and if a mod added object has a different scale you may preffer not messing with it anyway, as it may be important for the mod in question.
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Sun Nov 18, 2012 8:16 am

I think this is something like what I was looking for and what I meant by "math" thanks...



Scriptname MyChangeScaleScript extends ActiveMagicEffect
{Make target of spell grow up to X it's base size, getting Y% larger per cast.}
Import Utility

float Property TargetScale Auto
{The scale towards which the target should grow (e.g. 1.5 is 50% base size)}
float Property GrowthPerEffect Auto
{The amount of size change per effect, negative value causes shrinking (e.g. if .2, a target with scale .5 grows to .6 (.2 * .5 = .1 increase)}

Event OnEffectStart(Actor akTarget, Actor akCaster)

float currentScale = akTarget.GetScale()
float nextScale = currentScale + currentScale * GrowthPerEffect
float loopScale = currentScale
float changePerLoop = 0.003
int numberOfLoops = 0

; figure out if scale is already being effected
Wait(0.2)
float changedScale = akTarget.GetScale()
if currentScale == changedScale
if (GrowthPerEffect > 0)
if nextScale > TargetScale
nextScale = TargetScale
EndIf
numberOfLoops = Math.Floor(Math.abs(currentScale - nextScale)/changePerLoop)
Debug.Trace("Entering Grow...currentScale=" + currentScale + ", nextScale=" + nextScale, 2)
While numberOfLoops > 0
loopScale+=changePerLoop
akTarget.SetScale(loopScale)
numberOfLoops-=1
EndWhile
Else
if nextScale < TargetScale
nextScale = TargetScale
EndIf
numberOfLoops = Math.Floor(Math.abs(currentScale - nextScale)/changePerLoop)
;Debug.Trace("Entering Shrink...currentScale=" + currentScale + ", nextScale=" + nextScale, 2)
While numberOfLoops > 0
loopScale-=changePerLoop
akTarget.SetScale(loopScale)
numberOfLoops-=1
EndWhile
EndIf
if currentScale == akTarget.GetScale()
Debug.Notification("This spell isn't powerful enough to change the target's size")
Else
;Debug.Trace("Exiting Grow/Shrink...currentScale=" + akTarget.GetScale(), 2)
EndIf
Else
Debug.Notification("The target is already undergoing a size change!")
EndIf

EndEvent
User avatar
Lloyd Muldowney
 
Posts: 3497
Joined: Wed May 23, 2007 2:08 pm


Return to V - Skyrim