Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
DefenseObjectClass.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#ifndef TT_INCLUDE__DEFENSEOBJECTCLASS_H
13#define TT_INCLUDE__DEFENSEOBJECTCLASS_H
14#include "DataSafe.h"
15#include "ReferencerClass.h"
16
17class OffenseObjectClass;
18class SmartGameObj;
19class DamageableGameObj;
20class DefenseObjectDefClass;
21class BitStreamClass;
22typedef unsigned int ArmorType;
23typedef unsigned int WarheadType;
24typedef safe_unsigned_int SafeArmorType;
25typedef safe_unsigned_int SafeWarheadType;
26class DefenseObjectClass {
27#define DEFAULT_HEALTH 100.0f
28public:
29 DefenseObjectClass( float health = DEFAULT_HEALTH, ArmorType skin = 0 ) :
30 Health( health ), HealthMax( health ), Skin( skin ), ShieldStrength( 0 ), ShieldStrengthMax( 0 ), ShieldType( 0 ), CanObjectDie( true ) {};//,
31 //LastSentHealth( -1 ), LastSentSkin( -1 ), LastSentShieldStrength( -1 ), LastSentShieldType( -1 ) {};
32 ~DefenseObjectClass() {};
33 void Init( const DefenseObjectDefClass & def, DamageableGameObj * owner);
34 bool Save( ChunkSaveClass & csave );
35 bool Load( ChunkLoadClass & cload );
36 void Set_Owner( DamageableGameObj *owner ) { Owner = (ScriptableGameObj *)owner; }
37 DamageableGameObj *Get_Owner( void ) const { return (DamageableGameObj *)Owner.Get_Ptr(); }
38 void Set_Skin( ArmorType skin ) { Skin = skin; }
39 ArmorType Get_Skin( void ) const { return Skin; }
40 enum {MAX_MAX_HEALTH = 2000};//500};
41 enum {MAX_MAX_SHIELD_STRENGTH = 2000};//500};
42 enum {MAX_MAX_HEALTH_NEW = 10000};//500};
43 enum {MAX_MAX_SHIELD_STRENGTH_NEW = 10000};//500};
44 void Set_Health(float health);
45 void Add_Health(float add_health);
46 float SCRIPTS_API Get_Health(void) const ;
47 void SCRIPTS_API Set_Health_Max(float health);
48 float SCRIPTS_API Get_Health_Max(void) const ;
49 void Set_Shield_Strength(float str);
50 void Add_Shield_Strength(float str);
51 float SCRIPTS_API Get_Shield_Strength(void) const ;
52 void SCRIPTS_API Set_Shield_Strength_Max(float str);
53 float SCRIPTS_API Get_Shield_Strength_Max(void) const ;
54 void SCRIPTS_API Set_Shield_Type( ArmorType type );
55 unsigned long Get_Shield_Type( void ) const { return ShieldType; }
56 float Apply_Damage( const OffenseObjectClass & offense, float scale = 1.0f, int alternate_skin = -1 );
57 float Do_Damage( const OffenseObjectClass & offense, float scale = 1.0f, int alternate_skin = -1 );
58 void Request_Damage( const OffenseObjectClass & offense, float scale = 1.0f );
59 bool Is_Repair( const OffenseObjectClass & offense, float scale = 1.0f );
60 bool Would_Damage( const OffenseObjectClass & offense, float scale = 1.0f );
61 bool Is_Soft( void );
62 void Set_Can_Object_Die( bool onoff ) { CanObjectDie = onoff; }
63 virtual void Import( BitStreamClass & packet );
64 virtual void Export( BitStreamClass & packet );
65 static void Set_Precision(void);
66 float Get_Damage_Points(void) const { return DamagePoints; }
67 float Get_Death_Points(void) const { return DeathPoints; }
68 bool Can_Trust_Client_Damage (SmartGameObj* damager) const;
69 void SCRIPTS_API Mark_Owner_Dirty( void );
70 void Set_Damage_Points(float points) {DamagePoints = points;}
71 void Set_Death_Points(float points) {DeathPoints = points;}
72private:
73 safe_float Health;
74 safe_float HealthMax;
75 SafeArmorType Skin;
76 safe_float ShieldStrength;
77 safe_float ShieldStrengthMax;
78 SafeArmorType ShieldType;
79 safe_float DamagePoints;
80 safe_float DeathPoints;
81 bool CanObjectDie;
82 ReferencerClass Owner;
83};
84#endif