Skip to content

Commit

Permalink
Merge pull request OpenSAGE#835 from charliefoxtwo/feature/special-po…
Browse files Browse the repository at this point in the history
…wer-documentation

Document Generals special powers
  • Loading branch information
Tarcontar authored Feb 5, 2024
2 parents b46e113 + 46c58d0 commit a57b79c
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 44 deletions.
171 changes: 147 additions & 24 deletions src/OpenSage.Game/Logic/Object/SpecialPower.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenSage.Audio;
using System;
using OpenSage.Audio;
using OpenSage.Content;
using OpenSage.Data.Ini;
using OpenSage.Mathematics;
Expand Down Expand Up @@ -111,114 +112,214 @@ public enum AcademyType

public enum SpecialPowerType
{
/// <summary>
/// USA fuel-air bomb science ability.
/// </summary>
[IniEnum("SPECIAL_DAISY_CUTTER")]
DaisyCutter,
FuelAirBomb = 2,

/// <summary>
/// USA paradrop infantry science ability.
/// </summary>
[IniEnum("SPECIAL_PARADROP_AMERICA")]
ParadropAmerica,
ParadropAmerica = 3,

/// <summary>
/// China carpet bomb science ability.
/// </summary>
[IniEnum("SPECIAL_CARPET_BOMB")]
CarpetBomb,

/// <summary>
/// China cluster mines science ability.
/// </summary>
[IniEnum("SPECIAL_CLUSTER_MINES")]
ClusterMines,
ClusterMines = 5,

/// <summary>
/// China EMP bomb science ability.
/// </summary>
[IniEnum("SPECIAL_EMP_PULSE")]
EmpPulse,
EmpPulse = 6,

[IniEnum("SPECIAL_CRATE_DROP")]
CrateDrop,

/// <summary>
/// USA A-10 Thunderbolt strike science ability.
/// </summary>
[IniEnum("SPECIAL_A10_THUNDERBOLT_STRIKE")]
A10ThunderboltStrike,
A10ThunderboltStrike = 8,

[IniEnum("SPECIAL_NAPALM_STRIKE")]
NapalmStrike,

/// <summary>
/// China nuclear missile superweapon launch.
/// </summary>
[IniEnum("SPECIAL_NEUTRON_MISSILE")]
NeutronMissile,
NuclearMissile = 10,

[IniEnum("SPECIAL_DETONATE_DIRTY_NUKE")]
DetonateDirtyNuke,

/// <summary>
/// GLA SCUD storm superweapon launch.
/// </summary>
[IniEnum("SPECIAL_SCUD_STORM")]
ScudStorm,
ScudStorm = 12,

/// <summary>
/// China artillery barrage science ability.
/// </summary>
[IniEnum("SPECIAL_ARTILLERY_BARRAGE")]
ArtilleryBarrage,
ArtilleryBarrage = 13,

/// <summary>
/// China cash hack science ability.
/// </summary>
[IniEnum("SPECIAL_CASH_HACK")]
CashHack,
CashHack = 14,

/// <summary>
/// USA spy satellite command center ability.
/// </summary>
[IniEnum("SPECIAL_SPY_SATELLITE")]
SpySatellite = 15,

/// <summary>
/// USA spy drone science ability.
/// </summary>
[IniEnum("SPECIAL_SPY_DRONE")]
SpyDrone = 16,

/// <summary>
/// GLA radar van scan ability.
/// </summary>
[IniEnum("SPECIAL_RADAR_VAN_SCAN")]
RadarVanScan,
RadarVanScan = 17,

[IniEnum("SPECIAL_DEFECTOR")]
Defector,

[IniEnum("SPECIAL_TERROR_CELL")]
TerrorCell,

/// <summary>
/// GLA rebel ambush science ability.
/// </summary>
[IniEnum("SPECIAL_AMBUSH")]
Ambush,
Ambush = 20,

[IniEnum("SPECIAL_BLACK_MARKET_NUKE")]
BlackMarketNuke,

/// <summary>
/// GLA anthrax bomb science ability.
/// </summary>
[IniEnum("SPECIAL_ANTHRAX_BOMB")]
AnthraxBomb,

/// <summary>
/// USA Missile Defender laser-lock ability.
/// </summary>
[IniEnum("SPECIAL_MISSILE_DEFENDER_LASER_GUIDED_MISSILES")]
MissileDefenderLaserGuidedMissiles,
MissileDefenderLaserGuidedMissiles = 23,

/// <summary>
/// China Tank Hunter TNT ability.
/// </summary>
[IniEnum("SPECIAL_TANKHUNTER_TNT_ATTACK")]
TankHunterTntAttack,
TankHunterTntAttack = 24,

/// <summary>
/// USA Colonel Burton remote demo charge ability (plus detonation).
/// </summary>
[IniEnum("SPECIAL_REMOTE_CHARGES")]
RemoteCharges = 25,

/// <summary>
/// USA Colonel Burton timed demo charge ability.
/// </summary>
[IniEnum("SPECIAL_TIMED_CHARGES")]
TimedCharges = 26,

/// <summary>
/// China Hacker disable building ability.
/// </summary>
[IniEnum("SPECIAL_HACKER_DISABLE_BUILDING")]
HackerDisableBuilding,

[IniEnum("SPECIAL_INFANTRY_CAPTURE_BUILDING")]
InfantryCaptureBuilding,
HackerDisableBuilding = 27,

/// <summary>
/// China Black Lotus capture building ability.
/// </summary>
[IniEnum("SPECIAL_BLACKLOTUS_CAPTURE_BUILDING")]
BlackLotusCaptureBuilding,
BlackLotusCaptureBuilding = 28,

/// <summary>
/// Infantry capture building ability.
/// </summary>
/// <remarks>
/// 29 for usa, 30 for china, 31 for gla (enum string is the same)
/// todo: figure out how to handle this
/// </remarks>
[IniEnum("SPECIAL_INFANTRY_CAPTURE_BUILDING")]
InfantryCaptureBuilding = 29,

/// <summary>
/// China Black Lotus disable vehicle ability.
/// </summary>
[IniEnum("SPECIAL_BLACKLOTUS_DISABLE_VEHICLE_HACK")]
BlackLotusDisableVehicleHack,
BlackLotusDisableVehicleHack = 32,

/// <summary>
/// China Black Lotus cash hack ability.
/// </summary>
[IniEnum("SPECIAL_BLACKLOTUS_STEAL_CASH_HACK")]
BlackLotusStealCashHack,
BlackLotusStealCashHack = 33,

/// <summary>
/// USA Detention Center intelligence ability.
/// </summary>
[IniEnum("SPECIAL_CIA_INTELLIGENCE")]
CiaIntelligence = 34,

/// <summary>
/// All-faction emergency repair science ability.
/// </summary>
[IniEnum("SPECIAL_REPAIR_VEHICLES")]
RepairVehicles,
RepairVehicles = 35,

/// <summary>
/// GLA Bomb Truck disguise as vehicle ability.
/// </summary>
[IniEnum("SPECIAL_DISGUISE_AS_VEHICLE")]
DisguiseAsVehicle,

DisguiseAsVehicle = 36,

/// <summary>
/// USA Particle Cannon superweapon launch.
/// </summary>
/// <remarks>
/// Uses <see cref="OrderType.DirectParticleCannon"/> to guide.
/// </remarks>
[IniEnum("SPECIAL_PARTICLE_UPLINK_CANNON")]
ParticleUplinkCannon = 37,

[IniEnum("SPECIAL_CASH_BOUNTY")]
CashBounty,

/// <summary>
/// USA Strategy center Bombardment/Hold the Line/Search and Destroy abilities.
/// </summary>
/// <remarks>
/// Uses flags to set plan type.
/// </remarks>
[IniEnum("SPECIAL_CHANGE_BATTLE_PLANS")]
ChangeBattlePlans = 41,

/// <summary>
/// USA Ambulance clean up toxins ability.
/// </summary>
[IniEnum("SPECIAL_CLEANUP_AREA")]
CleanupArea = 42,

Expand Down Expand Up @@ -715,4 +816,26 @@ public enum SpecialPowerFlag
[IniEnum("RESPECT_RECHARGE_TIME_DISCOUNT")]
RespectRechargeTimeDiscount,
}

// todo: these entries are very similar to CommandButtonOrderType. Perhaps in the future CommandButtonOrderType should be reordered as the ordinal values don't appear to be used?
[Flags]
public enum SpecialPowerOrderFlags
{
NeedTargetEnemyObject = 1 << 0,
NeedTargetNeutralObject = 1 << 1,
NeedTargetAllyObject = 1 << 2,
Unknown1 = 1 << 3,
Unknown2 = 1 << 4,
NeedTargetPosition = 1 << 5,
NeedUpgrade = 1 << 6,
NeedSpecialPowerScience = 1 << 7,
OkForMultiSelect = 1 << 8,
ContextModeCommand = 1 << 9,
CheckLike = 1 << 10,
Unknown3 = 1 << 11,
Unknown4 = 1 << 12,
OptionOne = 1 << 13,
OptionTwo = 1 << 14,
OptionThree = 1 << 15,
}
}
21 changes: 19 additions & 2 deletions src/OpenSage.Game/Logic/Orders/OrderProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,13 @@ public void Process(IEnumerable<Order> orders)
break;
case OrderType.SpecialPowerAtLocation:
{
var specialPowerDefinitionId = order.Arguments[0].Value.Integer;
var specialPowerDefinitionId = (SpecialPowerType) order.Arguments[0].Value.Integer;
var specialPowerLocation = order.Arguments[1].Value.Position;
var unknownObjectId = order.Arguments[2].Value.ObjectId;
var commandFlags = (SpecialPowerOrderFlags) order.Arguments[3].Value.Integer;
var commandCenterSource = order.Arguments[4].Value.ObjectId;

var specialPower = _game.AssetStore.SpecialPowers.GetByInternalId(specialPowerDefinitionId);
var specialPower = _game.AssetStore.SpecialPowers.GetByInternalId((int)specialPowerDefinitionId); // todo: using the internal id is likely incorrect - these items have specific values that don't line up with how they are loaded
foreach (var unit in player.SelectedUnits) // todo: usa spy satellite is special power at location, but has nothing to do with selected objects
{
unit.SpecialPowerAtLocation(specialPower, specialPowerLocation);
Expand All @@ -322,8 +325,22 @@ public void Process(IEnumerable<Order> orders)
_game.Audio.PlayAudioEvent(specialPower.InitiateAtLocationSound?.Value); // todo: play this at location
}
break;

case OrderType.SpecialPower:
{
var specialPowerDefinitionId = (SpecialPowerType) order.Arguments[0].Value.Integer;
var commandFlags = (SpecialPowerOrderFlags) order.Arguments[1].Value.Integer;
var commandCenterSource = order.Arguments[2].Value.ObjectId;
}
throw new NotImplementedException();

case OrderType.SpecialPowerAtObject:
{
var specialPowerDefinitionId = (SpecialPowerType) order.Arguments[0].Value.Integer;
var targetId = order.Arguments[1].Value.ObjectId;
var commandFlags = (SpecialPowerOrderFlags) order.Arguments[2].Value.Integer;
var commandCenterSource = order.Arguments[3].Value.ObjectId;
}
throw new NotImplementedException();

case OrderType.EndGame:
Expand Down
24 changes: 6 additions & 18 deletions src/OpenSage.Game/Logic/Orders/OrderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,9 @@ public enum OrderType
SelectGroup8 = 1024,
SelectGroup9 = 1025,

// the leading integer for these special power arguments seems to correspond to SpecialPowerType
// burton detonate demo charge SpecialPower(Integer:25, Integer:256, ObjectId:0)
// detention center intelligence SpecialPower(Integer:34, Integer:0, ObjectId:0)
// strategy center bombardment SpecialPower(Integer:41, Integer:9216, ObjectId:0)
// strategy center hold the line SpecialPower(Integer:41, Integer:17408, ObjectId:0)
// strategy center search & destroy SpecialPower(Integer:41, Integer:33792, ObjectId:0)
SpecialPower = 1040,
// spy satellite SpecialPowerAtLocation(Integer:15, Position:<304.26398, 409.33313, 10>, ObjectId:0, Integer:544, ObjectId:0)
// spy drone SpecialPowerAtLocation(Integer:16, Position:<825.8123, 606.12665, 10>, ObjectId:0, Integer:928, ObjectId:4) // last object id could be command center source?
// particle cannon SpecialPowerAtLocation(Integer:37, Position:<442.46735, 318.8226, 10>, ObjectId:0, Integer:672, ObjectId:0)
// ambulance cleanup area SpecialPowerAtLocation(Integer:42, Position:<443.1347, 219.59857, 10>, ObjectId:0, Integer:288, ObjectId:0)
SpecialPowerAtLocation = 1041,
// burton remote demo charge SpecialPowerAtObject(Integer:25, ObjectId:2, Integer:771, ObjectId:0) // first object id is target
// burton timed demo charge SpecialPowerAtObject(Integer:26, ObjectId:3, Integer:259, ObjectId:0) // first object id is target
SpecialPowerAtObject = 1042, // Integer:29, ObjectId:199, Integer:323, ObjectId:0
SpecialPower = 1040, // Integer:25, Integer:256, ObjectId:0 // SpecialPowerType, SpecialPowerOrderFlags, source command center?
SpecialPowerAtLocation = 1041, // Integer:35, Position:<1105.9589, 728.7699, 18.75>, ObjectId:2816, Integer:672, ObjectId:657 // SpecialPowerType, location, unknown, SpecialPowerOrderFlags, source command center?
SpecialPowerAtObject = 1042, // Integer:14, ObjectId:674, Integer:643, ObjectId:657 // SpecialPowerType, target object, SpecialPowerOrderFlags, source command center?
SetRallyPoint = 1043,
PurchaseScience = 1044,
BeginUpgrade = 1045, //encountered while adding landmines to power plant: ObjectId:671,Integer:1604 (mines is Upgrades[13]), also when upgrading usa power plant (ObjectId:673,Integer:1593), (ObjectId:671,Integer:1593), also for flashbangs in the barracks (ObjectId:678,Integer:1594)
Expand Down Expand Up @@ -100,7 +88,7 @@ public enum OrderType
// dragon tank fire wall Integer:1, Position:<530.40765, 607.319, 9.9999695>, Integer:2147483647, ObjectId:0 // secondary weapon is fire wall
// comanche rocket pods Integer:2, Position:<373.81445, 256.29944, 10>, Integer:2147483647, ObjectId:0 // tertiary weapon is rocket pods
UseWeapon = 1038,
Unknown1039 = 1039,
SnipeVehicle = 1039, // Integer:1, ObjectId:6, Integer:2147483647 // first integer argument could be because sniper is secondary weapon (similar to useweapon above)
Unknown1050 = 1050,

Unknown1055 = 1055,
Expand All @@ -110,7 +98,7 @@ public enum OrderType
RepairVehicle = 1062, // ObjectId:3 includes vehicles returning to war factory for repair and helicopters landing and airfields for repair
Unknown1063 = 1063,
RepairStructure = 1064, // ObjectId:4 when a dozer is ordered to repair a structure
Enter = 1066,
Enter = 1066, // used for entering friendly vehicles and for hijacking vehicles
GatherDumpSupplies = 1067, // used for both gathering from a supply source and dumping supplies

AttackMove = 1069, // Position:<1343.561, 378.53568, 18.75>
Expand All @@ -120,7 +108,7 @@ public enum OrderType
Unknown1073 = 1073,
StopMoving = 1074,
Scatter = 1075, // no arguments
Unknown1076 = 1076,
HackInternet = 1076, // no arguments
Cheer = 1077, // no arguments

SelectWeapon = 1079, // Integer:1 // e.g. USA Ranger, 1 for flashbang 0 for machine gun
Expand Down
Loading

0 comments on commit a57b79c

Please sign in to comment.