]> icculus.org git repositories - btb/d2x.git/blob - main/fuelcen.h
convert file i/o to cfile
[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 #ifndef _FUELCEN_H
15 #define _FUELCEN_H
16
17 #include "segment.h"
18 #include "object.h"
19
20 //------------------------------------------------------------
21 // A refueling center is one segment... to identify it in the
22 // segment structure, the "special" field is set to 
23 // SEGMENT_IS_FUELCEN.  The "value" field is then used for how
24 // much fuel the center has left, with a maximum value of 100.
25
26 //-------------------------------------------------------------
27 // To hook into Inferno:
28 // * When all segents are deleted or before a new mine is created
29 //   or loaded, call fuelcen_reset().
30 // * Add call to fuelcen_create(segment * segp) to make a segment
31 //   which isn't a fuel center be a fuel center.  
32 // * When a mine is loaded call fuelcen_activate(segp) with each 
33 //   new segment as it loads. Always do this.
34 // * When a segment is deleted, always call fuelcen_delete(segp).
35 // * Call fuelcen_replentish_all() to fill 'em all up, like when
36 //   a new game is started.
37 // * When an object that needs to be refueled is in a segment, call
38 //   fuelcen_give_fuel(segp) to get fuel. (Call once for any refueling
39 //   object once per frame with the object's current segment.) This
40 //   will return a value between 0 and 100 that tells how much fuel
41 //   he got.
42
43
44 // Destroys all fuel centers, clears segment backpointer array.
45 void fuelcen_reset();
46 // Create materialization center
47 int create_matcen( segment * segp );
48 // Makes a segment a fuel center.
49 void fuelcen_create( segment * segp);
50 // Makes a fuel center active... needs to be called when 
51 // a segment is loaded from disk.
52 void fuelcen_activate( segment * segp, int station_type );
53 // Deletes a segment as a fuel center.
54 void fuelcen_delete( segment * segp );
55
56 // Charges all fuel centers to max capacity.
57 void fuelcen_replentish_all();
58
59 // Create a matcen robot
60 extern object *create_morph_robot(segment *segp, vms_vector *object_pos, int object_id);
61
62 // Returns the amount of fuel this segment can give up.
63 // Can be from 0 to 100.
64 fix fuelcen_give_fuel(segment *segp, fix MaxAmountCanTake );
65
66 // Call once per frame.
67 void fuelcen_update_all();
68
69 // Called when hit by laser.
70 void fuelcen_damage(segment *segp, fix AmountOfDamage );
71
72 // Called to repair an object
73 //--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg );
74
75 #define MAX_NUM_FUELCENS                        70
76
77 extern char Special_names[MAX_CENTER_TYPES][11];
78
79 //--repair-- //do the repair center for this frame
80 //--repair-- void do_repair_sequence(object *obj);
81 //--repair-- 
82 //--repair-- //see if we should start the repair center
83 //--repair-- void check_start_repair_center(object *obj);
84 //--repair-- 
85 //--repair-- //if repairing, cut it short
86 //--repair-- abort_repair_center();
87
88 // An array of pointers to segments with fuel centers.
89 typedef struct FuelCenter {
90         int                     Type;
91         int                     segnum;
92         byte                    Flag;
93         byte                    Enabled;
94         byte                    Lives;                  //      Number of times this can be enabled.
95         byte                    dum1;
96         fix                     Capacity;
97         fix                     MaxCapacity;
98         fix                     Timer;                  //used in matcen for when next robot comes out
99         fix                     Disable_time;           //      Time until center disabled.
100 //      object *                last_created_obj;
101 //      int                     last_created_sig;
102         vms_vector      Center;
103 } __pack__ FuelCenter;
104
105 // The max number of robot centers per mine.
106 #define MAX_ROBOT_CENTERS  20   
107
108 extern int Num_robot_centers;
109
110 typedef struct  {
111         int                     robot_flags;            // Up to 32 different robots
112         fix                     hit_points;                     // How hard it is to destroy this particular matcen
113         fix                     interval;                       // Interval between materialogrifizations
114         short                   segnum;                         // Segment this is attached to.
115         short                   fuelcen_num;            // Index in fuelcen array.
116 } __pack__ old_matcen_info;
117
118 typedef struct matcen_info {
119         int                     robot_flags[2]; // Up to 64 different robots
120         fix                     hit_points;                     // How hard it is to destroy this particular matcen
121         fix                     interval;                       // Interval between materialogrifizations
122         short                   segnum;                         // Segment this is attached to.
123         short                   fuelcen_num;            // Index in fuelcen array.
124 } __pack__ matcen_info;
125
126 extern matcen_info RobotCenters[MAX_ROBOT_CENTERS];
127
128 //--repair-- extern object *RepairObj;                  //which object getting repaired, or NULL
129
130 //      Called when a materialization center gets triggered by the player flying through some trigger!
131 extern void trigger_matcen(int segnum);
132
133 extern void disable_matcens(void);
134
135 extern FuelCenter Station[MAX_NUM_FUELCENS];
136 extern int Num_fuelcenters;
137
138 extern void init_all_matcens(void);
139
140 extern fix EnergyToCreateOneRobot;
141
142 void fuelcen_check_for_hoard_goal(segment *segp);
143
144 #ifdef FAST_FILE_IO
145 #define old_matcen_info_read(mi, fp) cfread(mi, sizeof(old_matcen_info), 1, fp)
146 #define matcen_info_read(mi, fp) cfread(mi, sizeof(matcen_info), 1, fp)
147 #else
148 /*
149  * reads an old_matcen_info structure from a CFILE
150  */
151 void old_matcen_info_read(old_matcen_info *mi, CFILE *fp);
152
153 /*
154  * reads a matcen_info structure from a CFILE
155  */
156 void matcen_info_read(matcen_info *ps, CFILE *fp);
157 #endif
158
159 #endif