Last change
on this file since 534 was
49,
checked in by Sam Hocevar, 15 years ago
|
- Imported original public domain release, for future reference.
|
-
Property svn:keywords set to
Id
|
File size:
1.1 KB
|
Line | |
---|
1 | #include "lisp.hpp" |
---|
2 | #include "lisp_gc.hpp" |
---|
3 | #include "compiled.hpp" |
---|
4 | #include "objects.hpp" |
---|
5 | #include "level.hpp" |
---|
6 | #include "game.hpp" |
---|
7 | #include "jrand.hpp" |
---|
8 | #include "clisp.hpp" |
---|
9 | |
---|
10 | enum { un_offable }; // vars |
---|
11 | |
---|
12 | void *sensor_ai() |
---|
13 | { |
---|
14 | game_object *o=current_object,*b; |
---|
15 | if (o->aistate()==0) // turned off, what for player to enter |
---|
16 | { |
---|
17 | if (player_list->next) // find closest player |
---|
18 | b=current_level->attacker(current_object); |
---|
19 | else b=player_list->focus; |
---|
20 | if (abs(b->x-o->x)<o->xvel() && abs(b->y-o->y)<o->yvel()) // inside area? |
---|
21 | { |
---|
22 | if (!o->hp()) |
---|
23 | o->set_aistate(1); |
---|
24 | else |
---|
25 | o->set_aistate(o->hp()); |
---|
26 | o->set_state((character_state)S_blocking); |
---|
27 | } else if (o->state!=stopped) |
---|
28 | o->set_state(stopped); |
---|
29 | } else if (!o->lvars[un_offable]) |
---|
30 | { |
---|
31 | if (!o->hp()) |
---|
32 | { |
---|
33 | if (player_list->next) |
---|
34 | b=current_level->attacker(current_object); |
---|
35 | else b=player_list->focus; |
---|
36 | if (abs(o->x-b->x)>o->xacel() || abs(o->y-b->y)>o->yacel()) |
---|
37 | o->set_aistate(0); |
---|
38 | } else o->set_aistate(o->aistate()-1); |
---|
39 | } |
---|
40 | return true_symbol; |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.