Persistent placables non NWNX
vonstorm
Member Posts: 66
There used to be a system on the vault that let you place furniture and have it persistent without nwnx. That file is now 0kb sadly. Ive tried to use setcampaignlocation etc, but I guess it's more complicated than that. Does anyone have a pointer to where a system is that will remember placable locations persistently? My placement code is currently
The Area Enter for the building zone is ugly but using it to see if it works:
void main()
{
object oSpawn;
object oPC = GetItemActivator();
object oActTarget = GetItemActivatedTarget();
location lActTarget = GetItemActivatedTargetLocation();
object oArea = GetArea(oPC);
int ibuildable = GetLocalInt(oArea,"buildable");
// This item must target a location (not an object).
if ( GetIsObjectValid(oActTarget) )
{
SendMessageToPC(oPC, "Improper use of this item!");
return;
}
if ( ibuildable =1)
{
// Spawn "crane".
int itotbuilds = GetCampaignInt("Housing","Buildings",oArea);
int icurrentbuild = itotbuilds +1;
SetCampaignInt("Housing","Buildings",icurrentbuild,oArea);
string icurr = IntToString(icurrentbuild);
SetCampaignString("Housing","Type"+icurr,"scaffold",oArea);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "scaffold", lActTarget);
SetCampaignLocation("Housing",icurr,lActTarget,oArea);
string pcname = GetName(oPC);
SetCampaignString("Housing","owner"+icurr,pcname,oArea);
DestroyObject(GetItemPossessedBy(oPC, "sethouse"));
SetName(oSpawn,pcname = " Construction Site");
return;
}
SendMessageToPC(oPC,"This Area is not buildable");
// Give "deed" to the PC.
}
The Area Enter for the building zone is ugly but using it to see if it works:
void spawnhouse(int icurr,object oArea,object oSpawn)
{
//run 1st placement
icurr = icurr + 1;
string snum = IntToString(icurr);
string type = GetCampaignString("Housing","Type"+snum,oArea);
location lLocation = GetCampaignLocation("Housing",snum,oArea);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE,type,lLocation);
string pcname = GetCampaignString("Housing","owner"+snum,oArea);
SetTag(oSpawn,pcname+"House");
SetLocalString(oSpawn,"owner",pcname);
int stoneamt = GetCampaignInt("construction","stone",oSpawn);
SetLocalInt(oSpawn,"stone",stoneamt);
int woodamt = GetCampaignInt("construction","wood",oSpawn);
SetLocalInt(oSpawn,"wood",stoneamt);
}
void main()
{
// Get the creature who triggered this event.
object oPC = GetEnteringObject();
object oSpawn;
object oArea = OBJECT_SELF;
int bnum = GetCampaignInt("Housing","Buildings",oArea);
int icurr = 0;
// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;
if (bnum < 1)
return;
spawnhouse(icurr,oArea,oSpawn);
if (bnum < 2)
return;
spawnhouse(icurr,oArea,oSpawn);
if (bnum < 3)
return;
}
0
Comments
So I made this for setting:
// Store the direction the object is facing. SetCampaignFloat("db_name", ("F" + sName), GetFacingFromLocation(lLocation)); // Get the 3D position of the object. vector vPosition = GetPositionFromLocation(lObject); // Store them individually. SetCampaignFloat("db_name", ("X" + sName), vPosition.x); SetCampaignFloat("db_name", ("Y" + sName), vPosition.y); SetCampaignFloat("db_name", ("Z" + sName), vPosition.z);And this for getting:
float fOrientation = GetCampaignFloat("db_name", ("F" + sName)); float fX = GetCampaignFloat("db_name", ("X" + sName)); float fY = GetCampaignFloat("db_name", ("Y" + sName)); float fZ = GetCampaignFloat("db_name", ("Z" + sName)); vector vPosition = Vector(fX, fY, fZ); location lPlace = Location(oArea, vPosition, fOrientation);I only used those once each, so they're not wrapped in functions, but you can do that easily.