[+] Added CPreference::MineNotifications, to show notifications when player-controlled mine is running low (as in Warcraft 3)
This commit is contained in:
parent
a25d28c04d
commit
57244d7e53
7 changed files with 23 additions and 2 deletions
|
@ -47,6 +47,7 @@
|
|||
#include "script.h"
|
||||
#include "sound.h"
|
||||
#include "tileset.h"
|
||||
#include "translate.h"
|
||||
#include "ui.h"
|
||||
#include "unit.h"
|
||||
#include "unit_find.h"
|
||||
|
@ -764,6 +765,9 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
|||
// Don't destroy the resource twice.
|
||||
// This only happens when it's empty.
|
||||
if (!dead) {
|
||||
if (Preference.MineNotifications && unit.Player->Index == ThisPlayer->Index) {
|
||||
unit.Player->Notify(NotifyYellow, source->tilePos, _("%s has collapsed!"), source->Type->Name.c_str());
|
||||
}
|
||||
LetUnitDie(*source);
|
||||
// FIXME: make the workers inside look for a new resource.
|
||||
}
|
||||
|
@ -832,6 +836,12 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
|||
Assert(source->Resource.Active >= 0);
|
||||
//Store resource position.
|
||||
this->Resource.Mine = source;
|
||||
|
||||
if (Preference.MineNotifications && unit.Player->Index == ThisPlayer->Index
|
||||
&& source->IsAlive() && !source->MineLow && source->ResourcesHeld * 100 / source->Variable[GIVERESOURCE_INDEX].Max <= 10) {
|
||||
unit.Player->Notify(NotifyYellow, source->tilePos, _("%s is running low!"), source->Type->Name.c_str());
|
||||
source->MineLow = 1;
|
||||
}
|
||||
|
||||
if (source->Type->MaxOnBoard) {
|
||||
int count = 0;
|
||||
|
|
|
@ -363,6 +363,7 @@ public:
|
|||
|
||||
unsigned Summoned : 1; /// Unit is summoned using spells.
|
||||
unsigned Waiting : 1; /// Unit is waiting and playing its still animation
|
||||
unsigned MineLow : 1; /// This mine got a notification about its resources being low
|
||||
|
||||
unsigned TeamSelected; /// unit is selected by a team member.
|
||||
CPlayer *RescuedFrom; /// The original owner of a rescued unit.
|
||||
|
@ -428,7 +429,7 @@ public:
|
|||
CPreference() : ShowSightRange(false), ShowReactionRange(false),
|
||||
ShowAttackRange(false), ShowMessages(true), BigScreen(false),
|
||||
PauseOnLeave(true), AiExplores(true), GrayscaleIcons(false),
|
||||
IconsShift(false), StereoSound(true),
|
||||
IconsShift(false), StereoSound(true), MineNotifications(false),
|
||||
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0) {};
|
||||
|
||||
bool ShowSightRange; /// Show sight range.
|
||||
|
@ -441,6 +442,7 @@ public:
|
|||
bool GrayscaleIcons; /// Use grayscaled icons for unavailable units, upgrades, etc
|
||||
bool IconsShift; /// Shift icons slightly when you press on them
|
||||
bool StereoSound; /// Enables/diables stereo sound effects
|
||||
bool MineNotifications; /// Show mine is running low/depleted messages (as in Warcraft 3)
|
||||
|
||||
int ShowOrders; /// How many second show orders of unit on map.
|
||||
int ShowNameDelay; /// How many cycles need to wait until unit's name popup will appear.
|
||||
|
|
|
@ -39,6 +39,7 @@ extern bool GameObserve;
|
|||
extern bool GameEstablishing;
|
||||
|
||||
extern unsigned long GameCycle;
|
||||
extern unsigned long FastForwardCycle;
|
||||
|
||||
|
||||
$#include "settings.h"
|
||||
|
|
|
@ -28,6 +28,7 @@ class CPreference
|
|||
bool GrayscaleIcons;
|
||||
bool IconsShift;
|
||||
bool StereoSound;
|
||||
bool MineNotifications;
|
||||
|
||||
unsigned int ShowOrders;
|
||||
unsigned int ShowNameDelay;
|
||||
|
|
|
@ -381,7 +381,10 @@ static int CclUnit(lua_State *l)
|
|||
unit->Summoned = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "waiting")) {
|
||||
unit->Summoned = 1;
|
||||
unit->Waiting = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "mine-low")) {
|
||||
unit->MineLow = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "rescued-from")) {
|
||||
unit->RescuedFrom = &Players[LuaToNumber(l, 2, j + 1)];
|
||||
|
|
|
@ -457,6 +457,7 @@ void CUnit::Init()
|
|||
CacheLock = 0;
|
||||
Summoned = 0;
|
||||
Waiting = 0;
|
||||
MineLow = 0;
|
||||
memset(&Anim, 0, sizeof(Anim));
|
||||
memset(&WaitBackup, 0, sizeof(WaitBackup));
|
||||
CurrentResource = 0;
|
||||
|
|
|
@ -183,6 +183,9 @@ void SaveUnit(const CUnit &unit, CFile &file)
|
|||
if (unit.Waiting) {
|
||||
file.printf(" \"waiting\",");
|
||||
}
|
||||
if (unit.MineLow) {
|
||||
file.printf(" \"mine-low\",");
|
||||
}
|
||||
if (unit.RescuedFrom) {
|
||||
file.printf(" \"rescued-from\", %d,", unit.RescuedFrom->Index);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue