View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Jan 24, 2018 1:46 Post subject: |
|
|
Question around your possession code..
I am trying to integrate your possession code from nwnx_patch into my nwnx_cool implementation - which is where I have most of my hooks defined.
I am able to get the possession to occur.
It uses PossessFamiliar - to get me into the body of the intended target.
Your code uses some fields on the creature class to store what I guess are variables to track the master and the pseudo familiar.
I couldnt get the same strategy working using those fields - I think my header class may be outdated- it has uint8 against alot of the data types and I am scared to change them in case it ruins the rest of the header file - eg: messing with offsets or something.
I tried to do something else - outside of the fields:
Code: |
void CCoolFunc::PossessCreature()
{
Coolt->Log(0,"o Possess Creature called \n");
Coolt->Log(1, "o Possess Creature args %s\n",params);
nwn_objid_t oID, oTarget;
sscanf_s(params, "%x", &oID);
sscanf_s(params, "%x|%x", &oID, &oTarget);
Coolt->Log(1, "o Possess Creature called against %x :\n", oTarget);
CNWSCreature * cre = (*NWN_AppManager)->app_server->srv_internal->GetCreatureByGameObjectID(oID);
CNWSCreature *target = (*NWN_AppManager)->app_server->srv_internal->GetCreatureByGameObjectID(oTarget);
Coolt->Log(2, "o Possess Creature on %x %s \n", obj->obj_generic.obj_id, obj->obj_generic.obj_tag);
if (cre && oID != OBJECT_INVALID && target)
{
Coolt->Log(1, "o Possess Creature valid so far %x :\n", oID);
if (cre->cre_is_pc && !target->cre_is_pc)
{
Coolt->Log(1, "o Possess Creature should be getting done %x :\n", oID);
cre->obj.obj_vartable.SetObject(CExoString("famtemp"), oTarget);
target->cre_MasterID = oID;//workaround for unpossessing non-associate
target->obj.obj_vartable.SetObject(CExoString("masttemp"), oID);
//target->field_B2C = oID;//workaround for automatical unpossess when dead
cre->PossessFamiliar();
}
}
} |
This gets me into the body of my target.
However- the unpossess button does not exist.
In order to get the Unpossess button to appear, I need to trigger:
cre->AddAssociate(oTarget, 3);
To make the system think that oTarget is my familiar.
However- when I then click the Unpossess button - the server crashes.
Dont suppose you can see where I am going wrong?
Code: |
void __fastcall CNWSCreature__PossessFamiliar_Hook(CNWSCreature *pThis, void*)
{
Cool.frames++;
//Log(2, "o CNWSCreature__PossessFamiliar start\n");
int prev = helper;
CNWSCreature *cre = (*NWN_AppManager)->app_server->srv_internal->GetCreatureByGameObjectID(pThis->obj.obj_vartable.GetObjectA(CExoString("famtemp")));
if (cre)
{
helper = 222;
}
CNWSCreature__PossessFamiliar(pThis, NULL);
helper = prev;
}
void __fastcall CNWSCreature__UnpossessFamiliar_Hook(CNWSCreature *pThis, void*)
{
Cool.frames++;
Cool.Log(1, "o unpossess called: %x\n", pThis->obj.obj_generic.obj_id);
int prev = helper;
CNWSCreature *cre = (*NWN_AppManager)->app_server->srv_internal->GetCreatureByGameObjectID(pThis->obj.obj_vartable.GetObjectA(CExoString("famtemp")));
if (cre)
{
helper = 222;
Cool.Log(1, "o unpossess helper = 222: %x\n", pThis->obj.obj_generic.obj_id);
}
CNWSCreature__UnpossessFamiliar(pThis, NULL);
pThis->obj.obj_vartable.DestroyObject(CExoString("famtemp"));
helper = prev;
}
unsigned long __fastcall CNWSCreature__GetAssociateId_Hook(CNWSCreature *pThis, void*, unsigned short type, int th)
{
//Log(2, "o CNWSCreature__GetAssociateId start\n");
Cool.frames++;
CNWSCreature *cre_orig = (*NWN_AppManager)->app_server->srv_internal->GetCreatureByGameObjectID(pThis->obj.obj_vartable.GetObject(CExoString("famtemp")));
if (helper == 222 && cre_orig)
{
return cre_orig->obj.obj_generic.obj_id;
}
return CNWSCreature__GetAssociateId(pThis, NULL, type, th);
}
|
|
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Thu Jan 25, 2018 5:01 Post subject: |
|
|
I am not sure if there aren't some mid-function hooks to make this possible too.
I recall some issues with storing the pseudo familiar and master though, might be why I re-used some field in player's CNWSCreature, but in theory using local variables should work as well. Not sure why it is crashing, I don't see into this anymore, was too long gone from nwnx...
Of course, you can always use mine plugin instead of "stealing" its functionalities, but I guess thats out of question as it does 3 or more things you don't need (Proleric's argument btw) right? _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Thu Jan 25, 2018 16:57 Post subject: |
|
|
'Stealing' is a strong, confrontational word for something that was freely available on github.
If your intent was for the community 'not' to use your works, perhaps a private repo might have been what you were after?
I'm unsure what argument you are referring to by Proleric - I am simply interested in implementing custom Possession code for a subrace. |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Wed May 02, 2018 1:44 Post subject: |
|
|
NWNCX_Patch and NWNX_Patch v1.34
DOWNLOAD
Highly experimental. I am following on my previous work, I might forgot what I did, if it is finished and if there are some issues. So treat it that way.
Fixes to the plugin:
- fixed issue with threat roll and negative ab
Revisited fixes/features:
- reworked favored enemy and hidden spells (don't ask me for details because I forgot why and how...)
New fixes and features:
- added VersusRacialType/VersusAlignment support into NWNXPatch_EffectttackIncreaseUncapped
- allowed to modify player's hitpoints, integer variable "HP_BONUS" will be added into max hp value of a player, can be negative as well, integer variable "HP_%" will increase or decrease hitpoints by percent of max hp
- softcoded animal empathy skill into 70_s2_empathy.nss
- some change into Character Validation that should work with custom learner spellcasters - untested!!!
New custom functions:
- GetSpellProgression - private function for community patch spell engine, returns the total bonus to spell progression calculated by nwnx_plugin (function is not defined in 70_inc_nwnx - if anyone thinks it would be usefull I will add it)
Development notes:
As I wrote in beginning I lost connection to nwnx. Been away for some time and I still don't have all tools setup as I recently changed computer. So let me know if something doesn't work or works differently than you expected, especially the features that I reworked - hidden spells, favored enemy and the ELC with changed values in cls_spopt_*.2da _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
DarkSet
Joined: 06 Jun 2016 Posts: 98
|
Posted: Wed May 02, 2018 13:30 Post subject: |
|
|
oh, great!
Does this mean that you're back to this project or it's just occasional update?
And as you are in NWN:EE question for that - how much of nwnx_patch and nwncx_patch can we expect in NWN:EE? Sticky combat modes are already there and i assume you are related to that. |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Wed May 02, 2018 18:12 Post subject: |
|
|
DarkSet wrote: | oh, great!
Does this mean that you're back to this project or it's just occasional update?
And as you are in NWN:EE question for that - how much of nwnx_patch and nwncx_patch can we expect in NWN:EE? Sticky combat modes are already there and i assume you are related to that. |
Well there was a bug that needed to be fixed. Thats why the update. The other features were already done from the time before.
I am not sure yet if I will continue on this. Don't even know what more to add.
As for NWN:EE my contributions consisted of providing as many details to hardcoded bugs (that I knew about and fixed in my nwnx plugin) to BeamDog. Same as well I was lobbying for many features that I added in my nwnx plugin and yes sticky combat modes made it into offic release which is great. Now, if we would get possibility to make custom spellcasters...
Anyway NWNX for EE still has no support for windows afaik, while it promises that plugins will work on multiple platforms I really have no idea where and how to start developing for linux. What editor to use how to compile it how to test it. I was pointed to the docker but that didn't really answer all my questions... So right now I can't do much for NWN:EE and the linux plugins already brought lots of functioonalities, if they gonna work for windows automatically we might not need nwnx_patch anymore? _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
DarkSet
Joined: 06 Jun 2016 Posts: 98
|
Posted: Wed May 02, 2018 23:26 Post subject: |
|
|
so many ifs that i think we will need it |
|
Back to top |
|
|
DarkSet
Joined: 06 Jun 2016 Posts: 98
|
Posted: Sat May 05, 2018 0:44 Post subject: |
|
|
with this new version my server started to crash again, like it was with 1.33
Had to go back to earlier again. |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sat May 05, 2018 1:14 Post subject: |
|
|
DarkSet wrote: | with this new version my server started to crash again, like it was with 1.33
Had to go back to earlier again. |
when this crash occured? at loading server? randomly anytime later? anything specific that could help me track it? _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Valbor
Joined: 26 Dec 2016 Posts: 145
|
Posted: Sat May 05, 2018 10:50 Post subject: |
|
|
Code: |
object oPC = GetLastPCRested();
if (GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED)
{
object oHenchman_01 = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, 1);
NWNXPatch_SetMemorisedSpellSlot(oHenchman_01, CLASS_TYPE_CLERIC, 1, 0, NWNXPatch_GetMemorisedSpellSlot(oPC, CLASS_TYPE_CLERIC, 1, 0));
NWNXPatch_SetMemorisedSpellSlot(oHenchman_01, CLASS_TYPE_CLERIC, 1, 1, NWNXPatch_GetMemorisedSpellSlot(oPC, CLASS_TYPE_CLERIC, 1, 1));
}
|
after use it, server is crash when player is exit from game! (from patch v1.33f)
Also possible to make for any NPC or henchman of his own experience so that they can develop themselves? |
|
Back to top |
|
|
DarkSet
Joined: 06 Jun 2016 Posts: 98
|
Posted: Sat May 05, 2018 15:51 Post subject: |
|
|
ShaDoOoW wrote: | DarkSet wrote: | with this new version my server started to crash again, like it was with 1.33
Had to go back to earlier again. |
when this crash occured? at loading server? randomly anytime later? anything specific that could help me track it? |
pity but no detailes. It's not on server start, i started it, went to work, came back and found a dozen of crach windows. Nwnx started server successfully after each of them and players told me nothing yet.
And i dont use NWNXPatch_SetMemorisedSpellSlot. I use another version of this functionality from another plugin. nwnx_functions if I remember right |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Sat May 05, 2018 22:38 Post subject: |
|
|
DarkSet wrote: | ShaDoOoW wrote: | DarkSet wrote: | with this new version my server started to crash again, like it was with 1.33
Had to go back to earlier again. |
when this crash occured? at loading server? randomly anytime later? anything specific that could help me track it? |
pity but no detailes. It's not on server start, i started it, went to work, came back and found a dozen of crach windows. Nwnx started server successfully after each of them and players told me nothing yet.
And i dont use NWNXPatch_SetMemorisedSpellSlot. I use another version of this functionality from another plugin. nwnx_functions if I remember right |
There are some additional debugs at level 2, dont remember in which ini and under what string to do it, though, that wont help probably as it shows only normal hooks and these crashes are usually caused by inline hooks where debugging is bit more problematic.
Give me some time to find this and fix it. The memorisedspellslot issue won't be any easy either... _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Tue May 08, 2018 16:34 Post subject: |
|
|
NWNX_Patch v1.34 fix
DOWNLOAD
This is just a quick fix for the crash happening on character login with ELC turned on. Last version attempted to calculate and compare number of spells new character learns with number of spells he is supposed to learn and disallow entry to players who have more spells than they should have.
Unfortunately, I don't intent to correct the code and make it work again. The code is available on github so if someone wants to, he can attempt to do that himself. _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
ShaDoOoW
Joined: 20 Aug 2005 Posts: 584
|
Posted: Tue May 08, 2018 19:59 Post subject: |
|
|
Valbor wrote: | after use it, server is crash when player is exit from game! (from patch v1.33f)
Also possible to make for any NPC or henchman of his own experience so that they can develop themselves? |
cannot reproduce, tried lvl 40 cleric bard rdd build and high lvl Linu henchman but it didn't crash - can you send me both player character and henchman if possible?
also, check for any additional messages in nwnx_patch and try also temporarily comment out OnExit script as it might be related _________________ Community Patch / NWNX Patch / NWNX Files / NWNX Connect |
|
Back to top |
|
|
Valbor
Joined: 26 Dec 2016 Posts: 145
|
Posted: Wed May 09, 2018 19:54 Post subject: |
|
|
ShaDoOoW wrote: | Valbor wrote: | after use it, server is crash when player is exit from game! (from patch v1.33f)
Also possible to make for any NPC or henchman of his own experience so that they can develop themselves? |
cannot reproduce, tried lvl 40 cleric bard rdd build and high lvl Linu henchman but it didn't crash - can you send me both player character and henchman if possible?
also, check for any additional messages in nwnx_patch and try also temporarily comment out OnExit script as it might be related |
If you have the time and the desire to look, maybe you can find the cause reason of my misfortune.
My project: http://TransFiles.ru/ywb4g |
|
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
|