1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "sound_man.hh"
|
---|
10 | #include "objs/model_id.hh"
|
---|
11 | #include "objs/model_draw.hh"
|
---|
12 | #include "input.hh"
|
---|
13 | #include "math/pi.hh"
|
---|
14 | #include "math/trig.hh"
|
---|
15 | #include "math/angle.hh"
|
---|
16 | #include "resources.hh"
|
---|
17 | #include "saver.hh"
|
---|
18 | #include "map_cell.hh"
|
---|
19 | #include "map.hh"
|
---|
20 | #include "sound/sfx_id.hh"
|
---|
21 | #include "objs/engineer.hh"
|
---|
22 | #include "objs/verybiggun.hh"
|
---|
23 | #include "object_definer.hh"
|
---|
24 | #include "map_man.hh"
|
---|
25 | #include "lisp/lisp.hh"
|
---|
26 | #include "li_objref.hh"
|
---|
27 | #include "objs/path_object.hh"
|
---|
28 | #include "player.hh"
|
---|
29 |
|
---|
30 | #include "image_man.hh"
|
---|
31 | static g1_team_icon_ref radar_im("bitmaps/radar/engineer.tga");
|
---|
32 |
|
---|
33 | enum {DATA_VERSION=2};
|
---|
34 |
|
---|
35 | static g1_model_ref model_ref("engineer_body"),
|
---|
36 | shadow_ref("engineer_shadow"),
|
---|
37 | back_wheels_ref("engineer_back_wheels"),
|
---|
38 | front_wheels_ref("engineer_front_wheels"),
|
---|
39 | lod_ref("engineer_lod");
|
---|
40 |
|
---|
41 | static g1_object_type takeover_pad;
|
---|
42 | static i4_3d_vector back_attach, back_offset, front_attach, front_offset;
|
---|
43 |
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | void g1_engineer_init()
|
---|
48 | {
|
---|
49 | takeover_pad = g1_get_object_type("takeover_pad");
|
---|
50 |
|
---|
51 | back_attach.set(-0.12,0.0,0.1);
|
---|
52 | model_ref()->get_mount_point("Back Wheels", back_attach);
|
---|
53 | back_wheels_ref()->get_mount_point("Back Wheels", back_offset);
|
---|
54 | back_offset.reverse();
|
---|
55 |
|
---|
56 | front_attach.set(0.11,0.0,0.1);
|
---|
57 | model_ref()->get_mount_point("Front Wheels", front_attach);
|
---|
58 | front_wheels_ref()->get_mount_point("Front Wheels", front_offset);
|
---|
59 | front_offset.reverse();
|
---|
60 | }
|
---|
61 |
|
---|
62 | g1_object_definer<g1_engineer_class>
|
---|
63 | g1_engineer_def("engineer",
|
---|
64 | g1_object_definition_class::TO_MAP_PIECE |
|
---|
65 | g1_object_definition_class::EDITOR_SELECTABLE |
|
---|
66 | g1_object_definition_class::MOVABLE,
|
---|
67 | g1_engineer_init);
|
---|
68 |
|
---|
69 |
|
---|
70 | g1_engineer_class::g1_engineer_class(g1_object_type id, g1_loader_class *fp)
|
---|
71 | : g1_map_piece_class(id,fp)
|
---|
72 | {
|
---|
73 | draw_params.setup(model_ref.id(),shadow_ref.id(), lod_ref.id());
|
---|
74 |
|
---|
75 | allocate_mini_objects(3,"Enemy Engineer Mini-Objects");
|
---|
76 |
|
---|
77 | back_wheels = &mini_objects[0];
|
---|
78 | back_wheels->defmodeltype = front_wheels_ref.id();
|
---|
79 | back_wheels->position(back_attach);
|
---|
80 | back_wheels->offset = front_offset;
|
---|
81 |
|
---|
82 | front_wheels = &mini_objects[1];
|
---|
83 | front_wheels->defmodeltype = front_wheels_ref.id();
|
---|
84 | front_wheels->position(front_attach);
|
---|
85 | front_wheels->offset = front_offset;
|
---|
86 |
|
---|
87 | w16 ver,data_size;
|
---|
88 | if (fp)
|
---|
89 | fp->get_version(ver,data_size);
|
---|
90 | else
|
---|
91 | ver = 0;
|
---|
92 |
|
---|
93 | switch (ver)
|
---|
94 | {
|
---|
95 | case DATA_VERSION:
|
---|
96 | fp->read_format("ff", &front_wheels->rotation.y, &front_wheels->rotation.z);
|
---|
97 | front_wheels->rotation.x = 0;
|
---|
98 | front_wheels->grab_old();
|
---|
99 | back_wheels->rotation.x = 0;
|
---|
100 | back_wheels->rotation.y = front_wheels->rotation.y;
|
---|
101 | back_wheels->rotation.z = 0;
|
---|
102 | back_wheels->grab_old();
|
---|
103 | break;
|
---|
104 |
|
---|
105 | case 1:
|
---|
106 | back_wheels->rotation.x = fp->read_float();
|
---|
107 | back_wheels->rotation.y = fp->read_float();
|
---|
108 | back_wheels->rotation.z = fp->read_float();
|
---|
109 | back_wheels->lrotation.x = fp->read_float();
|
---|
110 | back_wheels->lrotation.y = fp->read_float();
|
---|
111 | back_wheels->lrotation.z = fp->read_float();
|
---|
112 |
|
---|
113 | front_wheels->rotation.x = fp->read_float();
|
---|
114 | front_wheels->rotation.y = fp->read_float();
|
---|
115 | front_wheels->rotation.z = fp->read_float();
|
---|
116 | front_wheels->lrotation.x = fp->read_float();
|
---|
117 | front_wheels->lrotation.y = fp->read_float();
|
---|
118 | front_wheels->lrotation.z = fp->read_float();
|
---|
119 | break;
|
---|
120 | default:
|
---|
121 | if (fp)
|
---|
122 | fp->seek(fp->tell() + data_size);
|
---|
123 | back_wheels->rotation.x = 0;
|
---|
124 | back_wheels->rotation.y = 0;
|
---|
125 | back_wheels->rotation.z = 0;
|
---|
126 | back_wheels->grab_old();
|
---|
127 | front_wheels->rotation.x = 0;
|
---|
128 | front_wheels->rotation.y = 0;
|
---|
129 | front_wheels->rotation.z = 0;
|
---|
130 | front_wheels->grab_old();
|
---|
131 | break;
|
---|
132 | }
|
---|
133 |
|
---|
134 | if (fp)
|
---|
135 | fp->end_version(I4_LF);
|
---|
136 |
|
---|
137 | init_rumble_sound(G1_RUMBLE_GROUND);
|
---|
138 |
|
---|
139 |
|
---|
140 | radar_image=&radar_im;
|
---|
141 | radar_type=G1_RADAR_VEHICLE;
|
---|
142 | set_flag(BLOCKING |
|
---|
143 | TARGETABLE |
|
---|
144 | GROUND |
|
---|
145 | SHADOWED |
|
---|
146 | DANGEROUS, 1);
|
---|
147 | }
|
---|
148 |
|
---|
149 | void g1_engineer_class::save(g1_saver_class *fp)
|
---|
150 | {
|
---|
151 | g1_map_piece_class::save(fp);
|
---|
152 |
|
---|
153 | fp->start_version(DATA_VERSION);
|
---|
154 |
|
---|
155 | fp->write_format("ff", &front_wheels->rotation.y, &front_wheels->rotation.z);
|
---|
156 |
|
---|
157 | fp->end_version();
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 |
|
---|
162 | void g1_engineer_class::think()
|
---|
163 | {
|
---|
164 | g1_map_piece_class::think();
|
---|
165 |
|
---|
166 | if (!alive())
|
---|
167 | return;
|
---|
168 |
|
---|
169 | i4_float dangle = (theta-ltheta);
|
---|
170 | if (dangle>i4_pi())
|
---|
171 | dangle -= 2*i4_pi();
|
---|
172 | else if (dangle<-i4_pi())
|
---|
173 | dangle += 2*i4_pi();
|
---|
174 |
|
---|
175 | back_wheels->rotation.y += speed*0.2;
|
---|
176 | front_wheels->rotation.y += speed*0.2;
|
---|
177 |
|
---|
178 | front_wheels->rotation.z = dangle*0.2;
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 | static li_symbol_ref reached("reached");
|
---|
183 |
|
---|
184 | li_object *g1_engineer_class::message(li_symbol *message_name,
|
---|
185 | li_object *message_params,
|
---|
186 | li_environment *env)
|
---|
187 | {
|
---|
188 | if (message_name==reached.get())
|
---|
189 | {
|
---|
190 | g1_object_class *who=li_g1_ref::get(message_params,env)->value();
|
---|
191 | if (who)
|
---|
192 | {
|
---|
193 | g1_path_object_class *po=g1_path_object_class::cast(who);
|
---|
194 | if (po && po->total_links(get_team()))
|
---|
195 | who->change_player_num(player_num);
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | return g1_map_piece_class::message(message_name, message_params, env);
|
---|
200 | }
|
---|
201 |
|
---|