Author Topic: Always changing  (Read 503 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Always changing
« Reply #15 on: January 01, 2013, 12:45:13 am »


               <resolves...>

While not needed for this (though that was my original thought), that could come in pretty handy for my Reg Mods... Especially making trees diseased or covered in webs...

Thanks, FS :-)

<...to get rolling with nwnx in 2013>
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Always changing
« Reply #16 on: January 01, 2013, 01:56:20 am »


               Funky, what does the change of appearance do? Is it just the look of the thing or will it also use all aspects of the model and apply it?

I have been playing with placeables that use models with the tile classification and an aabb mesh, and noticed that they will override or at least influence the Z values of the underlying tile''s aabb mesh if set to static. Typical placeables also have PWKs of course. So I was wondering if all that would come into play with the NWNX function you posted.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Always changing
« Reply #17 on: January 01, 2013, 03:57:57 am »


               OK, Try

FloatToInt(-375.0 + sqrt(2262000 + 8.0*nGPValue) / 4);

Ill test it in a bit myself also.
               
               

               


                     Modifié par Lightfoot8, 01 janvier 2013 - 06:07 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Always changing
« Reply #18 on: January 01, 2013, 05:25:57 am »


               

henesua wrote...

Funky, what does the change of appearance do? Is it just the look of the thing or will it also use all aspects of the model and apply it?

I have been playing with placeables that use models with the tile classification and an aabb mesh, and noticed that they will override or at least influence the Z values of the underlying tile''s aabb mesh if set to static. Typical placeables also have PWKs of course. So I was wondering if all that would come into play with the NWNX function you posted.


I have all this secondhand from acaos, but it's accurate so far as I know. When set to static, NWN 'bakes' places into an area's tiles in a fashion similar to the eponymous NWN2 function, though not identical. This helps optimize the areas for all sorts of purposes, most especially pathing. When you spawn in places, you lose that optimization, whether or not the new places are set to 'static' - but it's not the end of the world. When you spawn them in popular thoroughfares with pwks, it's not great, but we still do it with our wall spells, and while it does sometimes create some lag, it's not so bad that we feel the need to do something about it - and we're fairly picky in that regard.

Incidentally, if memory serves, spawned in places set to static are unlike toolset-placed static places in other regards as well - I seem to remember them being reachable with nwscript.

When you use the nwnx placeable appearance setting, you get the whole kit-and-kaboodle - it swaps to the new appy and accompanying pwk. It's little different from spawning in a new place and wiping the old one - save that you don't need a place with that appy to spawn in. If you're building areas with a ton of vfx applied on or around places, it's incredibly valuable for seeing how things will look on the fly - a single useable placeable can stand in for any appearance you need, instantly allowing you to tell which vfx (by way of dm_vfx) will show on it, and how they look. Past that, I'm not sure what you could do with it.

Dynamically changing placeable appearances has long been a point of difficulty for NWN - I remember someone trying to figure out a horse-and-carriage setup. Without making creatures with placeable appearances, it's hard to get anything that looks credible.

Funky
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Always changing
« Reply #19 on: January 01, 2013, 08:11:59 am »


               ok,  With the modified formula :  FloatToInt(-375.0 + sqrt(2262000 + 8.0*nGPValue) / 4);

the progression is now: 

bit0 = 2
bit1 = 1508
bit2 = 4532
bit3 = 10628
bit4 = 23012
bit5 = 48548
bit6 = 102692
bit7 = 223268
bit8 = 513572
bit9 = 1290788

And Keep in mind that the bits are 0 based, Your first placable ResRef should be: ResRefPrefix + "0" not ResRefPrefix + "1";

Corrections made to the script:
-Added a Filter to stop Total Chest Values of 3631652gp or more from filtering into the 10th bit and removing lower set bits.

-Added Code to catch the value of gold added to the chest.

-Added code to Value unidentified items at there full cost, not there unidentified value.

-Added an underline in the Created Placable Tags to advoid possiable Hash collision.

Here is the adjusted code. My testing showed it all working.
EDIT: Location of placables is still right on top of the old one in my code.


/////////////////////////////////////////////////

const string ResRefPrefix = "???" ;

int GetPlacableFlags( object oChest = OBJECT_SELF)
{
    int nGPValue,bID;
    object oItem = GetFirstItemInInventory( oChest );
    while (GetIsObjectValid(oItem))
   {
        bID = GetIdentified(oItem);
        SetIdentified(oItem,TRUE);
        nGPValue += GetGoldPieceValue(oItem);
        if ( GetBaseItemType(oItem) == BASE_ITEM_GOLD)
            nGPValue += GetItemStackSize(oItem);
        SetIdentified(oItem,bID);
        oItem = GetNextItemInInventory (oChest);
    }
    int seReturn = FloatToInt(-375.0 + sqrt(2262000 + 8.0*nGPValue) / 4);
    if ( seReturn > 0x3ff) seReturn = 0x3ff;
    return seReturn;
    // FloatToInt(log(nGPValue*2.0)/log(2.0));
}

int GetCurrentdrawnPLCSet( object oChest = OBJECT_SELF)
{
    return GetLocalInt( oChest,"PLC_Drawn_set");
}

void StoreCurrentdrawnPLCSet( int nDrawnSet, object oChest = OBJECT_SELF )
{
    SetLocalInt( oChest,"PLC_Drawn_set",nDrawnSet);
}

void DestroyPLCsInSet(int nSet, object oChest =OBJECT_SELF)
{
    string sTagPreFix = ObjectToString(oChest);
     while(nSet)
    {
        int nFlag = nSet & -nSet;
        nSet ^= nFlag;
        DestroyObject( GetObjectByTag(sTagPreFix + "_" + IntToString(nFlag)));
        //SpeakString( "Destroying Placable with tag :" + sTagPreFix+ "_" + IntToString(nFlag));
    }
}


void DrawPLCsInSet(int nSet, object oChest =OBJECT_SELF )
{

    string sTagPreFix = ObjectToString(oChest);
    string sResRef, sTag;
    while(nSet)     
    {
        int nFlag = nSet & -nSet;
        nSet ^= nFlag;
        sTag = sTagPreFix + "_" + IntToString(nFlag);
        nFlag = FloatToInt( log(nFlag*1.0)/log(2.0));
        sResRef = ResRefPrefix +IntToString(nFlag);
        location lLoc = GetLocation(oChest);

        CreateObject( OBJECT_TYPE_PLACEABLE, sResRef, lLoc, FALSE, sTag );
        //SpeakString("Creating placable :" + sResRef + " Tag :" +sTag);
    }
}

void UpdateTresurePlacables(object oTresureContainer = OBJECT_SELF)
{
    int nOldSet = GetCurrentdrawnPLCSet(oTresureContainer);
    int nNewSet = GetPlacableFlags(oTresureContainer);
    int nChange = nOldSet ^ nNewSet;

    if ( nChange )
    {
        StoreCurrentdrawnPLCSet( nNewSet, oTresureContainer);
        DestroyPLCsInSet(nChange & nOldSet ,oTresureContainer );
        DrawPLCsInSet (nChange & nNewSet ,oTresureContainer );
    }
}

void main()
{
    UpdateTresurePlacables();
}
               
               

               


                     Modifié par Lightfoot8, 01 janvier 2013 - 08:19 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Always changing
« Reply #20 on: January 01, 2013, 05:12:44 pm »


               <putting in another...>

Ah, yes. 10 bits, not 9. Starting at 0. *sigh*
Okay, moved 1,2 &3 down one and will make a new Number 3.

Works :-) Thank you LF!

<...work order for the dwarf>