| 1 |
#ifdef HAVE_CONFIG_H |
| 2 |
#include <config.h> |
| 3 |
#endif |
| 4 |
|
| 5 |
#include "brain.h" |
| 6 |
#include "live_sprites_manager.h" |
| 7 |
#include "rect.h" |
| 8 |
#include "gfx_sprites.h" |
| 9 |
#include "dinkc.h" |
| 10 |
|
| 11 |
void button_brain(int h ) |
| 12 |
{ |
| 13 |
rect box; |
| 14 |
if (spr[h].move_active) |
| 15 |
{ |
| 16 |
process_move(h); |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
if (spr[h].script == 0) return; |
| 22 |
|
| 23 |
rect_copy(&box, &k[getpic(h)].hardbox); |
| 24 |
rect_offset(&box, spr[h].x, spr[h].y); |
| 25 |
|
| 26 |
if (spr[h].brain_parm == 0) |
| 27 |
{ |
| 28 |
if (inside_box(spr[1].x, spr[1].y, box)) |
| 29 |
{ |
| 30 |
spr[h].brain_parm = 1; |
| 31 |
|
| 32 |
if (locate(spr[h].script, "BUTTONON")) |
| 33 |
{ |
| 34 |
run_script(spr[h].script); |
| 35 |
|
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
} |
| 42 |
else |
| 43 |
{ |
| 44 |
if (!inside_box(spr[1].x, spr[1].y, box)) |
| 45 |
{ |
| 46 |
spr[h].brain_parm = 0; |
| 47 |
|
| 48 |
if (locate(spr[h].script, "BUTTONOFF")) |
| 49 |
{ |
| 50 |
|
| 51 |
run_script(spr[h].script); |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
} |