Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Neverwinter Nights: Enhanced Edition has been released! Visit nwn.beamdog.com to make an order. NWN:EE FAQ is available.
Soundtracks for BG:EE, SoD, BG2:EE, IWD:EE, PST:EE are now available in the Beamdog store.
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Looking for a script to scale placeable size.

TKBoldTKBold Member Posts: 13
I have a script that allows me to scale up NPCs with an OnSpawn script line, and adding a Scale Variable with a float integer, and let me tell you if that isn't one of the greatest things ever.

Though, now I've got to account for larger objects as well. Nothin' too big or fancy, just a simple, full XYZ object Scale. If anyone knows how to find one, or if they have one on hand, I'd be especially much obliged.

Comments

  • DazDaz Member Posts: 34
    You can put this in the OnHeartBeat script of a placeable. It'll grab a local float variable called 'Scale', set it, and remove the heartbeat script from itself.
    void main()
    {
        float fScale = GetLocalFloat(OBJECT_SELF, "Scale");
    
        if( fScale > 0.0f )
            SetObjectVisualTransform(OBJECT_SELF, OBJECT_VISUAL_TRANSFORM_SCALE, fScale);
    
        SetEventScript(OBJECT_SELF, EVENT_SCRIPT_PLACEABLE_ON_HEARTBEAT, "");
    }
    

    TKBold
  • TKBoldTKBold Member Posts: 13
    Woohoo!
    It does work, but it doesn't seem to work for Static objects. Any way to get around that?

  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 984
    Uncheck the static box for said placeable.

  • OlpeOlpe Member Posts: 1
    TKBold wrote: »
    I have a script that allows me to scale up NPCs with an OnSpawn script line, and adding a Scale Variable with a float integer, and let me tell you if that isn't one of the greatest things ever.

    Can you post the script for scaling NPC's? Does it work with part-based creatures with armors, shields and helmets?

    TKBold
  • TKBoldTKBold Member Posts: 13
    edited April 3
    Olpe wrote: »
    TKBold wrote: »
    I have a script that allows me to scale up NPCs with an OnSpawn script line, and adding a Scale Variable with a float integer, and let me tell you if that isn't one of the greatest things ever.

    Can you post the script for scaling NPC's? Does it work with part-based creatures with armors, shields and helmets?

    Sure! I kind of got mine piggybacked on one of the default spawn scripts but the way it works is basically the same as the object one. Variables, Scale, float integer. Pretty sure it was like that when I got it. And it will scale up or down, literally any creature you have the OnSpawn and the Variable attached to. 1 is default, 2 is double-sized, 0.5 is half-sized, etc.
    //::///////////////////////////////////////////////
    //:: Name x2_def_spawn
    //:: Copyright (c) 2001 Bioware Corp.
    //:://////////////////////////////////////////////
    /*
        Default On Spawn script
    
    
        2003-07-28: Georg Zoeller:
    
        If you set a ninteger on the creature named
        "X2_USERDEFINED_ONSPAWN_EVENTS"
        The creature will fire a pre and a post-spawn
        event on itself, depending on the value of that
        variable
        1 - Fire Userdefined Event 1510 (pre spawn)
        2 - Fire Userdefined Event 1511 (post spawn)
        3 - Fire both events
    
        2007-12-31: Deva Winblood
        Modified to look for X3_HORSE_OWNER_TAG and if
        it is defined look for an NPC with that tag
        nearby or in the module (checks near first).
        It will make that NPC this horse's master.
    
    */
    //:://////////////////////////////////////////////
    //:: Created By: Keith Warner, Georg Zoeller
    //:: Created On: June 11/03
    //:://////////////////////////////////////////////
    
    const int EVENT_USER_DEFINED_PRESPAWN = 1510;
    const int EVENT_USER_DEFINED_POSTSPAWN = 1511;
    
    
    #include "x2_inc_switches"
    void main()
    {
        string sTag;
        object oNPC;
        // User defined OnSpawn event requested?
        int nSpecEvent = GetLocalInt(OBJECT_SELF,"X2_USERDEFINED_ONSPAWN_EVENTS");
    
    
        // Pre Spawn Event requested
        if (nSpecEvent == 1  || nSpecEvent == 3  )
        {
        SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_PRESPAWN ));
        }
    
        sTag=GetLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");
        if (GetStringLength(sTag)>0)
        { // look for master
            oNPC=GetNearestObjectByTag(sTag);
            if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)
            { // master found
                AddHenchman(oNPC);
            } // master found
            else
            { // look in module
                oNPC=GetObjectByTag(sTag);
                if (GetIsObjectValid(oNPC)&&GetObjectType(oNPC)==OBJECT_TYPE_CREATURE)
                { // master found
                    AddHenchman(oNPC);
                } // master found
                else
                { // master does not exist - remove X3_HORSE_OWNER_TAG
                    DeleteLocalString(OBJECT_SELF,"X3_HORSE_OWNER_TAG");
                } // master does not exist - remove X3_HORSE_OWNER_TAG
            } // look in module
        } // look for master
    
        /*  Fix for the new golems to reduce their number of attacks */
    
        int nNumber = GetLocalInt(OBJECT_SELF,CREATURE_VAR_NUMBER_OF_ATTACKS);
        if (nNumber >0 )
        {
            SetBaseAttackBonus(nNumber);
        }
    
        // Execute default OnSpawn script.
        ExecuteScript("nw_c2_default9", OBJECT_SELF);
    
    
        //Post Spawn event requeste
        if (nSpecEvent == 2 || nSpecEvent == 3)
        {
        SignalEvent(OBJECT_SELF,EventUserDefined(EVENT_USER_DEFINED_POSTSPAWN));
        }
    
    float fScale =GetLocalFloat(OBJECT_SELF,"Scale");
    if(fScale != 0.0)SetObjectVisualTransform(OBJECT_SELF,OBJECT_VISUAL_TRANSFORM_SCALE,fScale);
    }
    
    Uncheck the static box for said placeable.

    Well yuh, that's the obvious solution, but I was wondering if there was a way to have it go into effect as a static object? If the Static box thing is turned off, if you move far enough away from the object, it will disappear. It's probably one of the only really annoying things with NWN and modern systems. Alternate solution would be to find a way to increase the 'view' range, or disable it altogether.

    Olpe
  • ProlericProleric Member Posts: 437
    What you say about dynamic placeables disappearing is true - hope Beamdog can fix that one day.

    The term "static" means that the appearance is baked before the game starts, just like the tiles. So, scaling during the game is dynamic, not static, by definition. The only way I can see static scaling working is if Beamdog could allow scaling in the toolset to be hard baked - anything done by script can only apply to dynamic objects.

    TKBold
  • TKBoldTKBold Member Posts: 13
    edited April 17
    Proleric wrote: »
    What you say about dynamic placeables disappearing is true - hope Beamdog can fix that one day.

    The term "static" means that the appearance is baked before the game starts, just like the tiles. So, scaling during the game is dynamic, not static, by definition. The only way I can see static scaling working is if Beamdog could allow scaling in the toolset to be hard baked - anything done by script can only apply to dynamic objects.

    Boooooo. If there's some way to increase the visibility range on things, I'd be okay with that.

  • TerrorbleTerrorble Member Posts: 65
    edited April 17
    I think this is exactly what they are doing in the latest version of the toolset. (look at the first 2 posts on page 1)

    https://forums.beamdog.com/discussion/75035/nwn-toolset-enhanced-edition-try-the-new-updates-and-share-your-feedback#latest

Sign In or Register to comment.