Skip to content

Commit bac4dac

Browse files
authored
Drone carrier (#56)
1 parent 0ed3c22 commit bac4dac

File tree

21 files changed

+1940
-4
lines changed

21 files changed

+1940
-4
lines changed

Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,5 +677,10 @@ static PoolSizeRec PoolSizes[] =
677677
{ "SmudgeSet", 32, 32},
678678
{ "Smudge", 128, 32},
679679
{ "ResetSpecialPowerTimerWhileAliveUpdate", 8, 8 },
680+
{ "DroneCarrierAIUpdate", 8, 8 },
681+
{ "DroneCarrierSlavedUpdate", 8, 8 },
682+
{ "DroneCarrierContain", 8, 8 },
683+
{ "W3DDependencyCarrierDraw", 16, 16 },
684+
{ "CarrierDroneAIUpdate", 16, 16 },
680685
{ 0, 0, 0 }
681686
};

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ set(GAMEENGINE_SRC
335335
Include/GameLogic/Module/DelayedUpgradeBehavior.h
336336
Include/GameLogic/Module/FlammableUpdate.h
337337
Include/GameLogic/Module/FlightDeckBehavior.h
338+
Include/GameLogic/Module/DroneCarrierAIUpdate.h
338339
Include/GameLogic/Module/FloatUpdate.h
339340
Include/GameLogic/Module/FXListDie.h
340341
Include/GameLogic/Module/GarrisonContain.h
@@ -497,6 +498,9 @@ set(GAMEENGINE_SRC
497498
Include/GameLogic/Module/WorkerAIUpdate.h
498499
Include/GameLogic/Module/KodiakDeploymentUpdate.h
499500
Include/GameLogic/Module/KodiakUpdate.h
501+
Include/GameLogic/Module/DroneCarrierSlavedUpdate.h
502+
Include/GameLogic/Module/DroneCarrierContain.h
503+
Include/GameLogic/Module/CarrierDroneAIUpdate.h
500504
Include/GameLogic/Object.h
501505
Include/GameLogic/ObjectCreationList.h
502506
Include/GameLogic/ObjectIter.h
@@ -946,6 +950,7 @@ set(GAMEENGINE_SRC
946950
Source/GameLogic/Object/Contain/RiderChangeContain.cpp
947951
Source/GameLogic/Object/Contain/TransportContain.cpp
948952
Source/GameLogic/Object/Contain/TunnelContain.cpp
953+
Source/GameLogic/Object/Contain/DroneCarrierContain.cpp
949954
Source/GameLogic/Object/Create/CreateModule.cpp
950955
Source/GameLogic/Object/Create/GrantUpgradeCreate.cpp
951956
Source/GameLogic/Object/Create/LockWeaponCreate.cpp
@@ -1017,6 +1022,8 @@ set(GAMEENGINE_SRC
10171022
Source/GameLogic/Object/Update/AIUpdate/WanderAIUpdate.cpp
10181023
Source/GameLogic/Object/Update/AIUpdate/TeleporterAIUpdate.cpp
10191024
Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp
1025+
Source/GameLogic/Object/Update/AIUpdate/DroneCarrierAIUpdate.cpp
1026+
Source/GameLogic/Object/Update/AIUpdate/CarrierDroneAIUpdate.cpp
10201027
Source/GameLogic/Object/Update/AnimationSteeringUpdate.cpp
10211028
Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp
10221029
Source/GameLogic/Object/Update/AutoDepositUpdate.cpp
@@ -1094,6 +1101,7 @@ set(GAMEENGINE_SRC
10941101
Source/GameLogic/Object/Update/ArmorDamageScalarUpdate.cpp
10951102
Source/GameLogic/Object/Update/KodiakDeploymentUpdate.cpp
10961103
Source/GameLogic/Object/Update/KodiakUpdate.cpp
1104+
Source/GameLogic/Object/Update/DroneCarrierSlavedUpdate.cpp
10971105
Source/GameLogic/Object/Upgrade/ActiveShroudUpgrade.cpp
10981106
Source/GameLogic/Object/Upgrade/ArmorUpgrade.cpp
10991107
Source/GameLogic/Object/Upgrade/CommandSetUpgrade.cpp
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "Common/STLTypedefs.h"
4+
#include "Common/GameMemory.h"
5+
#include "GameLogic/AIStateMachine.h"
6+
#include "GameLogic/Module/AIUpdate.h"
7+
8+
9+
//-------------------------------------------------------------------------------------------------
10+
class CarrierDroneAIUpdate : public AIUpdateInterface
11+
{
12+
13+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(CarrierDroneAIUpdate, "CarrierDroneAIUpdate")
14+
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA(CarrierDroneAIUpdate, AIUpdateModuleData)
15+
16+
//virtual UpdateSleepTime update();
17+
18+
public:
19+
20+
CarrierDroneAIUpdate(Thing* thing, const ModuleData* moduleData);
21+
// virtual destructor prototype provided by memory pool declaration
22+
23+
//stop contained drones from attacking
24+
virtual void privateAttackPosition(const Coord3D* pos, Int maxShotsToFire, CommandSourceType cmdSource) override; ///< attack given spot
25+
};
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// FILE: DroneCarrierAIUpdate.h /////////////////////////////////////////////////////////////////////
2+
// Desc: Mobile drone carrier.
3+
///////////////////////////////////////////////////////////////////////////////////////////////////
4+
5+
#pragma once
6+
7+
#ifndef __DRONE_CARRIER_AI_UPDATE_H
8+
#define __DRONE_CARRIER_AI_UPDATE_H
9+
10+
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
11+
#include "GameLogic/Module/BehaviorModule.h"
12+
#include "GameLogic/Module/DieModule.h"
13+
#include "GameLogic/Module/AIUpdate.h"
14+
#include "GameLogic/Module/SpawnBehavior.h"
15+
16+
17+
//-------------------------------------------------------------------------------------------------
18+
class DroneCarrierAIUpdateModuleData : public AIUpdateModuleData
19+
{
20+
public:
21+
Int m_slots;
22+
UnsignedInt m_respawn_time;
23+
24+
std::vector<AsciiString> m_spawnTemplateNameData;
25+
26+
DroneCarrierAIUpdateModuleData();
27+
28+
static void buildFieldParse(MultiIniFieldParse& p);
29+
};
30+
31+
//-------------------------------------------------------------------------------------------------
32+
//-------------------------------------------------------------------------------------------------
33+
class DroneCarrierAIUpdate : public AIUpdateInterface,
34+
public SpawnBehaviorInterface,
35+
public DieModuleInterface
36+
//public ExitInterface
37+
{
38+
39+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DroneCarrierAIUpdate, "DroneCarrierAIUpdate")
40+
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA(DroneCarrierAIUpdate, DroneCarrierAIUpdateModuleData)
41+
42+
public:
43+
44+
DroneCarrierAIUpdate(Thing* thing, const ModuleData* moduleData);
45+
// virtual destructor prototype provided by memory pool declaration
46+
47+
static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_DIE); }
48+
49+
// BehaviorModule
50+
virtual DieModuleInterface* getDie() { return this; }
51+
52+
// UpdateModule
53+
virtual UpdateSleepTime update();
54+
55+
// SpawnBehaviorInterface
56+
virtual SpawnBehaviorInterface* getSpawnBehaviorInterface() { return this; }
57+
58+
virtual Bool maySpawnSelfTaskAI(Real maxSelfTaskersRatio) { return false; };
59+
virtual void onSpawnDeath(ObjectID deadSpawn, DamageInfo* damageInfo);
60+
virtual Object* getClosestSlave(const Coord3D* pos);
61+
virtual void orderSlavesToAttackTarget(Object* target, Int maxShotsToFire, CommandSourceType cmdSource);
62+
virtual void orderSlavesToAttackPosition(const Coord3D* pos, Int maxShotsToFire, CommandSourceType cmdSource);
63+
virtual CanAttackResult getCanAnySlavesAttackSpecificTarget(AbleToAttackType attackType, const Object* target, CommandSourceType cmdSource);
64+
virtual CanAttackResult getCanAnySlavesUseWeaponAgainstTarget(AbleToAttackType attackType, const Object* victim, const Coord3D* pos, CommandSourceType cmdSource);
65+
virtual Bool canAnySlavesAttack();
66+
virtual void orderSlavesToGoIdle(CommandSourceType cmdSource);
67+
virtual void orderSlavesDisabledUntil(DisabledType type, UnsignedInt frame);
68+
virtual void orderSlavesToClearDisabled(DisabledType type);
69+
virtual void giveSlavesStealthUpgrade(Bool grantStealth);
70+
virtual Bool areAllSlavesStealthed() const;
71+
virtual void revealSlaves();
72+
virtual Bool doSlavesHaveFreedom() const { return false; };
73+
74+
// DieModule
75+
virtual void onDie(const DamageInfo* damageInfo);
76+
77+
// AIUpdateInterface
78+
virtual void aiDoCommand(const AICommandParms* parms);
79+
80+
static bool isDroneCombatReady(Object* drone);
81+
82+
private:
83+
84+
Bool is_full(); ///< has this carrier an open spot?
85+
Bool createSpawn(); ///< Actual work of creating a guy
86+
87+
void deployDrones(); ///< let all drones exit the transport
88+
void retrieveDrones(); ///< order all drones to go back to the transport
89+
90+
void propagateOrdersToDrones();
91+
void propagateOrderToSpecificDrone(Object* drone);
92+
93+
//works for both Object and Coord3D
94+
template <typename T>
95+
bool targetInRange(const T* target);
96+
97+
const ThingTemplate* m_spawnTemplate; ///< What it is I spawn
98+
std::vector<ObjectID> m_spawnIDs; ///< IDs of currently active drones
99+
std::vector<AsciiString>::const_iterator m_templateNameIterator;
100+
UnsignedInt m_rebuild_time; // which frame a drone will be rebuilt. 0 if not active
101+
Bool m_active; ///< Am I currently turned on
102+
Bool m_initial_spawns; ///< Have initial drones be spawned? (first update frame)
103+
ObjectID m_designatedTarget;
104+
AICommandType m_designatedCommand;
105+
Coord3D m_designatedPosition;
106+
};
107+
108+
template bool DroneCarrierAIUpdate::targetInRange<Object>(const Object* target);
109+
template bool DroneCarrierAIUpdate::targetInRange<Coord3D>(const Coord3D* target);
110+
111+
#endif // __DRONE_CARRIER_AI_UPDATE_H
112+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// FILE: DroneCarrierContain.h ////////////////////////////////////////////////////////////////////////
2+
// Desc: expanded transport contain to work with drone carrier
3+
///////////////////////////////////////////////////////////////////////////////////////////////////
4+
5+
#pragma once
6+
7+
#ifndef __DRONE_CARRIER_CONTAIN_H_
8+
#define __DRONE_CARRIER_CONTAIN_H_
9+
10+
// USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
11+
#include "GameLogic/Module/OpenContain.h"
12+
#include "GameLogic/Module/TransportContain.h"
13+
#include "GameLogic/Module/GarrisonContain.h"
14+
15+
//-------------------------------------------------------------------------------------------------
16+
class DroneCarrierContainModuleData: public TransportContainModuleData
17+
{
18+
public:
19+
Real m_launchVelocityBoost;
20+
21+
DroneCarrierContainModuleData();
22+
23+
static void buildFieldParse(MultiIniFieldParse& p);
24+
25+
};
26+
27+
//-------------------------------------------------------------------------------------------------
28+
class DroneCarrierContain: public TransportContain
29+
{
30+
31+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DroneCarrierContain, "DroneCarrierContain")
32+
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA(DroneCarrierContain, DroneCarrierContainModuleData)
33+
34+
public:
35+
36+
DroneCarrierContain(Thing* thing, const ModuleData* moduleData);
37+
// virtual destructor prototype provided by memory pool declaration
38+
39+
//Only allow slaved units in
40+
virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
41+
42+
virtual Bool isEnclosingContainerFor(const Object* obj) const { return true; } //TODO param in module
43+
44+
virtual Bool isPassengerAllowedToFire(ObjectID id = INVALID_ID) const override; ///< Hey, can I shoot out of this container?
45+
46+
//support for specific exit bones
47+
virtual void onRemoving(Object* obj) override;
48+
virtual void onContaining(Object* obj, Bool wasSelected) override; ///< object now contains 'obj'
49+
50+
virtual short getRiderSlot(ObjectID riderID) const override;
51+
virtual short getPortableSlot(ObjectID portableID) const override;
52+
virtual const ContainedItemsList* getAddOnList() const override;
53+
virtual ContainedItemsList* getAddOnList() override;
54+
55+
// Called from the AI update to reload the contained drones
56+
void updateContainedReloadingStatus();
57+
58+
protected:
59+
60+
// Saves slot assignement and frame when entered
61+
std::vector<std::tuple<ObjectID, UnsignedInt>> m_contained_units;
62+
};
63+
64+
#endif // __TransportContain_H_
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
// FILE: DroneCarrierSlavedUpdate.cpp /////////////////////////////////////////////////////////////////////////
3+
// Desc: expanded Slaved update to work with drone carrier
4+
///////////////////////////////////////////////////////////////////////////////////////////////////
5+
#pragma once
6+
7+
#ifndef _DRONE_CARRIER_SLAVED_UPDATE_H_
8+
#define _DRONE_CARRIER_SLAVED_UPDATE_H_
9+
#include "Common/INI.h"
10+
#include "GameLogic/Module/UpdateModule.h"
11+
#include "GameLogic/Module/SlavedUpdate.h"
12+
13+
//-------------------------------------------------------------------------------------------------
14+
class DroneCarrierSlavedUpdateModuleData : public SlavedUpdateModuleData
15+
{
16+
public:
17+
Real m_leashRange;
18+
19+
DroneCarrierSlavedUpdateModuleData();
20+
static void buildFieldParse(MultiIniFieldParse& p);
21+
};
22+
23+
class DroneCarrierSlavedUpdate : public SlavedUpdate
24+
{
25+
26+
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DroneCarrierSlavedUpdate, "DroneCarrierSlavedUpdate")
27+
MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA(DroneCarrierSlavedUpdate, DroneCarrierSlavedUpdateModuleData)
28+
29+
public:
30+
31+
DroneCarrierSlavedUpdate(Thing* thing, const ModuleData* moduleData);
32+
// virtual destructor prototype provided by memory pool declaration
33+
34+
virtual UpdateSleepTime update(); ///< Deciding whether or not to make new guys
35+
36+
virtual SlavedUpdateInterface* getSlavedUpdateInterface() { return this; }
37+
38+
};
39+
40+
#endif

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SlavedUpdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class SlavedUpdate : public UpdateModule, public SlavedUpdateInterface
167167

168168
virtual UpdateSleepTime update(); ///< Deciding whether or not to make new guys
169169

170-
private:
170+
protected:
171171
void startSlavedEffects( const Object *slaver ); ///< We have been marked as Slaved, so we can't be selected or move too far or other stuff
172172
void stopSlavedEffects(); ///< We are no longer slaved.
173173

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/TransportContain.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ class TransportContain : public OpenContain
109109
void letRidersUpgradeWeaponSet( void );
110110

111111
Bool m_payloadCreated;
112-
113-
private:
114-
115112
Int m_extraSlotsInUse;
113+
116114
UnsignedInt m_frameExitNotBusy;
117115

118116
};

GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ class Object : public Thing, public Snapshot
478478
// Weapons & Damage -------------------------------------------------------------------------------------------------
479479
void reloadAllAmmo(Bool now);
480480
Bool isOutOfAmmo() const;
481+
Bool isFullAmmo() const; //added by OFS
481482
Bool hasAnyWeapon() const;
482483
Bool hasAnyDamageWeapon() const; //Kris: a should be used for real weapons that directly inflict damage... not deploy, hack, etc.
483484
Bool hasWeaponToDealDamageType(DamageType typeToDeal) const;

GeneralsMD/Code/GameEngine/Include/GameLogic/WeaponSet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class WeaponSet : public Snapshot
238238
void updateWeaponSet(const Object* obj);
239239
void reloadAllAmmo(const Object *obj, Bool now);
240240
Bool isOutOfAmmo() const;
241+
Bool isFullAmmo() const; // Added for OFS
241242
Bool hasAnyWeapon() const { return m_filledWeaponSlotMask != 0; }
242243
Bool hasAnyDamageWeapon() const { return m_hasDamageWeapon; }
243244
Bool hasWeaponToDealDamageType(DamageType typeToDeal) const { return m_totalDamageTypeMask.test(typeToDeal); }
@@ -281,6 +282,7 @@ class WeaponSet : public Snapshot
281282

282283
Weapon* getWeaponInWeaponSlot(WeaponSlotType wslot) const;
283284

285+
284286
static ModelConditionFlags getModelConditionForWeaponSlot(WeaponSlotType wslot, WeaponSetConditionType a);
285287
};
286288

0 commit comments

Comments
 (0)