Debian Codegraph @

src/brain_text.cpp

raw
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include "brain.h"
6 #include "live_sprites_manager.h"
7
8 void text_brain(int h)
9 {
10 if (!lsm_isValidSprite(h)
11 || (spr[h].text_owner != 0 && spr[h].text_owner != 1000 && !lsm_isValidSprite(spr[h].text_owner))) {
12 lsm_remove_sprite(h);
13 return;
14 }
15
16 // Select text type
17 // Note: scripters can make hybrids, e.g. narrator (owner=1000) sprite that moves
18 if ((spr[h].damage == -1) && (spr[h].text_owner != 1000)) {
19 // Normal text sprite
20
21 // Kill text if owner was killed
22 if (!spr[spr[h].text_owner].active) {
23 lsm_remove_sprite(h);
24 return;
25 }
26 //give this text the cords from it's owner sprite
27 // strength/defense = text sprite center
28 spr[h].x = spr[spr[h].text_owner].x - spr[h].strength;
29 spr[h].y = spr[spr[h].text_owner].y - spr[h].defense;
30
31 if (spr[h].x < 1) spr[h].x = 1;
32 if (spr[h].y < 1) spr[h].y = 1;
33 } else if (spr[h].move_active) {
34 // damage/experience gain (damage=0)
35 process_move(h);
36 } else {
37 // Narrator text sprite (owner=1000)
38 automove(h);
39 }
40 }