Using SetObjectVisualTransform with encounters

I need some help with my script, I am not a scripter so I use the LS Script Generator lots and combine it with stuff I know how to do.

I have been trying to use this function “SetObjectVisualTransform”. This new function has literally transformed my perception of NwN1 and inspired me back to the toolset. It truely opens up new dimensions and literally the sky is the limit:

:slight_smile: Thanks Beamdog!

I want to use this to change the size and/or z-axis of spawns on some encounter OnEnter event. I am using it on the turtle model, which is too large for my purpose (porpoise - haha!) and becomes too low when 50% of size. But unfortunately this script only transforms the first spawn to the new parameters, and I am struggling with how to get it to transform all the spawns. I think I need a WHILE LOOP because the encounter itself and will have a different number of spawns depending on the level of the player triggering the encounter.

This is for my current module which is just a step short of BETA release:

Chapter 1 of “No Man’s Land”

  • an E.E.-module using only CEP 3.03
  • with a lot of underwater content
  • (no swimming animations as these are not in CEP, but lots of other creative solutions)

So this is what I have until now:

/* Script "t_ent_turtle001" by GonzoGygax April 2023
   Put this script OnEnter of the Encounter */
// unfortunately this only fires on the first spawn of the encounter

void main()
{
    // check if entering object is a PC
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;

    // if a PC, continue script and select spawn-in TAG as object of script
    object oTarget;
    oTarget = GetObjectByTag("GZ_TURTL001");

    /* now do the transformation:
    - make them 50% of size
    - hover 0.8m off ground = 80cm
    - rename as doublecheck */
    SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_SCALE, 0.5);
    SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, 0.8);
    SetName(oTarget, "Small turtle");
}

To be honest, I am not even sure if this is the right way to go about this at all, maybe I would be better off creating an entirely new script for a custom encounter, but I am trying to avoid that because I am not a scripter and to keep the scripts to a minimum, besides I would really like to be able to use this kind of script on a few other encounters as well. Can anybody offer some assistance with this?

It’s probably simpler to put the transform in the OnSpawn script for the creature. Add your custom code after the comment as follows:

 // ***** ADD ANY SPECIAL ON-SPAWN CODE HERE ***** //
object oTarget = OBJECT_SELF;
   SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_SCALE, 0.5);
    SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, 0.8);
    SetName(oTarget, "Small turtle");

You can save your script with a different name, so that it only affects those creatures.

(There are some advanced scripting options, such as using local variables and/or the user-defined script, but that’s probably over-complicated just now).

P.S. The Flying / Swimming animation is in the latest CEP 2.x, where it is described as Flying. I can’t speak for CEP 3, but my guess is that it might be in the phenos hak, or, if not, easily copied from CEP 2.x. Or perhaps you meant a more sophisticated swimming animation?

I second Proleric’s suggestion.

Also keep in mind that visual transforms doesn’t alter the actual model position or height. Which means, that this “small turtle” will still fill up and block whole corridor.

Thank you so much, I will do exactly that, because I want this to apply to all my turtles…as for the squid, I hope to make them hover off the seabed a little, so I can also use an OnSpawn script for that. Indeed the variables is a bit too high level for my skills, so thank you for thinking with me on this creative solution.
Thank you as well for your input on the swimming animations; for now I do not want to overcomplicate things with another hak from older CEP, it’s probably too complex for me, but I will defo keep that in mind for a later date. I saw some really good swimming animations on the Vault, as well as combat animations, but it’s also probably too high level for my purposes, although it would definitely be nice to have, no doubt!

Yes, thank you Shadooow, I am aware that the “actual” size of the creature is not altered by this method, but for my turtle, which will be more of a decorative feature, this is not important. But thank you for pointing it out.

Just for the record, regarding CEP, “Despite the names, one fork isn’t necessarily newer or better than the other”

Yes, I didn’t mean to imply anything - it’s just that one is forwards- and the other backwards compatible isn’t it…
Anyway it works a TREAT, I used the following script, now that it’s all clear where to put it:

/* Script by Gonzo Gygax April 2023
   Put this script OnSpawn of the turtle creature */

void main()
{
    // Execute default OnSpawn script.
    ExecuteScript("nw_c2_default9", OBJECT_SELF);

    /* now do the transformation:
    - make them 50% of size
    - hover 0.8m off ground = 80cm
    object oTarget = OBJECT_SELF;
     SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_SCALE, 0.5);
     SetObjectVisualTransform(oTarget, OBJECT_VISUAL_TRANSFORM_TRANSLATE_Z, 0.8);
}

This really saves me hours of hard work at investigating, searching and testing so thank you again for your help. You’re amazing!

Sorry, that simply isn’t the case. CEP 2.x is fully forward-compatible with EE, with new content for EE, and will remain so. It’s also fully backward-compatible with NWN 1.69 and modules using earlier versions of CEP (given that CEP 1 now is bundled with it).

CEP 2.x and CEP 3 have both added new content since 2.65 - it’s just not the same content.

Well I love them both! It’s just really hard to decide which has the better content for my porpoises, lols

CEP 3 also has a swimming phenotype but unfortunately it’s broken in CEP 3.03 (will be fixed in the next version). However you can use the phenotype from v3.02 which is not broken.

Here’s a module using CEP 3.03 with also lots of swimming / underwater combat:
https://neverwintervault.org/project/nwnee/module/texts-thaan-chapter-1

OMG that’s just too cool - i didn’t realize its already in CEP 3.03 - if I can somehow implement this in my module!!! Probably when I upgrade to CEP 3.04 (after the upcoming EE patch) I should be able to put some work into that. Thank you for pointing this out Karimyn.