Jump to content

OnEnter script not behaving


Nihilisaurus

Recommended Posts

[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 by Lt Albrecht
Link to comment
Share on other sites

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

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 by Lt Albrecht
Link to comment
Share on other sites

would a timer work?

 

if mode==1

set timer to timer + getsecondspassed

if timer > 3

set timer to 0

set mode to 0

; close gate

endif

 

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 nothing

in faction = open gate

has just opened gate = close gate

it 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

  • Recently Browsing   0 members

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