Jump to content


Photo

Revised Thievery addition - [IMPLEMENTED]


  • Please log in to reply
53 replies to this topic

#41 Taimon

Taimon
  • Member
  • 387 posts

Posted 23 May 2009 - 04:24 AM

(not included in that, right?)

Yep.

Gone are the days when "hardc0ded" = "can't be done" :woot:.

Don't overestimate my abilities. Doing those things takes time and it clearly is limited to changing very specific (and easy to find) stuff.

Also note that executable patching should be done with care and isn't an option in every "environment". Virus scanners and other protection programs might interfere. The users should be aware that the mod is modifying the exe.

And all those offsets are only valid for the patched ToB executable. I don't think I will do those patches for anything else.

#42 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 23 May 2009 - 07:47 AM

Also note that executable patching should be done with care and isn't an option in every "environment". Virus scanners and other protection programs might interfere. The users should be aware that the mod is modifying the exe.

Right, right. The usual disclaimers should go in the readme I suppose, with a redirect to RTFM if someone messes something up. :lol:

And all those offsets are only valid for the patched ToB executable. I don't think I will do those patches for anything else.

Yeah. Well that should cover at least 95% of the games these days (including Tutu and BGT). It should be possible to do it in theory for SoA but I don't think it's worth it unless enough people complain...

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#43 aVENGER

aVENGER
  • Modder
  • 1680 posts

Posted 24 May 2009 - 02:26 AM

It also worked as intended for me.


It seems I spoke too soon.

For some reason, the game crashes on me whenever a visible character fails a pickpocket attempt. OTOH, if the character is invisible everything works as intended. Can you guys reproduce this?

#44 Taimon

Taimon
  • Member
  • 387 posts

Posted 24 May 2009 - 07:03 AM

Yeah, I can. Nullpointer dereference. :(

Try replacing the previous patch_part2 with this:
OUTER_PATCH_SAVE patch_part2 "" BEGIN
	INSERT_BYTES 0x00 len_part2
	WRITE_LONG   0x00 0x8b51006a
	WRITE_LONG   0x04 0xb773cc0d
	WRITE_LONG   0x08 0x48c18100
	WRITE_LONG   0x0c 0xe800006c
	WRITE_LONG   0x10 0xffc75947
	WRITE_LONG   0x14 0xff10958b
	WRITE_LONG   0x18 0x1a8bffff
	WRITE_LONG   0x1c 0x1874db85
	WRITE_LONG   0x20 0x90909090
	WRITE_LONG   0x24 0x8b52006a
	WRITE_LONG   0x28 0xb773cc0d
	WRITE_LONG   0x2c 0x48c18100
	WRITE_LONG   0x30 0xe800006c
	WRITE_LONG   0x34 0xffc75923
	WRITE_LONG   0x38 0xfd448d8b
	WRITE_LONG   0x3c 0x118bffff
	WRITE_LONG   0x40 0x8a1052ff
END
Not the cleanest solution but hopefully it will work.

#45 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 26 May 2009 - 12:33 PM

Try replacing the previous patch_part2 with this

So did this work or do you need someone else to test it?

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#46 Taimon

Taimon
  • Member
  • 387 posts

Posted 26 May 2009 - 09:19 PM

It worked for me, but you should test it as well.

#47 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 28 May 2009 - 10:50 AM

It worked for me, but you should test it as well.

Ok, it seemed to work properly - tested invis fail/vis fail/invis succeed/vis succeed, all with PickPocketFailed() trigger.

Why isn't it the cleanest solution?

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#48 Taimon

Taimon
  • Member
  • 387 posts

Posted 28 May 2009 - 11:32 AM

Because it relies on the fact that a certain pointer is zero when you are not invisible and I don't know if this is necessarily true in all cases.

#49 aVENGER

aVENGER
  • Modder
  • 1680 posts

Posted 30 May 2009 - 03:49 AM

Because it relies on the fact that a certain pointer is zero when you are not invisible and I don't know if this is necessarily true in all cases.


It appears to be working properly now but, for safety reasons, I think I'll just use the part which restores the PickPocketFailed() trigger in RR.

#50 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 30 May 2009 - 05:15 PM

It appears to be working properly now but, for safety reasons, I think I'll just use the part which restores the PickPocketFailed() trigger in RR.

Well you could put the "pickpocketing success does not break invisibility" in an optional beta component with the proper warnings (as the BG2 Fixpack does for new fixes) so folks who want to can test it further. For that matter, you could "dialogue for failed pickpocketing attempts" optional too, for those who are edgy about any sort of .exe patch.

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#51 aVENGER

aVENGER
  • Modder
  • 1680 posts

Posted 30 May 2009 - 10:45 PM

FYI, I've made some minor changes to the anti-pickpocket script:

IF
	PickPocketFailed([PC])
	Allegiance(Myself,NEUTRAL)
	General(Myself,HUMANOID)
	!StateCheck(Myself,CD_STATE_NOTVALID)
	See(LastTrigger)
	!Allegiance(LastTrigger,FAMILIAR)
THEN
	RESPONSE #100
		StartDialogOverride("RR#PICKP",LastTrigger)
END

IF
	PickPocketFailed([FAMILIAR])
	Allegiance(Myself,NEUTRAL)
	General(Myself,HUMANOID)
	!StateCheck(Myself,CD_STATE_NOTVALID)
	See(LastTrigger)
THEN
	RESPONSE #100
		SetInterrupt(FALSE)
		FaceObject(LastTrigger)
		DisplayStringHead(Myself,@9203) // Get away from me you filthy creature!
		SetSequence(SEQ_ATTACK)
		ActionOverride(LastTrigger,MakeUnselectable(12))
		ActionOverride(LastTrigger,RandomWalkContinuous())
		SetInterrupt(TRUE)
END

Basically, I wanted to take into account familiars who can pick pockets and make a special response in that case. So, if a familiar fails a pickpocket check against a non-hostile NPC it will be reprimanded (via cosmetic swing, no actual damage will be dealt) which will make it run around in panic for a while. Anyway, the in-game results are fairly hilarious. :D

I've also excluded charbase.cre, RR's creatures and joinable NPCs from having their scripts patched:

// Taimon and Miloch's EXE patch for re-enabling the PickPocketFailed() trigger

COPY "bgmain.exe" "bgmain.exe"
	PATCH_IF ((LONG_AT 0x5437B2) == 0xAA5E6C) THEN BEGIN
		WRITE_LONG 0x5437B2 0xAA5F22
	END ELSE PATCH_PRINT "Target bytes don't match. Aborting..."
BUT_ONLY_IF_IT_CHANGES

COMPILE ~RR/RR_CORE/COMPILE/RR#PICKP.BAF~										  // compile the new anti-pickpocketing script
COMPILE ~RR/RR_CORE/COMPILE/RR#PICKP.D~											// RR's new pickpocket related dialogue


// Extend creature scripts

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~								   // parse through all creatures in the game
PATCH_IF (%SOURCE_SIZE% > 0x2d3) THEN BEGIN										// file size sanity check (filters out 0 byte files i.e. ALLOW_MISSING)
READ_ASCII 0x248 "ovrscript"
READ_BYTE  0x270 "allegiance"
READ_BYTE  0x271 "general"
READ_ASCII 0x280 "deathvar"
 PATCH_IF (%allegiance% = "128" AND %general% = "1") BEGIN						 // only patch non-hostile humanoid creatures
  PATCH_IF ("%SOURCE_RES%" STRING_CONTAINS_REGEXP ~RR#~ = 1) BEGIN				 // don't patch files prefixed with the designated strings (i.e. skip RR's own creatures)
   PATCH_IF (~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~ = 0) AND (NOT FILE_CONTAINS_EVALUATED (~pdialog.2da~ ~%deathvar%~)) BEGIN // exclude CHARBASE.CRE and joinable NPCs
	PATCH_IF NOT FILE_EXISTS_IN_GAME ~%ovrscript%.bcs~ THEN BEGIN				  // if the override script doesn't exist
	 WRITE_ASCII 0x248 ~RR#PICKP~ #8											   // assign RR#PICKP.BCS as the new override script
	END ELSE
	   INNER_ACTION BEGIN
		ACTION_IF FILE_EXISTS_IN_GAME ~%ovrscript%.bcs~ AND (NOT FILE_CONTAINS_EVALUATED (~%ovrscript%.bcs~ ~RR#PICKP~)) AND ("%ovrscript%" STRING_CONTAINS_REGEXP ~RR#~ = 1) BEGIN
		EXTEND_TOP ~%ovrscript%.bcs~ ~RR/RR_CORE/COMPILE/RR#PICKP.BAF~			 // otherwise just extend the script unless it was already done
		END																		// ends ACTION_IF check which prevents extending the same script multiple times
	   END																		 // ends inner action
   END																			 // ends charbase and joinable NPC check
  END																			  // ends prefix check
 END																			   // ends allegiance and general check
END																				// end file size sanity check
BUT_ONLY_IF_IT_CHANGES

Edited by aVENGER, 31 May 2009 - 03:56 AM.


#52 Miloch

Miloch

    Barbarian

  • Modder
  • 6573 posts

Posted 31 May 2009 - 10:13 PM

Cool. I suppose there's nothing stopping someone from using a familiar to keep picking someone's pocket after failed attempts as long as they're willing to wait around a while, but I've never even tried that, so I don't know how practical it is.

Just one thing - if the .exe patch fails (for SoA or an unpatched game perhaps) there's no reason to run that regexp to patch the CRE scripts. So you might want to nest that in the success loop and do a FAIL ~message~ instead of PATCH_PRINT ~message~ so that the component doesn't even install, assuming you're making it a separate component.

No need to credit me on the patch - Taimon did all the work. Not that he requires credit either apparently, but he deserves it :).

Infinity Engine Contributions
Aurora * BG1 NPC * BG1 Fixpack * Haiass * Infinity Animations * Level 1 NPCs * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * BG:EE * BGII:EE * IWD:EE
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * Creature Checker * Creature Fixer * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Infinity turns out to be the opposite of what people say it is. It is not 'that which has nothing beyond itself' that is infinite, but 'that which always has something beyond itself'." -Aristotle


#53 Elve

Elve
  • Member
  • 11 posts

Posted 03 August 2009 - 06:58 AM

Yeah, I can. Nullpointer dereference. :(

Try replacing the previous patch_part2 with this:

OUTER_PATCH_SAVE patch_part2 "" BEGIN
	INSERT_BYTES 0x00 len_part2
	WRITE_LONG   0x00 0x8b51006a
	WRITE_LONG   0x04 0xb773cc0d
	WRITE_LONG   0x08 0x48c18100
	WRITE_LONG   0x0c 0xe800006c
	WRITE_LONG   0x10 0xffc75947
	WRITE_LONG   0x14 0xff10958b
	WRITE_LONG   0x18 0x1a8bffff
	WRITE_LONG   0x1c 0x1874db85
	WRITE_LONG   0x20 0x90909090
	WRITE_LONG   0x24 0x8b52006a
	WRITE_LONG   0x28 0xb773cc0d
	WRITE_LONG   0x2c 0x48c18100
	WRITE_LONG   0x30 0xe800006c
	WRITE_LONG   0x34 0xffc75923
	WRITE_LONG   0x38 0xfd448d8b
	WRITE_LONG   0x3c 0x118bffff
	WRITE_LONG   0x40 0x8a1052ff
END
Not the cleanest solution but hopefully it will work.


still seems to crash with me...

Visible: Try pickpocket -> fail -> crash
Invisible: Try pickpocket -> fail -> dialog -> visible -> fail -> dialog

#54 aVENGER

aVENGER
  • Modder
  • 1680 posts

Posted 03 August 2009 - 07:54 AM

still seems to crash with me...

Visible: Try pickpocket -> fail -> crash
Invisible: Try pickpocket -> fail -> dialog -> visible -> fail -> dialog


Just for reference, I didn't incorporate that part of Taimon's patch into Rogue Rebalancing. I only used the part which restores the PickPocketFailed() trigger.

Therefore, it might be better to report issues which are related to the visibility patch in the appropriate G3 thread.