Jump to content

NPCs & AI Packages


Recommended Posts

I'm currently making a mod that adds 13 companions into the game. The idea is to simulate a squad of USMC Soldiers consisting of a Squad Leader (SL) and 3 Fire Teams (FT) of 4 Fire Team Member (FTM).

 

Now what I wanna do is make the NPCs follow one another.

i.e. In Fire Team 1-3,

Fire Team Leader (FTL) < FTM 1 < FTM 2 < FTM 3

 

I want them the FTM to follow the FTL where ever they move, and that if the FTL is in combat they would join the fight and scatter/find cover and once the battle is over they regroup and follow the Fire Team leader as per normal. Keeping in mind that my mod would be based on the Sharing and Caring Companions (SCC)

 

What I have in mind is this, I want to use SCC to recruit ONLY the FTL. Thus with the AI Package, the FTM would follow and act as a squad. What I have done is set the FTL to "Guard the area" and the rest of the FTM to follow and engage enemies accordingly.

 

I am aware that this can be done using the AI Packages. This is what I have done.

 

FOLLOW PACKAGE

I used the follow package and it was successful as NPCs move around in a trail HOWEVER, when the FT Leader engages the enemy all the squad members does is run around doing nothing.

 

ESCORT PACKAGE

Squad Members don't even follow

 

IN SHORT:

1) How do I make NPCs follow one another in a trial

2) Engage the enemy that is engaging the NPC he/she is following

3) Take cover, etc, while engaging. (Optional)

Link to comment
Share on other sites

1) Your idea to have each member follow another member is correct. An Escort package is a 'lead' package usually reserved for when you want the player to follow an NPC, The NPC will then lead the player, but wait if the player gets out of the Escort package distance.

 

2) This is done through Factions & AI Data. You need to setup a common faction for all members of your team so they will have the same reaction to enemies as the leader. Set their Aggression to at least aggressive and set their confidence to Foolhardy if you do not want them to ever flee. Setting their aggression to Very Aggressive will make them attack neutrals on-sight.

 

3) This should happen automatically during combat based on each NPC's Combat Style.

Link to comment
Share on other sites

I'm currently making a mod that adds 13 companions into the game. The idea is to simulate a squad of USMC Soldiers consisting of a Squad Leader (SL) and 3 Fire Teams (FT) of 4 Fire Team Member (FTM).

 

Now what I wanna do is make the NPCs follow one another.

i.e. In Fire Team 1-3,

Fire Team Leader (FTL) < FTM 1 < FTM 2 < FTM 3

 

I want them the FTM to follow the FTL where ever they move, and that if the FTL is in combat they would join the fight and scatter/find cover and once the battle is over they regroup and follow the Fire Team leader as per normal. Keeping in mind that my mod would be based on the Sharing and Caring Companions (SCC)

 

What I have in mind is this, I want to use SCC to recruit ONLY the FTL. Thus with the AI Package, the FTM would follow and act as a squad. What I have done is set the FTL to "Guard the area" and the rest of the FTM to follow and engage enemies accordingly.

 

I am aware that this can be done using the AI Packages. This is what I have done.

 

FOLLOW PACKAGE

I used the follow package and it was successful as NPCs move around in a trail HOWEVER, when the FT Leader engages the enemy all the squad members does is run around doing nothing.

 

ESCORT PACKAGE

Squad Members don't even follow

 

IN SHORT:

1) How do I make NPCs follow one another in a trial

2) Engage the enemy that is engaging the NPC he/she is following

3) Take cover, etc, while engaging. (Optional)

 

To make sure the FTM help the leader, create a Faction - MyFireTeamFaction and put all the NPC's into this faction. In the 'interfaction relation' box for this faction, add this same faction and specify that it is an 'Ally' to itself.

In all the NPC 'AI Data' tabs, set 'assistance' to 'Helps Allies'. You probably want to also set 'aggressive' and 'foolhardy' for the other attributes.

 

In the follower packages, you should have 'continue during combat' box checked. You could create a unique package for each FTM with a different following distance for each FTM. Have all the follow packages follow a 'specific reference' which will be the FTL.

 

You can also check the box 'no combat alert' in the FTM follow packages. This will make it so the FTL will detect enimies first, unless they are right on top of you. So this should have the effect where the FTL will be initiating combat most of the time, then the FTM will help.

 

You can also give the FTM NPCs their own script that can help them along in picking their initial target when entering combat:

 

scn MyFireTeamFTMNPCScript


ref FTLTargetREF
short iTargetSet


BEGIN GameMode

if (IsInCombat == 1 || FTLNPCREF.IsInCombat == 1); FTLNPCREF is the leader NPC reference
	if (iTargetSet == 0)
		if (FTLNPCREF.GetCombatTarget)	;Does Leader have a target?
			if (GetCombatTarget == 0)	;Do I not have a target?
				set FTLTargetREF to FTLNPCREF.GetCombatTarget
				if (FTLTargetREF)
					if (FTLTargetREF.GetDead == 0)
						StartCombat FTLTargetREF ;Attack the Leader's target if not busy with my own
						set iTargetSet to 1	;Do this just once per combat cycle!
					endif
				endif
			endif
		endif
	endif
endif




BEGIN OnCombatEND

set iTargetSet to 0

END

Link to comment
Share on other sites

Wow thanks for the help guys. I managed to figure it out already, all it takes is just Follow Package & Faction like you guys mentioned it.

What's that little script and how do I add it in?

 

From what I can decipher (I'm no programmer!), its something like:

Do I have a target?

Yes, Engage my target

No, Engage Fire Team Leader's Target

 

This thus would make movement more cohesive no?

 

I've already uploaded the mod if you guys wanna check it out :) Here

Link to comment
Share on other sites

Wow thanks for the help guys. I managed to figure it out already, all it takes is just Follow Package & Faction like you guys mentioned it.

What's that little script and how do I add it in?

 

From what I can decipher (I'm no programmer!), its something like:

Do I have a target?

Yes, Engage my target

No, Engage Fire Team Leader's Target

 

This thus would make movement more cohesive no?

 

I've already uploaded the mod if you guys wanna check it out :) Here

 

you create the script as an 'object' type script. Then you go into the NPC object where the 'Script' pulldown is and select it.

 

first it checks if either the leader or itself 'isincombat' . isincombat doesn't necessarily mean that there is shooting going on - they could be searching for enemies that are 'almost' detected.

 

Then it checks to see if the rest of the code is enabled - iTargetSet disables the block if the 'Startcombat' command is finally reached, because an NPC script runs every frame, and your NPC will freeze up if 'StartCombat FTLTargetREF' runs every frame.

 

Then it checks if the leader has a target. If so, go to the next check, otherwise nothing else is done this frame.

 

Then it checks if itself has a target. If it does, the rest of the code is skipped. If, not, the next code is done

 

The rest of it captures the reference that is the target , and makes sure it is not dead so the NPC can be told to start combat with it.

 

the iTargetSet gets reset when the NPC exits combat so the block is enabled for next time.

 

I use this in my follower mods and there are times when I can send one bullet at a target and the follower will engage it immediatly, then on to the next one I hit, etc. Kinda like 'lighting up' the target ;)

 

If you don't have 'no combat alert' checked in the follow packages, then this code probably won't do much good because they'll be just as 'sensitive' as the leader and will be aquiring targets at the same time the leader does anyway.

 

The 'no combat alert' also helps to keep them from wandering off in 'combat search' mode when you really want them to follow. Combat overrides everything.

Link to comment
Share on other sites

Oh wow, sounds like an awesome script dude!

 

So would it be right to say that, if in sneak mode (undetected) I DO NOT fire upon the target (that is in clear view of the NPCs),

the rest of my squad would just hold their fire?

 

But the moment I FIRE (detected), all the NPCs would fire upon enemies?

Link to comment
Share on other sites

Quick question:

How do I make the NPCs follow their leader's stance? Weather he's sneaking, not sneaking or weapons drawn/holstered.

Where do I go to edit this?

 

Package Type

Follow

 

Pretend in Combat Behavior

The actor will draw his weapon and follow the leader. The actor will also follow the sneak state of the leader when within a distance of fCombatFollowSneakFollowRadius( default: 512.0 ), so if the leader begins sneaking, the follower will too.

 

Continue During Combat Behavior

The actor will go into combat with the targets, but will always try to stay within the follow radius of the leader. The same sneak following behavior as in Pretend in Combat occurs

 

Notes

The follow radius is the package radius * fCombatFollowRadiusMult( default: 3.0 ) or fCombatFollowRadiusMin( default: 512.0 ), whichever is higher

 

So how do I make it such that they will always follow stances? Please help!

Link to comment
Share on other sites

Update:

Bearing in mind that I'm using TalkieToaster's Companions Share and Recruit Mod,

It seems that sometimes follow sneak works and sometimes it doesnt work. It normally stops working after I "wait" in-game.

 

What I did is recruit the Fire Team Leader (FTL) as a friend, and get him to follow me. When I move, the FTL moves towards me, and the Fireteam Members (FTM) follows the FTL etc. So it works that way. When I just reload a save game and enter sneak mode, the whole Fireteam follows (bearing in mind that each NPC follows the NPC he/she is designated to follow). But when I wait, it seems that somehow the script or whatever is broken and tje FTMembers cease following the stance/sneak. Only the FTLeader is sneaking. However, the FTMembers still do trail each other, only that now, they would no longer enter sneak mode.

 

I don't know what's wrong or what's going on. I dont think its the load order. Perhaps there should be a check script i must enter somewhere?

 

P.S. is there a way to teleport the NPC towards its target shud the NPC is beyond the radius of 500? Like what SCC does.

__________________________________________________________________________________

 

EDIT: It seems that this is a pretty serious problem. The script seems to break after events.

 

e.g.

#1) FTmembers stop following FTLeader after Combat

#2) FTmembers are "activated" thus, when FTLeader sneaks they sneaks too

#3) All the more making it an important aspect to have the NPCs teleport to its target

#4) Some kind of "check" to be implemented (i.e. Am i following the leader? If not in combat and not engaged in coversation, follow the leader)

 

I'm not good at scripting, can someone please teach me how to go aobut doing this? And I really think there's a need to have a "check" for the NPCs if they are following their "leader" or not in the script. Could someone pls help out?

*hint hint @ rickerhk* :D

Link to comment
Share on other sites

Update:

Bearing in mind that I'm using TalkieToaster's Companions Share and Recruit Mod,

It seems that sometimes follow sneak works and sometimes it doesnt work. It normally stops working after I "wait" in-game.

 

What I did is recruit the Fire Team Leader (FTL) as a friend, and get him to follow me. When I move, the FTL moves towards me, and the Fireteam Members (FTM) follows the FTL etc. So it works that way. When I just reload a save game and enter sneak mode, the whole Fireteam follows (bearing in mind that each NPC follows the NPC he/she is designated to follow). But when I wait, it seems that somehow the script or whatever is broken and tje FTMembers cease following the stance/sneak. Only the FTLeader is sneaking. However, the FTMembers still do trail each other, only that now, they would no longer enter sneak mode.

 

I don't know what's wrong or what's going on. I dont think its the load order. Perhaps there should be a check script i must enter somewhere?

 

P.S. is there a way to teleport the NPC towards its target shud the NPC is beyond the radius of 500? Like what SCC does.

__________________________________________________________________________________

 

EDIT: It seems that this is a pretty serious problem. The script seems to break after events.

 

e.g.

#1) FTmembers stop following FTLeader after Combat

#2) FTmembers are "activated" thus, when FTLeader sneaks they sneaks too

#3) All the more making it an important aspect to have the NPCs teleport to its target

#4) Some kind of "check" to be implemented (i.e. Am i following the leader? If not in combat and not engaged in coversation, follow the leader)

 

I'm not good at scripting, can someone please teach me how to go aobut doing this? And I really think there's a need to have a "check" for the NPCs if they are following their "leader" or not in the script. Could someone pls help out?

*hint hint @ rickerhk* :D

 

Make sure you turn off that flag 'continue when PC near', because that may be preventing them from evaluating their packages properly after combat. The way you have the packages set up, the NPC should just start following again after combat. You don't need a script for that. They will always run the first package in their list that matches the conditions. If there are no conditions, it will just run.

 

 

To do the teleport thing, you can use your quest script to check if an NPC is too far away from the FTL, then you do a moveto

Link to comment
Share on other sites

No luck with the "sneak together" and "continue following after combat" same problem persists.

I've unchecked the "Continue when PC Near flag" and checked the "Pretend in combat" but still, they'd sometimes stop following after combat.

and cease to sneak together after i "wait" for an hour or two ingame.

 

I tried to "emulate" some scripts from Companions Share and Recruit Mod but I can't read programming language :(

 

P.S. how do I do a quest script?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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