> How would one show a list of objects that had immunities on them.  IE
>
> Vnum   Immunity
> 1234     weapon
> 2345     magic
>
> Items that when worn you are immune from those attacks....
>
> Any ideas?  the code I attemted didnt want to work :P
>
> Thanks
>
> -K


I'm a little tired and haven't perused the ROM code in several months, but
this should be rather straightforward.

You're gonna want to have an OBJ_INDEX_DATA pointer and use it to loop
through all the objects read in from the area files. If memory serves me,
it's a hash table. So you'll either want to do something like loop through
the VNUMs calling some function to return a pointer to a given object
(slow - 0(n^2) probably if you are grabbing them based on VNUM) or loop
through the hash table manually (O(n) since you're ignoring order this
way).

Then it's just bit comparisons.  You should already have some function
able to spit out immunities for a given object in handler.c, since the
stat functions display such information now.  Either use this or modify it
to suit your needs. Or if you don't have one, just use the bitmask macros
defined in merc.h to check for immunities.

Having said that, unless you need to run this command in real time, I
would probably create a function like this that runs during bootup of the
mud and dumps the results to a CSV that I could parse or import into a
spreadsheet.  The reason I say that is the data won't change very often,
and the hash table isn't sorted to the best of my memory, so it'd be slow
to do it real time, especially on arbitrarily large data sets.  Also, if
you dump to a CSV you can do all kinds of sorting and filtering after the
fact in the program of your choice.

Potato.

Reply via email to