]> icculus.org git repositories - btb/d2x.git/blob - main/fuelcen.h
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / main / fuelcen.h
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  *
16  * Definitions for fueling centers.
17  *
18  */
19
20 #ifndef _FUELCEN_H
21 #define _FUELCEN_H
22
23 #include "segment.h"
24 #include "object.h"
25
26 //------------------------------------------------------------
27 // A refueling center is one segment... to identify it in the
28 // segment structure, the "special" field is set to
29 // SEGMENT_IS_FUELCEN.  The "value" field is then used for how
30 // much fuel the center has left, with a maximum value of 100.
31
32 //-------------------------------------------------------------
33 // To hook into Inferno:
34 // * When all segents are deleted or before a new mine is created
35 //   or loaded, call fuelcen_reset().
36 // * Add call to fuelcen_create(segment * segp) to make a segment
37 //   which isn't a fuel center be a fuel center.
38 // * When a mine is loaded call fuelcen_activate(segp) with each
39 //   new segment as it loads. Always do this.
40 // * When a segment is deleted, always call fuelcen_delete(segp).
41 // * Call fuelcen_replentish_all() to fill 'em all up, like when
42 //   a new game is started.
43 // * When an object that needs to be refueled is in a segment, call
44 //   fuelcen_give_fuel(segp) to get fuel. (Call once for any refueling
45 //   object once per frame with the object's current segment.) This
46 //   will return a value between 0 and 100 that tells how much fuel
47 //   he got.
48
49
50 // Destroys all fuel centers, clears segment backpointer array.
51 void fuelcen_reset(void);
52 // Create materialization center
53 int create_matcen( segment * segp );
54 // Makes a segment a fuel center.
55 void fuelcen_create( segment * segp);
56 // Makes a fuel center active... needs to be called when
57 // a segment is loaded from disk.
58 void fuelcen_activate( segment * segp, int station_type );
59 // Deletes a segment as a fuel center.
60 void fuelcen_delete( segment * segp );
61
62 // Charges all fuel centers to max capacity.
63 void fuelcen_replentish_all(void);
64
65 // Create a matcen robot
66 extern object *create_morph_robot(segment *segp, vms_vector *object_pos, int object_id);
67
68 // Returns the amount of fuel/shield this segment can give up.
69 // Can be from 0 to 100.
70 fix fuelcen_give_fuel(segment *segp, fix MaxAmountCanTake );
71 fix repaircen_give_shields(segment *segp, fix MaxAmountCanTake );
72
73 // Call once per frame.
74 void fuelcen_update_all(void);
75
76 // Called when hit by laser.
77 void fuelcen_damage(segment *segp, fix AmountOfDamage );
78
79 // Called to repair an object
80 //--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg );
81
82 #define MAX_NUM_FUELCENS    70
83
84 extern char Special_names[MAX_CENTER_TYPES][11];
85
86 //--repair-- //do the repair center for this frame
87 //--repair-- void do_repair_sequence(object *obj);
88 //--repair--
89 //--repair-- //see if we should start the repair center
90 //--repair-- void check_start_repair_center(object *obj);
91 //--repair--
92 //--repair-- //if repairing, cut it short
93 //--repair-- abort_repair_center();
94
95 // An array of pointers to segments with fuel centers.
96 typedef struct FuelCenter {
97         int     Type;
98         int     segnum;
99         sbyte   Flag;
100         sbyte   Enabled;
101         sbyte   Lives;          // Number of times this can be enabled.
102         sbyte   dum1;
103         fix     Capacity;
104         fix     MaxCapacity;
105         fix     Timer;          // used in matcen for when next robot comes out
106         fix     Disable_time;   // Time until center disabled.
107         //object  *last_created_obj;
108         //int     last_created_sig;
109         vms_vector Center;
110 } __pack__ FuelCenter;
111
112 // The max number of robot centers per mine.
113 #define MAX_ROBOT_CENTERS  20
114
115 extern int Num_robot_centers;
116
117 typedef struct  {
118         int     robot_flags;    // Up to 32 different robots
119         fix     hit_points;     // How hard it is to destroy this particular matcen
120         fix     interval;       // Interval between materialogrifizations
121         short   segnum;         // Segment this is attached to.
122         short   fuelcen_num;    // Index in fuelcen array.
123 } __pack__ old_matcen_info;
124
125 typedef struct matcen_info {
126         int     robot_flags[2]; // Up to 64 different robots
127         fix     hit_points;     // How hard it is to destroy this particular matcen
128         fix     interval;       // Interval between materialogrifizations
129         short   segnum;         // Segment this is attached to.
130         short   fuelcen_num;    // Index in fuelcen array.
131 } __pack__ matcen_info;
132
133 extern matcen_info RobotCenters[MAX_ROBOT_CENTERS];
134
135 //--repair-- extern object *RepairObj;  // which object getting repaired, or NULL
136
137 // Called when a materialization center gets triggered by the player
138 // flying through some trigger!
139 extern void trigger_matcen(int segnum);
140
141 extern void disable_matcens(void);
142
143 extern FuelCenter Station[MAX_NUM_FUELCENS];
144 extern int Num_fuelcenters;
145
146 extern void init_all_matcens(void);
147
148 extern fix EnergyToCreateOneRobot;
149
150 void fuelcen_check_for_hoard_goal(segment *segp);
151
152 #ifdef FAST_FILE_IO
153 #define old_matcen_info_read(mi, fp) cfread(mi, sizeof(old_matcen_info), 1, fp)
154 #define matcen_info_read(mi, fp) cfread(mi, sizeof(matcen_info), 1, fp)
155 #else
156 /*
157  * reads an old_matcen_info structure from a CFILE
158  */
159 void old_matcen_info_read(old_matcen_info *mi, CFILE *fp);
160
161 /*
162  * reads a matcen_info structure from a CFILE
163  */
164 void matcen_info_read(matcen_info *ps, CFILE *fp);
165 #endif
166
167 void matcen_info_write(matcen_info *mi, short version, PHYSFS_file *fp);
168
169 #endif