-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.c
286 lines (259 loc) · 8.75 KB
/
items.c
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// Verlies - ein Adventure im Retrodesign
//
// Copyright (C) 2018-2022 Heiko Wolf
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License As published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE. See the
// GNU General Public License For more details.
//
// You should have received a copy of the GNU General Public License along
// With this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Kontakt: projekte@kabelmail.net
//#pragma bank=12
#include "items.h"
#include "hud.h"
#include "engine.h"
#include "tiledat.h"
#include "player.h"
#include "other.h"
void p_items_init (void) __banked
{
v_selectItem == 0;
}
void p_drawSelectItem (void) __banked
{
if (v_selectItem == 0) {v_tile [0] = 127; }
else if (v_selectItem == 1) { v_tile [0] = 62; } //Heiltrank
else if (v_selectItem == 2) { v_tile [0] = 61; } //Ausdauertrank
else if (v_selectItem == 4) { v_tile [0] = 51; } //spitzhacke
else if (v_selectItem == 5) { v_tile [0] = 50; } //Sichel
else if (v_selectItem == 6) { v_tile [0] = 60; } //Kraut
else if (v_selectItem == 7) { v_tile [0] = 48; } //Schaufel
else if (v_selectItem == 8) { v_tile [0] = 49; } //Portalrune
set_bkg_tiles (9, 16, 1, 1, v_tile);
}
///Berechnung der Kartenposition bestimmter Items (Spitzhacke, Sichel, Schaufel)
void p_calc_mapK () __banked
{
v_imk = ((v_ixk - 16) / 8) + 18 * ((v_iyk - 24) / 8);
}
///Itemauswahl
void p_changeItem (void) __banked
{
//Null
if (v_selectItem == 0)
{
if (v_sht != 0) v_selectItem = 1;
else if (v_sat != 0) v_selectItem = 2;
else if (v_spitzhacke == TRUE) v_selectItem = 4;
}
//heiltrank
else if (v_selectItem == 1)
{
if (v_sat != 0) v_selectItem = 2;
else if (v_spitzhacke == TRUE) v_selectItem = 4;
else v_selectItem = 0;
}
//ausdauertrank
else if (v_selectItem == 2)
{
if (v_spitzhacke == TRUE) v_selectItem = 4;
else if (v_sht != 0) v_selectItem = 1;
else v_selectItem = 0;
}
//Spitzhacke zu Sichel
else if (v_selectItem == 4)
{
if (v_sichel == TRUE) v_selectItem = 5;
else if (v_sht != 0) v_selectItem = 1;
else v_selectItem = 0;
}
//Sichel zu Kraut
else if (v_selectItem == 5)
{
if (v_shk != 0) v_selectItem = 6;
else if (v_schaufel == TRUE) v_selectItem = 7;
else if (v_sht != 0) v_selectItem = 1;
else v_selectItem = 0;
}
//Kraut zu Schaufel
else if (v_selectItem == 6)
{
if (v_schaufel == TRUE) v_selectItem = 7;
else if (v_sht != 0) v_selectItem = 1;
else v_selectItem = 0;
}
//Schaufel zu Portalrune
else if (v_selectItem == 7)
{
if ((v_portalrune == TRUE) && (v_sstaub > 0)) v_selectItem = 8;
else if (v_sht != 0) v_selectItem = 1;
else v_selectItem = 0;
}
//Portalrune zu null
else if (v_selectItem == 8) {
v_selectItem = 0;
}
p_drawSelectItem ();
delay (210);
}
///Anwendung des Proviant (automatisch)
void p_proviant () __banked
{
if (v_ssc == 255)
{
if (v_spr > 0)
{
--v_spr; v_ssc = 0;
p_hud_showPR ();
}
else if (v_spr == 0)
{
--v_slp; v_ssc = 125;
p_hud_showLP ();
}
}
}
///Heiltrank, füllt 3 Lebenspunkte auf
void p_use_heiltrank () __banked
{
if (v_keyflag == 2)
{
if ((v_sht > 0) && (v_slp < v_smlp))
{
--v_sht;
if (v_slp + 3 <= v_smlp)
{
v_slp = v_slp + 3;
}
else
{
v_slp = v_smlp;
}
p_spieler_setSprite (3);
delay (1000);
p_spieler_setSprite (1);
if (v_sht == 0) { v_selectItem = 0; p_drawSelectItem (); }
p_hud_show ();
v_tile [0] = 69;
set_bkg_tiles (1, 16, 1, 1, v_tile);
}
}
}
///Benutzung Ausdauertrank
void p_use_ausdauertrank () __banked
{
if (v_keyflag == 2)
{
if ((v_sat > 0) && (v_saus < v_smaus))
{
--v_sat;
v_saus = v_smaus;
p_spieler_setSprite (3);
delay (1000);
p_spieler_setSprite (1);
if (v_sat == 0) { v_selectItem = 0; p_drawSelectItem (); }
p_hud_show ();
}
}
}
void p_select_spitzhacke (void) __banked
{
set_sprite_tile (9, 104);
set_sprite_tile (10, 105);
set_sprite_tile (11, 106);
set_sprite_tile (12, 107);
}
void p_select_sichel (void) __banked
{
set_sprite_tile (9, 100);
set_sprite_tile (10, 101);
set_sprite_tile (11, 102);
set_sprite_tile (12, 103);
}
void p_select_schaufel (void) __banked
{
set_sprite_tile (9, 112);
set_sprite_tile (10, 113);
set_sprite_tile (11, 114);
set_sprite_tile (12, 115);
}
///Benutzung der Spitzhacke
void p_use_item (void) __banked
{
if (v_keyflag == 2)
{
if (v_selectItem == 4) p_select_spitzhacke ();
else if (v_selectItem == 5) p_select_sichel ();
else if (v_selectItem == 7) p_select_schaufel ();
if ((v_sri == MOVE_NORTH) && (v_saus != 0) && (v_syk != 24))
{
v_ixk = v_sxk; v_iyk = v_syk - 16;
move_sprite (9, v_sxk, v_syk - 16);
move_sprite (10, v_sxk, v_syk - 8);
move_sprite (11, v_sxk + 8, v_syk - 16);
move_sprite (12, v_sxk + 8, v_syk - 8);
}
//Süd
else if ((v_sri == MOVE_SOUTH) && (v_saus != 0) && (v_syk != 120))
{
v_ixk = v_sxk; v_iyk = v_syk + 16;
move_sprite (9, v_sxk, v_syk + 16);
move_sprite (10, v_sxk, v_syk + 24);
move_sprite (11, v_sxk + 8, v_syk + 16);
move_sprite (12, v_sxk + 8, v_syk + 24);
}
//West
else if ((v_sri == MOVE_WEST) && (v_saus != 0) && (v_sxk != 16))
{
v_ixk = v_sxk - 16; v_iyk = v_syk;
move_sprite (9, v_sxk - 16, v_syk);
move_sprite (10, v_sxk - 16, v_syk + 8);
move_sprite (11, v_sxk - 8, v_syk);
move_sprite (12, v_sxk - 8, v_syk + 8);
}
//Ost
else if ((v_sri == 4) && (v_saus != 0) && (v_sxk != 144))
{
v_ixk = v_sxk + 16; v_iyk = v_syk;
move_sprite (9, v_sxk + 16, v_syk);
move_sprite (10, v_sxk + 16, v_syk + 8);
move_sprite (11, v_sxk + 24, v_syk);
move_sprite (12, v_sxk + 24, v_syk + 8);
}
if (v_saus != 0)
{
v_itemlooptime = 0; v_sused = TRUE; --v_saus;
p_calc_mapK ();
p_hud_showAD ();
}
}
}
///
void p_hide_item () __banked
{
move_sprite (9, 0, 0);
move_sprite (10, 0, 0);
move_sprite (11, 0, 0);
move_sprite (12, 0, 0);
}
void p_collectGold () __banked
{
BOOLEAN l_wert;
l_wert = p_zahl ();
if (l_wert == TRUE)
{
if (v_sgo < v_smgo)
{
++v_sgo;
}
}
}