1 | /* |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | Simple object (power ups, non-moving objects) |
---|
6 | long x,y; |
---|
7 | schar direction; |
---|
8 | ushort otype,state |
---|
9 | ushort current_frame; |
---|
10 | extension * |
---|
11 | |
---|
12 | |
---|
13 | Moving object (simple lisp controlled characters) |
---|
14 | uchar flags; |
---|
15 | long xvel,yvel,xacel,yacel; |
---|
16 | uchar fx,fy,fxvel,fyvel,fxacel,fyacel,aitype; |
---|
17 | ushort aistate,aistate_time; |
---|
18 | unsigned short hp,mp, |
---|
19 | extension * |
---|
20 | |
---|
21 | |
---|
22 | Complex objects (can controll lights, other characters, and have a neural net ai) |
---|
23 | uchar tobjs,tlights; |
---|
24 | object_list * |
---|
25 | light_list * |
---|
26 | nnet_info * |
---|
27 | schar fade_dir, frame_dir; |
---|
28 | unsigned char fade_count,fade_max; |
---|
29 | morph_char *morph_status; |
---|
30 | |
---|
31 | |
---|
32 | */ |
---|
33 | #include "extend.hpp" |
---|
34 | #include "view.hpp" |
---|
35 | #include "objects.hpp" |
---|
36 | #include "lisp.hpp" |
---|
37 | |
---|
38 | |
---|
39 | void simple_object::add_light(light_source *ls) |
---|
40 | { |
---|
41 | if (!ls) return ; |
---|
42 | ls->known=1; |
---|
43 | for (int i=0;i<tlights;i++) if (lights[i]==ls) return; |
---|
44 | tlights++; |
---|
45 | lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"Light list"); |
---|
46 | lights[tlights-1]=ls; |
---|
47 | } |
---|
48 | |
---|
49 | void simple_object::add_object(game_object *o) |
---|
50 | { |
---|
51 | if (!o) return ; |
---|
52 | for (int i=0;i<tobjs;i++) if (objs[i]==o) return; |
---|
53 | o->set_flags(o->flags()|KNOWN_FLAG); |
---|
54 | tobjs++; |
---|
55 | objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list"); |
---|
56 | objs[tobjs-1]=o; |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | void simple_object::remove_light(light_source *ls) |
---|
61 | { |
---|
62 | for (int i=0;i<tlights;i++) |
---|
63 | { |
---|
64 | if (lights[i]==ls) |
---|
65 | { |
---|
66 | tlights--; |
---|
67 | for (int j=i;j<tlights;j++) // don't even think about it :) |
---|
68 | lights[j]=lights[j+1]; |
---|
69 | lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"object's lights"); |
---|
70 | return ; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | void simple_object::remove_object(game_object *o) |
---|
76 | { |
---|
77 | for (int i=0;i<tobjs;i++) |
---|
78 | { |
---|
79 | if (objs[i]==o) |
---|
80 | { |
---|
81 | tobjs--; |
---|
82 | for (int j=i;j<tobjs;j++) // don't even think about it :) |
---|
83 | objs[j]=objs[j+1]; |
---|
84 | objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"object's lights"); |
---|
85 | return ; |
---|
86 | } |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | simple_object::simple_object() |
---|
92 | { |
---|
93 | |
---|
94 | x=y=0; |
---|
95 | direction=1; |
---|
96 | otype=0; |
---|
97 | state=stopped; |
---|
98 | current_frame=0; |
---|
99 | |
---|
100 | Fade_dir=0; |
---|
101 | Fade_count=0; |
---|
102 | Fade_max=16; |
---|
103 | |
---|
104 | |
---|
105 | tobjs=tlights=0; |
---|
106 | objs=NULL; |
---|
107 | lights=NULL; |
---|
108 | Frame_dir=1; |
---|
109 | mc=NULL; |
---|
110 | Controller=NULL; |
---|
111 | |
---|
112 | Flags=0; |
---|
113 | Xvel=Yvel=Xacel=Yacel=0; |
---|
114 | Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0; |
---|
115 | Aistate=Aistate_time=0; |
---|
116 | Hp=Mp=Fmp=0; |
---|
117 | grav_on=1; |
---|
118 | targetable_on=1; |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | void simple_object::set_morph_status(morph_char *Mc) |
---|
124 | { |
---|
125 | mc=Mc; |
---|
126 | } |
---|
127 | |
---|
128 | void simple_object::clean_up() |
---|
129 | { |
---|
130 | if (tlights) jfree(lights); |
---|
131 | if (tobjs) jfree(objs); |
---|
132 | if (Controller) |
---|
133 | Controller->focus=NULL; |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | simple_object default_simple; |
---|
138 | |
---|
139 | |
---|