Jump to content

Enable/disable and SetScaleEX


wjslk

Recommended Posts

I want to rescale actors using the OBSE command SetScaleEX (SetScale only takes values between 0.5 and 2.0, so that's not an option). Now, if I just do something like SetScaleEX 0.3, the graphics do not update themselves. The OBSE Documentation recommends disabling and enabling and this works for me, but only if I do it manually using the console. When writing a script that should do the enable/disable for me, one of two things appear to happen.

1) If I just write something like

 

disable

SetScaleEX 0.3

enable

 

Then the actor stays enabled and its size is 0.3 but the graphics are not updated, so the rescale is not visible (only if I do disable/enable manually in the console again).

2) If I wait a frame or several with the enable then the actor disappears and won't come back, even though it is enabled.

 

I'm really confused by that. Does anyone know a solution? Or maybe there is a better way than that disable/enable business?

Link to comment
Share on other sites

Enabling the reference must be doen at least one frame later.

 

Something like this:

if <some condition>
  MyRef.Disable
  MyRef.SetScaleEX <some value>
  let iFrame := 2 
endif


if iFrame
  let iFrame -= 1
  if iFrame == 0
    MyRef.enable
  endif
endif

Actors change position when going thru this process (most likely related to the path grid), so you may want to save their X, Y and Z positions when disabling and set them back after enabling.

 

 

 

Link to comment
Share on other sites

 

Enabling the reference must be doen at least one frame later.

 

Something like this:

 

if <some condition>  MyRef.Disable  MyRef.SetScaleEX <some value>  let iFrame := 2 endifif iFrame  let iFrame -= 1  if iFrame == 0    MyRef.enable  endifendif
Actors change position when going thru this process (most likely related to the path grid), so you may want to save their X, Y and Z positions when disabling and set them back after enabling.

 

 

 

 

 

Thank you for your help! Unfortunately, I still don't get it to work. Anyway, I'm currently trying to make a rescaling spell, and that should actually be very simple, but the problem that I mentioned in my first post still remains. I don't have any experience with scripting so maybe I'm just doing something fundamentally wrong. Here's what it looks like.

 

scriptname xyz

float t

Begin ScriptEffectStart
  let t := 2
  disable
  SetScaleEx 0.3
end

Begin ScriptEffectUpdate
  if (t==0)
    enable
  else
    let t -= 1
  endif
end
That should first disable and rescale the spell target and then enable it one frame later. At least that's where I was going with it. Unfortunately, it makes the taget vanish (even though it is enabled). I was also trying to store the position and set if after enabling but that didn't change anything noticeable either. Any advice is much appreciated.

 

Actually, the easiest way would be to remove the restrictions on SetScale and use that command, but I suppose those boundaries are hardcoded somewhere and not easily changed?

Link to comment
Share on other sites

Comparing a float variable with zero is not a good practice, as floats may store 0.0000001 and that is not zero.

 

I don't think this is the problem here, but change your float to short, just in case.

 

If the actor disappears, there are two possible reasons: either it is not getting enabled or it has been moved somewhere else.

 

To eliminate one of the possibilities, add this line after the 'enable'

 

printc "Enabled"

 

This line showing up in the console will tell you that the enable statement has been used and the problem is the second option.

Link to comment
Share on other sites

Thanks for the hint. I've changed the variable to short and included the print command. It prints "enabled" to the console, so the enable is definitely executed. I'm very puzzled. Basically I'm just letting the spell do something that works fine if I do it in console but still it doesn't work.

Link to comment
Share on other sites

If it is being enabled, then, most likely, the engine is moving it somewhere else.

 

Do the area have pathgrid? (Use TPG on the console to show the pathgrid).

Is it an interior or exterior area?

 

On my tests, every time I enable the NPC, she spawns on a different spot, half the times in a pathgrid node, half the times in a pathgrid connection line. And never anywhere else.

Link to comment
Share on other sites

Just a quick idea I suddenly had whle reading this:

 

I know very little about scripting, but, is there a way to have the spell use the prid function to pick the new, downscaled instance of the target's RefId ant then apply it to the command moveto player?

 

If that would be factible, then no matter where the new scaled instance of the target NPC spawns, it would be teleported to the player (although probably not in the very same spot where the original instance was).

 

Cheers!

Link to comment
Share on other sites

Thanks again for the replies!

You were absolutely right in that the actor was just moved somewhere else and I could just move it back to the player. Unfortunately, it turned out that the size was still not updated, despite having the actor disabled for a frame. Oh well :-(

Link to comment
Share on other sites

  • Recently Browsing   0 members

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