Jump to content

Party Script - HotKey Option


plainab

Recommended Posts

Okay, I'm wanting to build on the fly a hotkey option that allows any type of thief to find traps and remove traps. I've already got the script set up. What I need is a way to get the container and trap names. I know where to get the names and I've gotten them. However, there is no set length within the 32 char array. The null is not read except with the default of 8 char. So when I want to get a name longer than 8, I most of the time end up with a bunch of junk left over from who knows what following the name. I have tried reading in blocks of 8 char and then adding them together. It's a little cleaner, but there is still junk. With name length not being standard, I am at a loss with my current understanding.

 

Is there any way with weidu that I can get said names cleanly and without the extra junk?

Link to comment

Read the whole string and iterate through it by character until you hit a null. It won't be fast. Keep track of the number of loops 'n', and then re-READ_ASCII where what (n). Nythrun will be along shortly to post sample code.

 

I have to do this for correcting the flags in dialog.tlk (thanks for nothing, bigg) since fucking string regexp matching doesn't work AT ALL. As expected, iterating through every character of every string in the talk table searching for a retarded '<' is glacial (you can't even imagine).

 

There will be more Shaqtastic ways of doing this, but this should get you started. Maybe the bigg can code a READ_ASCII_NULL to read arbitrary-length null-terminated strings.

Link to comment

I don't actually know how, or if, RemoveTraps() works, so you'll mostly likely want to replace the rubbish this generates with a functional script - extra pointless street cred if you SPRINT your script actions and triggers to the "compiled" forms at runtime.

 

Shouldn't be as slow as all that, though no promises as to parsing (I'm sorry; very tired).

OUTER_PATCH ~this_is_not_a_variable~ BEGIN
 FOR ("i1" = 0x0; "i1" < 0x100; "i1" += 0x1) BEGIN
WRITE_BYTE 0x0 "i1"
READ_ASCII 0x0 ~c~ (0x1)
SPRINT EVALUATE_BUFFER ~0t%i1%~ ~%c%~
 END
END

OUTER_SPRINT ~trigger_list~   ~~

COPY_EXISTING_REGEXP GLOB ~^\(ar\|fw\)[0-9][0-9][0-9][0-9]\.are$~ ~override~
 PATCH_IF (SOURCE_SIZE > 0x11b) THEN BEGIN
READ_SHORT 0x5a "tc"
READ_LONG  0x5c "to"
READ_LONG  0x70 "co"
READ_SHORT 0x74 "cc"
READ_LONG  0xa4 "dc"
READ_LONG  0xa8 "do"
FOR ("i1" = 0x00; "i1" < ("tc" * 0xc4); "i1" += 0xc4) BEGIN
  SPRINT ~trigger~ ~~
  READ_SHORT ("to" + "i1" + 0x68) "trap_detect"
  READ_SHORT ("to" + "i1" + 0x6a) "trap_disarm"
  READ_SHORT ("to" + "i1" + 0x6c) "trapped"
  PATCH_IF (("trap_detect" < 0x64) AND ("trap_disarm" < 0x64) AND (("trapped" & 0x01) = 0x01)) THEN BEGIN
	FOR ("i2" = 0x00; "i2" < 0x20; "i2" += 0x01) BEGIN
	  READ_BYTE ("to" + "i1" + "i2") "char"
	  PATCH_IF		  (("char" = 0x00) AND ("i2" = 0x00)) THEN BEGIN
		SET "i2" = 0x20
	  END ELSE PATCH_IF (("char" = 0x00) AND ("i2" > 0x00)) THEN BEGIN
		READ_ASCII ("to" + "i1" + 0x00) ~trigger~ ("i2")
		SPRINT ~trigger_list~ ~%trigger_list%%0t10%IF%0t10%  HotKey(X)%0t10%  AreaCheck("%SOURCE_RES%")%0t10%  Detect("%trigger%")%0t10%THEN%0t10%  RESPONSE #100%0t10%	RemoveTraps("%trigger%")%0t10%END%0t10%~
		SET "i2" = 0x20
	  END
	END
  END
END
FOR ("i1" = 0x00; "i1" < ("cc" * 0xc0); "i1" += 0xc0) BEGIN
  SPRINT ~trigger~ ~~
  READ_SHORT ("co" + "i1" + 0x2c) "trap_detect"
  READ_SHORT ("co" + "i1" + 0x2e) "trap_disarm"
  READ_SHORT ("co" + "i1" + 0x30) "trapped"
  PATCH_IF (("trap_detect" < 0x64) AND ("trap_disarm" < 0x64) AND (("trapped" & 0x01) = 0x01)) THEN BEGIN
	FOR ("i2" = 0x00; "i2" < 0x20; "i2" += 0x01) BEGIN
	  READ_BYTE ("co" + "i1" + "i2") "char"
	  PATCH_IF		  (("char" = 0x00) AND ("i2" = 0x00)) THEN BEGIN
		SET "i2" = 0x20
	  END ELSE PATCH_IF (("char" = 0x00) AND ("i2" > 0x00)) THEN BEGIN
		READ_ASCII ("co" + "i1" + 0x00) ~trigger~ ("i2")
		SPRINT ~trigger_list~ ~%trigger_list%%0t10%IF%0t10%  HotKey(X)%0t10%  AreaCheck("%SOURCE_RES%")%0t10%  Detect("%trigger%")%0t10%THEN%0t10%  RESPONSE #100%0t10%	RemoveTraps("%trigger%")%0t10%END%0t10%~
		SET "i2" = 0x20
	  END
	END
  END
END
FOR ("i1" = 0x00; "i1" < ("dc" * 0xc8); "i1" += 0xc8) BEGIN
  SPRINT ~trigger~ ~~
  READ_SHORT ("do" + "i1" + 0x6c) "trap_detect"
  READ_SHORT ("do" + "i1" + 0x6e) "trap_disarm"
  READ_SHORT ("do" + "i1" + 0x70) "trapped"
  PATCH_IF (("trap_detect" < 0x64) AND ("trap_disarm" < 0x64) AND (("trapped" & 0x01) = 0x01)) THEN BEGIN
	FOR ("i2" = 0x00; "i2" < 0x20; "i2" += 0x01) BEGIN
	  READ_BYTE ("do" + "i1" + "i2") "char"
	  PATCH_IF		  (("char" = 0x00) AND ("i2" = 0x00)) THEN BEGIN
		SET "i2" = 0x20
	  END ELSE PATCH_IF (("char" = 0x00) AND ("i2" > 0x00)) THEN BEGIN
		READ_ASCII ("do" + "i1" + 0x00) ~trigger~ ("i2")
		SPRINT ~trigger_list~ ~%trigger_list%%0t10%IF%0t10%  HotKey(X)%0t10%  AreaCheck("%SOURCE_RES%")%0t10%  Detect("%trigger%")%0t10%THEN%0t10%  RESPONSE #100%0t10%	RemoveTraps("%trigger%")%0t10%END%0t10%~
		SET "i2" = 0x20
	  END
	END
  END
END
 END
BUT_ONLY

<<<<<<<<disarm.bcs
%trigger_list%
>>>>>>>>

COPY ~disarm.bcs~ ~override~
 EVALUATE_BUFFER
 COMPILE_BAF_TO_BCS

 

/edit

 

Erm, share, if you've more information how this action works :( ?

Link to comment

RemoveTraps() disables the "Is trapped?" value for a supported object type. The value needs to be yes for trap scripts (only scripts that check Entered() or Opened(); it's ignored elsewhere) and regions that should be detectable.

 

The normal behavior is that you detect and disarm the trap (setting the trapped value to 0) or spring the trap (running the Entered() or Opened() code and setting the trapped value to 0). Once the trapped value is off, the Entered() or Opened() code in the object script will never return true.

Link to comment

Thanks for the code Nythrun. With a little modification, I was able to add in my code and now I've got a working hotkey option for my script.

 

Thank you. You're in my readme. If anyone ever reads it. Oh, even if they don't I force a "readme in brief" (without any windows popping up) during the install process so everyone can see it!

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...