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

Diff of /enigma/src/stones_simple.cc

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

revision 1.53.2.3 by dheck, Wed Oct 1 22:40:37 2003 UTC revision 1.53.2.4 by dheck, Fri Oct 3 13:44:29 2003 UTC
# Line 1509  namespace Line 1509  namespace
1509      public:      public:
1510          FloppyStone() : OnOffStone("st-floppy") {}          FloppyStone() : OnOffStone("st-floppy") {}
1511      private:      private:
1512          void init_model() {          // Stone interface
1513              set_model(is_on() ? "st-floppy1" : "st-floppy0");          void init_model();
1514          }          void actor_hit(const StoneContact &sc);
1515            const char *collision_sound() { return "st-metal"; }
1516        };
1517    }
1518    
1519          void actor_hit(const StoneContact &sc)  void FloppyStone::init_model()
1520    {
1521        set_model(is_on() ? "st-floppy1" : "st-floppy0");
1522    }
1523    
1524    
1525    void FloppyStone::actor_hit (const StoneContact &sc)
1526    {
1527        if (player::Inventory *inv = player::GetInventory(sc.actor))
1528        {
1529            if (is_on())
1530          {          {
1531              if (player::Inventory *inv = player::GetInventory(sc.actor))              if (!inv->is_full()) {
1532              {                  inv->add_item(MakeItem("it-floppy"));
1533                  if (is_on())                  set_on(false);
1534                  {                  PerformAction(this, is_on());
                     if (!inv->is_full()) {  
                         inv->add_item(MakeItem("it-floppy"));  
                         set_on(false);  
                         PerformAction(this, is_on());  
                     }  
                 }  
                 else if (player::wielded_item_is(sc.actor, "it-floppy"))  
                 {  
                     DisposeObject(inv->yield_first());  
                     set_on(true);  
                     PerformAction(this, is_on());  
                 }  
1535              }              }
1536          }          }
1537          const char *collision_sound() { return "st-metal"; }          else if (player::wielded_item_is(sc.actor, "it-floppy"))
1538      };          {
1539                DisposeObject(inv->yield_first());
1540                set_on(true);
1541                PerformAction(this, is_on());
1542            }
1543        }
1544  }  }
1545    
1546    
1547  //----------------------------------------  //----------------------------------------
1548  // FartStone  // FartStone
1549  //----------------------------------------  //----------------------------------------
1550    
1551  /** \page st-fart Fart Stone  /** \page st-fart Fart Stone
1552    
1553  The fart stone has the unpleasant habit of "blowing off" when triggered  The fart stone has the unpleasant habit of "blowing off" when
1554  (by actor hit or signal) and will close all oxyd stones.  triggered (by actor contact or signal) and will close all oxyd stones.
1555    
1556  \subsection fartm Messages  \subsection fartm Messages
1557    
# Line 1567  namespace Line 1574  namespace
1574                  return;                  return;
1575    
1576              switch (newstate) {              switch (newstate) {
1577                  case IDLE:              case IDLE:
1578                      state = IDLE;                  state = IDLE;
1579                      init_model();                  init_model();
1580                      break;                  break;
1581                  case FARTING:              case FARTING:
1582                  case BREAKING:              case BREAKING:
1583                      if (state == IDLE) {                  if (state == IDLE) {
1584                          Object *ox = world::GetObjectTemplate("st-oxyd");                      Object *ox = world::GetObjectTemplate("st-oxyd");
1585                          SendMessage(ox, "closeall");                      SendMessage(ox, "closeall");
1586                          play_sound("fart");                      play_sound("fart");
1587                          set_anim(newstate == FARTING ? "st-farting" : "st-fartbreak-anim");                      set_anim(newstate == FARTING ? "st-farting" : "st-fartbreak-anim");
1588                          state = newstate;                      state = newstate;
1589                      }                  }
1590                      break;                  break;
1591              }              }
1592          }          }
1593    
1594          void animcb() {          void animcb() {
1595              if (state == FARTING) {              if (state == FARTING)
1596                  change_state(IDLE);                  change_state(IDLE);
1597              }              else if (state == BREAKING)
             else if (state == BREAKING) {  
1598                  KillStone(get_pos());                  KillStone(get_pos());
             }  
1599          }          }
1600    
1601          void actor_hit(const StoneContact &sc) {          void actor_hit(const StoneContact &sc) {
# Line 1616  namespace Line 1621  namespace
1621  //----------------------------------------  //----------------------------------------
1622  // Thief Stone  // Thief Stone
1623  //  //
1624  // Takes one item from inventory after actor hit.  // Steals one item from the player's inventory when hit.
1625  //----------------------------------------  //----------------------------------------
1626  namespace  namespace
1627  {  {
# Line 1624  namespace Line 1629  namespace
1629          CLONEOBJ(ThiefStone);          CLONEOBJ(ThiefStone);
1630    
1631          enum State { IDLE, EMERGING, RETREATING } state;          enum State { IDLE, EMERGING, RETREATING } state;
1632          int m_affected_player;          Actor *m_affected_actor;
1633      public:      public:
1634          ThiefStone() : Stone("st-thief"), state(IDLE) {          ThiefStone() : Stone("st-thief"), state(IDLE) {
1635              m_affected_player = -1;              m_affected_actor = 0;
1636          }          }
1637      private:      private:
1638    
# Line 1635  namespace Line 1640  namespace
1640              if (state==IDLE) {              if (state==IDLE) {
1641                  set_anim("st-thief-emerge");                  set_anim("st-thief-emerge");
1642                  state = EMERGING;                  state = EMERGING;
1643                  m_affected_player = -1;                  m_affected_actor = sc.actor;
                 sc.actor->int_attrib("player", &m_affected_player);  
1644              }              }
1645          }          }
1646    
# Line 1657  namespace Line 1661  namespace
1661          }          }
1662    
1663          void steal_from_player() {          void steal_from_player() {
1664              if (m_affected_player != -1) {              if (m_affected_actor && !m_affected_actor->has_shield()) {
1665                  player::Inventory *inv = player::GetInventory(m_affected_player);                  int iplayer;
1666                    m_affected_actor->int_attrib("player", &iplayer);
1667                    player::Inventory *inv = player::GetInventory(iplayer);
1668                  if (inv && inv->size() > 0)                  if (inv && inv->size() > 0)
1669                  {                  {
1670                      int i = IntegerRand (0, inv->size()-1);                      int i = IntegerRand (0, inv->size()-1);
# Line 1713  namespace Line 1719  namespace
1719              }              }
1720          }          }
1721    
1722          // variables :          // Variables
1723          enum State { IDLE, PULSING, BROKEN };          enum State { IDLE, PULSING, BROKEN };
1724          State state;          State state;
1725      };      };

Legend:
Removed from v.1.53.2.3  
changed lines
  Added in v.1.53.2.4

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