Jump to content

How to Make an Object Detect Multiple NPCs?


user826

Recommended Posts

Hey, all. I tried Googling this first but I couldn't find anything (maybe I'm just not using the right keywords) so I'm hoping someone here can help me. Anyway, is there a function that can detect if any NPC is using an object? For instance, is there some way for a chair to detect if anyone is sitting on it, not just a single actor ID reference? I know of the IsCurrentFurnitureRef and IsCurrentFurnitureObj functions, but these only detect a single actor. How can I, for example, make a booby-trapped chair that explodes as soon as anyone sits in it? Thanks for any help you can give me!

Link to comment
Share on other sites

That's one way, but if I want the chair to use the Pants Exploded method and deposit a live grenade into the inventory of the NPC, is there a way to do so, like:

 

begin OnActivate

if [**AnyNPC**].IsCurrentFurnitureRef TotallyNormalChairREF == 1
   ;Add a live grenade to [**AnyNPC**]'s inventory
endif

end
Or, if I want to attach the script on a couch, and only run it if two or more NPCs are sitting on the couch? Edited by user826
Link to comment
Share on other sites

mmmh... Why that last "Activate"? didn't you want to make them explode?

 

(A couple of things, which are more for your curiosity: the b in front of the Occupied variable should be an i, you are admitting at least 3 values so it's not a boolean-it's just to make things easier when you need to read a script you wrote the month before and you're not remembering parts; the Return in that spot is unuseful - in bigger scripts, using too many Returns could lead me to not see issues when something doesn't work as intended, so I personally tend to not use them if they are not necessary)

Edited by Fallout2AM
Link to comment
Share on other sites

Heh, you can probably tell I'm not much of a scripter and that I mostly just copy/paste from pre-existing code. Most of the stuff you pointed out is just me imitating what worked in other scripts I found.

 

As for the "Activate", I'd replace that with the exploding code, once I've found/written it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...