source: abuse/trunk/src/sensor.cpp @ 97

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