/[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.86 by dheck, Tue Sep 9 19:23:04 2003 UTC revision 1.87 by dheck, Thu Sep 11 17:54:42 2003 UTC
# Line 1876  namespace Line 1876  namespace
1876          int get_load() const { return int_attrib("load"); }          int get_load() const { return int_attrib("load"); }
1877          void set_load( int load) { set_attrib("load", load); }          void set_load( int load) { set_attrib("load", load); }
1878    
         ItemAction activate(Actor *, GridPos p) {  
             if( get_load() > 0) {  
                 extinguish (p);  
                 extinguish (move(p, NORTH));  
                 extinguish (move(p, SOUTH));  
                 extinguish (move(p, EAST));  
                 extinguish (move(p, WEST));  
                 if( get_load() > 1) {  
                     // full extinguisher have a higher range  
                     extinguish (move(move(p, NORTH),NORTH));  
                     extinguish (move(move(p, NORTH),EAST));  
                     extinguish (move(move(p, SOUTH),SOUTH));  
                     extinguish (move(move(p, SOUTH),WEST));  
                     extinguish (move(move(p, EAST),EAST));  
                     extinguish (move(move(p, EAST),SOUTH));  
                     extinguish (move(move(p, WEST),WEST));  
                     extinguish (move(move(p, WEST),NORTH));  
                 }  
                 set_load( get_load() - 1);  
                 init_model();  
             }  
             return ITEM_DROP;  
         }  
   
1879          void extinguish( GridPos p) {          void extinguish( GridPos p) {
1880              if (Item *it = GetItem(p)) {              if (Item *it = GetItem(p)) {
1881                  SendMessage (it, "extinguish");                  SendMessage (it, "extinguish");
# Line 1908  namespace Line 1884  namespace
1884              }              }
1885          }          }
1886    
1887            //
1888            // Item interface
1889            //
1890    
1891            ItemAction activate(Actor *a, GridPos p);
1892    
1893          void init_model() {          void init_model() {
1894              switch (get_load()) {              set_model (get_inventory_model());
                 case 0:  set_model("it-extinguisher_empty"); break;  
                 case 1:  set_model("it-extinguisher_medium"); break;  
                 default: set_model("it-extinguisher_full"); break;  
             }  
1895          }          }
1896    
1897          string get_inventory_model() {          string get_inventory_model() {
1898              switch (get_load()) {              switch (get_load()) {
1899                  case 0:  return("it-extinguisher_empty"); break;              case 0:  return("it-extinguisher_empty"); break;
1900                  case 1:  return("it-extinguisher_medium"); break;              case 1:  return("it-extinguisher_medium"); break;
1901                  default: return("it-extinguisher_full"); break;              default: return("it-extinguisher_full"); break;
1902              }              }
1903          }          }
   
1904      };      };
1905  }  }
1906    
1907    ItemAction
1908    Extinguisher::activate(Actor *a, GridPos p)
1909    {
1910        if( get_load() > 0) {
1911            extinguish (p);
1912            extinguish (move(p, NORTH));
1913            extinguish (move(p, SOUTH));
1914            extinguish (move(p, EAST));
1915            extinguish (move(p, WEST));
1916            if( get_load() > 1) {
1917                // full extinguisher have a higher range
1918                extinguish (move(move(p, NORTH),NORTH));
1919                extinguish (move(move(p, NORTH),EAST));
1920                extinguish (move(move(p, SOUTH),SOUTH));
1921                extinguish (move(move(p, SOUTH),WEST));
1922                extinguish (move(move(p, EAST),EAST));
1923                extinguish (move(move(p, EAST),SOUTH));
1924                extinguish (move(move(p, WEST),WEST));
1925                extinguish (move(move(p, WEST),NORTH));
1926            }
1927            set_load( get_load() - 1);
1928    
1929            // ### HACK ###
1930            // update the player's inventory
1931            if (player::Inventory *inv = player::GetInventory(a)) {
1932                inv->redraw();
1933            }
1934                    
1935            //init_model();
1936        }
1937        return ITEM_DROP;
1938    }
1939    
1940    
1941    
1942  //----------------------------------------  //----------------------------------------
1943  // Flags  // Flags

Legend:
Removed from v.1.86  
changed lines
  Added in v.1.87

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