]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/items.cpp
Added .gitignore to ignore certain files + fixed access rights on Makefile* as
[quix0rs-blobwars.git] / src / items.cpp
index 0a54e67c7990eb0e4c277cc683f7662848af0770..5b78d4a1a3b568708ac21e2ac4608ca596eff332 100644 (file)
@@ -1,5 +1,6 @@
 /*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -234,7 +235,7 @@ void pickUpItem(Entity *item)
                case ITEM_SPREAD:
                        player.currentWeapon = &weapon[item->id];
                        game.currentWeapon = item->id;
-                       audio.playSound(SND_GETWEAPON, CH_ITEM);
+                       audio.playSound(SND_GETWEAPON, CH_ITEM, item->x);
                        break;
                case ITEM_POINTS:
                case ITEM_POINTS2:
@@ -243,19 +244,19 @@ void pickUpItem(Entity *item)
                case ITEM_POINTS5:
                case ITEM_POINTS6:
                case ITEM_POINTS7:
-                       game.score += item->value;
-                       audio.playSound(SND_ITEM, CH_ITEM);
+                       addPlayerScore(item->value);
+                       audio.playSound(SND_ITEM, CH_ITEM, item->x);
                        break;
                case ITEM_CHERRY:
                case ITEM_DOUBLECHERRY:
                case ITEM_TRIPLECHERRY:
                        Math::limitInt(&(player.health += item->value), 0, MAX_HEALTH);
-                       audio.playSound(SND_GULP + (Math::prand() % 2), CH_ITEM);
+                       audio.playSound(SND_GULP + (Math::prand() % 2), CH_ITEM, item->x);
                        break;
                case ITEM_MISC:
                        item->owner = &player;
                case ITEM_MISC_NOSHOW:
-                       audio.playSound(SND_ITEM, CH_ITEM);
+                       audio.playSound(SND_ITEM, CH_ITEM, item->x);
                        break;
        }
 
@@ -278,10 +279,10 @@ void pickUpItem(Entity *item)
                        case 'o':
                        case 'U':
                        case 'u':
-                               sprintf(string, _("Picked up an %s"), item->name);
+                               snprintf(string, sizeof string, _("Picked up an %s"), item->name);
                                break;
                        default:
-                               sprintf(string, _("Picked up a %s"), item->name);
+                               snprintf(string, sizeof string, _("Picked up a %s"), item->name);
                                break;
                }
 
@@ -289,6 +290,11 @@ void pickUpItem(Entity *item)
                        engine.setInfoMessage(string, 0, INFO_NORMAL);
 
                checkObjectives(item->name, true);
+               
+               if (strcmp(item->name, "LRTS") == 0)
+               {
+                       presentPlayerMedal("LRTS_PART");
+               }
        }
 }
 
@@ -356,13 +362,10 @@ void showCarriedItems()
 void doItems()
 {
        Entity *item = (Entity*)map.itemList.getHead();
-       Entity *previous = item;
-
-       int x, y;
 
        while (item->next != NULL)
        {
-               previous = item;
+               Entity *previous = item;
                
                item = (Entity*)item->next;
                
@@ -371,8 +374,8 @@ void doItems()
                        continue;
                }
 
-               x = (int)(item->x - engine.playerPosX);
-               y = (int)(item->y - engine.playerPosY);
+               int x = (int)(item->x - engine.playerPosX);
+               int y = (int)(item->y - engine.playerPosY);
 
                item->think();