View previous topic :: View next topic |
Author |
Message |
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Sat Nov 08, 2008 23:41 Post subject: JumpToLimbo |
|
|
can someone show me an example of using this function? Im look on how to put them in and take them out of limbo
Code: | // Jump to Limbo.
// Object can be returned from Limbo with JumpToLocation/JumpToObject
int JumpToLimbo(object oObject); |
|
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Nov 09, 2008 1:30 Post subject: Re: JumpToLimbo |
|
|
Extreme wrote: | Im look on how to put them in and take them out of limbo | It's described in the comment to the function you just quoted. |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Sun Nov 09, 2008 5:19 Post subject: |
|
|
unfortunately i dont understand how i can target the creature in limbo. JumpToObject wants a object to function. This is an int. I dont understand how to target the object in limbo.
JumpToObject(JumpToLimbo(oObject)) cant work due to mismatched types. I dont understand how to taget the object when its here as an int |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Sun Nov 09, 2008 6:08 Post subject: |
|
|
You need to keep a reference to oObject around somewhere else (for instance, in a local).
Code: |
SetLocalObject(oSelf, "Limboed", oObj);
JumpToLimbo(oObj);
... later ...
object oObj = GetLocalObject(oSelf, "Limboed");
AssignCommand(oObj, JumpToLocation(lTarget));
|
Acaos |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Sun Nov 09, 2008 10:19 Post subject: |
|
|
ok i see. i have not used setlocalobject much, but now that you meantion it, i think i can use it in another script
im hoping this will help me keep my pallette count downa nd not lag out an area |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Mon Nov 10, 2008 3:29 Post subject: |
|
|
would this work to store creatures in a area that have several waypoints and creatures set in them. this being ran from the OnModLoad
Code: | #include "nwnx_functions"
void StoreCreatures(object oArea)
{
object oObj = GetFirstObjectInArea(oArea);//creature holding room
int n;
while(GetIsObjectValid(oObj) && GetObjectType(oObj) == OBJECT_TYPE_WAYPOINT){
n = 1;
object oSpawn = GetNearestCreatureToLocation(CREATURE_TYPE_IS_ALIVE, TRUE, GetLocation(oObj), n);
if(GetDistanceBetween(oSpawn, oObj) < 4.5){
SetLocalObject(oArea, GetTag(oObj) + "_" + IntToString(n), oSpawn);
JumpToLimbo(oSpawn);
n++;
}else{
continue;
}
oObj = GetNextObjectInArea(oArea);
}
} |
and this beign used in a CreateObject statement
Code: | object SpawnInCreature(object oArea)
{
object oSpawnRoom = GetObjectByTag("CREATURE_STORAGE_ROOM");
int nCount = GetLocalInt(GetWaypointByTag("TAG_OF_AREA_CALLING"), "CreatureCount");
return GetLocalObject(oSpawnRoom, GetTag(oArea) + "_" + IntToString(TrueRandom(nCount)));
} |
|
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Mon Nov 10, 2008 3:52 Post subject: |
|
|
Does the JumpT option to return them from limbo delete the local object? Can it be reused or will it need to be reset? |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Mon Nov 10, 2008 4:39 Post subject: |
|
|
You control locals; they will only be set or deleted when you do so.
Acaos |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Wed Nov 12, 2008 10:47 Post subject: |
|
|
I am not sure if this is an issue with the function or with the scripting. if its in the scripting, i will take my question to BW if wanted
The script below is working as i am getting all the messages as i should be. I set up a ObjectToString() message to myself to make sure that the script is finding a LocalObject to use for a creature and it is finding them and the hex numbers are changing thru the different levels i went thru. So i am sure that it is finding the various localobjects for use.
But the problem is that thru all the areas, only one creature is actually showing up. Is this an issue with the JumpToLocation? I am going to try it now with JumpToObject and use the waypoint as the object
Code: | #include "inc_common_funcs"
#include "nwnx_functions"
////////////////////////////////////////////////////////////////////////////////
location GetRandomSpawnPoint(object oArea, object oCreature)
{
object oWayPoint = GetFirstObjectInArea(oArea);
int nWayPointTally = 0;
while(GetIsObjectValid(oWayPoint)){
nWayPointTally += 1;
oWayPoint = GetNextObjectInArea(oArea);}
object oSpawnPoint = GetNearestObjectByTag("SpawnPoint", oCreature, TrueRandom(nWayPointTally));
return GetLocation(oSpawnPoint);
}
////////////////////////////////////////////////////////////////////////////////
object SpawnInCreature(object oArea)
{
string sAreaTag = GetTag(oArea);
int nCount = GetLocalInt(GetWaypointByTag(sAreaTag), "CreatureCount");
object oSpawnRoom = GetObjectByTag("EncounterStorage");
SendMessageToPC(GetFirstPC(), "We are in SpawnInCreature()");
return GetLocalObject(oSpawnRoom, GetTag(oArea) + "_" + IntToString(TrueRandom(nCount)));
}
////////////////////////////////////////////////////////////////////////////////
int TotalMandatorySpawns(object oCreature)
{
int X = 2;
if(GetHitDice(oCreature) > 30) {return X += 4;}
if(GetHitDice(oCreature) > 20) {return X += 3;}
if(GetHitDice(oCreature) > 10) {return X += 2;}
return X;
}
////////////////////////////////////////////////////////////////////////////////
void PlaceMandatoryCreatures(object oCreature, object oArea)
{
SendMessageToPC(GetFirstPC(), "inside the mandatory placing");
int nCount = GetLocalInt(oArea, "MandCount");
int nTest = TotalMandatorySpawns(oCreature);
int i;int n;
for(i = 0; i < nCount; i++){
SendMessageToPC(GetFirstPC(), "inside the first for|we are on " +IntToString(i));
object oMandPoint = GetNearestObjectByTag("MandatorySpawnPoint", GetFirstObjectInArea(oArea), i);
location lMandSpawn = GetLocation(oMandPoint);
for(n = 0; n < nTest; n++){
SendMessageToPC(GetFirstPC(), "inside the 2nd for| we are on " +IntToString(n));
object oMonster = SpawnInCreature(oArea);
AssignCommand(oMonster, JumpToLocation(lMandSpawn));
}
}
}
////////////////////////////////////////////////////////////////////////////////
void CreateCreatures(object oCreature, object oArea, int nSpawnCount)
{
location lSpawnPoint;
SendMessageToPC(GetFirstPC(), "firing the create creatures");
while( --nSpawnCount >= 0){
SendMessageToPC(GetFirstPC(), "about to create a creature");
lSpawnPoint = GetRandomSpawnPoint(oArea, oCreature);//FIX ME
object oMonster = SpawnInCreature(oArea);
AssignCommand(oMonster, JumpToLocation(lSpawnPoint));
SendMessageToPC(GetFirstPC(), "creating a creature");
}
} |
|
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Wed Nov 12, 2008 10:58 Post subject: |
|
|
same thing with the JumpToObject |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Thu Nov 13, 2008 12:21 Post subject: |
|
|
i have done several tests, but this still has yet to spawn more then one in an area. Will the JumpToObject with the function work in loops as it is scripted? |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Thu Nov 13, 2008 17:12 Post subject: |
|
|
You need to use CopyObject() to copy the one stored in limbo. You're only getting one creature because you're moving your original with JumpToLocation.
Acaos |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Fri Nov 14, 2008 1:22 Post subject: |
|
|
i was laying in bed last night, half in and half out of sleep and i had that epiphany. I just got up and will be testing that very soon |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Fri Nov 14, 2008 4:22 Post subject: |
|
|
now that did get it working fine, but i have noticed a small glitch. in the tower i have been testing this in, there are a choice of 2 creatures per level with 3 at the top. on all of the levels that have 2 choices, it only ever pulls in 1. It doesnt switch between the 2. and on the top level, where there are 3, it only chooses 2. I think it is not settingthe count on them right |
|
Back to top |
|
|
Extreme
Joined: 28 Nov 2007 Posts: 135
|
Posted: Mon Nov 17, 2008 17:43 Post subject: |
|
|
Is JumpToLimbo() supposed to remove the creature from the area? In my loop, it is still reading them as valid in the area
this is inside a loop
Code: | if( !GetIsPC( oMaster)){
WriteTimestampedLogEntry( "Storing - "+GetName( oSpawn)+" in "+GetName(oArea));
SetLocalObject( oArea, GetTag( oObj) +"_" +IntToString( n), oSpawn);
JumpToLimbo( oSpawn);
if(GetIsObjectValid(oSpawn)){
WriteTimestampedLogEntry("oSpawn is valid after JumpToLimbo() and is being destroyed");
DestroyObject(oSpawn);
}
++n;
} |
|
|
Back to top |
|
|
|