annotate varydamage.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: varydamage.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 * redraw.c
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include "copyright.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #include <signal.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include <math.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include "packets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include "gameconf.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 doShields(dx, dy, ship_bits, j)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 int dx, dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 struct ship_shape *ship_bits;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 struct player *j;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 if (showShields && (j->p_flags & PFSHIELD)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 /*-----------Colored shields by shield damage--------*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 int color = playerColor(j);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 if (show_shield_dam && j == me) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 float ft;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 ft = (float) j->p_shield / (float) j->p_ship->s_maxshield;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 if (ft > 0.66)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 color = gColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 else if (ft > 0.33)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 color = yColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 else if (j->p_shield > 5)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 color = rColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 color = unColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 #if 0 /* shields the alert color, ick */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 switch (me->p_flags & (PFGREEN | PFYELLOW | PFRED)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 case PFGREEN:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 color = gColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 case PFYELLOW:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 color = yColor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 /* red shield tough to see */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 case PFRED:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 color = playerColor(j);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 W_WriteBitmap(dx - (ship_bits->width / 2),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 dy - (ship_bits->height / 2),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 ship_bits->shield, color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 #ifdef VARY_HULL
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 doHull(dx, dy, ship_bits, j)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 int dx, dy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 struct ship_shape *ship_bits;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 struct player *j;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 if (j == me && vary_hull) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 int hull_left = (100 * (me->p_ship->s_maxdamage -
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 me->p_damage)) / me->p_ship->s_maxdamage, hull_num = 7;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 int hull_color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 if (hull_left <= 16) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 hull_num = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 hull_color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 } else if (hull_left <= 28) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 hull_num = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 hull_color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 } else if (hull_left <= 40) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81 hull_num = 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 hull_color = W_Red;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 } else if (hull_left <= 52) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 hull_num = 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 hull_color = W_Yellow;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 } else if (hull_left <= 64) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 hull_num = 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 hull_color = W_Yellow;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 } else if (hull_left <= 76) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 hull_num = 5;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 hull_color = W_Yellow;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 } else if (hull_left <= 88) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 hull_num = 6;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 hull_color = W_Green;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 hull_color = W_Green /* playerColor (j) */ ;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 W_WriteBitmap(dx - (ship_bits->width / 2 + 1),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 dy - (ship_bits->height / 2 + 1),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 hull[hull_num], hull_color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 #endif /* VARY_HULL */