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

Diff of /enigma/src/objects.cc

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

revision 1.9 by sfennig, Sun Jan 19 03:35:01 2003 UTC revision 1.10 by dheck, Thu Jan 23 22:41:00 2003 UTC
# Line 17  Line 17 
17   *   *
18   * $Id$   * $Id$
19   */   */
20  #include "enigma.hh"  #include "game.hh"
21  #include "objects.hh"  #include "objects.hh"
22  #include "object_mixins.hh"  #include "object_mixins.hh"
23  #include "display.hh"  #include "display.hh"
# Line 40  using namespace std; Line 40  using namespace std;
40  using namespace world;  using namespace world;
41  using namespace enigma;  using namespace enigma;
42    
 using tools::Value;  
   
43  namespace  namespace
44  {  {
45      player::Inventory *      player::Inventory *
# Line 1228  namespace Line 1226  namespace
1226  //----------------------------------------  //----------------------------------------
1227  // ScissorsStone  // ScissorsStone
1228  //----------------------------------------  //----------------------------------------
1229    
1230    /** \page st-scissors Scissors stone
1231      
1232    This stone cuts \c all rubber bands attached to an actor that touches
1233    it.
1234    
1235    \image html st-scissors
1236    */
1237  namespace  namespace
1238  {  {
1239      class ScissorsStone : public Stone {      class ScissorsStone : public Stone {
# Line 1236  namespace Line 1242  namespace
1242          ScissorsStone() : Stone("st-scissors") {}          ScissorsStone() : Stone("st-scissors") {}
1243      private:      private:
1244          void actor_hit(const StoneContact &sc) {          void actor_hit(const StoneContact &sc) {
1245              // cut all rubber bands connected to sc.actor              world::KillRubberBand (sc.actor, (Stone*)0);
1246                world::KillRubberBand (sc.actor, (Actor*)0);
1247                set_anim("st-scissors-snip");
1248          }          }
1249      };      };
1250  }  }
1251    
1252  //----------------------------------------  //----------------------------------------
1253    // RubberBand stone
1254    //----------------------------------------
1255    
1256    /** \page st-rubberband Rubberband stone
1257    
1258    If hit by a marble, this stone first removes existing connections with
1259    other rubberband stones and then attaches a new elastic between the
1260    marble and itself.  Nothing happens if the marble was already attached
1261    to this particular stone.
1262    
1263    This stone can be moved if hit with a magic wand.
1264    
1265    \image html st-rubberband.png
1266    */
1267    namespace
1268    {
1269        class RubberBandStone : public MovableStone {
1270        public:
1271            RubberBandStone () : MovableStone ("st-rubberband")
1272            {}
1273        private:
1274    
1275        };
1276    }
1277    
1278    
1279    //----------------------------------------
1280  // BolderStone  // BolderStone
1281  //----------------------------------------  //----------------------------------------
1282    
1283  /** \page st-bolder Bolder Stone  /** \page st-bolder Bolder Stone
1284    
1285  The bolder stone will move in one direction until another stone will  The bolder stone will move in one direction until another stone will
1286  block. Using a magick wand the bolder stone will move to the reversed  block.  When hit with a magic wand, the bolder stone reverse its
1287  direction. When hitting a blocking stone it can activate switches or  direction. When hitting a blocking stone it can activate switches or
1288  oxyd stones.  oxyd stones.
1289    
# Line 1259  oxyd stones. Line 1294  oxyd stones.
1294  */  */
1295  namespace  namespace
1296  {  {
1297      class BolderStone : public Stone, public tools::TimeHandler      class BolderStone : public Stone, public TimeHandler
1298      {      {
1299          CLONEOBJ(BolderStone);          CLONEOBJ(BolderStone);
1300      public:      public:
# Line 1664  namespace Line 1699  namespace
1699    
1700      private:      private:
1701          virtual string model_basename() { return get_kind(); }          virtual string model_basename() { return get_kind(); }
1702          virtual void init_model() {          virtual void init_model();
1703              string mname = model_basename();          virtual string opening_sound() const { return ""; }
1704              if (state == CLOSED)          virtual string closing_sound() const { return ""; }
                 mname += "-closed";  
             else if (state==OPEN)  
                 mname += "-open";  
             set_model(mname);  
         }  
1705    
1706          void change_state(State newstate) ;          void change_state(State newstate) ;
1707          void message(const string &m, const Value &);          void message(const string &m, const Value &);
# Line 1681  namespace Line 1711  namespace
1711          void actor_hit(const StoneContact &sc);          void actor_hit(const StoneContact &sc);
1712          void actor_contact(Actor *a);          void actor_contact(Actor *a);
1713    
1714          void animcb() {          void animcb();
             if (state == OPENING)  
                 change_state(OPEN);  
             else if (state == CLOSING)  
                 change_state(CLOSED);  
         }  
1715          bool on_laserhit(Direction dir) {return state==OPEN;}          bool on_laserhit(Direction dir) {return state==OPEN;}
1716      };      };
1717  }  }
# Line 1706  DoorBase::message(const string &m, const Line 1731  DoorBase::message(const string &m, const
1731      }      }
1732  }  }
1733    
1734    void
1735    DoorBase::init_model()
1736    {
1737        string mname = model_basename();
1738        if (state == CLOSED)
1739            mname += "-closed";
1740        else if (state==OPEN)
1741            mname += "-open";
1742        set_model(mname);
1743    }
1744    
1745    void
1746    DoorBase::animcb()
1747    {
1748        if (state == OPENING)
1749            change_state(OPEN);
1750        else if (state == CLOSING)
1751            change_state(CLOSED);
1752    }
1753    
1754    
1755  StoneResponse  StoneResponse
1756  DoorBase::collision_response(const StoneContact &sc)  DoorBase::collision_response(const StoneContact &sc)
1757  {  {
# Line 1734  DoorBase::change_state(State newstate) Line 1780  DoorBase::change_state(State newstate)
1780          laser::MaybeRecalcLight(get_pos());          laser::MaybeRecalcLight(get_pos());
1781          break;          break;
1782      case OPENING:      case OPENING:
1783  //         sound::PlaySound("dooropen");          play_sound(opening_sound().c_str());
1784          if (state == CLOSING)          if (state == CLOSING)
1785              get_model()->reverse();              get_model()->reverse();
1786          else          else
1787              set_anim(basename+"-opening");              set_anim(basename+"-opening");
1788          break;          break;
1789      case CLOSING:      case CLOSING:
1790  //         sound::PlaySound("doorclose");          play_sound(closing_sound().c_str());
1791          if (state == OPENING)          if (state == OPENING)
1792              get_model()->reverse();              get_model()->reverse();
1793          else          else
# Line 1779  namespace Line 1825  namespace
1825      public:      public:
1826          Door() : DoorBase("st-door") {set_attrib("type", "h");}          Door() : DoorBase("st-door") {set_attrib("type", "h");}
1827      private:      private:
1828            virtual string opening_sound() const { return "dooropen"; }
1829            virtual string closing_sound() const { return "doorclose"; }
1830    
1831          string get_type() const {          string get_type() const {
1832              string type="h";              string type="h";
1833              string_attrib("type", &type);              string_attrib("type", &type);
# Line 1872  set_stone("st-timer", 10,10, Line 1921  set_stone("st-timer", 10,10,
1921  */  */
1922  namespace  namespace
1923  {  {
1924      class TimerStone : public OnOffStone, public tools::TimeHandler      class TimerStone : public OnOffStone, public TimeHandler
1925      {      {
1926          CLONEOBJ(TimerStone);          CLONEOBJ(TimerStone);
1927      public:      public:
# Line 2197  ShogunStone::actor_hit(const StoneContac Line 2246  ShogunStone::actor_hit(const StoneContac
2246    
2247  //----------------------------------------  //----------------------------------------
2248  // FartStone  // FartStone
 //  
 // Messages:  
 //  
 // :trigger  
2249  //----------------------------------------  //----------------------------------------
2250    
2251  /** \page st-fart Fart Stone  /** \page st-fart Fart Stone
# Line 2320  namespace Line 2365  namespace
2365              if (state == IDLE) {              if (state == IDLE) {
2366                  double forcefac = 200;                  double forcefac = 200;
2367                  sc.actor->add_force (forcefac * normalize(sc.normal));                  sc.actor->add_force (forcefac * normalize(sc.normal));
2368  //              play_sound("stoneimpulse");                  play_sound("impulse");
2369                  set_anim("st-actorimpulse-anim");                  set_anim("st-actorimpulse-anim");
2370                  state = PULSING;                  state = PULSING;
2371              }              }
# Line 2355  namespace Line 2400  namespace
2400    
2401          void stoneimpulse() {          void stoneimpulse() {
2402              if (state == IDLE) {              if (state == IDLE) {
2403  //                play_sound("stoneimpulse");                  play_sound("impulse");
2404                  set_anim("st-stoneimpulse-anim1");                  set_anim("st-stoneimpulse-anim1");
2405                  state = PULSING;                  state = PULSING;
2406              }              }
# Line 2410  namespace Line 2455  namespace
2455    
2456          void stoneimpulse() {          void stoneimpulse() {
2457              if (state == IDLE) {              if (state == IDLE) {
2458  //                play_sound("stoneimpulse");                  play_sound("impulse");
2459                  set_anim("st-stoneimpulse-hollow-anim1");                  set_anim("st-stoneimpulse-hollow-anim1");
2460                  state = PULSING;                  state = PULSING;
2461                  GridPos p = get_pos();                  GridPos p = get_pos();
# Line 2516  namespace Line 2561  namespace
2561          void actor_hit(const StoneContact &sc);          void actor_hit(const StoneContact &sc);
2562          void on_creation();          void on_creation();
2563          void on_removal();          void on_removal();
2564          const char *collision_sound() { return "st-metal"; }          const char *collision_sound() { return "st-stone"; }
2565          void message(const string &m, const Value &);          void message(const string &m, const Value &);
2566    
2567          // Animation callback          // Animation callback
# Line 2617  OxydStone::change_state(State newstate) Line 2662  OxydStone::change_state(State newstate)
2662          break;          break;
2663                    
2664      case CLOSING:      case CLOSING:
2665            if (state == CLOSED || state==CLOSING)
2666                return;
2667    
2668            play_sound("st-oxydclose");
2669          if (state == OPENING)          if (state == OPENING)
2670              get_model()->reverse();              get_model()->reverse();
2671          else if (state == BLINKING || state == OPEN) {          else if (state == BLINKING || state == OPEN) {
2672              set_anim(modelname + "-closing");              set_anim(modelname + "-closing");
2673          }          }
         else if (state == CLOSED || state==CLOSING)  
             return; // do nothing  
2674          break;          break;
2675      }      }
2676      state = newstate;      state = newstate;
# Line 3005  BombStone::actor_hit(const StoneContact Line 3052  BombStone::actor_hit(const StoneContact
3052      {      {
3053          if (!inv->is_full())          if (!inv->is_full())
3054          {          {
3055              Item *it = dynamic_cast<Item*>(MakeObject("it-blackbomb"));              Item *it = MakeItem("it-blackbomb");
3056              inv->add_item(it);              inv->add_item(it);
3057          }          }
3058      }      }
# Line 3098  set_stone("st-coinslot", 20,13,{action=" Line 3145  set_stone("st-coinslot", 20,13,{action="
3145    
3146  namespace  namespace
3147  {  {
3148      class CoinSlot : public OnOffStone, public tools::TimeHandler {      class CoinSlot : public OnOffStone, public TimeHandler {
3149          CLONEOBJ(CoinSlot);          CLONEOBJ(CoinSlot);
3150      public:      public:
3151          CoinSlot();          CoinSlot();

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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