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

Diff of /enigma/src/player.cc

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

revision 1.20 by reallysoft, Wed May 28 12:30:08 2003 UTC revision 1.21 by reallysoft, Fri May 30 08:01:31 2003 UTC
# Line 222  Inventory::activate_first() Line 222  Inventory::activate_first()
222                  it->on_drop(ac);                  it->on_drop(ac);
223              }              }
224              break;              break;
225            case world::ITEM_DROP_AS_STONE:
226                if (world::GetStone(p) == 0 && ac->can_drop_items()) {
227                    items.erase(items.begin());
228                    redraw();
229                    world::SetItemAsStone(p, it);
230                }
231                break;
232          case world::ITEM_KILL:          case world::ITEM_KILL:
233              delete it;              delete it;
234              items.erase(items.begin());              items.erase(items.begin());
# Line 348  void Line 355  void
355  player::Suicide()  player::Suicide()
356  {  {
357      for (unsigned i=0; i<players.size(); ++i) {      for (unsigned i=0; i<players.size(); ++i) {
358          vector<Actor *> &al = players[icurrent_player].actors;          vector<Actor *> &al = players[i].actors;
359          for (unsigned j=0; j<al.size(); ++j) {          for (unsigned j=0; j<al.size(); ++j) {
360                if (j == 0)
361                    leveldat.remove_extralife(al[0]);
362              SendMessage(al[j], "shatter");              SendMessage(al[j], "shatter");
363          }          }
364      }      }
# Line 522  player::InhibitPickup(bool flag) Line 531  player::InhibitPickup(bool flag)
531      current_player_inhibit_pickup = flag;      current_player_inhibit_pickup = flag;
532  }  }
533    
534  void  namespace
 player::PickupItem(Actor *a, GridPos p)  
535  {  {
536      int iplayer=-1;      // returns pointer to inventory if actor may pickup sth
537      a->int_attrib("player", &iplayer);      //         0 otherwise
     if (iplayer < 0 || (unsigned)iplayer >= players.size()) {  
 //        cerr << "PickupItem: illegal 'player' entry\n";  
         return;  
     }  
538    
539      if ((unsigned)iplayer==icurrent_player && current_player_inhibit_pickup)      Inventory *MayPickup(Actor *a) {
540      {          int iplayer=-1;
541          // do not pick up items if current player doesn't want to          a->int_attrib("player", &iplayer);
542          return;          if (iplayer < 0 || (unsigned)iplayer >= players.size()) {
543      }              //        cerr << "PickupItem: illegal 'player' entry\n";
544                return 0;
545            }
546    
547      if (a->is_flying())          if ((unsigned)iplayer==icurrent_player && current_player_inhibit_pickup) {
548      {              // do not pick up items if current player doesn't want to
549          // do not pick up items while flying              return 0;
550          return;          }
551    
552            if (a->is_flying()) { // do not pick up items while flying
553                return 0;
554            }
555    
556            Inventory *inv = &players[iplayer].inventory;
557            if (inv->is_full()) { // do not pickup if inventory is full
558                return 0;
559            }
560            return inv;
561      }      }
562    }
563    
564      Inventory &inv = players[iplayer].inventory;  void
565      if (!inv.is_full())  player::PickupItem(Actor *a, GridPos p)
566      {  {
567        Inventory *inv = MayPickup(a);
568        if (inv) {
569          Item *item = world::YieldItem(p);          Item *item = world::YieldItem(p);
570          inv.add_item(item);          if (item) {
571          sound::PlaySound("pickup");              inv->add_item(item);
572                sound::PlaySound("pickup");
573            }
574      }      }
575  }  }
576    
577  void  void
578    player::PickupStoneAsItem(Actor *a, enigma::GridPos p) {
579        Inventory *inv = MayPickup(a);
580        if (inv) {
581            world::Stone *stone = world::YieldStone(p);
582            if (stone) {
583                Item *item = world::ConvertToItem(stone); // disposes stone
584                if (item) {
585                    inv->add_item(item);
586                    sound::PlaySound("pickup");
587                }
588            }
589        }
590    }
591    
592    
593    void
594  player::ActivateItem()  player::ActivateItem()
595  {  {
596      Inventory &inv = players[icurrent_player].inventory;      Inventory &inv = players[icurrent_player].inventory;

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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