logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Hooking
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Sat Jan 30, 2010 21:54    Post subject: Reply with quote

Very Happy
So many new options and ugly prc workarounds to rewrite.
Thank you very much.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Sat Jan 30, 2010 23:11    Post subject: Reply with quote

indeed good work, finally I can make (my own lite PRC version) Storm Lord to use his feat properly Smile

thanks!
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sat Jan 30, 2010 23:56    Post subject: Reply with quote

Updated nwn ign entry: http://nwvault.ign.com/View.php?view=Other.Detail&id=1429
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Sun Jan 31, 2010 0:45    Post subject: Reply with quote

What are the chances of getting an override for the events?

Don't you hate people who keep demanding more constantly? Twisted Evil
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sun Jan 31, 2010 2:36    Post subject: Reply with quote

Code:
;Paste these inte NWNX.ini and configure as desired
;1 = on, 0 = off
;all hooks are disabled by default
[EVENTS]
event_script=nwnx_events
log=1
DownloadCharacter=0
PickPocket=0
Attack=0
ExamineItem=0
ExamineCreature=0
ExaminePlaceable=0
ExamineDoor=0
ToggleMode=0
StealthMode=0
DevastatingCritical=0
UnPolymorph=0
TrapTrigger=0
EndDialog=0
RemoveSanctuary=0


You mean those?
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Sun Jan 31, 2010 2:39    Post subject: Reply with quote

Bad choice of words on my end, sorry about that.

I meant setting a bypass local var in the script so that the event doesn't take place at all.
E.g. the character never entering Stealth mode or not executing the attack.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sun Jan 31, 2010 2:59    Post subject: Reply with quote

Yeah, thats the next step, didnt manage to do that in a working fashion. Stealthmode ended up getting stuck in stealthmode without being in stealthmode and attack can be avoided with AssignCommand( oPC, ClearAllActions( TRUE ) );. Razz
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Wed Feb 24, 2010 14:41    Post subject: Reply with quote

Edit: nevermind, I solved it.

Ok, thread recycled.

I'm looking/trying to hook a nwn function or find a way to turn object ID(IE: ObjectToString) to the actual object since nwn uses the object ID rather then the actual objectpointer in some arrays, area list on module as an example.

I've been working on a memory editor plugin (Set/GetPointer/String/Int/word/byte, NewString/Int, Delete, etc) and so far I've managed to make functions such as Set/GetScriptEvent, SetTag, SetResRef, Set/GetLocalVariableInIndex, SetItemAppearance/Color/Part. So reason I want StringToObject is to read the area list on the module for a GetFirst/NextArea functionality.

I've tried calling some nwn functions CServerApp::GetObject(ulong) something, don't remember the address offhand. But it just causes the server to crash and I'm don't quite have the assembly skills to figure out why. Anyone willing to help?

P.S. What I got so far
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Fri Mar 12, 2010 4:44    Post subject: Reply with quote

Thank you very much for the memory editor, Terra Very Happy

My C skills are way too rusty to figure out how to port anything to windows but with this I managed to figure out how to access and change the effects structs (SetEffectSpellId will be very useful for PRC scripts).
Thank you again!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Fri Mar 12, 2010 20:09    Post subject: Reply with quote

Oh? Care to share? Razz
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Fri Mar 12, 2010 23:53    Post subject: Reply with quote

Terra_777 wrote:
Oh? Care to share? Razz


Of course.
I "proof of concept" script implementation using your SetPointer and SetInt functions which is a little clunky but works for now. I might write actual code to do this directly later.

Anyways:
Starting with NWNX_GetObjectPointer:
The offset for the pointer to the effects pointer array is 0xE8.
The pointer array holds the addresses to the individual effects.

The order is 1, n, n-1, n-2, ... Four effects applied in succession would be stored like this 1, 4, 3, 2. So the last effect applied will alway be the second one in the list; unless of course there is only 1 effect, then it's the first. This is probably standard array or linked list behaviour but I'm not sure.
[Edit]
So much for the order. Seems if they're applied within the same function one after the other the order is the same as returned by GetFirst-/GetNextEffect.
[/Edit]
I'm still trying to figure out if the number of effects is stored anywhere.

The offsets for the effect struct itself I took from CGameEffect.h (Thanks to all the linux people working on that):

Code:

struct CGameEffect_s {
    uint32_t            eff_id;                 /* 00 */

    uint32_t            field_04;               /* 04 */

    uint16_t            eff_type;               /* 08 */
    uint16_t            eff_dursubtype;         /* 0A */

    float               eff_duration;           /* 0C */

    uint32_t            eff_expire_day;         /* 10 */
    uint32_t            eff_expire_time;        /* 14 */

    nwn_objid_t         eff_creator;            /* 18 */
    int32_t             eff_spellid;            /* 1C */

    uint32_t            eff_is_exposed;         /* 20 */
    uint32_t            eff_is_iconshown;       /* 24 */

    uint32_t            field_28;               /* 28 */

    uint32_t            eff_link_id1;           /* 2C */
    uint32_t            eff_link_id2;           /* 30 */

    uint32_t            eff_num_integers;       /* 34 */
    int32_t            *eff_integers;           /* 38 */

    float               eff_floats[4];          /* 3C */
    CExoString          eff_strings[6];         /* 40 */
    nwn_objid_t         eff_objects[4];         /* 44 */

    uint32_t            eff_skiponload;         /* 48 */
};



To set the EffectSpellID for the first effect applied to oPC:
Code:

string sPCAddress = NWNX_GetObjectPointer(oPC);
int iPCAddress = NWNX_HexToInt(sPCAddress);
   
string sEffectArray = NWNX_IntToHex(iPCAddress + 0xE8);
WriteTimestampedLogEntry("Effect Array Address: "+sEffectArray);
NWNX_SetPointer(sEffectArray); //pointing to Effects Array Address

int nFirstEffectAddress = NWNX_GetInt();
WriteTimestampedLogEntry("First Effect Address: "+NWNX_IntToHex(nFirstEffectAddress));
NWNX_SetPointer(NWNX_IntToHex(nFirstEffectAddress)); //pointing to first effect Address

int nFirstEffect = NWNX_GetInt();
NWNX_SetPointer(NWNX_IntToHex(nFirstEffect)); //pointing to start of first effect struct
WriteTimestampedLogEntry("Start of First Effect: "+NWNX_IntToHex(NWNX_GetInt()));

int iSpellId = nFirstEffect + 0x1C;
NWNX_SetPointer(NWNX_IntToHex(iSpellId)); //pointing to Spell ID

NWNX_SetInt(113); // setting new spell id (Mass Haste)    
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Sun Mar 14, 2010 19:57    Post subject: Reply with quote

Alright, I grabbed CNWSObject.h and CGameEffect.h and it seems to work quite nicely.

Code:

   else if (strcmp(Request, "PRINTEFFECT") == 0) {
      const CNWSObject *obj;
      const CGameEffect *eff;
      obj = (CNWSObject*)gameObject;
      Log("ID: %08X\n", obj->obj_id);
      Log("Eff: %08X\n", obj->obj_effects);
      int i=0;
      for (i=0; i< obj->obj_effects_len; i++) {
         eff = obj->obj_effects[i];
         if (eff == NULL) continue;
         Log("Eff_id [%i]: %08X\t", i, eff->eff_id);
         Log("Eff_Type [%i]: %08i\t", i, eff->eff_type);
         Log("Eff_creator[%i]: %08X\n",i , eff->eff_creator);
      }
   }


Unfortunately when the player this is ran on exits the game the server crashes with a memory access violation Sad
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sun Mar 14, 2010 22:42    Post subject: Reply with quote

MaxRock wrote:
I'm still trying to figure out if the number of effects is stored anywhere.


Code:
int NWNX_GetNumberOfEffect( object oObj ){

    int nAddr = NWNX_HexToInt( NWNX_GetObjectPointer( oObj ) )+236;
    NWNX_SetPointer( NWNX_IntToHex( nAddr ) );
    //A target always has 3 effects? Offset them away then
    return NWNX_GetInt( )-3;
}


I think that should do it, most array has the length of the array next bytes after the address to the instances. So the length is at offset 0xEC (236). I did some testing and my test subjects always had 3 effects without any effects applied. Could have been some bioware default things but I'm unsure hence the -3 offsetting.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Sun Mar 14, 2010 23:06    Post subject: Reply with quote

Terra_777 wrote:

I think that should do it, most array has the length of the array next bytes after the address to the instances. So the length is at offset 0xEC (236). I did some testing and my test subjects always had 3 effects without any effects applied. Could have been some bioware default things but I'm unsure hence the -3 offsetting.


That's indeed it.
Apparently there are some effects applied that aren't quite "regular" - Racial Type, for example, or Speed Increase and Vision for DMs - which are not returned by GetFirst-/GetNextEffect.

I got the crashes fixed by simply deleting the localstring Embarassed and with a few lines of code I can now change the effect creator and spell id; and I guess everything else defined in the effects struct.

Sorry for hijacking your thread by the way.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sun Mar 14, 2010 23:10    Post subject: Reply with quote

Its fine, I've been looking for ways to do that myself. Could I be so rude as to ask you to send the modified source to the mailaddress in my profile? Razz
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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