Skip to content

Commit 20f28d8

Browse files
committed
增加盟军,苏军增加部分单位,删除比赛版对e1和v2的调整
1 parent e1b2551 commit 20f28d8

7 files changed

Lines changed: 116 additions & 67 deletions

File tree

COPLIOT_MODIFICATIONS.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# OpenRA Copilot Mod Project Analysis
2+
3+
## Project Structure
4+
The project is based on the OpenRA engine (Red Alert 1).
5+
- **Base Game**: `mods/ra` (Original Red Alert assets and rules).
6+
- **Mod**: `mods/copilot` (Custom modification).
7+
- **Socket API**: Implemented to allow external control via socket connection.
8+
9+
## Copilot Mod Architecture
10+
The `copilot` mod inherits from `ra` but applies specific overrides in its `rules` directory.
11+
12+
### Factions
13+
Defined in `mods/copilot/rules/world.yaml`.
14+
- Currently, most factions are set to `Selectable: False`.
15+
- **Russia** (Soviet) is the primary active faction.
16+
- **Germany** (Allies) is present but likely disabled (`Selectable: False`).
17+
18+
### Units
19+
Defined in `mods/copilot/rules/vehicles.yaml`, `infantry.yaml`, etc.
20+
- **Health**: Units have approximately **3x Health** compared to the original `ra` mod.
21+
- **Cost/Build Speed**: There are global or specific modifiers reducing cost and build time by half (and potentially another half for build speed).
22+
23+
### Socket API
24+
- **Server Entry Point**: `OpenRA.Game/CopilotCommandServer.cs`
25+
- Handles socket connections, JSON parsing, and command dispatching.
26+
- **Command Logic**: `OpenCodeAlert/OpenRA.Mods.Common/ServerCommands.cs`
27+
- Contains the actual implementation of game commands (Move, Attack, etc.).
28+
- **Client Library**: `Copilot/openra_ai/OpenRA_Copilot_Library/game_api.py` (Python client for testing/usage).
29+
30+
## Proposed Modifications
31+
32+
### 1. Factions & Units
33+
**Target Files**:
34+
- `mods/copilot/rules/world.yaml`
35+
- `mods/copilot/rules/vehicles.yaml`
36+
37+
**Tasks**:
38+
- **Enable Germany**: Modify `mods/copilot/rules/world.yaml` to make Germany (`Faction@3`) selectable and ensure it has a stripped-down unit set similar to the Soviet faction.
39+
- **Add APC**: Add the `APC` unit to `mods/copilot/rules/vehicles.yaml`.
40+
- Base definition from `mods/ra/rules/vehicles.yaml`.
41+
- Apply **3x Health** rule.
42+
- Assign to Soviet faction (Russia) prerequisites if needed (or ensure it's buildable).
43+
44+
### 2. Socket API
45+
**Target Files**:
46+
- `OpenCodeAlert/OpenRA.Mods.Common/ServerCommands.cs`
47+
48+
**Tasks**:
49+
- **Fix Error**: Identify and fix the logic error in current socket commands (likely related to movement or target handling).
50+
- **Add New Commands**: Implement additional API commands as required.
51+
52+
## Reference Data
53+
- **APC (Original)**: `mods/ra/rules/vehicles.yaml` (Line 460).
54+
- **Germany (Original)**: `mods/ra/rules/world.yaml`.

OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -405,33 +405,34 @@ public bool CanQueue(ActorInfo actor, out string notificationAudio, out string n
405405
return false;
406406

407407
if (!developerMode.AllTech)
408-
{
409-
if (Info.PayUpFront && actor.TraitInfo<ValuedInfo>().Cost > playerResources.GetCashAndResources())
410-
return false;
411-
412-
if (Info.QueueLimit > 0 && Queue.Count >= Info.QueueLimit)
413408
{
414-
notificationAudio = Info.LimitedAudio;
415-
notificationText = Info.LimitedTextNotification;
416-
return false;
417-
}
409+
// 预付模式下的可负担性判断改为使用 GetProductionCost,确保与统一减半逻辑一致
410+
if (Info.PayUpFront && GetProductionCost(actor) > playerResources.GetCashAndResources())
411+
return false;
418412

419-
var queueCount = Queue.Count(i => i.Item == actor.Name);
420-
if (Info.ItemLimit > 0 && queueCount >= Info.ItemLimit)
421-
{
422-
notificationAudio = Info.LimitedAudio;
423-
notificationText = Info.LimitedTextNotification;
424-
return false;
425-
}
413+
if (Info.QueueLimit > 0 && Queue.Count >= Info.QueueLimit)
414+
{
415+
notificationAudio = Info.LimitedAudio;
416+
notificationText = Info.LimitedTextNotification;
417+
return false;
418+
}
426419

427-
if (bi.BuildLimit > 0)
428-
{
429-
var owned = Actor.Owner.World.ActorsHavingTrait<Buildable>()
430-
.Count(a => a.Info.Name == actor.Name && a.Owner == Actor.Owner);
431-
if (queueCount + owned >= bi.BuildLimit)
420+
var queueCount = Queue.Count(i => i.Item == actor.Name);
421+
if (Info.ItemLimit > 0 && queueCount >= Info.ItemLimit)
422+
{
423+
notificationAudio = Info.LimitedAudio;
424+
notificationText = Info.LimitedTextNotification;
432425
return false;
426+
}
427+
428+
if (bi.BuildLimit > 0)
429+
{
430+
var owned = Actor.Owner.World.ActorsHavingTrait<Buildable>()
431+
.Count(a => a.Info.Name == actor.Name && a.Owner == Actor.Owner);
432+
if (queueCount + owned >= bi.BuildLimit)
433+
return false;
434+
}
433435
}
434-
}
435436

436437
notificationAudio = Info.QueuedAudio;
437438
notificationText = Info.QueuedTextNotification;
@@ -545,8 +546,9 @@ public virtual int GetBuildTime(ActorInfo unit, BuildableInfo bi)
545546
.Select(t => t.GetProductionTimeModifier(techTree, Info.Type))
546547
.Append(bi.BuildDurationModifier)
547548
.Append(Info.BuildDurationModifier);
548-
if (!Actor.Owner.IsBot)
549-
time /= 2;
549+
550+
// 人类与AI统一:生产时间减半
551+
time /= 2;
550552
return Util.ApplyPercentageModifiers(time, modifiers);
551553
}
552554

@@ -559,10 +561,8 @@ public virtual int GetProductionCost(ActorInfo unit)
559561
var modifiers = unit.TraitInfos<IProductionCostModifierInfo>()
560562
.Select(t => t.GetProductionCostModifier(techTree, Info.Type));
561563

562-
if (!Actor.Owner.IsBot)
563-
return Util.ApplyPercentageModifiers(valued.Cost / 2, modifiers);
564-
565-
return Util.ApplyPercentageModifiers(valued.Cost, modifiers);
564+
// 人类与AI统一:生产成本减半
565+
return Util.ApplyPercentageModifiers(valued.Cost / 2, modifiers);
566566
}
567567

568568
protected virtual void PauseProduction(string itemName, bool paused)
@@ -809,3 +809,4 @@ public void Tick(PlayerResources pr)
809809
public void Pause(bool paused) { Paused = paused; }
810810
}
811811
}
812+

mods/copilot/rules/aircraft.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ TRAN:
313313
Queue: Aircraft
314314
BuildAtProductionType: Helicopter
315315
BuildPaletteOrder: 10
316-
Prerequisites: ~hpad, ~techlevel.medium
316+
Prerequisites: ~hpad, ~techlevel.medium, ~never-build
317317
Description: actor-tran.description
318318
Valued:
319319
Cost: 900
@@ -376,7 +376,7 @@ HELI:
376376
UpdatesPlayerStatistics:
377377
AddToArmyValue: true
378378
Health:
379-
HP: 12000
379+
HP: 36000
380380
RevealsShroud:
381381
MinRange: 10c0
382382
Range: 12c0
@@ -576,7 +576,7 @@ MH60:
576576
UpdatesPlayerStatistics:
577577
AddToArmyValue: true
578578
Health:
579-
HP: 10000
579+
HP: 30000
580580
RevealsShroud:
581581
MinRange: 8c0
582582
Range: 10c0

mods/copilot/rules/infantry.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ E1:
118118
ExternalCondition@CP_INF_FRAGILE:
119119
Condition: cp_inf_fragile
120120

121-
FirepowerMultiplier:
122-
Modifier: 150
123-
124121
SpeedMultiplier@CP_INF_SLOW:
125122
RequiresCondition: cp_inf_slow
126123
Modifier: 20
@@ -350,7 +347,7 @@ E4:
350347
Queue: Infantry
351348
BuildAtProductionType: Soldier
352349
BuildPaletteOrder: 70
353-
Prerequisites: ~\1
350+
Prerequisites: ~never-build
354351
Description: actor-e4.description
355352
Valued:
356353
Cost: 300
@@ -394,7 +391,7 @@ E6:
394391
Queue: Infantry
395392
BuildAtProductionType: Soldier
396393
BuildPaletteOrder: 60
397-
Prerequisites: ~never-build
394+
Prerequisites: ~barracks, ~techlevel.infonly
398395
Description: actor-e6.description
399396
Valued:
400397
Cost: 400
@@ -441,7 +438,7 @@ SPY:
441438
Queue: Infantry
442439
BuildAtProductionType: Soldier
443440
BuildPaletteOrder: 90
444-
Prerequisites: ~!infantry.england, dome, ~tent, ~techlevel.medium
441+
Prerequisites: ~!infantry.england, dome, ~tent, ~techlevel.medium, ~never-build
445442
Description: actor-spy.description
446443
Valued:
447444
Cost: 500
@@ -497,7 +494,7 @@ SPY:
497494
SPY.England:
498495
Inherits: SPY
499496
Buildable:
500-
Prerequisites: ~infantry.england, dome, ~tent, ~techlevel.medium
497+
Prerequisites: ~infantry.england, dome, ~tent, ~techlevel.medium, ~never-build
501498
Valued:
502499
Cost: 250
503500
GivesExperience:
@@ -574,7 +571,7 @@ MEDI:
574571
Queue: Infantry
575572
BuildAtProductionType: Soldier
576573
BuildPaletteOrder: 40
577-
Prerequisites: ~tent, ~techlevel.infonly
574+
Prerequisites: ~tent, ~techlevel.infonly, ~never-build
578575
Description: actor-medi.description
579576
Valued:
580577
Cost: 200
@@ -617,7 +614,7 @@ MECH:
617614
Queue: Infantry
618615
BuildAtProductionType: Soldier
619616
BuildPaletteOrder: 100
620-
Prerequisites: ~tent, fix, ~techlevel.medium
617+
Prerequisites: ~tent, fix, ~techlevel.medium, ~never-build
621618
Description: actor-mech.description
622619
Valued:
623620
Cost: 500
@@ -887,7 +884,7 @@ Ant:
887884
Queue: Infantry
888885
BuildAtProductionType: Soldier
889886
BuildPaletteOrder: 1954
890-
Prerequisites: ~barracks, ~bio
887+
Prerequisites: ~barracks, ~bio, ~never-build
891888
Description: actor-ant.description
892889
Selectable:
893890
Bounds: 1024, 1024, 0, -213

mods/copilot/rules/structures.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ GAP:
8585
Buildable:
8686
Queue: Defense
8787
BuildPaletteOrder: 110
88-
Prerequisites: atek, ~structures.allies, ~techlevel.high
88+
Prerequisites: atek, ~structures.allies, ~techlevel.high, ~never-build
8989
Description: actor-gap.description
9090
Selectable:
9191
Bounds: 1024, 1024
@@ -278,7 +278,7 @@ SYRD:
278278
Buildable:
279279
Queue: Building
280280
BuildPaletteOrder: 40
281-
Prerequisites: anypower, ~structures.allies, ~techlevel.low
281+
Prerequisites: anypower, ~structures.allies, ~techlevel.low, ~never-build
282282
Description: actor-syrd.description
283283
Valued:
284284
Cost: 1000
@@ -471,7 +471,7 @@ PDOX:
471471
Buildable:
472472
Queue: Defense
473473
BuildPaletteOrder: 120
474-
Prerequisites: atek, ~structures.allies, ~techlevel.unrestricted
474+
Prerequisites: atek, ~structures.allies, ~techlevel.unrestricted, ~never-build
475475
BuildLimit: 1
476476
Description: actor-pdox.description
477477
Valued:
@@ -621,7 +621,7 @@ AGUN:
621621
Bounds: 1024, 1024
622622
DecorationBounds: 1024, 1365, 0, -170
623623
Health:
624-
HP: 40000
624+
HP: 120000
625625
Armor:
626626
Type: Heavy
627627
RevealsShroud:
@@ -722,7 +722,7 @@ PBOX:
722722
CustomSellValue:
723723
Value: 400
724724
Health:
725-
HP: 40000
725+
HP: 120000
726726
Armor:
727727
Type: Heavy
728728
RevealsShroud:
@@ -777,7 +777,7 @@ HBOX:
777777
Buildable:
778778
Queue: Defense
779779
BuildPaletteOrder: 50
780-
Prerequisites: tent, ~structures.allies, ~techlevel.medium
780+
Prerequisites: tent, ~structures.allies, ~techlevel.medium, ~never-build
781781
Description: actor-hbox.description
782782
Valued:
783783
Cost: 750
@@ -843,7 +843,7 @@ GUN:
843843
Name: actor-gun.name
844844
Building:
845845
Health:
846-
HP: 40000
846+
HP: 120000
847847
Armor:
848848
Type: Heavy
849849
RevealsShroud:
@@ -1002,7 +1002,7 @@ ATEK:
10021002
Dimensions: 2,3
10031003
LocalCenterOffset: 0,-512,0
10041004
Health:
1005-
HP: 60000
1005+
HP: 180000
10061006
Armor:
10071007
Type: Wood
10081008
RevealsShroud:
@@ -1419,7 +1419,7 @@ HPAD:
14191419
Dimensions: 2,3
14201420
LocalCenterOffset: 0,-512,0
14211421
Health:
1422-
HP: 80000
1422+
HP: 240000
14231423
Armor:
14241424
Type: Wood
14251425
RevealsShroud:
@@ -1953,7 +1953,7 @@ TENT:
19531953
Dimensions: 2,3
19541954
LocalCenterOffset: 0,-512,0
19551955
Health:
1956-
HP: 60000
1956+
HP: 180000
19571957
Armor:
19581958
Type: Wood
19591959
RevealsShroud:

0 commit comments

Comments
 (0)