Lemonworm Posted August 4, 2019 Share Posted August 4, 2019 (edited) Hello all,I'm new to GECK and making mods in general, and Im trying to create a simple mod in which you are stalked at a distance by a creepy dude. In order to discourage the player from running up to him when they see him, I wanted to program him to flee if the player got within a certain distance. I have attempted to write a script and there are no errors but unfortunately it still doesn't work. Ill post it below. BasicStalk is a Follow AI package I created.ScriptName StalkerboiScript begin Gamemode If Stalkerboi.GetDistance Playerref <= 4000RemoveScriptPackage BasicStalk,ForceFlee Vault3aendif If Stalkerboi.GetAttackedRemoveScriptPackage BasicStalk,ForceFlee Vault3aendif If Stalkerboi.GetDistance Playerref > 5000AddScriptPackage BasicStalkendif ENDIf any of yall modding veterans could give me some tips on my entry level code to make it functional it would be very appreciatedIdeally I would have him at a distance hiding in cover and making sure to maintain a constaint distance but I cant quite figure out how to make the cover thing work either so I just have him fleeing to Vault 3 immediately upon being approached or attacked for nowThank you all for your help and sorry for being a noob lol !! Edited August 4, 2019 by Lemonworm Link to comment Share on other sites More sharing options...
Lemonworm Posted August 4, 2019 Author Share Posted August 4, 2019 (also if any of yall have advice on how to not make him show up right next to you when you fast travel dispite him having a set following distance that would be greatly appreciated cause right now im just making him slow to compensate) Link to comment Share on other sites More sharing options...
GamerRick Posted August 5, 2019 Share Posted August 5, 2019 That's a heck of a task for a noob to take on. For starters, a GameMode block runs every frame. So, it will redo all of the code in it up to 60 times a second. You gotta be careful to make sure it does certain things only once. like adding the package once if the package isn't already added, and doing the ForceFlee constantly in an NPC already fleeing. Look in the GECK at packages that exist to make an NPC flee. You can control what they are fleeing from and how far they flee. Then you need to control which package is active for the NPC between the flee and follow packages. Once you get that figure out, there is other stuff to worry about. What if the NPC gets attacked by something or someone? What happens when you fast travel or enter an interior? A follower is always teleported with you. I don't know how to deal with that. Link to comment Share on other sites More sharing options...
dubiousintent Posted August 5, 2019 Share Posted August 5, 2019 While your idea may appear "simple" in concept to you, it appears to me to be quite complex to implement in practice. So I waited to see if someone who has actually been creating such mods replied to confirm or refute that assumption, which GamerRick has. Not to say you can't do this. But you need to think of it as learning exercise that is going to take some time and perseverance to work out the details. It will help if you have some programming experience to help you figure out the logic problems. You need to understand the difference between an "AIPackage" and an "AIProcedure". Also, check out the "Category:AI Functions" to understand the less obvious things you can do with them. (Take the time to read the linked wiki pages.) Firstly you have to chose the correct type of Package to use (I'm guessing "Follow" or "Escort" but you need to investigate how each is intended to be used and actually functions in practice for your purposes) with at least three major procedures / packages to develop and test one at a time before combining: 1. "Stalking" is a procedure that is more than just a simple "follower" script because you want the Actor to try to remain unnoticed. For one thing, "sneaking" is inherently slower than normal movement, but NPCs "cheat" by "teleporting" when they get too far away from the target they are following. (You might not have noticed this unless you checked on companions behind yourself frequently in rough terrain.) But you might find you need to shift in and out of "sneak" mode. Various companions may affect what you need for the effective follow distance to avoid having aggressive followers attacking your "stalker". 2. Once you get that functional, you need a "flee" procedure that will keep that Actor at a proper distance from the Player without losing track of the Player so it can resume "following". A "special case" to test is if your "stalker" is fleeing while the Player changes cells. 3. When the Actor gets far enough from the Player, they then need a procedure to find somewhere to "hide" (break line-of-sight between them and the Player), wait a reasonable amount of time for companions to stop "searching for enemies", and then resume the "Follow" / "Stalk" AI procedure/package. 4. As pointed out, each package needs to consider that it may encounter conditions that require another package or procedure to take precedence and execute. You do not simply "resume" an AI package where you left off. It starts over whatever the current situation is when it gets invoked. That could be in a completely different cell than where it left off. AI packages are in a hierarchy list of "conditions". ("Conditions" are just variables, often called "flags", you define and set to control things. A common use is a "do once" variable in a "quest" script. You are going to need a number of them for this to indicate when to use only one procedure or package at a time.) The first package that meets all of it's conditions as "true" then is used. Just adding a package does not place the package within that list; it overrides the list for immediate implementation but goes away once completed and won't matter after that as it's conditions are never evaluated as "true" after that point. While the "AddScriptPackage" might seem like the appropriate function to use, it has major limitations. (Read the linked description.) Typically you will want to place your package in the list of packages, set the appropriate "conditional flag variables", and use the "Evaluate Package" (EVP) function to cause the list to be processed again to determine which is now the "first true" package. Finally, while there isn't a lot on "AI Packages" per se, you will probably benefit from some of the other information in the "Scripting" section of the wiki "Getting started creating mods using GECK" article. -Dubious- Link to comment Share on other sites More sharing options...
Recommended Posts