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 "g1_object.hh"
|
---|
10 | #include "objs/model_draw.hh"
|
---|
11 | #include "lisp/lisp.hh"
|
---|
12 | #include "tex_id.hh"
|
---|
13 | #include "objs/particle_emitter.hh"
|
---|
14 | #include "object_definer.hh"
|
---|
15 |
|
---|
16 |
|
---|
17 | static li_symbol_ref part_emit("particle_emitter");
|
---|
18 | static r1_texture_ref smoke_texture("smoke_particle");
|
---|
19 |
|
---|
20 | class g1_carcass_class : public g1_object_class
|
---|
21 | {
|
---|
22 | public:
|
---|
23 | int time_left;
|
---|
24 |
|
---|
25 | g1_carcass_class(g1_object_type id, g1_loader_class *fp)
|
---|
26 | : g1_object_class(id, fp)
|
---|
27 | {
|
---|
28 | if (fp) // remove from game on load
|
---|
29 | x=-1;
|
---|
30 | }
|
---|
31 |
|
---|
32 | void draw(g1_draw_context_class *context)
|
---|
33 | {
|
---|
34 | g1_model_draw(this, draw_params, context);
|
---|
35 | flags|=TARGETABLE | GROUND | BLOCKING | CAN_DRIVE_ON;
|
---|
36 | }
|
---|
37 |
|
---|
38 | void setup(g1_object_class *from,
|
---|
39 | g1_quad_object_class *model,
|
---|
40 | int ticks,
|
---|
41 | int ticks_to_smoke,
|
---|
42 | g1_quad_object_class *lod_model)
|
---|
43 | {
|
---|
44 | if (ticks_to_smoke>0)
|
---|
45 | {
|
---|
46 | g1_particle_emitter_class *smoke=
|
---|
47 | (g1_particle_emitter_class *)g1_create_object(g1_get_object_type(part_emit.get()));
|
---|
48 |
|
---|
49 | g1_particle_emitter_params params;
|
---|
50 | params.defaults();
|
---|
51 | params.texture=smoke_texture.get();
|
---|
52 | params.start_size=0.05;
|
---|
53 | params.grow_speed=0.005;
|
---|
54 | params.particle_lifetime=50;
|
---|
55 | params.num_create_attempts_per_tick=1;
|
---|
56 | params.creation_probability=0.5;
|
---|
57 | params.speed=i4_3d_vector(0.001, 0.001, 0.05);
|
---|
58 | params.emitter_lifetime = ticks_to_smoke;
|
---|
59 |
|
---|
60 | if (smoke) smoke->setup(from->x, from->y, from->h, params);
|
---|
61 | }
|
---|
62 |
|
---|
63 | time_left = ticks;
|
---|
64 |
|
---|
65 | theta=from->theta;
|
---|
66 | x=from->x;
|
---|
67 | y=from->y;
|
---|
68 | h=from->h;
|
---|
69 | grab_old();
|
---|
70 |
|
---|
71 | draw_params.setup(model, 0, lod_model);
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | void think()
|
---|
76 | {
|
---|
77 | if (time_left>=0)
|
---|
78 | {
|
---|
79 | time_left--;
|
---|
80 | if (time_left<=0)
|
---|
81 | {
|
---|
82 | unoccupy_location();
|
---|
83 | request_remove();
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|
87 | };
|
---|
88 |
|
---|
89 | g1_object_definer<g1_carcass_class>
|
---|
90 | g1_carcass_def("carcass", g1_object_definition_class::EDITOR_SELECTABLE);
|
---|
91 |
|
---|
92 | g1_object_class *g1_create_carcass(g1_object_class *from,
|
---|
93 | g1_quad_object_class *model,
|
---|
94 | int ticks,
|
---|
95 | int ticks_to_smoke,
|
---|
96 | g1_quad_object_class *lod_model)
|
---|
97 | {
|
---|
98 | g1_carcass_class *c=(g1_carcass_class *)g1_create_object(g1_carcass_def.type);
|
---|
99 | c->setup(from, model, ticks, ticks_to_smoke, lod_model);
|
---|
100 | c->occupy_location();
|
---|
101 | return c;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|