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