goldredblue0798 Posted April 4, 2010 Share Posted April 4, 2010 Hey there modders... I am looking for a script or AI packedge that will allow a FREINDLY NPC to become HOSTILE but ONLY when the player comes within close range of that NPC... It would have to function so that the NPC would start combat with the PC after a few seconds and ONLY when the PC has stayed within very close range (melee or just beyond melee range). P.S. Not very good with creating quests and referancing so no such suggestions please. A script to make something like this possible would be useful. Its a advanced ambush tactic... -KC Link to comment Share on other sites More sharing options...
pkleiss Posted April 4, 2010 Share Posted April 4, 2010 There are a couple of ways to do that. Simplest way - Make sure the NPC belongs to a faction that is neutral to the PlayerFaction and setup 'Aggro Radius Behavior' on the NPC. Set his AI to Very Aggressive and he will attack Neutrals when they get within the Aggro radius. This won't do for an NPC who is initually freindly though. More complex way - This assumes that the NPC was friendly for a while such that the player can have normal conversations with the NPC and then, at some point, the NPC turns hostile, say, after a dialogue option... Define a control variable inside of a script running on the NPC or in a quest script or use a quest stage. You just need something you can control to be used as a condition for the AI Package. Create a faction that is set as an enemy of the player faction. At the point where the NPC switches - I am using a dialogue option as an example - add this code to the results script of the dialogue: Set NPCRef.[someControlVariable] to 1 You could also use 'SetStage SomeQuest X' or 'Set SomeQuest.SomeQuestVariable to 1' Then, in my example of using a script on the NPC, you would add this bit of code: Begin GameMode If SomeControlVariable == 1 && GetDistance Player < SomeDistance Set SomeControlVariable to 2 AddtoFaction SomeFaction 1 NPCRef.evp EndIf EndIf you have an AI Package that you want to run as well, you can add a condition to it using the function 'GetScriptVariable' that check if 'SomeControlVariable' is equal to 2. In my example, this will kick in right away becasue after the dialogue, the player will be within proximity already. There are other ways of doing it too. If you knew that the NPC was in a faction all to himself, you could just use SetEnemy or SetPCEnemyOfFaction if that faction is setup to track crime. Link to comment Share on other sites More sharing options...
goldredblue0798 Posted April 5, 2010 Author Share Posted April 5, 2010 Good idea but making it so that the PC has to "talk" with the freindly-to-be-hostile NPC means that YOU HAVE TO TALK TO THAT NPC and thats just not always going to happen all of the time and wont work the way I need it to... plus that also means having to create quests which I am not that good with. A script is really the best way because it takes priority over most other AI commands and what I really require is a script so that when the PC gets within very close range of the freindly NPC he/she will instantly initiate combat (switch faction or just become aggressive it dont matter how). This has to be a ambush tactic and not just some NPC that begins shooting at the PC from long range which is why I need this script. -KC Link to comment Share on other sites More sharing options...
pkleiss Posted April 5, 2010 Share Posted April 5, 2010 Like, I said, it was an example. You can set it up anyway you want. From my earlier post... Simplest way - Make sure the NPC belongs to a faction that is neutral to the PlayerFaction and setup 'Aggro Radius behavior' on the NPC. Set his AI to Very Aggressive and he will attack Neutrals when they get within the Aggro radius. This won't do for an NPC who is initually freindly though. Just setup an aggro radius for the NPC who is in a faction that is neutral the the player and friend/ally to any other NPCs in the area. If you want the NPCs to join the fight, make them friend/ally to the NPC faction and set them to help friends/allys. If you don't want other NPCs to join the fight, make them neutral to the NPC faction. Link to comment Share on other sites More sharing options...
goldredblue0798 Posted April 6, 2010 Author Share Posted April 6, 2010 Like, I said, it was an example. You can set it up anyway you want. From my earlier post... Simplest way - Make sure the NPC belongs to a faction that is neutral to the PlayerFaction and setup 'Aggro Radius behavior' on the NPC. Set his AI to Very Aggressive and he will attack Neutrals when they get within the Aggro radius. This won't do for an NPC who is initually freindly though. Just setup an aggro radius for the NPC who is in a faction that is neutral the the player and friend/ally to any other NPCs in the area. If you want the NPCs to join the fight, make them friend/ally to the NPC faction and set them to help friends/allys. If you don't want other NPCs to join the fight, make them neutral to the NPC faction. And like I said that just wont work for some good reasons... 1. You would have to assign faction standings (allies with MOST factions to stop the NPC's attacking neutrals).2. Would have to have NPC's saying "stay back or I shoot your!" for seconds before they actually attack which is VERY out of context with my mod.3. This mod will be a general mod that puts "action" in the Wasteland of FO3 where their is NO action and doing it using the method suggested by yourself wont be of much use.4. If done that way with the agro radius + faction standing it may cause conflicts with ANY other mod that changes those same factions or if a player chooses to add their own faction to the game.5. My mod will be a MAST type mod meaning it will NOT be able to be edited by others. These are mostly the reasons why it has to be a script so every NPC funcitons the same way (freind who becomes foe) and ONLY towards the player themself... -KC Link to comment Share on other sites More sharing options...
pkleiss Posted April 6, 2010 Share Posted April 6, 2010 Well, an AI package isn't going to make an NPC become hostile, you have to do that with factions. So put a script on your NPC that uses GetDistance and AddTofaction Like this: scn MyNPCScript Short DoOnce Begin GameMode If DoOnce == 0 If GetDistace Player < SomeValue AddToFaction Somefaction 1 Set DoOnce to 1 EndIf Endif EndWhere SomeValue is the distance from the player at which the NPC will become hostile and SomeFaction is a faction that is setup to be an enemy of the player. Lastly, if your original question was as specific as your last post, then my suggestions could have been geared towards what you were looking for sooner. None of us are mind readers, at least I think none of us are mind readers. My appologies to any mind readers out there. Link to comment Share on other sites More sharing options...
goldredblue0798 Posted April 6, 2010 Author Share Posted April 6, 2010 Hey there modders... I am looking for a script or AI packedge that will allow a FREINDLY NPC to become HOSTILE but ONLY when the player comes within close range of that NPC... It would have to function so that the NPC would start combat with the PC after a few seconds and ONLY when the PC has stayed within very close range (melee or just beyond melee range). P.S. Not very good with creating quests and referancing so no such suggestions please. A script to make something like this possible would be useful. Its a advanced ambush tactic... -KC Update: Got a script that does exactly what I need it to do... problem solved! -KC Link to comment Share on other sites More sharing options...
goldredblue0798 Posted April 6, 2010 Author Share Posted April 6, 2010 Well, an AI package isn't going to make an NPC become hostile, you have to do that with factions. So put a script on your NPC that uses GetDistance and AddTofaction Like this: scn MyNPCScript Short DoOnce Begin GameMode If DoOnce == 0 If GetDistace Player < SomeValue AddToFaction Somefaction 1 Set DoOnce to 1 EndIf Endif EndWhere SomeValue is the distance from the player at which the NPC will become hostile and SomeFaction is a faction that is setup to be an enemy of the player. Lastly, if your original question was as specific as your last post, then my suggestions could have been geared towards what you were looking for sooner. None of us are mind readers, at least I think none of us are mind readers. My appologies to any mind readers out there. Thats actually almost identical to the script I chose to use except the "< SomeValue" text was not being recognised so I used a number value instead and it works like a dream =) Also used another command text "StartCombat Player" P.S. Mind reading would be VERY cool... -KC Link to comment Share on other sites More sharing options...
pkleiss Posted April 6, 2010 Share Posted April 6, 2010 FYI - SomeValue and SomeFaction were place holders for an actual distance (a number in units) and an actual faction. Link to comment Share on other sites More sharing options...
goldredblue0798 Posted April 6, 2010 Author Share Posted April 6, 2010 FYI - SomeValue and SomeFaction were place holders for an actual distance (a number in units) and an actual faction. Oh... Would have been better if you just put "radiusvaluehere" and "createdfactionhere" or something... because the script commands are confusing that way... heh tomatoe-tomato =P -KC Link to comment Share on other sites More sharing options...
Recommended Posts