Nicolas Weeger wrote: > Hello. > > I've noticed some monsters don't use wands/rods/horns anymore. > Tracking the issue, I found some hints: > > * monster_check_apply, which is used when a just generated item is put > in monster inventory, will use manual_apply on the rod/wand/horn. Which > checks for skill, ie 'use magic item'. But sometimes the monster doesn't > have it yet (treasure list _after_ current one). > * even if the monster has it 'FLAG_CAN_USE_SKILL' is not set, so skill > can't be used. > * also, change_skill is called for monsters when applying item, thus > crash (who->contr == NULL) It may make sense to change the logic a bit - such that we don't set all the flags for the monster until after all the monsters treasure has been generated. That said, there is some amount of leftover cruft in terms of objects monsters can and can not use. With the body_info code, this can arguably be removed (at one point, the can_use flags were the only real way to tell that a monster had a arm for example). The only case where it may still show up is cases where a creature is 'humanoid' but not considered smart enough to use sophisticated items like wands or rods. > > > I attached a patch that enables monsters to fire their favorite > wand/horn/rod :) > > It's dirty, and probably has some redundance (like 'FLAG_APPLIED' is > set, but never really tested) I notice some code was lost, like checking the type of spell being fired and adjusting direction if it is a zero range spell. But at a quick glance, it looks OK, but probably should be thoroughly tested. > > Basically i grabbed the wand/rod firing code from > server/player.c:fire_misc_object( ), and pasted it in > server/monster.c:monster_use_range( ) to actually fire rod/bow. > > I think we should, at some point, use only one logic for players / > monsters when firing bow/range, and for skills/spells too. > Though java editor can't link between 'can use wands' flag and the 'use > magic item' skill which is required, so that isn't great. Probably using the same logic makes sense, except as mentioned above, if there are cases where a creature is deemed too stupid yet has a hand or whatever. But a lot of the problem may be that many monsters need to get updated treasurelists for the skills they do have. _______________________________________________ crossfire-devel mailing list crossfire-devel at lists.real-time.com https://mailman.real-time.com/mailman/listinfo/crossfire-devel