-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrash.txt
More file actions
186 lines (177 loc) · 8.22 KB
/
trash.txt
File metadata and controls
186 lines (177 loc) · 8.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
///////// useful trash ////////////////////////////////////
//// Have troops use siege engines near movement commands
//[HarmonyPatch(typeof(MovementOrder), "OnApply")]
//public static class Patch_OnApply
//{
// public static bool Prefix(this Formation formation)
// {
// if (formation.CountOfUnits < 1) { return true; }
// if (!Main.IsPIC(formation)) { return true; }
// //if (Mission.Current.GetMissionBehaviour<SiegeDeploymentHandler>() != null) { return true; } // allows blue-gearing siege engines during deployment
// Main.Log("Movement order given: " + formation.MovementOrder.OrderType.ToString());
// if (formation.MovementOrder.OrderType == OrderType.FollowEntity) { return true; };
// foreach (SiegeWeapon sw in Mission.Current.ActiveMissionObjects.FindAllWithType<SiegeWeapon>())
// {
// if (sw.Side == Mission.Current.PlayerTeam.Side) // only works when player gives order for player's side's siegeweapon
// {
// bool start = false; bool stop = false; bool cont = false;
// bool isUsing = formation.IsUsingMachine(sw);
// bool isOrderNear = Main.IsOrderNear(formation, sw, 12f);
// if (formation.MovementOrder.OrderType == OrderType.StandYourGround & isUsing) { stop = true; goto eval; };
// if (isOrderNear & isUsing) { cont = true; goto eval; }
// if (isOrderNear & !isUsing) { start = true; goto eval; }
// if (!isOrderNear & !isUsing) { continue; }
// eval:
// string swStr = sw.GetSiegeEngineType().ToString();
// if (start)
// {
// Main.Log("Formation starting using: " + swStr, true);
// if (sw is BatteringRam | sw is SiegeTower)
// {
// MovementOrder mo = formation.MovementOrder;
// Traverse.Create(mo).Method("MovementOrderFollowEntity", sw.GameEntity).GetValue();
// }
// sw.ForcedUse = true;
// Traverse.Create(formation).Method("JoinDetachment", (sw as UsableMachine)).GetValue();
// return false;
// }
// if (stop)
// {
// Main.Log("Formation stopping using: " + swStr, true);
// sw.ForcedUse = false;
// Traverse.Create(formation).Method("LeaveDetachment", (sw as UsableMachine)).GetValue();
// continue;
// }
// if (cont)
// {
// Main.Log("Formation continuing to use: " + swStr, true);
// continue;
// }
// }
// }
// return true;
// }
//}
//if (formation.MovementOrder.OrderType == OrderType.Charge)
// {
// foreach (MissionObject gatemo in Mission.Current.MissionObjects)
// {
// if (gatemo is CastleGate && gatemo.GameEntity.HasTag("inner_gate"))
// {
// CastleGate ig = gatemo as CastleGate;
// }
// if (gatemo is CastleGate && gatemo.GameEntity.HasTag("outer_gate"))
// {
// CastleGate og = gatemo as CastleGate;
// }
// }
// if (og.IsDestroyed() && !ig.IsDestroyed())
// {
// Traverse.Create(formation).Method("FormAttackEntityDetachment", ig.GameEntity).GetValue();
// }
// return true;
// }
//// Old harmony patch that failed to completely prevent dumb AI behavior
//[HarmonyPatch(typeof(ModuleExtensions), "StartUsingMachine")]
//public static class Prefix_StartUsingMachine
//{
// public static bool Prefix(this Formation formation, UsableMachine usable, bool isPlayerOrder) // variable names must match exactly
// {
// if (formation.CountOfUnits < 1) { return true; }
// if (!Main.IsPIC(formation)) { return true; }
// SiegeWeapon sw = (usable as SiegeWeapon);
// Main.St();
// Main.Log("Formation told to start using: " + sw.GetSiegeEngineType().ToString());
// Main.Log("Is it forced used?:" + sw.ForcedUse.ToString());
// Main.Log("Is it a player order?: " + isPlayerOrder.ToString());
// return true;
// }
//}
//// Old harmony patch that failed to completely prevent dumb AI behavior
//[HarmonyPatch(typeof(ModuleExtensions), "StartUsingMachine")]
//public static class Prefix_StartUsingMachine
//{
// public static bool Prefix(this Formation formation, UsableMachine usable, bool isPlayerOrder) // variable names must match exactly
// {
// if (formation.CountOfUnits < 1) { return true; }
// if (!Main.IsPIC(formation)) { return true; }
// SiegeWeapon sw = (usable as SiegeWeapon);
// Main.Log("Formation told to start using: " + sw.GetSiegeEngineType().ToString());
// Main.Log("Is it forced used?:" + sw.ForcedUse.ToString());
// Main.Log("Is it a player order?: " + isPlayerOrder.ToString());
// return true;
// }
//}
//bool isOrderFar = !Main.IsOrderNear(formation, sw, 45f);
//if (isAIC) { Main.Log("Player in charge, but AI in command. Allowing order."); return true; } // prevents any ai movement orders if player is alive and in charge
//if (formation.IsUsingMachine(usable)) { Main.Log("Already using."); return false; } // prevent redundant orders
//Mission.Current.MainAgent.MakeVoice(SkinVoiceManager.VoiceType.UseSiegeWeapon, SkinVoiceManager.CombatVoiceNetworkPredictionType.Prediction);
//foreach (Formation fs in formation.Team.FormationsIncludingSpecial) { };
//Main.Log("Num of formations with special: "+formation.Team.FormationsIncludingSpecial.Count().ToString());
//Main.Log("Num of formations without special: " + formation.Team.Formations.Count().ToString());
//Main.Log("Num of formations without special: " + formation.Team.Formations.Count().ToString());
//Main.Log("Num of units including detachments: " + formation.CountOfUnits.ToString());
//Main.Log("Num of units not including detachments: " + formation.CountOfUnitsWithoutDetachedOnes.ToString());
//Environment.NewLine + Environment.NewLine +
//formation.MovementOrder = MovementOrder.MovementOrderFollow;
//formation.Team.ResetTactic();
//formation.ReleaseFormationFromAI();
//BehaviorAssaultWalls baw = BehaviorAssaultWalls;
//AIBehaviorComponent;
// formation.AI.ResetBehaviorWeights
// formation.AI.Can
//BehaviorComponent sdfsd = new BehaviorStop(formation);
//formation.AI.AddBehavior(sdfsd);
//formation.AI.ResetBehaviorWeights();
//(usable as SiegeLadder).HasCompletedAction
//(usable as SiegeLadder).State.
//(usable as SiegeLadder).State.Equals(SiegeLadder.LadderState.OnLand
// var f_loc = formation.QuerySystem.MedianPosition.Position;
//BehaviorUseSiegeMachines busm = new BehaviorUseSiegeMachines(formation);
// if (sw is SiegeTower) { formation.AI.AddBehavior(busm);}
// formation.AI.
// }
//OrderController oc = Mission.Current.PlayerTeam.GetOrderControllerOf(formation.PlayerOwner);
//Mission.Current.MainAgent.MakeVoice(SkinVoiceManager.VoiceType.UseSiegeWeapon, SkinVoiceManager.CombatVoiceNetworkPredictionType.NoPrediction);
//bool ordIsForward = (formation.MovementOrder.OrderType == OrderType.Advance);
//bool swMoves = (sw is SiegeLadder || sw is SiegeTower || sw is BatteringRam);
//if (ordIsForward & swMoves & !isUsing) { start = true; goto eval; }
//if (ordIsForward & swMoves & isUsing) { cont = true; goto eval; }
//Mission.Current.ActiveMissionObjects.FindAllWithType<CastleGate>();
// Override charge
//[HarmonyPatch(typeof(OrderController), "GetChargeOrderSubstituteForSiege")]
//public static class Patch_GetChargeOrderSubstituteForSiege
//{
// public static bool Prefix(OrderController __instance, ref MovementOrder __result, Formation formation)
// {
// Team team = formation.Team;
// TeamAISiegeComponent teamAISiegeComponent = ((team != null) ? team.TeamAI : null) as TeamAISiegeComponent;
// if (Mission.Current.IsTeleportingAgents || teamAISiegeComponent == null || teamAISiegeComponent.IsAnyLaneThroughWallsOpen())
// {
// __result = MovementOrder.MovementOrderCharge;
// return false;
// }
// if (!formation.Team.IsAttacker)
// {
// CastleGate castleGate = (!teamAISiegeComponent.InnerGate.IsGateOpen) ? teamAISiegeComponent.InnerGate : teamAISiegeComponent.OuterGate;
// if (castleGate != null && !formation.IsUsingMachine(castleGate))
// {
// formation.StartUsingMachine(castleGate, true);
// }
// __result = MovementOrder.MovementOrderCharge;
// return false;
// }
// if (teamAISiegeComponent.Ladders.Count > 0)
// {
// SiegeLadder siegeLadder = teamAISiegeComponent.Ladders.MinBy((SiegeLadder l) => l.WaitFrame.origin.DistanceSquared(formation.QuerySystem.MedianPosition.GetNavMeshVec3()));
// if (!formation.IsUsingMachine(siegeLadder))
// {
// formation.StartUsingMachine(siegeLadder, true);
// }
// __result = MovementOrder.MovementOrderMove(siegeLadder.WaitFrame.origin.ToWorldPosition());
// return false;
// }
// __result = MovementOrder.MovementOrderCharge;
// return false;
// }
//}