-
Notifications
You must be signed in to change notification settings - Fork 1
/
extend.cpp
161 lines (128 loc) · 3.07 KB
/
extend.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* Abuse - dark 2D side-scrolling platform game
* Copyright (c) 1995 Crack dot Com
* Copyright (c) 2005-2011 Sam Hocevar <[email protected]>
*
* This software was released into the Public Domain. As with most public
* domain software, no warranty is made or implied by Crack dot Com, by
* Jonathan Clark, or by Sam Hocevar.
*/
#if defined HAVE_CONFIG_H
# include "config.h"
#endif
#include "common.h"
#include "extend.h"
#include "view.h"
#include "objects.h"
#include "lisp.h"
/*
Simple object (power ups, non-moving objects)
int32_t x,y;
int8_t direction;
uint16_t otype,state
uint16_t current_frame;
extension *
Moving object (simple lisp controlled characters)
uint8_t flags;
int32_t xvel,yvel,xacel,yacel;
uint8_t fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
uint16_t aistate,aistate_time;
uint16_t hp,mp,
extension *
Complex objects (can controll lights, other characters, and have a neural net ai)
uint8_t tobjs,tlights;
object_list *
light_list *
nnet_info *
int8_t fade_dir, frame_dir;
uint8_t fade_count,fade_max;
morph_char *morph_status;
*/
void simple_object::add_light(light_source *ls)
{
if (!ls) return ;
ls->known=1;
for (int i=0; i<tlights; i++) if (lights[i]==ls) return;
tlights++;
lights=(light_source **)realloc(lights,sizeof(light_source *)*tlights);
lights[tlights-1]=ls;
}
void simple_object::add_object(game_object *o)
{
if (!o) return ;
for (int i=0; i<tobjs; i++) if (objs[i]==o) return;
o->set_flags(o->flags()|KNOWN_FLAG);
if(_team != -1)
o->set_team(_team);
if(_tint != -1)
o->set_tint(_tint);
tobjs++;
objs=(game_object **)realloc(objs,sizeof(game_object *)*tobjs);
objs[tobjs-1]=o;
}
void simple_object::remove_light(light_source *ls)
{
for (int i=0; i<tlights; i++)
{
if (lights[i]==ls)
{
tlights--;
for (int j=i; j<tlights; j++) // don't even think about it :)
lights[j]=lights[j+1];
lights=(light_source **)realloc(lights,sizeof(light_source *)*tlights);
return ;
}
}
}
void simple_object::remove_object(game_object *o)
{
for (int i=0; i<tobjs; i++)
{
if (objs[i]==o)
{
tobjs--;
for (int j=i; j<tobjs; j++) // don't even think about it :)
objs[j]=objs[j+1];
objs=(game_object **)realloc(objs,sizeof(game_object *)*tobjs);
return ;
}
}
}
simple_object::simple_object()
{
x=y=0;
direction=1;
otype=0;
state=stopped;
current_frame=0;
Fade_dir=0;
Fade_count=0;
Fade_max=16;
tobjs=tlights=0;
objs=NULL;
lights=NULL;
Frame_dir=1;
mc=NULL;
Controller=NULL;
Flags=0;
Xvel=Yvel=Xacel=Yacel=0;
Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0;
Aistate=Aistate_time=0;
Hp=Mp=Fmp=0;
_tint = -1;
_team = -1;
grav_on=1;
targetable_on=1;
}
void simple_object::set_morph_status(morph_char *Mc)
{
mc=Mc;
}
void simple_object::clean_up()
{
if (tlights) free(lights);
if (tobjs) free(objs);
if (Controller)
Controller->m_focus=NULL;
}
simple_object default_simple;