Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
dp88_ar.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#pragma once
13
14#include "dp88_customAI.h"
15#include "dp88_custom_timer_defines.h"
16#include "dp88_misc.h"
17
18// -------------------------------------------------------------------------------------------------
19
77{
78public:
79 // Events
80 void Created( GameObject *obj );
81 void Custom( GameObject *obj, int type, int param, GameObject *sender );
82 void Timer_Expired( GameObject *obj, int number );
83 void Destroyed( GameObject *obj );
84
87
88protected:
89 bool created;
90
91 short team0_countryID; // Country ID for Soviets
92 short team1_countryID; // Country ID for Allies
93
94public:
95 // Mirage Tank
96 char* mirageTank_disguisePresets[3];
97};
98
99// -------------------------------------------------------------------------------------------------
100
104class dp88_AR_Vehicle : public ScriptImpClass
105{
106 // Variables
107 int pilotID; // Pilots GameObject ID
108 int attackingTerrorDroneID; // ID of any Terror Drones attacking this vehicle
109 bool dead; // Set to true when we die
110
111 // Events
112 void Custom(GameObject *obj,int type,int param,GameObject *sender);
113 void Created(GameObject *obj);
114 void Timer_Expired( GameObject *obj,int number );
115 void Killed(GameObject *obj, GameObject *killer);
116 void Damaged(GameObject *obj, GameObject *damager, float amount);
117 void Animation_Complete ( GameObject *obj, const char *animation_name );
118};
119
120
121
122
123/*------------------------
124Deployable Infantry script
125 Allows an infantry unit to 'deploy', which involves switching to
126 a more powerful weapon and creating a defensive structure of some
127 kind at the players location.
128--------------------------*/
129
130class dp88_AR_Deployable_Infantry : public JFW_Key_Hook_Base
131{
132public:
133 // Events
134 void Created( GameObject *obj );
135 void Killed( GameObject *obj, GameObject *killer );
136 void Destroyed ( GameObject* obj );
137 void KeyHook();
138 void Custom( GameObject *obj, int type, int param, GameObject *sender );
139 void Timer_Expired( GameObject *obj,int number ); // TEMPORARY
140
141 // Get armour type to set for the given veterancy level
142 const char* GetArmourType ( int vetLevel );
143
144 // Get weapon powerup to grant for the given veterancy level
145 const char* GetWeaponPowerup ( int vetLevel );
146
147protected:
148 void Deploy(GameObject* obj);
149
150 void Undeploy(GameObject* obj);
151
152 // Variables
153 int objectID;
154 bool deployed;
155 char* undeployedWeapon;
156 int deployedObjectId;
157
158 int cannotDeployStringId;
159 int cannotDeploySoundId;
160 time_t lastDeploy; // Timestamp of last deploy keyhook event (prevent constant spamming)
161
162 /* Current veterancy level */
163 int currentVetLevel;
164
165 /* Flags to mark which veterancy levels have deployed weapon powerups */
166 bool hasRookieWeaponPowerup, hasVeteranWeaponPowerup, hasEliteWeaponPowerup;
167
168 /* Original values for Skin & Armour types */
169 char undeployedSkinType[128], undeployedArmourType[128];
170
172 bool m_bCanDrive;
173};
174
175
176
177
178/*------------------------
179Chrono Legionnaire
180--------------------------*/
181
182class dp88_AR_CLEG : public ScriptImpClass {
183 bool phasing;
184 bool phasingBack;
185 int zPosDropObj;
186 short timeRemaining;
187 int dropObjID;
188
189 void Created(GameObject *obj);
190 void Damaged(GameObject *obj, GameObject *damager, float amount);
191 void Killed(GameObject *obj, GameObject *killer);
192 void Timer_Expired( GameObject *obj,int number );
193};
194
195class dp88_AR_CLEG_target : public ScriptImpClass {
196 void Created(GameObject *obj);
197 void Damaged(GameObject *obj, GameObject *damager, float amount);
198 void Killed(GameObject *obj, GameObject *killer);
199 void Timer_Expired( GameObject *obj,int number );
200
201 int currentResistance;
202 int lastResistanceCheck;
203 int effectObjectId;
204};
205
206
207
208
209// -------------------------------------------------------------------------------------------------
210
270class dp88_Ore_Miner : public JFW_Key_Hook_Base // Inherit from keyhook base for chrono miner
271{
272protected:
274
277
280
283 bool m_bUseAI;
287 const char* m_resourceName;
288
289 const char* m_animations[3];
290 const char* m_animSounds[3];
293public:
294 // Default event handlers for the AI miners
295 virtual void Created ( GameObject *obj );
296 virtual void Custom ( GameObject *obj, int type, int param, GameObject *sender );
297 virtual void Action_Complete( GameObject *obj, int action_id, ActionCompleteReason complete_reason );
298 virtual void KeyHook() {};
299
300protected:
301 // These functions implement standard drive to ore field, harvest some ore, return to refinery,
302 // dock and unload ore functionlity for an AI miner. They can be overloaded to provide custom
303 // functionality in derived classes.
304 virtual void DriveToOreField ( GameObject *obj );
305 virtual void EnteredOreField ( GameObject *obj, GameObject* oreField );
306 virtual void ExitedOreField ( GameObject *obj, GameObject* oreField );
307 virtual void ReturnToRefinery ( GameObject *obj );
308 virtual void DockAtRefinery ( GameObject *obj );
309 virtual void DockedAtRefinery ( GameObject *obj );
310 virtual void UndockedFromRefinery ( GameObject *obj );
311
312 // AI states for the miner
313 enum MINER_AISTATES
314 {
315 MINER_AISTATE_IDLE,
316 MINER_AISTATE_SEARCH_FOR_ORE,
317 MINER_AISTATE_DRIVE_TO_ORE,
318 MINER_AISTATE_COLLECTING_ORE,
319 MINER_AISTATE_RETURN_TO_REFINERY,
320 MINER_AISTATE_DOCK_AT_REFINERY,
321 MINER_AISTATE_UNLOADING_ORE
322 };
323
324 enum MINER_ACTIONIDS
325 {
326 MINER_ACTIONID_DRIVE_TO_ORE,
327 MINER_ACTIONID_RETURN_TO_REFINERY,
328 MINER_ACTIONID_DOCK_AT_REFINERY
329 };
330
331 enum MINER_ANIMID
332 {
333 MINER_ANIM_IDLE,
334 MINER_ANIM_MINING,
335 MINER_ANIM_DUMPING
336 };
337
338 void UpdateAnimation ( GameObject* pObj, MINER_ANIMID animId );
339};
340
341// -------------------------------------------------------------------------------------------------
342
351{
352protected:
355
356public:
357 void Created ( GameObject *obj );
358 void Damaged ( GameObject *obj, GameObject *damager, float amount );
359 void Custom ( GameObject *obj, int type, int param, GameObject *sender );
360 void KeyHook();
361
362private:
363 void ReturnToRefinery ( GameObject *obj );
364 bool Start_Chronoshift( GameObject *obj );
365 void Do_Chronoshift( GameObject *obj, int target_zone_id );
366 void Complete_Chronoshift( GameObject *obj );
367
368 bool CanChronoshiftToLocation ( GameObject* obj, Vector3& location );
369
370 enum CMINER_AISTATES
371 {
372 CMINER_AISTATE_CHRONOSHIFTING = MINER_AISTATE_UNLOADING_ORE+1
373 };
374};
375
376// -------------------------------------------------------------------------------------------------
377
385class dp88_AR_Chrono_Miner_Chronozone : public ScriptImpClass
386{
387 void Created( GameObject *obj );
388
389public:
390 // Set by dp88_AR_Chrono_Miner when it is shifting to this zone, used
391 // to prevent multiple miners trying to shift to the same place
392 int chronominer_id;
393};
394
395// -------------------------------------------------------------------------------------------------
396
445class dp88_Ore_Field : public ScriptImpClass
446{
447public:
448 dp88_Ore_Field() : m_pZoneObserver(NULL) {}
449 void Created ( GameObject* pObj );
450 void Detach ( GameObject* pObj );
451 void Entered ( GameObject* pZoneObj, GameObject* pEnterer );
452 void Exited ( GameObject* pZoneObj, GameObject* pExiter );
453
460 void AddOre ( unsigned int nUnits );
461
470 unsigned int RemoveOre ( unsigned int nUnits = 1 );
471
477 unsigned int NumOreUnits() { return m_nOreUnits; }
478
480 unsigned int GetOreValue() { return m_oreValue; }
481
483 bool IsInfinite() { return m_oreCapacity == 0; }
484
486 bool IsSuitableForAI() { return !m_bAiIgnore; }
487
488
489protected:
490 void UpdateAnimationFrame();
491 void UpdateAnimationFrame( GameObject* pObj );
492
493
494 unsigned int m_myObjId;
495 unsigned int m_nOreUnits;
496 int m_minerZoneId;
497
500 unsigned int m_oreValue;
501 unsigned int m_oreCapacity;
502
503 const char* m_strAnimation;
504 unsigned int m_nAnimationFullFrame;
505 unsigned int m_nAnimationEmptyFrame;
506
507 Vector3 m_zoneSizeFull;
508 float m_zoneStepX;
509 float m_zoneStepY;
510
511 bool m_bAiIgnore;
516 class dp88_Ore_Field_Observer : public GameObjObserverClass
517 {
518 public:
520 { m_pParent = pParent; }
521
522 protected:
523 dp88_Ore_Field* m_pParent;
524
525 // These are observer events we actually use
526 void Entered( GameObject* pObj, GameObject* pEnterer ) { m_pParent->Entered(pObj, pEnterer); }
527 void Exited( GameObject* pObj, GameObject* pExiter ) { m_pParent->Exited(pObj, pExiter); }
528
529 private:
530 // These are observer events we don't use but have to provide an implementation for to compile
531 void Attach ( GameObject* pObj ) {};
532 void Detach ( GameObject* pObj ) {};
533 void Animation_Complete ( GameObject *pObj, const char *animation_name ) {};
534 void Created(GameObject* pObj) {};
535 void Destroyed(GameObject* pObj) {};
536 void Killed(GameObject* pObj,GameObject* pKiller) {};
537 void Damaged(GameObject* pObj,GameObject* pDamager,float amount) {};
538 void Custom(GameObject* pObj,int type,int param,GameObject* pSender) {};
539 void Sound_Heard(GameObject* pObj,const CombatSound & sound) {};
540 void Enemy_Seen(GameObject* pObj,GameObject* pEnemy) {};
541 void Action_Complete(GameObject* pObj,int action_id,ActionCompleteReason complete_reason) {};
542 void Timer_Expired(GameObject* pObj,int number) {};
543 void Poked(GameObject* pObj,GameObject* pPoker) {};
544
545
546 // We also need to provide an implementation for Get_Name to compile
547 const char* Get_Name() { return "dp88_Ore_Field_Observer"; }
548 };
549
550 dp88_Ore_Field_Observer* m_pZoneObserver;
551};
552
553// -------------------------------------------------------------------------------------------------
554
577class dp88_Ore_Extractor : public ScriptImpClass
578{
579public:
580 void Created ( GameObject* pObj );
581 void Timer_Expired ( GameObject* pObj, int number );
582 void Animation_Complete ( GameObject* pObj, const char* animationName );
583
584protected:
585 int m_oreFieldId;
586
589 unsigned int m_nOreUnits;
590 unsigned int m_interval;
591 const char* m_strAnimation;
593};
594
595// -------------------------------------------------------------------------------------------------
596
603class dp88_Ore_Dump_Zone : public ScriptImpClass
604{
605public:
606 void Entered( GameObject *obj, GameObject *enterer );
607};
608
609// -------------------------------------------------------------------------------------------------
610
621class dp88_Aircraft_LandingZone : public ScriptImpClass
622{
623 void Entered( GameObject *obj, GameObject *enterer );
624 void Exited ( GameObject *obj, GameObject *exiter );
625};
626
627// -------------------------------------------------------------------------------------------------
628
664class dp88_Aircraft_LandingZone_Aircraft : public ScriptImpClass
665{
666 void Created ( GameObject *obj );
667 void Killed ( GameObject *obj, GameObject* killed );
668 void Custom ( GameObject *obj, int type, int param, GameObject *sender );
669
670private:
671 int driverID;
672 unsigned int landingZoneCount; // Since we may be in more than one at a time
673};
674
675// -------------------------------------------------------------------------------------------------
676
677
678
679/*------------------------
680Terror Drone Script
681--------------------------*/
682
683/*class dp88_AR_TerrorDrone : public ScriptImpClass {
684 void Created( GameObject *obj );
685 void Custom( GameObject *obj, int type, int param, GameObject *sender );
686 void Killed( GameObject *obj, GameObject *killer );
687
688 int targetID;
689 int pilotID;
690 int consoleID;
691 char defaultModel[32];
692};*/
693
694// -------------------------------------------------------------------------------------------------
695
755class dp88_RemoteControlConsole : public ScriptImpClass
756{
757 void Created( GameObject *obj );
758 void Detach ( GameObject* obj );
759 void Poked ( GameObject *obj, GameObject *poker );
760 void Custom( GameObject *obj, int type, int param, GameObject *sender );
761 void Timer_Expired( GameObject *obj, int number );
762 void SetEnabled ( GameObject* obj, bool state );
763
764 int vehicleID;
765 int pilotID;
766 Collision_Group_Type m_pilotCachedCollisionGroup;
767 int m_pilotDummyID;
768 Vector3 pilotDummyPos;
769 bool m_bEnabled;
770 int m_nChargeTime;
771
772 void HandleDriverEnter(GameObject* obj, GameObject* pilot, GameObject* vehicle);
773 void HandleDriverExit(GameObject* obj, GameObject* pilot, GameObject* vehicle);
774
775 void CreateDummy ( GameObject* pilot, Vector3 position, float facing );
776 void DestroyDummy();
777
778 void UpdateAnimation(GameObject* obj);
779
780protected:
781 LoopedAnimationController* m_pLoopedAnimCtrl;
782public:
783 dp88_RemoteControlConsole() : m_pLoopedAnimCtrl(0) {}
784};
785
786// -------------------------------------------------------------------------------------------------
787
788/*------------------------
789Remote Control Vehicle script
790--------------------------*/
791
792class dp88_RemoteControlVehicle : public ScriptImpClass
793{
794 void Created( GameObject *obj );
795 void Custom( GameObject *obj, int type, int param, GameObject *sender );
796 void Killed( GameObject *obj, GameObject *killer );
797
798 int consoleID;
799 int pilotID;
800};
801
802
803
804/*------------------------
805Demo Truck Scripts
806--------------------------*/
807
808class dp88_AR_DemoTruck : public ScriptImpClass {
809
810 // Events
811 void Created( GameObject *obj );
812 void Custom( GameObject *obj, int type, int param, GameObject *sender );
813 void Killed( GameObject *obj, GameObject *killer );
814 void Damaged ( GameObject *obj, GameObject *damager, float amount );
815
816 // Custom functions
817 void dp88_AR_DemoTruck::Detonate( GameObject *obj );
818
819 // Variables
820 int pilotID;
821 bool canDetonate;
822};
823
824// -------------------------------------------------------------------------------------------------
825
833class dp88_AR_paradrop_Console : public ScriptImpClass {
834 void Created( GameObject *obj );
835 void Poked ( GameObject *obj, GameObject *poker );
836
837 int last_triggered;
838};
839
840// -------------------------------------------------------------------------------------------------
841
874class dp88_AR_Paradrop : public ScriptImpClass
875{
876public:
877 dp88_AR_Paradrop() : m_pAnimController(0) {};
878protected:
879 void Created( GameObject* pObj );
880 void Damaged( GameObject* pObj, GameObject* pDamager, float amount );
881 void Killed( GameObject* pObj, GameObject* pKilled );
882 void Timer_Expired ( GameObject* pObj, int number );
883 void Detach(GameObject* obj);
884
885 void Landed ( GameObject* pObj );
886
887 unsigned int earth_warhead;
890
891 LoopedAnimationController* m_pAnimController;
892};
893
894// -------------------------------------------------------------------------------------------------
895
896
897
898
899
900// -------------------------------------------------------------------------------------------------
901
978{
979 /* -----
980 Static variables
981 ----- */
982
983 static const int MAX_TOWERS = 20;
984 static int prismTowerCount;
985 static int prismTowerIds[MAX_TOWERS];
986 static dp88_AR_Prism_Tower* prismTowerScripts[MAX_TOWERS];
987
988 /* -----
989 Static functions
990 ----- */
991 static void registerTower(int towerId, dp88_AR_Prism_Tower* script);
992 static void deregisterTower(int towerId);
993 static void clearTowerMap(int idx);
994 static void calculateTowerMap();
995 static bool calculateTowerMapPathSearch(int* sortedConnections, int numConnections, int tower1, int tower2);
996
1001 static bool CanAssistTower(GameObject* tower1, GameObject* tower2, int maxRange);
1002
1003 /* -----
1004 Variables
1005 ----- */
1006
1007 // Is our current target a tower we are charging?
1008 bool isAssistingTower;
1009
1010 // Towers adjacent to us in the tower map
1011 int adjacentTowerCount;
1012 int* adjacentTowers;
1013
1014
1015 /* -----
1016 Events
1017 ----- */
1018
1019 void Created ( GameObject *obj );
1020 void Damaged ( GameObject *obj, GameObject *damager, float amount );
1021 void Killed ( GameObject *obj, GameObject *killer );
1022 void Destroyed ( GameObject *obj );
1023 void Custom ( GameObject *obj, int type, int param, GameObject *sender );
1024 void Timer_Expired ( GameObject *obj, int number );
1025
1026 /* -----
1027 Functions
1028 ----- */
1029
1030 // Override priority calculation with our own taking into account
1031 // the fact that the target might be a tower we are charging
1032 virtual float getPriority( GameObject *obj, GameObject *target );
1033
1038 virtual bool checkTeam( GameObject *obj, GameObject *target );
1039
1040 // Customised attack functionality
1041 virtual void attackTarget ( GameObject* obj, GameObject* target, bool primary );
1042 virtual void attackLocation ( GameObject* obj, Vector3 location, bool primary );
1043 virtual void stopAttacking ( GameObject* obj );
1044
1045 /* Functions to start and stop charging of another tower */
1046 void StartAssisting(GameObject* obj, GameObject* tower, float priority);
1047 void StopAssisting(GameObject* obj);
1048
1057 static Vector3 GetAssistAimPoint(GameObject* pTargetTower);
1058
1063 void SendAssistanceRequests(GameObject* obj);
1064
1068 void SendEndAssistanceNotifications(GameObject* obj);
1069};
1070
1071// -------------------------------------------------------------------------------------------------
1072
1101class dp88_linkHealth : public ScriptImpClass
1102{
1103 void Created ( GameObject *obj );
1104 void Timer_Expired ( GameObject *obj, int number );
1105 void Killed ( GameObject *obj, GameObject *killer );
1106 void equaliseHealth( GameObject* obj );
1107
1108 int parentObjID;
1109 float lastHealth;
1110 float lastArmour;
1111};
1112
1113// -------------------------------------------------------------------------------------------------
1114
1115
1116
1117
1118
1119
1120/*
1121void printDebug ( const char debugline[], int objID )
1122{
1123 FILE *f = fopen("dp88_debug.txt","at");
1124 fprintf(f,"[%d:%s] %s\n",objID,Commands->Get_Preset_Name(Commands->Find_Object(objID)),debugline);
1125 fclose(f);
1126}
1127*/
Controller for looped animations using a subset of frames.
Definition LoopedAnimationController.h:31
Charged Turret AI.
Definition dp88_customAI.h:715
AR Chrono Miner Chronoshift Zone.
Definition dp88_ar.h:386
AR Chrono Miner.
Definition dp88_ar.h:351
int objectId
ID of the object we are running on, since Keyhook() does not include the GameObject....
Definition dp88_ar.h:353
int driverId
ID of our current driver, or NULL.
Definition dp88_ar.h:354
Apocalypse Rising Game Controller.
Definition dp88_ar.h:77
AR Paradrop.
Definition dp88_ar.h:875
float m_fallRate
Falling speed at last check.
Definition dp88_ar.h:889
int m_nParachuteModel
ID of the spawned parachute model, if any.
Definition dp88_ar.h:888
unsigned int earth_warhead
ID of the "Earth" warhead.
Definition dp88_ar.h:887
Apocalypse Rising Prism Tower.
Definition dp88_ar.h:978
Definition dp88_ar.h:105
AR Paradrop Console.
Definition dp88_ar.h:833
Aircraft Landing Zone Animation.
Definition dp88_ar.h:665
Aircraft Landing Zone.
Definition dp88_ar.h:622
Camo Controller.
Definition dp88_misc.h:927
Ore Dump Zone.
Definition dp88_ar.h:604
Ore Extractor.
Definition dp88_ar.h:578
Ore Field.
Definition dp88_ar.h:446
unsigned int m_myObjId
My own GameObject ID, used by the zone observer callbacks.
Definition dp88_ar.h:494
unsigned int GetOreValue()
Definition dp88_ar.h:480
bool IsSuitableForAI()
Definition dp88_ar.h:486
unsigned int NumOreUnits()
Definition dp88_ar.h:477
bool IsInfinite()
Definition dp88_ar.h:483
void AddOre(unsigned int nUnits)
Definition dp88_ar.cpp:1757
unsigned int RemoveOre(unsigned int nUnits=1)
Definition dp88_ar.cpp:1768
Ore Miner.
Definition dp88_ar.h:271
int m_oreCapacity
Maximum number of mined ore units onboard.
Definition dp88_ar.h:284
float m_oreDumpTime
Time required to dump ore at a refinery.
Definition dp88_ar.h:286
int m_oreValue
Cumulative value of all ore loads onboard.
Definition dp88_ar.h:276
float m_oreMiningTime
Time required to mine one ore unit.
Definition dp88_ar.h:285
int m_oreFieldRand
Used to prevent glitching by entering/exiting an ore field rapidly. 0 = not in ore field.
Definition dp88_ar.h:279
int m_aiState
Current AI state.
Definition dp88_ar.h:273
const char * m_resourceName
Resource name for strings>
Definition dp88_ar.h:287
int m_oreMined
Current number of mined ore loads onboard.
Definition dp88_ar.h:275
int m_oreFieldId
ID of the ore field we are currently mining ore from.
Definition dp88_ar.h:278
bool m_bUseAI
Is AI enabled?
Definition dp88_ar.h:283
Remote Control Vehicle Console.
Definition dp88_ar.h:756