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 "objs/model_id.hh"
|
---|
10 | #include "objs/model_draw.hh"
|
---|
11 | #include "resources.hh"
|
---|
12 | #include "saver.hh"
|
---|
13 | #include "map_cell.hh"
|
---|
14 | #include "map.hh"
|
---|
15 | #include "map_man.hh"
|
---|
16 | #include "objs/moneyplane.hh"
|
---|
17 | #include "object_definer.hh"
|
---|
18 | #include "objs/moneycrate.hh"
|
---|
19 | #include "lisp/li_class.hh"
|
---|
20 |
|
---|
21 | static g1_model_ref model_ref("moneycrate");
|
---|
22 | static li_float_class_member li_vspeed("vspeed");
|
---|
23 | static li_int_class_member li_value("crate_value");
|
---|
24 |
|
---|
25 | static void g1_moneycrate_init()
|
---|
26 | {
|
---|
27 | }
|
---|
28 |
|
---|
29 | g1_object_definer<g1_moneycrate_class>
|
---|
30 | g1_moneycrate_def("moneycrate",
|
---|
31 | g1_object_definition_class::EDITOR_SELECTABLE |
|
---|
32 | g1_object_definition_class::MOVABLE);
|
---|
33 |
|
---|
34 | g1_moneycrate_class::g1_moneycrate_class(g1_object_type id,
|
---|
35 | g1_loader_class *fp)
|
---|
36 | : g1_object_class(id,fp)
|
---|
37 | {
|
---|
38 | draw_params.setup(model_ref.id());
|
---|
39 |
|
---|
40 | set_flag(BLOCKING, 1);
|
---|
41 | }
|
---|
42 |
|
---|
43 | i4_3d_vector g1_moneycrate_class::crate_attach()
|
---|
44 | {
|
---|
45 | i4_3d_vector crate_offset(0,0,0);
|
---|
46 | model_ref()->get_mount_point("mount",crate_offset);
|
---|
47 | return crate_offset;
|
---|
48 | }
|
---|
49 |
|
---|
50 | void g1_moneycrate_class::setup(i4_3d_vector pos, w32 value)
|
---|
51 | {
|
---|
52 | x = pos.x;
|
---|
53 | y = pos.y;
|
---|
54 | h = pos.z;
|
---|
55 | grab_old();
|
---|
56 |
|
---|
57 | li_class_context c(vars);
|
---|
58 |
|
---|
59 | li_value() = value;
|
---|
60 | li_vspeed() = 1.0;
|
---|
61 |
|
---|
62 | occupy_location();
|
---|
63 | request_think();
|
---|
64 | }
|
---|
65 |
|
---|
66 | void g1_moneycrate_class::follow(i4_3d_vector pos, i4_3d_vector rot)
|
---|
67 | {
|
---|
68 | unoccupy_location();
|
---|
69 | x = pos.x;
|
---|
70 | y = pos.y;
|
---|
71 | h = pos.z;
|
---|
72 | theta = rot.z;
|
---|
73 | pitch = rot.y;
|
---|
74 | roll = rot.x;
|
---|
75 |
|
---|
76 | li_class_context c(vars);
|
---|
77 | li_vspeed() = 1.0;
|
---|
78 | occupy_location();
|
---|
79 | request_think();
|
---|
80 | }
|
---|
81 |
|
---|
82 | void g1_moneycrate_class::release()
|
---|
83 | {
|
---|
84 | li_class_context c(vars);
|
---|
85 | li_vspeed() = 0;
|
---|
86 | request_think();
|
---|
87 | }
|
---|
88 |
|
---|
89 | w32 g1_moneycrate_class::value() const
|
---|
90 | {
|
---|
91 | li_class_context c(vars);
|
---|
92 | return li_value();
|
---|
93 | }
|
---|
94 |
|
---|
95 | void g1_moneycrate_class::think()
|
---|
96 | {
|
---|
97 | i4_float vspeed = li_vspeed();
|
---|
98 | if (vspeed<=0.0)
|
---|
99 | {
|
---|
100 | i4_float height = g1_get_map()->map_height(x,y,h);
|
---|
101 | if (h+vspeed-0.001 > height)
|
---|
102 | {
|
---|
103 | h += vspeed;
|
---|
104 | vspeed -= g1_resources.gravity;
|
---|
105 | request_think();
|
---|
106 | }
|
---|
107 | else
|
---|
108 | {
|
---|
109 | h = height;
|
---|
110 | vspeed = 0;
|
---|
111 |
|
---|
112 | unoccupy_location();
|
---|
113 | request_remove();
|
---|
114 | }
|
---|
115 | }
|
---|
116 | li_vspeed() = vspeed;
|
---|
117 | }
|
---|
118 |
|
---|