Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
dp88_veterancy.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 "scripts.h"
15#include "engine.h"
16
17// -------------------------------------------------------------------------------------------------
18
19struct dp88_Veterancy_Settings
20{
21 public:
22 dp88_Veterancy_Settings();
23
24 void Reset();
25
26 static dp88_Veterancy_Settings& GetInstance()
27 {
28 return ms_instance;
29 }
30
31 float valueMultiplier[3];
32 float carryOverPercentI;
33 float carryOverPercentV;
34 int boostPrice;
35
36private:
37 static dp88_Veterancy_Settings ms_instance;
38};
39
40// -------------------------------------------------------------------------------------------------
41
68class dp88_Veterancy_Controller : public ScriptImpClass
69{
70 public:
71 void Created(GameObject* obj);
72 void Destroyed(GameObject* obj);
73};
74
75// -------------------------------------------------------------------------------------------------
76
77/* Script to handle veterancy on any type of object, either player or AI controlled */
78class dp88_veterancyUnit : public MultiKeyHookScriptImpClass
79{
80 public:
81 void Created ( GameObject *obj );
82 void Damaged( GameObject *obj, GameObject *damager, float amount );
83 void Killed ( GameObject *obj, GameObject *killer );
84 void Destroyed ( GameObject *obj );
85 void Detach(GameObject* obj);
86 void Custom ( GameObject* obj, int type, int param, GameObject* sender );
87 void Timer_Expired( GameObject *obj, int number );
88 void KeyHook(const char* logicalKey);
89
90
91 // Recieve veterancy points
92 void recieveVeterancyPoints ( float points );
93
94 private:
95 /****************
96 Variables
97 *****************/
98
99 // Our data
100 int objectId;
101 int currentLevel;
102 float infantryVeterancyPoints, vehicleVeterancyPoints;
103 int infantryVeteranRequirement, infantryEliteRequirement;
104 int vehicleVeteranRequirement, vehicleEliteRequirement;
105 int chevronObjId, promotionChevronObjId;
106 bool chevronVisible;
107
108 /* Flags to mark whether we have upgraded weapons for veteran or rookie levels (saves lots of
109 string comparisions and preset validation later on) */
110 bool hasVeteranWeaponPowerup, hasEliteWeaponPowerup;
111
112 /* Original values for weapons / skin / armour type (req. for vehicles only) */
113 char rookieWeapon[128], rookieSkinType[128], rookieShieldType[128];
114
115 // ID for vehicle pilot (vehicles only)
116 int pilotId;
117
118 // Marker to indicate if we are dead or not, sometimes the promotion
119 // functions can get called after the unit is dead, so we need a quick
120 // and easy way to check this and abort promotion if we are dead
121 bool deregistered;
122
123
124 // Static arrays of pointers to all veterancy units
125 static dp88_veterancyUnit* playerData[128];
126 static dp88_veterancyUnit* AIUnitData[256];
127
128 // Logical key hooks
129 static const char ShowVeterancyPointsHookName[];
130 static const char BoostVeterancyHookName[];
131
132 /****************
133 Functions
134 *****************/
135
137 void Deregister(GameObject* obj);
138
140 void grantVeterancyPoints ( GameObject* obj, float points );
141
143 dp88_veterancyUnit* getVeterancyData ( GameObject* obj );
144
146 void promoteToVeteran();
147 void promoteToElite();
148
150 void demoteToRookie();
151
153 void createChevrons();
154 void clearChevrons();
155
156 /****************
157 Struct to carry-over points when purchasing new infantry (this is required since Destroyed()
158 is now called correctly in this instance so we can't rely on that mechanism for carry-over)
159 *****************/
160
161 struct PointsCarryOverData
162 {
163 long playerId;
164 unsigned int gameTime;
165 float infantryVeterancyPoints, vehicleVeterancyPoints;
166
167 PointsCarryOverData() : playerId(-1) {}
168 };
169
170 // Only need one instance, carry-over should happen immediately after Destroyed() is called
171 static PointsCarryOverData carryOverData;
172};
173
174// -------------------------------------------------------------------------------------------------
175
177class dp88_veterancyGrantPoints : public ScriptImpClass
178{
179 void Created ( GameObject *obj );
180 void Custom ( GameObject *obj, int type, int param, GameObject *sender );
181};
182
183// -------------------------------------------------------------------------------------------------
184
185// Script to link veterancy points of two objects together
186class dp88_linkVetPoints : public ScriptImpClass
187{
188 void Created ( GameObject *obj );
189 void Timer_Expired ( GameObject *obj, int number );
190 void equalisePoints( GameObject* obj );
191
192 int parentObjID;
193 float lastInfantryPoints;
194 float lastVehiclePoints;
195};
196
197// -------------------------------------------------------------------------------------------------
198
199// Script to grant extra health / armour upon promotion
200class dp88_veterancyPromotionHealthArmourIncrease : public ScriptImpClass
201{
202 void Created( GameObject *obj );
203 void Custom( GameObject *obj, int type, int param, GameObject *sender );
204
205private:
206 int m_veterancyLevel;
207};
208
209// -------------------------------------------------------------------------------------------------
210
234class dp88_veterancyGrantPowerup : public ScriptImpClass
235{
236 char weaponName[64];
237 char oldWeapon[64];
238
239 void Created( GameObject *obj );
240 void Custom( GameObject *obj, int type, int param, GameObject *sender );
241
242private:
243 int veterancyLevel;
244};
Script base class with support for multiple key hooks.
Definition engine_tt.h:578
Veterancy - Controller.
Definition dp88_veterancy.h:69
Definition dp88_veterancy.h:178
Veterancy - Grant Weapon.
Definition dp88_veterancy.h:235