Skip to content

Commit c933cbd

Browse files
marexMarek
authored and
Marek
committed
Add destructible objects
1 parent 6d224f7 commit c933cbd

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

cfg.h

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
#define MEDIKIT_RESPAWN_TIME 30000000 /* in microseconds */
127127
#define WEAPON_RESPAWN_TIME 30000000 /* in microseconds */
128128
#define AMMO_RESPAWN_TIME 25000000 /* in microseconds */
129+
#define PS_RESPAWN_TIME 3000000 /* in microseconds */
129130

130131
#define TOP_PLAYERS_N 10
131132

data.c

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ switch(c) {
173173
case 'x': return T_BIOMED;
174174
case 'r': return T_BLOODRAIN;
175175
case 'J': return T_JETPACK;
176+
case 'P': return T_PS;
176177

177178
/* birthplace */
178179
case 'B': return TYPE_BIRTHPLACE;

data.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define TYPE_BIRTHPLACE 666
2828

2929
/* object types */
30-
#define N_TYPES 31
30+
#define N_TYPES 32
3131

3232
#define T_PLAYER 0
3333
#define T_BULLET 1
@@ -60,6 +60,7 @@
6060
#define T_BLOODRAIN 28
6161
#define T_JETPACK 29
6262
#define T_JETFIRE 30
63+
#define T_PS 31
6364

6465
#define E_INCOMPATIBLE_VERSION 0
6566
#define E_PLAYER_REFUSED 1

data/level.dat

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
level1
22
level2
3+
level3

data/level1.dn

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
klesani F 727 229
2-
pivrnec F 354 176
2+
pivrnec P 354 176
33
zarivka N 902 476
44
zarivka N 177 192
55
zarivka N 49 192
@@ -68,7 +68,7 @@ water F 975 472
6868
blood r 79 192
6969
swing_lamp N 539 0
7070
swing_lamp F 478 0
71-
smoker F 317 428
71+
smoker P 317 428
7272
fan N 809 445
7373
--BIRTHPLACE-- B 880 479
7474
--BIRTHPLACE-- B 638 108

server.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ static void update_game(void)
20772077
{
20782078
static char packet[64];
20792079
char txt[256];
2080-
struct object_list *p;
2080+
struct object_list *p, *p2;
20812081
struct player_list *q;
20822082
int w,h,b,a;
20832083
unsigned char stop_x,stop_y;
@@ -2358,6 +2358,20 @@ br: offset = 0;
23582358
if (!(p->next))break;
23592359
continue;
23602360
}
2361+
2362+
/* Anything crashing into PS makes him into bloody goo */
2363+
for (p2=&objects;p2->next;p2=p2->next)
2364+
if ((p2->next->member.type == T_PS) && (!(p2->next->member.status & S_INVISIBLE)) &&
2365+
((p->next->member.type == T_BULLET) || (p->next->member.type == T_SHRAPNEL) ||
2366+
(p->next->member.type == T_CHAIN) || (p->next->member.type == T_BFGCELL)) &&
2367+
collision(
2368+
double2int(p2->next->member.x),double2int(p2->next->member.y),p2->next->member.type,p2->next->member.status,sprites[p2->next->member.sprite].positions,
2369+
double2int(p->next->member.x),double2int(p->next->member.y),p->next->member.type,p->next->member.status,sprites[p->next->member.sprite].positions)) {
2370+
p2->next->member.status |= S_INVISIBLE;
2371+
create_mess(double2int(p2->next->member.x),double2int(p2->next->member.y)+PLAYER_HEIGHT-MESS_HEIGHT,double2int(p2->next->member.y));
2372+
add_to_timeq(p2->next->member.id,T_PS,0,p2->next->member.sprite,0,0,p2->next->member.x,p2->next->member.y,0,0,0,PS_RESPAWN_TIME);
2373+
sendall_update_status(&(p2->next->member),0);
2374+
}
23612375
dc:
23622376
/* compute collision with other objects */
23632377
a=dynamic_collision(&(p->next->member));

0 commit comments

Comments
 (0)