I got it to help me with some bash scripting. And it helped me create a script that I have been banging my head to make even with asking in forums. Chat GPT was able to help create the script I wanted after a few attempts and testing and tweaking. It made a few errors but it actually helped me create some scripting.
I asked it to set up a Bannerlord mod template in C# sharp and it did it. I went further and asked it to create a script for 'body sliding' and after some explanation it produced something that is probably the script that can make that type of mod. The problem is that it thinks that Bannerlord is at 1.5.7 or something.
I asked it to set up a Bannerlord mod template in C# sharp and it did it. I went further and asked it to create a script for 'body sliding' and after some explanation it produced something that is probably the script that can make that type of mod. The problem is that it thinks that Bannerlord is at 1.5.7 or something.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;
using TaleWorlds.MountAndBlade.ViewModelCollection;
using TaleWorlds.MountAndBlade.ViewModelCollection.GameMenu;
using TaleWorlds.Localization;
using TaleWorlds.Engine;
using TaleWorlds.Engine.Screens;
using TaleWorlds.InputSystem;
using TaleWorlds.MountAndBlade.View.Missions;
using TaleWorlds.MountAndBlade.View.Screen;
using TaleWorlds.TwoDimension;
namespace MyBannerlordMod
{
public class ControlAllyOnKO : MissionBehaviour
{
private Agent _lastPlayerAgent;
private Agent _nextPlayerAgent;
private bool _playerKnockedOut = false;
public override void OnMissionTick(float dt)
{
base.OnMissionTick(dt);
if (Mission.Current.IsPlayerControlledAgentDead && !_playerKnockedOut)
{
_playerKnockedOut = true;
_lastPlayerAgent = Mission.Current.PlayerControlledAgent;
_nextPlayerAgent = GetNextPlayerAgent();
if (_nextPlayerAgent != null)
{
ChangePlayerAgent(_nextPlayerAgent);
}
}
}
private Agent GetNextPlayerAgent()
{
Agent nearestAgent = null;
var playerClan = _lastPlayerAgent.Clan;
var playerTroop = _lastPlayerAgent.Character.CurrentFormation.Troop;
//First Priority: Clan members
nearestAgent = Mission.Current.Agents
.Where(x => x.IsHuman && x.IsAlive && !x.IsPlayerControlled && x.Clan == playerClan)
.OrderBy(x => x.DistanceTo(_lastPlayerAgent))
.FirstOrDefault();
//Second Priority: Nobles
if(nearestAgent == null)
{
nearestAgent = Mission.Current.Agents
.Where(x => x.IsHuman && x.IsAlive && !x.IsPlayerControlled && x.Character.IsNoble)
.OrderBy(x => x.DistanceTo(_lastPlayerAgent))
.FirstOrDefault();
}
//Third Priority: Higher Tier Troops
if(nearestAgent == null)
{
nearestAgent = Mission.Current.Agents
.Where(x => x.IsHuman && x.IsAlive && !x.IsPlayerControlled && x.Character.CurrentFormation.Troop.IsBetterThan(playerTroop))
.OrderBy(x => x.DistanceTo(_lastPlayerAgent))
.FirstOrDefault();
}
return nearestAgent;
}
private void ChangePlayerAgent(Agent newAgent)
{
// Change the player-controlled agent to the new agent
Input.Current.PlayerOrderController.Agent = newAgent