Debian Codegraph @

src/brain_pig.cpp

raw
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include "brain.h"
6 #include "game_engine.h"
7 #include "live_sprites_manager.h"
8 #include "freedink.h"
9 #include "live_screen.h"
10 #include "gfx_sprites.h"
11 #include "gfx.h" /* GFX_RES_W -> a little off-screen ?? */
12 #include "sfx.h"
13
14 void pig_brain(int h)
15 {
16 int hold;
17
18 if (spr[h].move_active)
19 {
20 process_move(h);
21 return;
22 }
23
24 if ( (spr[h].damage > 0) )
25 {
26 //SoundPlayEffect( 1,3000, 800 );
27 draw_damage(h);
28 spr[h].hitpoints -= spr[h].damage;
29 spr[h].damage = 0;
30 if (spr[h].hitpoints < 1)
31 {
32 add_exp(spr[h].exp, h);
33 spr[h].damage = 0;
34 //lets kill the duck here, ha.
35 check_for_kill_script(h);
36 spr[h].speed = 0;
37 spr[h].base_walk = -1;
38 spr[h].seq = 164;
39 spr[h].brain = 7;
40 }
41
42 return;
43 }
44
45
46 if (spr[h].freeze) return;
47
48
49
50 if (spr[h].seq == 0 )
51 {
52
53 if (((rand() % 12)+1) == 1 )
54 {
55 hold = ((rand() % 9)+1);
56
57 if ( (hold != 4) && (hold != 6) && (hold != 2) && (hold != 8) && (hold != 5))
58 {
59 changedir(hold,h,spr[h].base_walk);
60
61 }
62 else
63 {
64 int junk = spr[h].size;
65
66 if (junk >= 100)
67 junk = 18000 - (junk * 50);
68
69 if (junk < 100)
70 junk = 16000 + (junk * 100);
71
72
73 hold = ((rand() % 4)+1);
74
75 if (!playing(spr[h].last_sound)) spr[h].last_sound = 0;
76
77 if (spr[h].last_sound == 0)
78 {
79
80
81 if (hold == 1)
82 spr[h].last_sound = SoundPlayEffect( 2,junk, 800 ,h,0);
83 if (hold == 2)
84 spr[h].last_sound = SoundPlayEffect( 3,junk, 800,h ,0);
85 if (hold == 3)
86 spr[h].last_sound = SoundPlayEffect( 4,junk, 800 ,h,0);
87 if (hold == 4)
88 spr[h].last_sound = SoundPlayEffect( 5,junk, 800,h,0 );
89
90 }
91
92 spr[h].mx = 0;
93 spr[h].my = 0;
94 spr[h].wait = thisTickCount + (rand() % 300)+200;
95
96 }
97
98 }
99 else
100 {
101
102 if ((spr[h].mx != 0) || (spr[h].my != 0))
103
104 {
105 spr[h].seq = spr[h].seq_orig;
106
107 }
108
109 }
110 }
111
112
113 if (spr[h].y > (playy-k[getpic(h)].box.bottom / 4))
114 {
115 changedir(9,h,spr[h].base_walk);
116 }
117
118 if (spr[h].x > (GFX_RES_W -k[getpic(h)].box.right-10))
119 {
120 changedir(1,h,spr[h].base_walk);
121 }
122
123 if (spr[h].y < 10)
124 {
125 changedir(1,h,spr[h].base_walk);
126 }
127
128 if (spr[h].x < 10)
129 {
130 changedir(3,h,spr[h].base_walk);
131 }
132
133 automove(h);
134
135 if (check_if_move_is_legal(h) != 0)
136
137 {
138 changedir(autoreverse_diag(h),h,spr[h].base_walk);
139 }
140
141 }