Last change
on this file was
676,
checked in by Sam Hocevar, 11 years ago
|
game: prefix a few class members with m_ to avoid confusion.
|
File size:
1.5 KB
|
Line | |
---|
1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
8 | * Jonathan Clark, or by Sam Hocevar. |
---|
9 | */ |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include "common.h" |
---|
16 | |
---|
17 | #include "lisp.h" |
---|
18 | #include "lisp_gc.h" |
---|
19 | #include "compiled.h" |
---|
20 | #include "objects.h" |
---|
21 | #include "level.h" |
---|
22 | #include "game.h" |
---|
23 | #include "jrand.h" |
---|
24 | #include "clisp.h" |
---|
25 | |
---|
26 | enum { un_offable }; // vars |
---|
27 | |
---|
28 | void *sensor_ai() |
---|
29 | { |
---|
30 | game_object *o=current_object,*b; |
---|
31 | if (o->aistate()==0) // turned off, what for player to enter |
---|
32 | { |
---|
33 | if (player_list->next) // find closest player |
---|
34 | b=current_level->attacker(current_object); |
---|
35 | else b=player_list->m_focus; |
---|
36 | if (abs(b->x-o->x)<o->xvel() && abs(b->y-o->y)<o->yvel()) // inside area? |
---|
37 | { |
---|
38 | if (!o->hp()) |
---|
39 | o->set_aistate(1); |
---|
40 | else |
---|
41 | o->set_aistate(o->hp()); |
---|
42 | o->set_state((character_state)S_blocking); |
---|
43 | } else if (o->state!=stopped) |
---|
44 | o->set_state(stopped); |
---|
45 | } else if (!o->lvars[un_offable]) |
---|
46 | { |
---|
47 | if (!o->hp()) |
---|
48 | { |
---|
49 | if (player_list->next) |
---|
50 | b=current_level->attacker(current_object); |
---|
51 | else b=player_list->m_focus; |
---|
52 | if (abs(o->x-b->x)>o->xacel() || abs(o->y-b->y)>o->yacel()) |
---|
53 | o->set_aistate(0); |
---|
54 | } else o->set_aistate(o->aistate()-1); |
---|
55 | } |
---|
56 | return true_symbol; |
---|
57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.