temnix Posted August 30, 2019 Share Posted August 30, 2019 You know how NPC that are present in areas can have schedules? For example, the Nashkel Carnival empties after sundown, the next morning everyone reappears. That's very nice for the atmosphere, but entering NPC into ARE files as actors with all of the settings using Weidu is difficult and limits the number of NPC you can have in an area. Especially if you plan on doing something dynamic with NPC, like spawning them off-screen, quietly removing or replicating them, and so on. Here is a little script that you can insert somewhere in any creature's slot to make it appear and disappear at the right hours: IF TimeOfDay(NIGHT) Global("ACTIVE","LOCALS",1) THEN RESPONSE #100 SetGlobal("ACTIVE","LOCALS",0) Deactivate(Myself) END IF TimeOfDay(DAY) Global("ACTIVE","LOCALS",0) THEN RESPONSE #100 Activate(Myself) SetGlobal("ACTIVE","LOCALS",1) END Of course, you can be more specific with hours - simply use Time() instead. You can add other conditions, too. For example, do not reappear if the party's reputation is below a certain value. This will make towns desolate around a villainous party. Quote Link to comment
Ardanis Posted September 5, 2019 Share Posted September 5, 2019 Note that double caution needs to be exercised when employing Activate()/Deactivate()/IsActive() functionality. During SoD development it led with a significant margin in the number of caused issues, compared to any other scripting function. In particular, I would add this after those two blocks to ensure no further script action would accidentally trigger while the actor is inactive: IF Global("ACTIVE","LOCALS",0) THEN RESPONSE #100 NoAction() END Quote Link to comment
DavidW Posted September 6, 2019 Share Posted September 6, 2019 Those functions were a complete nightmare in IWD-in-BG2 too - IWD handles spawning by Activate()ing already-present NPCs, but trying to duplicate that using BG2 triggers/actions was a huge bugfest. After several iterations I gave up and wrote code to auto-map all the inactive creatures to be spawned by area script instead, and iirc that code made it into IWDEE too. Quote Link to comment
temnix Posted September 14, 2019 Author Share Posted September 14, 2019 On 9/6/2019 at 1:02 AM, Ardanis said: Note that double caution needs to be exercised when employing Activate()/Deactivate()/IsActive() functionality. During SoD development it led with a significant margin in the number of caused issues, compared to any other scripting function. In particular, I would add this after those two blocks to ensure no further script action would accidentally trigger while the actor is inactive: IF Global("ACTIVE","LOCALS",0) THEN RESPONSE #100 NoAction() END Thank you, I will. What I'm tussling with right now is that deactivated creatures still display visual effects attached to them. I don't know if effects can attach to them while they are deactivated - the whirling things from Confusion, for example, and so on, hopefully not. But if they had them before, those graphics will still hover. This is really only a problem for a specific area, where a lot of these are handed out, and I think I'm going to put a block in the area script so it dispels those for everyone as soon as night comes. I'm open to alternatives, though. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.