Log in

View Full Version : Simplest function to detect enemy creatures in the room?



aramund
05-15-2019, 12:45 AM
Any suggestions, or code, are appreciated.

I've looked through bigshot a bit and it looks like I can obtain a NPC list for the room? Does that seem right? If I cycle through that list, is there a way to determine if an element is an offensive creature without comparing it to a list of target creatures?

Tgo01
05-15-2019, 12:47 AM
You can use aggressive type to look for critters that are aggressive.

So you could do:

target = GameObj.npcs.find { |npc| (npc.status !~ /dead/) && (npc.type =~ /aggressive/) }

Which would set the variable "target" to be a critter in the room that isn't dead and also aggressive, this way you don't target a Ranger's companion or a Wizard's familiar.

aramund
05-15-2019, 07:37 PM
Perfect. Thanks!