&ISCARRIED
Moderator: Zyx
Forum rules
Please read the Forum rules and policies before posting.
Please read the Forum rules and policies before posting.
&ISCARRIED
I'd need a function like &ISCARRIED (char# ID_item TYPE_item)
that would return how many targeted items are carried by a character, including chest's content.
char#: 0-3 to choose one of the character, 4 for the leader, 5 for the whole party
ID_item: if non-zero, look for a specific item
TYPE_item: if non-zero, scan for a type of item. The return value may thus be greater than 1.
that would return how many targeted items are carried by a character, including chest's content.
char#: 0-3 to choose one of the character, 4 for the leader, 5 for the whole party
ID_item: if non-zero, look for a specific item
TYPE_item: if non-zero, scan for a type of item. The return value may thus be greater than 1.
- Paul Stevens
- CSBwin Guru
- Posts: 4319
- Joined: Sun Apr 08, 2001 6:00 pm
- Location: Madison, Wisconsin, USA
How about this:
Searches a character's inventory. The search is
recursive. That is chests are searched and any
monsters found in the chests are searched and
any possessions of those monsters are searched, etc.
The search includes the cursor if the leader is
included in the search.
char#: 0-3 to choose one of the character, 4 for the leader, 5 for the whole party
Non-negative ID is the identifier for a particular object.
For example, a particular apple....the one found
in the northern corner of the supplies area.
If ID is non-negative then the return value is
-1 or the character number and the location on
that character where the item is carried. These
are encoded as 256*char + pos. If the object is
found in the cursor then the position is 255.
If ID is negative then it represents an object type.
For examplem any apple. The return value is the
number of items of type -ID being carried by that
character.
See "enum OBJECTTYPE" and
"BODY POSITIONS" at:
http://www.dianneandpaul.net/CSBwin/doc ... tants.html
Code: Select all
&ISCARRIED ( CHAR# ID . . . num )
Searches a character's inventory. The search is
recursive. That is chests are searched and any
monsters found in the chests are searched and
any possessions of those monsters are searched, etc.
The search includes the cursor if the leader is
included in the search.
char#: 0-3 to choose one of the character, 4 for the leader, 5 for the whole party
Non-negative ID is the identifier for a particular object.
For example, a particular apple....the one found
in the northern corner of the supplies area.
If ID is non-negative then the return value is
-1 or the character number and the location on
that character where the item is carried. These
are encoded as 256*char + pos. If the object is
found in the cursor then the position is 255.
If ID is negative then it represents an object type.
For examplem any apple. The return value is the
number of items of type -ID being carried by that
character.
See "enum OBJECTTYPE" and
"BODY POSITIONS" at:
http://www.dianneandpaul.net/CSBwin/doc ... tants.html
Last edited by Paul Stevens on Tue Jul 10, 2007 2:40 pm, edited 1 time in total.
- Paul Stevens
- CSBwin Guru
- Posts: 4319
- Joined: Sun Apr 08, 2001 6:00 pm
- Location: Madison, Wisconsin, USA
&ISCARRIED L5 L-50002 L0 L1 L0||1
would that look if the whole party (5) carries a torch (negative ID num 2 /torch/ + 50000 /weapontype/) either in left or right hand (0||1) ?
would that look if the whole party (5) carries a torch (negative ID num 2 /torch/ + 50000 /weapontype/) either in left or right hand (0||1) ?
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
- Paul Stevens
- CSBwin Guru
- Posts: 4319
- Joined: Sun Apr 08, 2001 6:00 pm
- Location: Madison, Wisconsin, USA
THere appears to be a lot of confusion in your
example.
&ISCARRIED needs two parameters. You provided
none. Perhaps you meant to put the 'L5' before
the '&ISCARRIED'.
L5 &ISCARRIED L-50002 L0 L1 L0||1
The '5' is to search the entire party.
Now we are only one parameter short.
You meant the 'L-50002' to be the type
so let us move that before the '&ISCARRIED'.
L5 L-50002 &ISCARRIED L0 L1 L0||1
You mention torches. If you look at the
'enum OBJECTTYPE' in the documentation
as noted above, you will see that torches
have types:
What the documentation does not say is that
when there are several options (such as for
torches) only the first is useful. It is what the
code refers to as the 'basic object type'. All
others are converted to this 'basic' type' for the
purposes of '&ISCARRIED'. So you can only
determine if a torch is carried, not whether a
particular type of torch is carried. So let us use
'torch' as the object type in your example.
L5 L-4 &ISCARRIED L0 L1 L0||1
Of course, th 'L-4' will not work. But we
can put a positiv number there and negate it.
L5 L4 &NEG &ISCARRIED L0 L1 L0||1
After the '&ISCARRIED' The stack will contain
the number of torches carried by the party.
It appears that you wanted to determine whether
the torches were in the hands of the characters
rather than in, for example, the backpacks. But,
as the discussion above reveals, when you ask
about a general class of objects (torches, screamer
slices, daggers, etc., for example), the function
returns the number of such objects. It does not
provide the location of those objects. And, if you
think about it, how could it -- since there could be
dozens of the objects in various locations. So, whatever
your code was intended to accomplish, it cannot
determine if the torches were in the character's
hands by using this method.
I think you had better simply look in each
character's two hands to see if there is a torch
there. That is only 8 very quick operations
every couple of seconds and will not contribute
much overhead.
Another problem that you may have overlooked:
What if the torch is in a chest and the chest is
in the character's hand. '&ISCARRIED' will report
the position of the torch as the character's hand.
example.
&ISCARRIED needs two parameters. You provided
none. Perhaps you meant to put the 'L5' before
the '&ISCARRIED'.
L5 &ISCARRIED L-50002 L0 L1 L0||1
The '5' is to search the entire party.
Now we are only one parameter short.
You meant the 'L-50002' to be the type
so let us move that before the '&ISCARRIED'.
L5 L-50002 &ISCARRIED L0 L1 L0||1
You mention torches. If you look at the
'enum OBJECTTYPE' in the documentation
as noted above, you will see that torches
have types:
Code: Select all
obj_Torch_a, //4 4
obj_Torch_b, //5 5
obj_Torch_c, //6 6
obj_Torch_d, //7 7
when there are several options (such as for
torches) only the first is useful. It is what the
code refers to as the 'basic object type'. All
others are converted to this 'basic' type' for the
purposes of '&ISCARRIED'. So you can only
determine if a torch is carried, not whether a
particular type of torch is carried. So let us use
'torch' as the object type in your example.
L5 L-4 &ISCARRIED L0 L1 L0||1
Of course, th 'L-4' will not work. But we
can put a positiv number there and negate it.
L5 L4 &NEG &ISCARRIED L0 L1 L0||1
After the '&ISCARRIED' The stack will contain
the number of torches carried by the party.
It appears that you wanted to determine whether
the torches were in the hands of the characters
rather than in, for example, the backpacks. But,
as the discussion above reveals, when you ask
about a general class of objects (torches, screamer
slices, daggers, etc., for example), the function
returns the number of such objects. It does not
provide the location of those objects. And, if you
think about it, how could it -- since there could be
dozens of the objects in various locations. So, whatever
your code was intended to accomplish, it cannot
determine if the torches were in the character's
hands by using this method.
I think you had better simply look in each
character's two hands to see if there is a torch
there. That is only 8 very quick operations
every couple of seconds and will not contribute
much overhead.
Another problem that you may have overlooked:
What if the torch is in a chest and the chest is
in the character's hand. '&ISCARRIED' will report
the position of the torch as the character's hand.
- Paul Stevens
- CSBwin Guru
- Posts: 4319
- Joined: Sun Apr 08, 2001 6:00 pm
- Location: Madison, Wisconsin, USA
whoops! I`m learning DSAs very slowly, sorry for the confusion!
it seems &CHPOSS looks for object ID, not for the object type in general..
can I use enumOBJECTTYPE value like this:
L0 L0 &CHPOSS L4
L0 L1 &CHPOSS L4
L1 L0 &CHPOSS L4
...etc ?
ooh, I just realized Zyx wanted to know the number of items of one type carried by a character..! My goal is to get know if the character carries object X on location Y (here: search handL and handR positions for the torches).. It seems I missunderstood a &ISCARRIED function a bit..how many targeted items are carried by a character
so the &ISCARRIED woundn`t fit here?I think you had better simply look in each
character's two hands to see if there is a torch
there. That is only 8 very quick operations
every couple of seconds and will not contribute
much overhead.
it seems &CHPOSS looks for object ID, not for the object type in general..
Code: Select all
&CHPOSS(<char num> <index> ...<objectID>)
<char num> = 0 to 3; <index = 0 to 29>
<char num> == 4 means 'Active Character'
<char num> == -1 means object in cursor
L0 L0 &CHPOSS L4
L0 L1 &CHPOSS L4
L1 L0 &CHPOSS L4
...etc ?
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
- Paul Stevens
- CSBwin Guru
- Posts: 4319
- Joined: Sun Apr 08, 2001 6:00 pm
- Location: Madison, Wisconsin, USA