source: golgotha/src/golg/objs/bomb_truck.cc

Last change on this file 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: 4.3 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/map_piece.hh"
10#include "object_definer.hh"
11#include "lisp/lisp.hh"
12#include "objs/explode_model.hh"
13#include "li_objref.hh"
14#include "objs/path_object.hh"
15#include "map_man.hh"
16#include "map.hh"
17#include "saver.hh"
18#include "objs/shockwave.hh"
19#include "image_man.hh"
20#include "tick_count.hh"
21#include "sound/sfx_id.hh"
22#include "controller.hh"
23
24static g1_team_icon_ref radar_im("bitmaps/radar/bomb_truck.tga");
25
26S1_SFX(bomb_coming, "computer_voice/bomb_truck_approaching_22khz.wav", S1_STREAMED, 200);
27
28S1_SFX(bleep, "misc/bleep_22khz.wav", 0, 100);
29
30
31static li_symbol_ref reached("reached");
32li_symbol_ref shockwave("shockwave");
33
34class g1_bomb_truck_class : public g1_map_piece_class
35{
36public:
37  int warning_level;
38  i4_bool user_warned;
39
40  g1_bomb_truck_class(g1_object_type id, g1_loader_class *fp)
41    : g1_map_piece_class(id,fp)
42  {
43    warning_level=0;
44    draw_params.setup("bomb_truck",0,"bomb_truck_lod");
45
46    allocate_mini_objects(1,"Bomb Truck Mini-Objects");
47    user_warned=i4_F;
48
49    radar_image=&radar_im;
50    radar_type=G1_RADAR_VEHICLE;
51    set_flag(BLOCKING      |
52             TARGETABLE    |
53             GROUND        |
54             SHADOWED      |
55             DANGEROUS, 1);
56  }
57
58  void think()
59  {
60    g1_map_piece_class::think();
61    if (warning_level>9)
62      warning_level=9;
63
64    if (g1_player_man.local_player!=player_num &&
65        warning_level && (g1_tick_counter+global_id)%(10-warning_level)==0)
66      bleep.play();
67     
68  }
69 
70
71
72  void damage(g1_object_class *who_is_hurting,
73              int how_much_hurt, i4_3d_vector damage_dir) 
74  {
75    g1_object_class::damage(who_is_hurting, how_much_hurt, damage_dir);
76    if (health<=0)
77    {
78      g1_shockwave_class *shock = NULL;
79      shock = (g1_shockwave_class *)g1_create_object(g1_get_object_type(shockwave.get()));
80      if (shock)
81        shock->setup(i4_3d_vector(x,y,h), 0.5);
82
83      g1_apply_damage(this, this, 0, i4_3d_vector(0,0,1));
84    }
85  }
86
87
88  li_object *message(li_symbol *message_name,
89                             li_object *message_params,
90                             li_environment *env)
91  {
92    if (message_name==reached.get())
93    {
94      g1_object_class *who=li_g1_ref::get(message_params,env)->value();
95      if (who)
96      {
97        g1_path_object_class *po=g1_path_object_class::cast(who);
98       
99        if (po->bomb_warning_level()>warning_level)
100          warning_level=po->bomb_warning_level();
101
102        if (warning_level && g1_player_man.local_player!=player_num &&
103            !user_warned)
104        {
105          user_warned=i4_T;
106          if (g1_current_controller.get())
107            g1_current_controller->scroll_message(i4gets("bomb_coming"));
108          bomb_coming.play();
109        }
110
111        if (po && !po->total_links(get_team()))
112        {
113          for (int i=0; i<po->total_controlled_objects(); i++)
114          {
115            g1_object_class *who=po->get_controlled_object(i);
116           
117            int e_type=g1_get_object_type("explode_model");
118            g1_explode_model_class *e = (g1_explode_model_class *)g1_create_object(e_type);
119            if (e && who && who->draw_params.model)
120            {
121              g1_explode_params params;             
122              e->setup(who, i4_3d_vector(who->x, who->y, who->h), params);
123
124              who->unoccupy_location();
125              who->request_remove();
126            }
127          }
128
129          who->change_player_num(player_num);
130        }
131      }
132   
133    }
134 
135    return g1_map_piece_class::message(message_name, message_params, env);
136  }
137};
138
139g1_object_definer<g1_bomb_truck_class>
140g1_bomb_truck_def("bomb_truck",
141                  g1_object_definition_class::EDITOR_SELECTABLE |
142                  g1_object_definition_class::TO_MAP_PIECE |
143                  g1_object_definition_class::MOVABLE);
144
145
Note: See TracBrowser for help on using the repository browser.