Hooking events from SDT/Loader (1 Viewer)

Churchill

Potential Patron
Joined
Jun 21, 2014
I'm using JPEXS to dissect both loader and sdt to see how things tick. My AS3 skill is a bit rusty so my learning curve is on a slight incline. I'm curious how one could hook into events such as catching when a character is loaded and determining which was loaded. Any kind souls willing to help a fella out?
 

Pim_gd

Content Creator
Joined
Jan 25, 2013
Code:
var lProxy = loader.lDOM.getDefinition("Modules.lProxy");
var onTriggerProxy:Object = lProxy.createProxy(g.dialogueControl, "checkWordAction");
onTriggerProxy.addPre(onTrigger, persist);

You'll want to proxy g.inGameMenu.characterMenu.select ... which can't be proxied.

Hmm.

I dunno, actually.
 

Churchill

Potential Patron
Joined
Jun 21, 2014
Thanks for the response, regardless. I wasn't certain a proxy would be the course fearing it would replace the source function instead of just hooking it. Still trying to brush up on the AS3 stuff. If it can't even be proxied then I suppose it is a moot point either way.

Perhaps there is a variable that could be evaluated to see if it changes?
 

stuntcock

Content Creator
Joined
Jun 5, 2012
Pim_gd said:
You'll want to proxy g.inGameMenu.characterMenu.select ... which can't be proxied.
Here's a partial solution - it works for custom characters, but it completely fails to fire when a vanilla character is loaded.

Code:
var loadData = (lProxy as Class).createProxy(g.inGameMenu, "loadData");
loadData.addPre(YOUR_METHOD_HERE, true);

Depending on your modding goals, you might be able to work around the limitation by creating a custom "clone" of each vanilla character. If you're looking for something which works with all characters then go ask ModGuy to beef up the lProxy stuff.
Churchill said:
I wasn't certain a proxy would be the course fearing it would replace the source function instead of just hooking it.
By default, it will hook without replacing. The lProxy technique is very useful and reliable -- once you get accustomed to it.
Perhaps there is a variable that could be evaluated to see if it changes?
I used that approach for my first mod ("check value on every frame; react if needed"). Terrible performance penalty, poor compatibility with other mods, and often inconsistent (or disruptive) to gameplay. Use proxies if possible.

One simple approach would be to proxy the hair-loading methods. A character may change her costume during a scene, but a new hairstyle usually means that the on-screen character has been replaced. If you keep track of the character name then you can easily reject/discard any special cases where the user switches between two hairstyle variants for the same character (or cases where the incoming character possesses a multi-part hairstyle, which could trigger your "reaction" code to execute several times).
  • customElementLoader.addDynamicHairMod
  • customElementLoader.hairLoaderComplete
 

Churchill

Potential Patron
Joined
Jun 21, 2014
Excellent information, thanks! My mod is an exploratory endeavor for the moment. It evaluates her hand positions against how deep she is on him, repositioning the hands if she is at a depth to interfere with handjob movement. THAT portion of it is evaluated by frame, not sure if there's a way around that.

All that position juggling can get messy, especially if a character is loaded AFTER a position is modified by the mod. I was hoping to hook into loading events to properly acknowledge when there are changes to the character.

I'll experiment some with what you've provided, it is a big help. Thanks again!
 

stuntcock

Content Creator
Joined
Jun 5, 2012
Churchill said:
It evaluates her hand positions against how deep she is on him, repositioning the hands if she is at a depth to interfere with handjob movement. THAT portion of it is evaluated by frame, not sure if there's a way around that.
My approach would be as follows:
  • attach a PRE function to g.her.leftArmIK.newTarget(...)
  • unhook the original function. Now, you'll have "veto" authority whenever she attempts to move her hands.
  • within your PRE function, apply your decision logic
    • if your code indicates that she's too close, then move her arm to a custom position (or invoke the Drop method if you just want to get the arm out of the way)
    • if your code indicates that she's at a safe distance, then invoke the original function with the arguments that you received (targetPoint, parent, forceMove)
    • if she's performing an unrelated change (e.g. switching from "arms on knees" to "arms behind back") then allow it as usual
  • do the same for g.her.rightArmIK
    • possible complication: what if there's enough room on the penis for one hand but not both?

Note: I've done only basic testing with this approach. It works (in terms of "vetoing hand movement") and it's presumably more efficient than a frame-by-frame loop. But there may be drawbacks or limitations that I haven't considered. I'm planning to do something vaguely similar with HIS hands, so I'll PM you if I find anything useful.

Of course, unhooking functions is tricky because you need to be mindful of Init and Reset. If your mod crashes (or gets unloaded) then you don't want to leave the game in a state where the girl is effectively paralyzed. But if this is just a proof-of-concept mod that you don't intend to release right away, then feel free to make risky edits. If you do eventually release your code, the senior devs tend to read it and they'll inform you about potential conflicts or improvements.
 

sby

Content Creator
Coder
Joined
Sep 11, 2012
looking around for how her name is determined, found
g.characterControl.currentName

you can try to proxy the function g.characterControl.loadStoredChar
public function loadStoredChar(param1:uint) : void
{
this.currentChar = param1 + g.baseCharNum;
g.inGameMenu.loadData(g.storedChars[param1].charData, true, true, g.storedChars[param1]);
this.currentName = g.storedChars[param1].charName;
g.dialogueControl.loadCustomDialogue(g.storedChars[param1].dialogue);
g.inGameMenu.updateCharMenu(param1, false, true);
return;
}// end function

i think i have had trouble in the past getting this one to work though. then again, that was in moreclothing loading mess
edit - this doesn't trigger on default vanilla chars
 

Churchill

Potential Patron
Joined
Jun 21, 2014
This is all coming together rather nicely now, it makes much more sense. I found the portion of the Dev Guide where it talks about proxies and pre/post functions. Ahem... pays to read the documentation, ehwhut?

I'll monitor the character composition as Sby recommends and use Stuntcock's idea to track arm movement by hooking newTarget() on both arms. Clever stuff, thanks for the assist! No doubt more questions will follow ;)
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.