Nihilisaurus Posted June 16, 2012 Share Posted June 16, 2012 (edited) [edit] Issue resolved. Cheers for the help, guys.[edit] So I've embarked on a slightly mad quest to 'fix' all the settlements in DC - using 'Best of Both Wastelands' - so they satisfy my beloved immersion, I've started with Tenpenny Tower, and want to write a script that will cause the gates to open for a certain subset of residents, and close behind them again. Getting the NPCs to go along with this is easy enough, due to the fact the navmesh extends under the gate by default, they'll simply run against it if told to pass through whilst it's closed. The scripts; however, are not so obliging. I want to create an OnTriggerEnter script box (Actually 2, but that'll be explained later) that will open the gate (set the 'open the gate' variable to 1 when there are NPCs of a specific faction - call it "TenpennyGateFaction" - inside the script box, which would cover both sides of the gate with enough space an npc could trigger the gate, walk through it and then close it behind them (when there are no TenpennyGateFaction members in the box, set 'open the gate' to 0). Here's the script I'm starting with, " set TenpennyGateRef.openGate to 1" is how the vanilla game opens the gate. This is just an 'emergency' script that opens the gate from the outside and lets any residents that managed (through sheer idiocy, one presumes) to get outside back in, rather than have them cluster in a pile of uselessness in front of the gate until the player opens it. scn TenpennyLetMeBackInIAmAnIdiot ref NPC begin OnTriggerEnter set NPC to GetActionRef if NPC.Getinfaction TenpennyResidentFaction == 1 set TenpennyGateRef.openGate to 1 endif end Cipscis Script checker pulls up nothing wrong with that, but there has to be something otherwise the GECK would let it compile. I think it's probably how I'm using the GetActionRef, as I've not come across it before. The next problem is how to check if there are no possible gate users in the box, as just checking for npcs not in the faction would return 0 if any of the other residents happened to be in the script box. The other option is to record the references of each npc that will use the gate, and check if they're within a certain distance of it, though depending on the number of NPCs and whether or not I can bunch them into groups reliably this could get prohibitively long and inefficient. Edited June 27, 2012 by Lt Albrecht Link to comment Share on other sites More sharing options...
Quetzlsacatanango Posted June 16, 2012 Share Posted June 16, 2012 Try it with the geck powerup, it will display syntax errors that prevent scripts from saving. Maybe "NPC" is a special string and you shouldn't use it for variables?Nothing jumps out at me as obviously wrong. Link to comment Share on other sites More sharing options...
viennacalling Posted June 16, 2012 Share Posted June 16, 2012 scn TenpennyLetMeBackInIAmAnIdiot ref NPC begin OnTriggerEnter set NPC to GetActionRef if NPC.Getinfaction TenpennyResidentFaction == 1 set TenpennyGateRef.openGate to 1 endif end Change TenpennyResidentFaction to TenpennyTowerResidentFaction. Link to comment Share on other sites More sharing options...
Nihilisaurus Posted June 16, 2012 Author Share Posted June 16, 2012 Change TenpennyResidentFaction to TenpennyTowerResidentFaction. ...That does it. Well, what we've learned today is that I can do basic logic but I can't copy and paste. Thanks guys, that would've kept me perplexed for hours wondering what I was doing wrong. Link to comment Share on other sites More sharing options...
Nihilisaurus Posted June 17, 2012 Author Share Posted June 17, 2012 (edited) Ok... Double-post time. That script works fine. NPC runs up, door opens up, npc runs through. How do I close it again? (want to be able to have npcs pass through both ways, so can't just use another script box...) Edited June 17, 2012 by Lt Albrecht Link to comment Share on other sites More sharing options...
caramellcube Posted June 24, 2012 Share Posted June 24, 2012 would a timer work? if mode==1set timer to timer + getsecondspassedif timer > 3set timer to 0set mode to 0; close gateendif endif I think there's a way to do it with trigger boxes though, maybe if you store the reference of the npc and have the ontriggerenter events check that, so they have 3 possible states,not in faction = do nothingin faction = open gatehas just opened gate = close gateit seems like it would need a global variable to pass the reference between the triggerboxes, and I don't know how well either option would work. Link to comment Share on other sites More sharing options...
Nihilisaurus Posted June 27, 2012 Author Share Posted June 27, 2012 Got it all working. The tenpenny gate already has globals so hooking the two script boxes (and a quest script that closes the gate after about 10 seconds) was easy enough once I figured out what things to stop doing. Link to comment Share on other sites More sharing options...
Recommended Posts