Jump to content

guard scripts


Recommended Posts

So what I want to achieve is this: When the bank opens at 8am, several reference ID's (5 bank guards) enable at the entrance and are given AI packages that make them travel to their post in the bank. Then at 8pm the AI pack given to them before is removed and one which makes them travel to the door is added. Once they reach the door they are disabled. I currently have the code for this in the quest script for the bank which is running just fine, but for some reason these guards don't do what they are supposed to. Any idea?

 

ScriptName CRbankhousenewsscript

Begin GameMode
setstage CRBankhouses 10

If GetCurrentTime == 20
CRBG1.addscriptpackage CRbankguardleave
CRBG2.addscriptpackage CRbankguardleave
CRBG3.addscriptpackage CRbankguardleave
CRBG4.addscriptpackage CRbankguardleave
CRBG5.addscriptpackage CRbankguardleave
endif

if CRBG1.getdistance CRbankdoor < 25
CRBG1.removescriptpackage CRbankguardleave
CRBG1.disable
endif

if CRBG2.getdistance CRbankdoor < 25
CRBG2.removescriptpackage CRbankguardleave
CRBG2.disable
endif

if CRBG3.getdistance CRbankdoor < 25
CRBG3.removescriptpackage CRbankguardleave
CRBG3.disable
endif

if CRBG4.getdistance CRbankdoor < 25
CRBG4.removescriptpackage CRbankguardleave
CRBG4.disable
endif

if CRBG5.getdistance CRbankdoor < 25
CRBG5.removescriptpackage CRbankguardleave
CRBG5.disable
endif

if GetCurrentTime == 8
CRBG1.enable
CRBG2.enable
CRBG3.enable
CRBG4.enable
CRBG5.enable
CRBG1.addscriptpackage CRbankguard1post
CRBG2.addscriptpackage CRbankguard2post
CRBG3.addscriptpackage CRbankguard3post
CRBG4.addscriptpackage CRbankguard4post
CRBG5.addscriptpackage CRbankguard5post
endif

if CRBG1.getdistance CRBG1mark < 100
CRBG1.removescriptpackage CRbankguard1post
endif

if CRBG2.getdistance CRBG2mark < 100
CRBG2.removescriptpackage CRbankguard2post
endif

if CRBG3.getdistance CRBG3mark < 100
CRBG3.removescriptpackage CRbankguard3post
endif

if CRBG4.getdistance CRBG4mark < 100
CRBG4.removescriptpackage CRbankguard4post
endif

if CRBG5.getdistance CRBG5mark < 100
CRBG5.removescriptpackage CRbankguard5post
endif

end

Link to comment
Share on other sites

There might be a problem with the logic on the code.

 

So at 8 the guards are enabled, right? The the ai package is removed if they are close to the maker, Are they close to the marker? I'm having some trouble following the code... haven't coded in a while

 

Have you seen "return" commands? They're helpful in stopping the engine from continuing to read the script code if certain criteria are not met within that frame it's red on. Maybe there's code running when it shouldn't?

 

It always helped me to re-read the code and follow it logically. I also avoided using just "<" or ">". I used "less than or equal" to avoid random bs.

Link to comment
Share on other sites

Thanks for the input, but I went ahead and avoided being tricky and just gave them each unique ID's and AI sets to go between the imperial palace barracks next door and the bank for their shift. Works fine now. There is one weird thing about the cell however. I have several NPCs that are supposed to go to a specific marker at certain times in this cell and every time I come into the cell when they are present, the NPC will be off their mark and will walk over to the right mark when I enter. If I leave and come back, the same thing happens. They are set to process AI even if I'm not around so that's not the problem, and I have the distance radius to the markers set at 0 so it's not like they're hitting the radius and the Ai says "good enough" so I'm not sure. It's kind of a neat effect because it looks like the employees are chatting or doing other work and return to their places when a customer (player) walks in, so it doesn't bug me that much but I'm the kind who likes to understand WHY it's doing it, even if the ultimate result is ok even if unintended.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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