/[enigma]/enigma/src/items.cc
ViewVC logotype

Diff of /enigma/src/items.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by dheck, Sun May 18 18:45:07 2003 UTC revision 1.37 by reallysoft, Mon May 19 12:14:35 2003 UTC
# Line 45  Item::get_inventory_model() Line 45  Item::get_inventory_model()
45      return get_kind();      return get_kind();
46  }  }
47    
48  void Item::stone_change (Stone *st) {}  void Item::stone_change (Stone */*st*/) {}
49  void Item::on_stonehit (Stone *st) {}  void Item::on_stonehit (Stone */*st*/) {}
50  void Item::on_drop (Actor *a) {}  void Item::on_drop (Actor */*a*/) {}
51  void Item::on_pickup (Actor *a) {}  void Item::on_pickup (Actor */*a*/) {}
52    
53  ItemAction Item::activate(Actor* a, GridPos p)  ItemAction Item::activate(Actor* /*a*/, GridPos /*p*/)
54  { return ITEM_DROP; }  { return ITEM_DROP; }
55    
56    
57  px::V2 Item::get_force(Actor *a)  px::V2 Item::get_force(Actor */*a*/)
58  { return px::V2(); }  { return px::V2(); }
59    
60  bool  bool
# Line 86  namespace Line 86  namespace
86    
87      class Sword : public Item {      class Sword : public Item {
88          CLONEOBJ(Sword);          CLONEOBJ(Sword);
89          bool on_laserhit(Direction d) {          bool on_laserhit(Direction /*d*/) {
90              play_sound("st-magic");              play_sound("st-magic");
91              world::SetItem(get_pos(), MakeItem("it-hammer"));              world::SetItem(get_pos(), MakeItem("it-hammer"));
92              return false;              return false;
# Line 97  namespace Line 97  namespace
97    
98      class Hammer : public Item {      class Hammer : public Item {
99          CLONEOBJ(Hammer);          CLONEOBJ(Hammer);
100          bool on_laserhit(Direction d) {          bool on_laserhit(Direction /*d*/) {
101              play_sound("st-magic");              play_sound("st-magic");
102              world::SetItem(get_pos(), MakeItem("it-sword"));              world::SetItem(get_pos(), MakeItem("it-sword"));
103              return false;              return false;
# Line 155  namespace Line 155  namespace
155      private:      private:
156          void init_model() { set_model(get_inventory_model()); }          void init_model() { set_model(get_inventory_model()); }
157    
158          bool on_laserhit(Direction d) {          bool on_laserhit(Direction /*d*/) {
159              play_sound("st-magic");              play_sound("st-magic");
160              switch(get_value()) {              switch(get_value()) {
161              case 1: SetItem (get_pos(), MakeItem("it-umbrella")); break;              case 1: SetItem (get_pos(), MakeItem("it-umbrella")); break;
# Line 165  namespace Line 165  namespace
165              return false;              return false;
166          }          }
167    
168          void on_stonehit(Stone *st) {          void on_stonehit(Stone */*st*/) {
169              switch(get_value()) {              switch(get_value()) {
170              case 1: set_attrib("value", 2.0); init_model(); break;              case 1: set_attrib("value", 2.0); init_model(); break;
171              case 2: set_attrib("value", 4.0); init_model(); break;              case 2: set_attrib("value", 4.0); init_model(); break;
# Line 223  namespace Line 223  namespace
223    
224          // Item interface          // Item interface
225          px::V2 get_force(Actor *a);          px::V2 get_force(Actor *a);
226          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
227          void on_stonehit(Stone *st);          void on_stonehit(Stone *st);
228    
229          // Object interface.          // Object interface.
# Line 243  HillHollow::HillHollow(const char *name, Line 243  HillHollow::HillHollow(const char *name,
243  : Item(name), m_type(t)  : Item(name), m_type(t)
244  {}  {}
245    
246  void HillHollow::on_stonehit(Stone *st)  void HillHollow::on_stonehit(Stone */*st*/)
247  {  {
248      shovel();      shovel();
249  }  }
# Line 287  V2 HillHollow::get_force(Actor *a) Line 287  V2 HillHollow::get_force(Actor *a)
287  void HillHollow::transmute(Type newtype)  void HillHollow::transmute(Type newtype)
288  {  {
289      m_type = newtype;      m_type = newtype;
290      static char *modelname[] = { "it-hill", "it-hollow",      static const char *modelname[] = { "it-hill", "it-hollow",
291                                   "it-tinyhill", "it-tinyhollow" };                                         "it-tinyhill", "it-tinyhollow" };
292      set_model(modelname[m_type]);      set_model(modelname[m_type]);
293  }  }
294    
# Line 543  namespace Line 543  namespace
543      private:      private:
544          CLONEOBJ(Document);          CLONEOBJ(Document);
545    
546          ItemAction activate(Actor *a, GridPos)          ItemAction activate(Actor */*a*/, GridPos)
547          {          {
548              string txt;              string txt;
549              if (string_attrib ("text", &txt))              if (string_attrib ("text", &txt))
550                  display::GetStatusBar()->show_text(txt);                  display::GetStatusBar()->show_text(txt);
551              return ITEM_KILL;          // remove from inventory              return ITEM_KILL;          // remove from inventory
552          }          }
553          void message(const string &msg, const Value &val) {          void message(const string &msg, const Value &/*val*/) {
554              if (msg == "ignite")              if (msg == "ignite")
555                  SetItem(get_pos(), new Explosion(Explosion::WEAK));                  SetItem(get_pos(), new Explosion(Explosion::WEAK));
556          }          }
# Line 584  namespace Line 584  namespace
584          void animcb() { explode(); }          void animcb() { explode(); }
585          void explode ();          void explode ();
586    
587          void message(const string &msg, const Value &val) {          void message(const string &msg, const Value &/*val*/) {
588              if (msg == "ignite")              if (msg == "ignite")
589                  change_state(BURNING);                  change_state(BURNING);
590              else if (msg == "explode")              else if (msg == "explode")
# Line 596  namespace Line 596  namespace
596              return false;           // block light              return false;           // block light
597          }          }
598    
599          void on_drop(Actor *a) {change_state(BURNING);}          void on_drop(Actor */*a*/) { change_state(BURNING); }
600    
601          bool actor_hit(Actor *a) {          bool actor_hit(Actor */*a*/) {
602              // don't pick up burning dynamite              // don't pick up burning dynamite
603              return (state == IDLE);              return (state == IDLE);
604          }          }
# Line 663  namespace Line 663  namespace
663              }              }
664          }          }
665    
666          void message(const string &msg, const Value &val) {          void message(const string &msg, const Value &/*val*/) {
667              if (msg == "ignite")              if (msg == "ignite")
668                  change_state(BURNING);                  change_state(BURNING);
669              else if (msg == "explode")              else if (msg == "explode")
# Line 674  namespace Line 674  namespace
674              change_state(BURNING);              change_state(BURNING);
675              return false;           // block light              return false;           // block light
676          }          }
677          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
678    
679          void on_stonehit(Stone *st) {          void on_stonehit(Stone */*st*/) {
680              explode();              explode();
681          }          }
682    
# Line 737  namespace Line 737  namespace
737              }              }
738          }          }
739    
740          void message(const string &msg, const Value &val) {          void message(const string &msg, const Value &/*val*/) {
741              if (msg == "ignite")              if (msg == "ignite")
742                  change_state(BURNING);                  change_state(BURNING);
743              else if (msg == "explode")              else if (msg == "explode")
# Line 748  namespace Line 748  namespace
748              change_state(BURNING);              change_state(BURNING);
749              return false;           // block light              return false;           // block light
750          }          }
751          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
752          void on_stonehit(Stone *st) {          void on_stonehit(Stone */*st*/) {
753              explode();              explode();
754          }          }
755      };      };
# Line 833  namespace Line 833  namespace
833          int objectcnt;          // number of objects on the trigger          int objectcnt;          // number of objects on the trigger
834          bool have_stone;          bool have_stone;
835    
836          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
837    
838    
839          void init_model() {          void init_model() {
# Line 893  namespace Line 893  namespace
893          CLONEOBJ(Seed);          CLONEOBJ(Seed);
894          enum State { IDLE, GROWING } state;          enum State { IDLE, GROWING } state;
895    
896          bool actor_hit(Actor *a) { return state==IDLE; }          bool actor_hit(Actor */*a*/) { return state==IDLE; }
897          void on_drop(Actor *a) { start_growing(); }          void on_drop(Actor */*a*/) { start_growing(); }
898          void on_stonehit(Stone *) { start_growing(); }          void on_stonehit(Stone *) { start_growing(); }
899    
900          void start_growing() {          void start_growing() {
# Line 938  namespace Line 938  namespace
938          void init_model();          void init_model();
939          void message(const string &str, const Value &v);          void message(const string &str, const Value &v);
940          void stone_change(Stone *st);          void stone_change(Stone *st);
941          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
942    
943    
944          // Variables.          // Variables.
# Line 963  ShogunDot::get_size() const Line 963  ShogunDot::get_size() const
963  void  void
964  ShogunDot::init_model()  ShogunDot::init_model()
965  {  {
966      char *models[] = {"it-shogun1", "it-shogun2", "it-shogun3"};      static const char *models[] = {"it-shogun1", "it-shogun2", "it-shogun3"};
967      set_model(models[get_size()-1]);      set_model(models[get_size()-1]);
968  }  }
969    
# Line 985  ShogunDot::stone_change(Stone *st) Line 985  ShogunDot::stone_change(Stone *st)
985  }  }
986    
987  void  void
988  ShogunDot::message(const string &str, const Value &v)  ShogunDot::message(const string &str, const Value &/*v*/)
989  {  {
990      int         size = get_size();      int         size = get_size();
991      const char *s    = str.c_str();      const char *s    = str.c_str();
# Line 1020  namespace Line 1020  namespace
1020    
1021              void set_pos(GridPos p) { center = to_vec(p) + V2(0.5,0.5); }              void set_pos(GridPos p) { center = to_vec(p) + V2(0.5,0.5); }
1022    
1023              V2 get_force(Actor *a, V2 x, V2 v, double time)              V2 get_force(Actor */*a*/, V2 x, V2 /*v*/, double /*time*/)
1024              {              {
1025                  if (!m_active)                  if (!m_active)
1026                      return V2();                      return V2();
# Line 1060  namespace Line 1060  namespace
1060              world::RemoveForceField(&ff);              world::RemoveForceField(&ff);
1061              Item::on_removal();              Item::on_removal();
1062          }          }
1063          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
1064    
1065          virtual void notify_onoff(bool on) {          virtual void notify_onoff(bool on) {
1066              ff.m_active = on;              ff.m_active = on;
# Line 1100  namespace Line 1100  namespace
1100    
1101          void set_pos(GridPos p) { center = to_vec(p) + V2(0.5,0.5); }          void set_pos(GridPos p) { center = to_vec(p) + V2(0.5,0.5); }
1102    
1103          V2 get_force(Actor *a, V2 x, V2 v, double time)          V2 get_force(Actor */*a*/, V2 x, V2 /*v*/, double /*time*/)
1104          {          {
1105              V2 b = center - x;              V2 b = center - x;
1106              double bb = length(b);              double bb = length(b);
# Line 1187  namespace Line 1187  namespace
1187                  return "it-yanying";                  return "it-yanying";
1188          }          }
1189    
1190          ItemAction activate(Actor *a, GridPos) {          ItemAction activate(Actor */*a*/, GridPos) {
1191              // Switch to other marble              // Switch to other marble
1192              player::SwapPlayers();              player::SwapPlayers();
1193              sound::PlaySound ("switch");              sound::PlaySound ("switch");
# Line 1259  namespace Line 1259  namespace
1259              set_model(get_inventory_model());              set_model(get_inventory_model());
1260          }          }
1261    
1262          bool actor_hit(Actor *a) {          bool actor_hit(Actor */*a*/) {
1263              return !active;              return !active;
1264          }          }
1265    
1266          void on_drop(Actor *a) { activate(); }          void on_drop(Actor */*a*/) { activate(); }
1267    
1268          void activate() {          void activate() {
1269              active=true;              active=true;
# Line 1331  namespace Line 1331  namespace
1331                  set_anim("it-crack_anim2");                  set_anim("it-crack_anim2");
1332              }              }
1333          }          }
1334          void actor_enter(Actor *a) {          void actor_enter(Actor */*a*/) {
1335              if (get_fixed())              if (get_fixed())
1336                  return;                  return;
1337    
1338              SendMessage(this, "crack");              SendMessage(this, "crack");
1339    
# Line 1384  namespace Line 1384  namespace
1384              }              }
1385          }          }
1386          bool actor_hit(Actor *a) {          bool actor_hit(Actor *a) {
1387              if (anim_end)              if (anim_end)
1388                  SendMessage(a, "fall");                  SendMessage(a, "fall");
1389              return false;              return false;
1390          }          }
1391          void message(const string &msg, const Value &val) {          void message(const string &msg, const Value &/*val*/) {
1392              if ((msg == "crack") && (get_fixed() == 0)) {              if ((msg == "crack") && (get_fixed() == 0)) {
1393                  set_attrib("type", Value(int_attrib("type") + 1));                  set_attrib("type", Value(int_attrib("type") + 1));
1394                  play_sound("crack");                  play_sound("crack");
# Line 1422  namespace Line 1422  namespace
1422  {  {
1423      class FlagWhite : public Item {      class FlagWhite : public Item {
1424          CLONEOBJ(FlagWhite);          CLONEOBJ(FlagWhite);
1425          void on_drop(Actor *a) { }          void on_drop(Actor */*a*/) { }
1426    
1427      public:      public:
1428          FlagWhite(): Item("it-flagwhite") {}          FlagWhite(): Item("it-flagwhite") {}
# Line 1430  namespace Line 1430  namespace
1430    
1431      class FlagBlack : public Item {      class FlagBlack : public Item {
1432          CLONEOBJ(FlagBlack);          CLONEOBJ(FlagBlack);
1433          void on_drop(Actor *a) { }          void on_drop(Actor */*a*/) { }
1434    
1435      public:      public:
1436          FlagBlack(): Item("it-flagblack") {}          FlagBlack(): Item("it-flagblack") {}
# Line 1538  namespace Line 1538  namespace
1538                  case COVERED:                  case COVERED:
1539                      grow();                      grow();
1540                      break;                      break;
1541                    case IDLE:
1542                    case SHRINKED:
1543                        // no action
1544                        break;
1545                  }                  }
1546              }              }
1547          }          }
# Line 1555  namespace Line 1559  namespace
1559              }              }
1560          }          }
1561    
1562          bool actor_hit(Actor *a) { return false; }          bool actor_hit(Actor */*a*/) { return false; }
1563    
1564      };      };
1565    

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26