View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Fri Aug 17, 2012 12:48 Post subject: Problems with visibility in Funcs |
|
|
Hi Guys,
I've been using SetVisibilityOverride - which works fine.
Marks a single object as being visible or invisible to all etc.
However, I have only now had the need to use the
Quote: |
void NWNXFuncs_SetVisibility(object oObject1, object oObject2, int nVisibility);
|
This should be setting object1 to be invisible to object2 with
Code: |
void NWNXFuncs_SetVisibility(myPlaceable, oPC, VISIBILITY_TYPE_INVISIBLE); // The const equates to 2
|
However, when used - it doesnt want to change the visibility.
this is the c++ code
can someone have a look and tell me if they can see a problem?
Code: |
int CVisibility::TestVisibility(nwn_objid_t oObject1, nwn_objid_t oObject2, int &nResult)
{
CNWSObject *Obj1 = (CNWSObject*)(*NWN_AppManager)->app_server->GetGameObject(oObject1);
CNWSObject *Obj2 = (CNWSObject*)(*NWN_AppManager)->app_server->GetGameObject(oObject2);
if (Obj1 && Obj2) {
if (Obj2->obj_type2 == OBJECT_TYPE2_CREATURE && ((CNWSCreature*)Obj2)->cre_stats->cs_is_dm) {
nResult = 1;
return 1;
}
int LocalVarOverride = Obj1->obj_vartable.GetInt(CExoString("NWNXFUNCS_VIS"));
if (LocalVarOverride) {
if (LocalVarOverride == Obj2->obj_vartable.GetInt(CExoString("NWNXFUNCS_VIS"))) {
nResult = 1;
return 1;
}
}
if(objects.find(oObject1) != objects.end()){
//__log(2, "Found object entry!");
if(objects[oObject1].vismap.find(oObject2) != objects[oObject1].vismap.end()){
//__log(2, "Found object-object entry!");
nResult = objects[oObject1].vismap[oObject2];
return 1;
}
else {
switch(objects[oObject1].eOverrideType){
case AlwaysVisible:
nResult = 1;
return 1;
break;
case AlwaysInvisible:
nResult = 0;
return 1;
break;
case Default:
default:
return 0;
}
}
}
}
return 0;
}
int __fastcall CHookFunctions::CNWSMessage__TestObjectVisibleHOOK(void *pMessage, void *pVOID, CNWSObject *pObject1, CNWSObject *pObject2) {
nwn_objid_t oObject1 = pObject1->obj_id;
nwn_objid_t oObject2 = pObject2->obj_id;
int nResult = 0;
if(!NWNFuncs.Visibility->TestVisibility(oObject1, oObject2, nResult)){
nResult = CNWSMessage__TestObjectVisibleNEXT(pMessage, NULL, pObject1, pObject2);
}
// _log(3, "Visibility check: %x - %x: %d\n", pObject1->obj_id, pObject2->obj_id, nResult);
return nResult;
}
|
What i've done to test this is
1 Create a placeable (plot, non static, usable)
2. Set the override to make it invisible to all
3. use the SetVisibility to try and make it visible to all players of specific subrace.
4. It does the correct statements etc, and fires with no errors
5. Logs do suggest that it is firing the correct function
6. But the placeable remains invisible
I've also done it without the override, and tried setting visibility individually, and it fails to work too.
Has anyone had success with this method? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Fri Aug 17, 2012 12:58 Post subject: |
|
|
Quote: |
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7fffffae 2"
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7fffffae 2"
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7ffffffd 1"
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7ffffffd 1"
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7fffff90 1"
[08/16/2012 23:23:04] - StrReq: "SET_VISIBILITY" Params: "7fffff90 1"
|
This is the requests made to the plugin to set invisible to the one player who was online - who should not see it,
and the 2 players who were online who should see it.
End result was that the object in question was visible by all.
Not sure why there are two entries per player - but either way, it didnt work.
|
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Fri Aug 17, 2012 22:55 Post subject: |
|
|
I think I have found the area where the problem lies
Code: |
int CVisibility::NssSetVisibility(CGameObject *oObject, char *Params) {
nwn_objid_t oObject2 = OBJECT_INVALID;
int nValue = -1;
CParams::ExtractP2(Params, oObject2, nValue);
SetVisibility(oObject->obj_id, oObject2, nValue);
return 1;
}
|
When I do GetVisibility on an object, it returns -1
Which suggests it is not getting the params from this function correctly.
Would anyone have any suggestions? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Fri Aug 17, 2012 23:02 Post subject: |
|
|
Code: |
int __fastcall CHookFunctions::CNWSMessage__TestObjectVisibleHOOK(void *pMessage, void *pVOID, CNWSObject *pObject1, CNWSObject *pObject2) {
nwn_objid_t oObject1 = pObject1->obj_id;
nwn_objid_t oObject2 = pObject2->obj_id;
int nResult = 0;
if(!NWNFuncs.Visibility->TestVisibility(oObject1, oObject2, nResult)){
nResult = CNWSMessage__TestObjectVisibleNEXT(pMessage, NULL, pObject1, pObject2);
}
// _log(3, "Visibility check: %x - %x: %d\n", pObject1->obj_id, pObject2->obj_id, nResult);
return nResult;
}
|
Its also never showing this log message in the logs, despite being set to log level 3.
Suggesting that it TestVisibility is failing? |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sun Aug 26, 2012 22:26 Post subject: |
|
|
The line is commented out, so no wonder it's not printing anything. _________________ In Soviet Russia, NWN plays you! |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Aug 26, 2012 22:28 Post subject: |
|
|
yeah - noticed that a day or so after posting it.
From what I can see - it looks like -1 is continuosly being wrote to the object table
Might be wrong though.
Still couldnt get it working.
Has anyone else got it working? |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Tue Aug 28, 2012 1:49 Post subject: |
|
|
Try to switch the params. It seems like you're actually making the player invisible to the object. _________________ In Soviet Russia, NWN plays you! |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Tue Aug 28, 2012 1:54 Post subject: |
|
|
I thought that might be the case
But I tried the following
NWNXFuncs_SetVisibility(object,oplayer,2);
NWNXFuncs_SetVisibility(oplayer,object,2);
I tried doing both calls at same time - and the effect was that I could still see the object |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|