Jump to content

point me to a mod that does this


phordicus

Recommended Posts

my intent is to make item type A make item type B unequippable (and vice versa but ignore that part for now unless it's obligatorily inclusive).

i've got the block that lets me do all A's for an individual B by setting the ascii at 0x14.

i need to insert whatever code will let me scan through all items, see if it's item type B, read its filename, and have that filename subbed in the ascii write.

i can post the code i have if this isn't making sense.

thanks.

 

[edit]

it just occurred to me i might be able to make an eff that forbids all B's and have that applied as an equipping effect.

[edit2]

nope, nevermind. eff can only forbid one at a time. i thought i might be able to use the IDS-General "shield" as the resource.

Link to comment
my intent is to make item type A make item type B unequippable (and vice versa but ignore that part for now unless it's obligatorily inclusive).

i've got the block that lets me do all A's for an individual B by setting the ascii at 0x14.

i need to insert whatever code will let me scan through all items, see if it's item type B, read its filename, and have that filename subbed in the ascii write.

i can post the code i have if this isn't making sense.

thanks.

You want something like an array of all items of type B?

ACTION_CLEAR_ARRAY b_items

COPY_EXISTING_REGEXP GLOB ~.+\.itm~ ~override~
 PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
PATCH_IF (SHORT_AT 0x1c == 0x03) BEGIN // b is for belts
  SET $b_items(~%SOURCE_RES%~) = 1
END
 END
 BUT_ONLY

ACTION_PHP_EACH b_items AS item => val BEGIN // iterate through items
 PRINT ~%item%~
END

Link to comment

i can't comment because i have no idea what ACTION_PHP_EACH does or at least where its references are.

 

here's what i've got so far. let's say i want people that wear any amulet to not be able to use any dagger.

 

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~				// read all items

PATCH_IF (SOURCE_SIZE > 0x71) BEGIN							// avoid invalid files
 READ_SHORT 0x1C type											// read item type
 PATCH_IF (type = 0x01) BEGIN									// is it an amulet
  READ_LONG 0x6a effoff										// read equipped effects offset
  READ_SHORT 0x70 effnum										// read equipped effects number
INSERT_BYTES effoff 0x30									// add new equipped effect (effects are 0x30 long)
WRITE_SHORT (0x00 + effoff) 180								// opcode - disallow item
WRITE_BYTE (0x02 + effoff) 1								// target
WRITE_BYTE (0x0c + effoff) 2								// timing mode
WRITE_BYTE (0x0d + effoff) 2								// resistance
WRITE_BYTE (0x12 + effoff) 100								// prob 1
WRITE_ASCII (0x14 + effoff) ~dagg01~						// resource
SET effnum = (effnum + 1)									// increment number of effects by 1
WRITE_SHORT 0x70 effnum
  END
 END
BUT_ONLY_IF_IT_CHANGES

 

all this does is prevent using the one dagg01. i want to be able to cycle through all ITMs marked as a dagger (0x10) inserted into that WRITE_ASCII resource.

Link to comment
i can't comment because i have no idea what ACTION_PHP_EACH does or at least where its references are.

http://www.weidu.org/~thebigg/README-WeiDU.html#PHP_EACH

 

It's a way to loop through an array. In this case, we add each qualifying item to an array [sET $amulets(~%SOURCE_RES%~) = 1], with the key set to the resource name of the item. We later loop through the array [ACTION_PHP_EACH amulets AS amulet => proper_amulet BEGIN], so for each item we added, the code will execute once with %amulet% containing the resource name of that item.

 

I tried to code up what you requested, switching to the built-in ADD_ITEM_EQEFFECT function and SHORT_AT to simplify the code. When you classify by item type, you're likely to get a few false positives or unused items in your list. Since you're using arrays, it's easy to exclude or include items.

 

ACTION_CLEAR_ARRAY amulets
ACTION_CLEAR_ARRAY daggers

// make a list of all amulets and daggers
COPY_EXISTING_REGEXP GLOB ~.+\.itm~ ~override~
 PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
PATCH_IF (SHORT_AT 0x1c == 0x01) BEGIN // item type is amulet
  TO_LOWER SOURCE_RES
  SET $amulets(~%SOURCE_RES%~) = 1
END
ELSE PATCH_IF (SHORT_AT 0x1c == 0x10) BEGIN // item type is dagger
  TO_LOWER SOURCE_RES
  SET $daggers(~%SOURCE_RES%~) = 1
END
 END
 BUT_ONLY

// remove false positives from the list
ACTION_FOR_EACH amulet IN antiweb cambion finmel01 goboom goboom2 goboom3 gopoof gorchr iceregen immcloud ipsion mageamul mglobe minhp1 minhp20 minhp60 monhp01 monhp1 monhp20 monhp80 poo ravag03 reghp2r seltest sengua04 sleep slimed1 spec01 stonskin tstatue wallpass BEGIN
 OUTER_SET $amulets(~%amulet%~) = 0
END
ACTION_FOR_EACH dagger IN daggshit sw1h13 BEGIN
 OUTER_SET $daggers(~%dagger%~) = 0
END

// patch each amulet to disallow all daggers
ACTION_PHP_EACH amulets AS amulet => proper_amulet BEGIN // for each amulet
 ACTION_IF (proper_amulet == 1) BEGIN // verify that we think this is actually an amulet
COPY_EXISTING ~%amulet%.itm~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
	PHP_EACH daggers AS dagger => proper_dagger BEGIN // for each dagger
	  PATCH_IF (proper_dagger == 1) BEGIN // verify that we think this is actually a dagger
		LAUNCH_PATCH_FUNCTION ~ADD_ITEM_EQEFFECT~ // add Disallow Item effect
		  INT_VAR opcode = 180 target = 1 timing = 2 resist_dispel = 2
		  STR_VAR resource = EVAL ~%dagger%~
		END
	  END
	END
  END
  BUT_ONLY
 END
END

// patch each dagger to disallow all amulets
ACTION_PHP_EACH daggers AS dagger => proper_dagger BEGIN // for each amulet
 ACTION_IF (proper_dagger == 1) BEGIN // verify that we think this is actually a dagger
COPY_EXISTING ~%dagger%.itm~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
	PHP_EACH amulets AS amulet => proper_amulet BEGIN // for each amulet
	  PATCH_IF (proper_amulet == 1) BEGIN // verify that we think this is actually an amulet
		LAUNCH_PATCH_FUNCTION ~ADD_ITEM_EQEFFECT~ // add Disallow Item effect
		  INT_VAR opcode = 180 target = 1 timing = 2 resist_dispel = 2
		  STR_VAR resource = EVAL ~%amulet%~
		END
	  END
	END
  END
  BUT_ONLY
 END
END

Note that players can still abuse the engine's Quick Weapon slots to switch to a weapon that's become unusable in the time since they equipped it.

Link to comment

groovy. the last programming i did was BASIC in 1983 so weidu is essentially still a foreign language for me and i'm sure my code is the IE equivalent of "where are the water closets?". it makes perfect sense if i see it in use. one of the most confusing things is figuring out if a particular word is part of the syntax or just an arbitrary variable name. i knew this was going to involve setting an array but i had no idea what or where. it also didn't help that i haven't updated my weidu docs in 6+ months. thanks.

[edit]

if there were no false positives to remove, would we still need to use ACTION_PHP_EACH since all the items in the array would be flagged 1 as valid?

wow, and how much better/easier it is with ADD_ITEM_EQEFFECT. i shoulda updated my docs sooner.

Link to comment
groovy. the last programming i did was BASIC in 1983 so weidu is essentially still a foreign language for me and i'm sure my code is the IE equivalent of "where are the water closets?". it makes perfect sense if i see it in use. one of the most confusing things is figuring out if a particular word is part of the syntax or just an arbitrary variable name. i knew this was going to involve setting an array but i had no idea what or where. it also didn't help that i haven't updated my weidu docs in 6+ months. thanks.

There's nothing wrong with your code if you're trying to add a single ability, though ADD_ITEM_EQEFFECT accomplishes the same thing with less effort. It's difficult to learn WeiDU best practices when many of the mods you look to for inspiration contain code that's outrageously out of date. I replied to this topic because WeiDU's array functionality is relatively new and familiarity with them can help with a variety of tasks.

 

if there were no false positives to remove, would we still need to use ACTION_PHP_EACH since all the items in the array would be flagged 1 as valid?

wow, and how much better/easier it is with ADD_ITEM_EQEFFECT. i shoulda updated my docs sooner.

If we didn't need to rule out false positives, the check to determine if proper_amulet/proper_dagger is set to 1 could be removed.

Link to comment

Archived

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

×
×
  • Create New...