source: golgotha/src/golg/objs/goal.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.2 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "objs/goal.hh"
10#include "object_definer.hh"
11#include "lisp/li_init.hh"
12#include "lisp/li_class.hh"
13#include "li_objref.hh"
14#include "map_man.hh"
15#include "map.hh"
16#include "saver.hh"
17
18#include <stdio.h>
19
20static g1_object_type stank;
21
22static void g1_goal_init()
23{
24  stank = g1_get_object_type("stank");
25}
26
27g1_object_definer<g1_goal_class>
28g1_goal_def("goal", g1_object_definition_class::EDITOR_SELECTABLE, g1_goal_init);
29
30static li_int_class_member type("type");
31static li_int_class_member ticks_to_think("ticks_to_think");
32static li_int_class_member think_delay("think_delay");
33
34static li_float_class_member range("range");
35
36g1_goal_class::g1_goal_class(g1_object_type id, g1_loader_class *fp)
37  : g1_object_class(id, fp)
38{
39  draw_params.setup("lightbulb");
40}
41
42void g1_goal_class::save(g1_saver_class *fp)
43{
44  g1_object_class::save(fp);
45}
46
47void g1_goal_class::draw(g1_draw_context_class *context)
48
49  g1_editor_model_draw(this, draw_params, context);
50}
51
52void g1_goal_class::think()
53{
54  if (ticks_to_think())
55    ticks_to_think()--;
56  else
57  {
58#if 0
59    for (int i=0; i<G1_MAX_PLAYERS; i++)
60      power[i] = 0;
61
62    ticks_to_think() = think_delay();
63
64    g1_map_class::range_iterator p;
65   
66    p.begin(x,y,range());
67    p.mask(g1_object_class::DANGEROUS);
68   
69    while (!p.end())
70#else
71    g1_object_class *objs[1024], **p;
72
73    int num = g1_get_map()->get_objects_in_range(x, y, range(),
74                                                 objs, 1024, g1_object_class::DANGEROUS);
75    p = objs;
76    for (int i=0; i<num; i++)
77#endif
78    {
79      g1_object_class *o = *p;
80      int n= o->player_num;
81
82      if (o->id == stank)
83        power[n] += 10;
84      else
85        power[n]++;
86
87      ++p;
88    }
89  }
90  request_think();
91}
Note: See TracBrowser for help on using the repository browser.