I'm trying to get a random static door, but exclude any door with the local int "nNoCAIUse" ==1 because I need to make sure some doors are unselectable (second floor, unable to reach the door because of cliffs, etc)
The following works, but when I switch to the commented out section which I expected to ensure I was getting a door that wasn't excluded I get what seems to be a near infinite loop, it hangs up for a bit and any debug text in it I see hundreds of times.
Not sure what I'm doing wrong here?
object GetRandomStaticDoor(float fMaxDistance)
//based on kevL's random object code.
{
int iObject; object oObject;
int i = 1;
object oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
// GetNearest seems to work only in the area of OBJECT_SELF, good.
while (
(GetIsObjectValid(oNear)) && (GetDistanceToObject(oObject) <= fMaxDistance) && (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN)))
//&& (nNoCAIUse != 1)
)
{
i ++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}
// count is one too many ..
i -= 1;
// Random starts w/ 0 (subtract 1), so add 1
iObject = Random(i) + 1; // iObject -> that's a pun, haha :|
// max the count at the number of objects, i
if (iObject > i) iObject = i;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
//original code
if ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
return oObject;
}
/*
int nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
while ((GetIsObjectValid(oObject)==FALSE) || (GetDistanceToObject(oObject) > fMaxDistance) || (nNoCAIUse==1))
{
SendMessageToPC(GetFirstPC(), "Debug: cai use door or distance");
//iObject = Random(i) + 1;
//check next, if we go beyond the number, go back round to 0.
iObject += 1;
if (iObject > i) iObject = 0;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
}
if ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
return oObject;
}
*/
return OBJECT_INVALID;
}
select random door, with exceptions.
Débuté par
kamal_
, janv. 14 2013 12:28
#1
Posté 14 janvier 2013 - 12:28
#2
Posté 14 janvier 2013 - 02:35
Try this, kam_
interesting puzzle; it searches through doors w'in fMaxDistance, checks if they are static & usable by the CAI, and if so sets them as local objects on the NPC [ Object_Self ]. Then before it chooses one and returns the door, it deletes the local_object doors ....
( i really like debug
It compiles but untested. My main concern is that it needs to delete the local objects before actually returning the door,
/Edit, updated slightly w/ a DelayCommand() ( + a declaration change pfft )
interesting puzzle; it searches through doors w'in fMaxDistance, checks if they are static & usable by the CAI, and if so sets them as local objects on the NPC [ Object_Self ]. Then before it chooses one and returns the door, it deletes the local_object doors ....
( i really like debug
It compiles but untested. My main concern is that it needs to delete the local objects before actually returning the door,
object GetRandomStaticDoor(float fMaxDistance)
{
SendMessageToPC(GetFirstPC(), "Debug: cai finding door ...");
int bNoCAIUse, iCAI_door;
int i = 1;
object oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
while (GetIsObjectValid(oDoor)
&& GetDistanceToObject(oDoor) <= fMaxDistance)
{
SendMessageToPC(GetFirstPC(), "Debug: cai checking door #"
+ IntToString(i));
bNoCAIUse = GetLocalInt(oDoor, "nNoCAIUse");
if (!bNoCAIUse
&& !GetIsDoorActionPossible(oDoor, DOOR_ACTION_OPEN))
{
iCAI_door += 1;
SetLocalObject(OBJECT_SELF, "caiDoor"
+ IntToString(iCAI_door), oDoor);
SendMessageToPC(GetFirstPC(), "Debug: cai found static door #"
+ IntToString(iCAI_door));
}
oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, ++ i);
}
int iCAI_i = Random(iCAI_door) + 1;
oDoor = GetLocalObject(OBJECT_SELF, "caiDoor" + IntToString(iCAI_i));
for (i = 1; i <= iCAI_door; i ++)
{
SendMessageToPC(GetFirstPC(), "Debug: deleting local door #"
+ IntToString(i));
DelayCommand(0.1f, DeleteLocalObject(OBJECT_SELF, "caiDoor"
+ IntToString(i)));
}
if (GetIsObjectValid(oDoor))
{
SendMessageToPC(GetFirstPC(), "Debug: cai using door #"
+ IntToString(iCAI_i));
return oDoor;
}
else
{
SendMessageToPC(GetFirstPC(), "Debug: cai door not found");
return OBJECT_INVALID;
}
}/Edit, updated slightly w/ a DelayCommand() ( + a declaration change pfft )
Modifié par kevL, 14 janvier 2013 - 02:43 .
#3
Posté 14 janvier 2013 - 03:25
That big compound conditional in your while loop seems off to me. First, how does it check iNoCAIUse? It's written like that variable's already been declared in the script/function, when I'm guessing it needs to be read off the next door during each while loop. Secondly, it seems the thing would loop until it found a door with the iNoCAIUse set, and then stop, even if there were useable doors further away.
Here's my stab at it:
object GetRandomDoor(float fMaxDist) {
object oReturn;
int i = 1;
object oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
while (GetIsObjectValid(oNear) && (i<20) && (GetDistanceToObject(oNear) <= fMaxDistance)) {
//The (i<20) is just a fail safe, especially when you have a bunch of ambient NPCs in an area with a lot of doors. I notice you also have "oObject" in the GetDistance function, that seems to be a type.
if (GetLocalInt(oNear, "iNoCAIUse") == 0) ) {
//I'm just checking that one variable here, but I see you also check if a door action is possible, and you could just nest that here.
if (!GetIsObjectValid(oReturn)) {
oReturn = oDoor;
}
else if (d2() = 1) {
oReturn = oDoor;
}
else {
i = 20;
}
//This is a quick and dirty randomization. If there's no return door found yet, use this one. If you already have a door, flip a coin to see whether you keep it or go for this new, further out door instead. If the flip fails, you just take the old door and break out of the while loop. With the odds set up this way, the NPC should go for the closed viable door 50% of the time, 2nd closest 25%. 3rd 12.5%, and so on.
}
i++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}//done with the while loop
return oReturn;
}
Here's my stab at it:
object GetRandomDoor(float fMaxDist) {
object oReturn;
int i = 1;
object oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
while (GetIsObjectValid(oNear) && (i<20) && (GetDistanceToObject(oNear) <= fMaxDistance)) {
//The (i<20) is just a fail safe, especially when you have a bunch of ambient NPCs in an area with a lot of doors. I notice you also have "oObject" in the GetDistance function, that seems to be a type.
if (GetLocalInt(oNear, "iNoCAIUse") == 0) ) {
//I'm just checking that one variable here, but I see you also check if a door action is possible, and you could just nest that here.
if (!GetIsObjectValid(oReturn)) {
oReturn = oDoor;
}
else if (d2() = 1) {
oReturn = oDoor;
}
else {
i = 20;
}
//This is a quick and dirty randomization. If there's no return door found yet, use this one. If you already have a door, flip a coin to see whether you keep it or go for this new, further out door instead. If the flip fails, you just take the old door and break out of the while loop. With the odds set up this way, the NPC should go for the closed viable door 50% of the time, 2nd closest 25%. 3rd 12.5%, and so on.
}
i++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}//done with the while loop
return oReturn;
}
#4
Posté 14 janvier 2013 - 03:43
Sorry, missed your post kevL.
Testing with more debug stuff shows GetIsDoorActionPossible is weird.
When I had my code spit out the value of i after the first while loop, it was always 1, indicating it was never entering the while loop despite 9 static doors (and no usable doors) in range. Taking out the ! and it properly stated i was 10 (i starts at 1, and gets incremented 9 times).
That seems to indicate GetIsDoorActionPossible is returning the opposite of what you'd expect.
Oddly I was getting random doors anyway with my debug indicating I was always getting i=1, and more debug text turned up some other issues inside the heartbeats I was checking. I had multiple bugs cancelling each other, and it worked out as I was getting my expected results :-) (minus the excluding doors, which I hadn't implemented yet).
The following seems to produce the desired results. However what is strange is that the first use of GetIsDoorActionPossible in the while loop is the opposite from the iwhile and if statement near the end, however it's use at the end is correctly identifying "no use" doors, and returning the door object, and would never return the doors when it was used without the ! (as it is in the first while loop. I tested without the ! and it didn't work, producing invalid objects. Strange.
object GetRandomStaticDoor(float fMaxDistance) //based on kevL's random object code.
{
int iObject; object oObject;
int i = 1;
object oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
// GetNearest seems to work only in the area of OBJECT_SELF, good.
while ((GetIsObjectValid(oNear)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& ((GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
//if door is static check needed. more code needed before relased kamal
i ++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}
// SendMessageToPC(GetFirstPC(), "Debug: num doors = " + IntToString(i));
// count is one too many ..
i -= 1;
// Random starts w/ 0 (subtract 1), so add 1
iObject = Random(i) + 1; // iObject -> that's a pun, haha :|
// max the count at the number of objects, i
if (iObject > i) iObject = i;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
int nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
while ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN)))
&& (nNoCAIUse==1))
{
SendMessageToPC(GetFirstPC(), "Debug: cai No use door");
iObject = Random(i) + 1;
if (iObject > i) iObject = i;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
}
//sanity check of found door.
if ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{ SendMessageToPC(GetFirstPC(), "Debug: returning door");
return oObject;
}
return OBJECT_INVALID;
}
Testing with more debug stuff shows GetIsDoorActionPossible is weird.
When I had my code spit out the value of i after the first while loop, it was always 1, indicating it was never entering the while loop despite 9 static doors (and no usable doors) in range. Taking out the ! and it properly stated i was 10 (i starts at 1, and gets incremented 9 times).
That seems to indicate GetIsDoorActionPossible is returning the opposite of what you'd expect.
Oddly I was getting random doors anyway with my debug indicating I was always getting i=1, and more debug text turned up some other issues inside the heartbeats I was checking. I had multiple bugs cancelling each other, and it worked out as I was getting my expected results :-) (minus the excluding doors, which I hadn't implemented yet).
The following seems to produce the desired results. However what is strange is that the first use of GetIsDoorActionPossible in the while loop is the opposite from the iwhile and if statement near the end, however it's use at the end is correctly identifying "no use" doors, and returning the door object, and would never return the doors when it was used without the ! (as it is in the first while loop. I tested without the ! and it didn't work, producing invalid objects. Strange.
object GetRandomStaticDoor(float fMaxDistance) //based on kevL's random object code.
{
int iObject; object oObject;
int i = 1;
object oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
// GetNearest seems to work only in the area of OBJECT_SELF, good.
while ((GetIsObjectValid(oNear)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& ((GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
//if door is static check needed. more code needed before relased kamal
i ++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}
// SendMessageToPC(GetFirstPC(), "Debug: num doors = " + IntToString(i));
// count is one too many ..
i -= 1;
// Random starts w/ 0 (subtract 1), so add 1
iObject = Random(i) + 1; // iObject -> that's a pun, haha :|
// max the count at the number of objects, i
if (iObject > i) iObject = i;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
int nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
while ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN)))
&& (nNoCAIUse==1))
{
SendMessageToPC(GetFirstPC(), "Debug: cai No use door");
iObject = Random(i) + 1;
if (iObject > i) iObject = i;
oObject = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, iObject);
nNoCAIUse = GetLocalInt(oObject, "nNoCAIUse");
}
//sanity check of found door.
if ((GetIsObjectValid(oObject)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& (!(GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{ SendMessageToPC(GetFirstPC(), "Debug: returning door");
return oObject;
}
return OBJECT_INVALID;
}
#5
Posté 14 janvier 2013 - 04:44
I've never used GetIsDoorActionPossible() -- it should work but .. you know.
i Gather you want NPCs to walk to only static doors and 'disappear' into them, unfollowed by players. Maybe write a little routine just to check what that function really returns TRUE for ......
& try my script i'm curious if it works
i Gather you want NPCs to walk to only static doors and 'disappear' into them, unfollowed by players. Maybe write a little routine just to check what that function really returns TRUE for ......
& try my script i'm curious if it works
I thought that at first too, but he's re-getting it in the loop.Lugaid wrote ...
That big compound conditional in your while loop seems off to me. First, how does it check iNoCAIUse? It's written like that variable's already been declared in the script/function, when I'm guessing it needs to be read off the next door during each while loop.
That is a problem .... those additional checks should be nested yes. ( See above )Secondly, it seems the thing would loop until it found a door with the iNoCAIUse set, and then stop, even if there were useable doors further away.
#6
Posté 14 janvier 2013 - 02:44
Here's a test of the GetIsDoorActionPossible() function via conversation. The function with door_action_open seems to be the only way to check if a door is static.
This is the conditional function I used to check, and the pic is the results, plus the conversation that produced them. It seems to perform as expected in conversation.
int StartingConditional(string sDoorTag) {
object oDoor = GetObjectByTag(sDoorTag);
if (GetIsDoorActionPossible(oDoor,DOOR_ACTION_OPEN)==TRUE) {
return TRUE;
} else {
return FALSE;
}
}
550x250https://dl.dropbox.com/u/3879894/static_door.jpg[/img]
Looking at my previous post, where I do the following:
while ((GetIsObjectValid(oNear)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& ((GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
//if door is static check needed. more code needed before relased kamal
i ++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}
Printing out i at this point prints "10" (i initialized at 1, +9 static doors, no non-static doors to be counted). However my test of the function show that should print out that i = 1 as there are no usable doors. In a mix of 9 static and 5 non-static doors, it prints "15", indicating it is counting the doors whether they are static or not. Meaning the function is not working. <_< (Changing things to GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN)==TRUE) does not change the results).
Additionally my npcs are moving to these usable doors when they are present, so it's definitely not working as expected.
This is the conditional function I used to check, and the pic is the results, plus the conversation that produced them. It seems to perform as expected in conversation.
int StartingConditional(string sDoorTag) {
object oDoor = GetObjectByTag(sDoorTag);
if (GetIsDoorActionPossible(oDoor,DOOR_ACTION_OPEN)==TRUE) {
return TRUE;
} else {
return FALSE;
}
}
550x250https://dl.dropbox.com/u/3879894/static_door.jpg[/img]
Looking at my previous post, where I do the following:
while ((GetIsObjectValid(oNear)) && (GetDistanceToObject(oObject) <= fMaxDistance)&& ((GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN))))
{
//if door is static check needed. more code needed before relased kamal
i ++;
oNear = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, i);
}
Printing out i at this point prints "10" (i initialized at 1, +9 static doors, no non-static doors to be counted). However my test of the function show that should print out that i = 1 as there are no usable doors. In a mix of 9 static and 5 non-static doors, it prints "15", indicating it is counting the doors whether they are static or not. Meaning the function is not working. <_< (Changing things to GetIsDoorActionPossible(oNear, DOOR_ACTION_OPEN)==TRUE) does not change the results).
Additionally my npcs are moving to these usable doors when they are present, so it's definitely not working as expected.
Modifié par kamal_, 14 janvier 2013 - 02:46 .
#7
Posté 14 janvier 2013 - 06:41
Did some tests. Pseudo-confirmed your results re. GetIsDoorActionPossible() -- seems to be closely related to GetLocked().
Since there doesn't seem to be a way to determine if a door is Static, why not reconsider your thinking on the int_variable and change it to "bCIAUse" instead? This way, static or not, locked or not, a designer must actively set a door as valid for CIA use,
"CIA use" <- doh!! loL
Since there doesn't seem to be a way to determine if a door is Static, why not reconsider your thinking on the int_variable and change it to "bCIAUse" instead? This way, static or not, locked or not, a designer must actively set a door as valid for CIA use,
"CIA use" <- doh!! loL
#8
Posté 14 janvier 2013 - 08:01
Yeah, may have to go with that, mark doors for use instead of mark for not using. It makes more work for the builder though, which I'm trying to avoid as this is for my commoner ai where minimizing the amount of builder work needed is a goal.
The variable name is short for Commoner AI use, not the spies. :-)
The variable name is short for Commoner AI use, not the spies. :-)
#9
Posté 14 janvier 2013 - 09:17
Look at the good side : if someone wants to customize it so merchants go to merchant doors, blacksmiths go to blacksmith doors, etc ... just alter the variable name and pass it into the argument,
here's my take on the basic function
here's my take on the basic function
#10
Posté 14 janvier 2013 - 09:21
How about using the default tags on the doors? I'd assume that any PC-usable door would have a custom tag, but builders tend to leave the default tags on all the others.
#11
Posté 15 janvier 2013 - 10:31
I've tried several ways to get around it, but it looks like the local variable is the only way to do it. I will record my results of the following pseudocode using human, gnome, and dwarf npc with stock stats.
In a test area with four door types:
locked
unlocked and usable and plot
unlocked and usable and non-plot
static.
pseudocode
----------------------
while
(GetIsDoorActionPossible(oObject,DOOR_ACTION_OPEN )==FALSE)
chose another door.
------------------------
This will avoid locked doors, but select usable unlocked doors and static doors. So static doors are viewed as openable.
Substitute:
(GetIsDoorActionPossible(oObject,DOOR_ACTION_OPEN )==TRUE) and only locked doors will be chosen.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_UNLOCK )==FALSE) and no door is chosen, plus infinite loop lag.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_UNLOCK )==TRUE) and the while loop will never enter, static, locked, and unlocked doors chosen.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_BASH )==TRUE) and static and plot doors are selected
(GetIsDoorActionPossible(oObject,DOOR_ACTION_IGNORE)==TRUE) , infinite loop, no doors selected.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_IGNORE)==FALSE) , while loop never entered, all doors selected.
Tried replacing DoorAction with GetIsPlaceableObjectActionPossible (as shown in http://www.nwnlexico...tActionPossible , the nwn1 lexicon has more information about this function than the nwn2 wiki...).
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_USE)==TRUE) , I expected this to do exactly what I wanted, as any usable door would trigger it while any static door is not usable in any way. However the while loop never entered, static, locked, and usable doors selected.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_USE)==FALSE) and no door is chosen, plus infinite loop lag. It does show that the function works with doors though.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_UNLOCK)==FALSE), same result, no door chosen, infinite loop lag.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_UNLOCK)==TRUE) while loop never enters.
In a test area with four door types:
locked
unlocked and usable and plot
unlocked and usable and non-plot
static.
pseudocode
----------------------
while
(GetIsDoorActionPossible(oObject,DOOR_ACTION_OPEN )==FALSE)
chose another door.
------------------------
This will avoid locked doors, but select usable unlocked doors and static doors. So static doors are viewed as openable.
Substitute:
(GetIsDoorActionPossible(oObject,DOOR_ACTION_OPEN )==TRUE) and only locked doors will be chosen.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_UNLOCK )==FALSE) and no door is chosen, plus infinite loop lag.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_UNLOCK )==TRUE) and the while loop will never enter, static, locked, and unlocked doors chosen.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_BASH )==TRUE) and static and plot doors are selected
(GetIsDoorActionPossible(oObject,DOOR_ACTION_IGNORE)==TRUE) , infinite loop, no doors selected.
(GetIsDoorActionPossible(oObject,DOOR_ACTION_IGNORE)==FALSE) , while loop never entered, all doors selected.
Tried replacing DoorAction with GetIsPlaceableObjectActionPossible (as shown in http://www.nwnlexico...tActionPossible , the nwn1 lexicon has more information about this function than the nwn2 wiki...).
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_USE)==TRUE) , I expected this to do exactly what I wanted, as any usable door would trigger it while any static door is not usable in any way. However the while loop never entered, static, locked, and usable doors selected.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_USE)==FALSE) and no door is chosen, plus infinite loop lag. It does show that the function works with doors though.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_UNLOCK)==FALSE), same result, no door chosen, infinite loop lag.
(GetIsPlaceableObjectActionPossible(oObject,PLACEABLE_ACTION_UNLOCK)==TRUE) while loop never enters.
#12
Posté 15 janvier 2013 - 11:01
To make the tag idea simpler, there are a few functions that manipulate strings. "GetStringLeft" in particular can be used to get the first n characters of a string. As all the default door tags start with "plc_" or "PLC_", you can just check those three or four characters when you check to see if a door is standard default door or one customized by the builder for PC use.
And as long as you're checking door tags, you could always check on the NPC for a string set by the builder directing the NPC to only use doors with a special tag:
int GetIsDoorValid(object oDoor, string sCheckTag == "default") {
int iReturn = FALSE;
string sDoorTag = GetTag(oDoor);
if (sCheckTag == "default") {
string sParsed = GetStringLeft(sDoorTag, 3);
if ((sParsed == "PLC") || (sParsed == "plc")) {return TRUE;}
else {return FALSE;}
}
else if (sDoorTag == sCheckTag) {return TRUE;}
return iReturn;
}
Before your big while loop you would check the NPC's local string:
string sCheckTag = "default";
if (GetLocalString(OBJECT_SELF, "iAmbientDoorTag") != "") {
sCheckTag = (GetLocalString(OBJECT_SELF, "iAmbientDoorTag");
}
And as long as you're checking door tags, you could always check on the NPC for a string set by the builder directing the NPC to only use doors with a special tag:
int GetIsDoorValid(object oDoor, string sCheckTag == "default") {
int iReturn = FALSE;
string sDoorTag = GetTag(oDoor);
if (sCheckTag == "default") {
string sParsed = GetStringLeft(sDoorTag, 3);
if ((sParsed == "PLC") || (sParsed == "plc")) {return TRUE;}
else {return FALSE;}
}
else if (sDoorTag == sCheckTag) {return TRUE;}
return iReturn;
}
Before your big while loop you would check the NPC's local string:
string sCheckTag = "default";
if (GetLocalString(OBJECT_SELF, "iAmbientDoorTag") != "") {
sCheckTag = (GetLocalString(OBJECT_SELF, "iAmbientDoorTag");
}
#13
Posté 16 janvier 2013 - 12:18
Thanks Lugaid. I decided to go with the local integer on the door for doors that are ok to use. I got it working in about 5 minutes after my post. There's no reason your method wouldn't work and I'm very familiar with string manipulation on tags since I use it for a number of things in Crimmor, but I'm personally more likely to use local variables than door tags (I don't normally tag my doors).





Retour en haut






