Skip to content

Looking for a script to scale placeable size.

TKBoldTKBold Member Posts: 15
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: 125
    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, "");
    }
    
    TKBoldOldTimeRadio
  • TKBoldTKBold Member Posts: 15
    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: 1,085
    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: 15
    edited April 2019
    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: 1,269
    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: 15
    edited April 2019
    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: 169
    edited April 2019
    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
  • Gerad_VizagaGerad_Vizaga Member Posts: 14
    Hopefully no one minds me piggy-backing off this thread, but...

    I'm having trouble scaling items when they are equipped. The tag-based scripting is running as it should, as I am able to debug the equipping PC and the item they equipped.

    The only line that doesn't seem to be firing is the scaling code itself, and it doesn't make any sense to me. I've been able to scale creatures and placeables through scripting just fine. I've also seen screenshots of scaled weapons, so I'm pretty sure it can be done.
    void main()
    {
        object oPC = GetPCItemLastEquippedBy();
        object oItem = GetPCItemLastEquipped();
        SendMessageToPC(oPC, "Equipping " + GetName(oItem));
        SetObjectVisualTransform(oItem, OBJECT_VISUAL_TRANSFORM_SCALE, 2.0);
    }
    

    Thanks for your help!
  • DazDaz Member Posts: 125
    Hopefully no one minds me piggy-backing off this thread, but...

    I'm having trouble scaling items when they are equipped. The tag-based scripting is running as it should, as I am able to debug the equipping PC and the item they equipped.

    The only line that doesn't seem to be firing is the scaling code itself, and it doesn't make any sense to me. I've been able to scale creatures and placeables through scripting just fine. I've also seen screenshots of scaled weapons, so I'm pretty sure it can be done.
    void main()
    {
        object oPC = GetPCItemLastEquippedBy();
        object oItem = GetPCItemLastEquipped();
        SendMessageToPC(oPC, "Equipping " + GetName(oItem));
        SetObjectVisualTransform(oItem, OBJECT_VISUAL_TRANSFORM_SCALE, 2.0);
    }
    

    Thanks for your help!

    I think SetObjectVisualTransform() checks if the item is actually equipped by a character but when the OnEquip event runs the item isn't actually equipped yet.

    To work around it, you can do something like:
    void ScaleItem(object oItem, float fScale)
    {
        SetObjectVisualTransform(oItem, OBJECT_VISUAL_TRANSFORM_SCALE, fScale);
    }
    
    void main()
    {
        object oPlayer = GetPCItemLastEquippedBy();
        object oItem = GetPCItemLastEquipped();
    
        DelayCommand(0.1f, ScaleItem(oItem, 2.0f));
    }
    
  • Gerad_VizagaGerad_Vizaga Member Posts: 14
    That did the trick!! Thanks, Daz!!
  • GruffbaneJoeGruffbaneJoe Member Posts: 39
    edited October 2019
    On the script above for creatures, which line sets the scale? And/or what is the name of the variable? Thanks in advance.
  • ArviragoArvirago Member Posts: 9
    Last line, variable: "Scale"
Sign In or Register to comment.