CanSelfDestruct.patch (1,775 bytes)
2007-11-19 01:38
Index: CommandAI/CommandAI.cpp
===================================================================
--- CommandAI/CommandAI.cpp (revision 4832)
+++ CommandAI/CommandAI.cpp (working copy)
@@ -554,18 +554,21 @@
switch (c.id) {
case CMD_SELFD: {
- if (!(c.options & SHIFT_KEY) || commandQue.empty()) {
- if (owner->selfDCountdown != 0) {
- owner->selfDCountdown = 0;
- } else {
- owner->selfDCountdown = owner->unitDef->selfDCountdown*2+1;
+ if (owner->unitDef->canSelfDestruct)
+ {
+ if (!(c.options & SHIFT_KEY) || commandQue.empty()) {
+ if (owner->selfDCountdown != 0) {
+ owner->selfDCountdown = 0;
+ } else {
+ owner->selfDCountdown = owner->unitDef->selfDCountdown*2+1;
+ }
}
- }
- else {
- if (commandQue.back().id == CMD_SELFD) {
- commandQue.pop_back();
- } else {
- commandQue.push_back(c);
+ else {
+ if (commandQue.back().id == CMD_SELFD) {
+ commandQue.pop_back();
+ } else {
+ commandQue.push_back(c);
+ }
}
}
return;
Index: UnitDef.h
===================================================================
--- UnitDef.h (revision 4832)
+++ UnitDef.h (working copy)
@@ -227,6 +227,7 @@
std::string iconType;
int selfDCountdown;
+ bool canSelfDestruct;
bool canSubmerge;
bool canfly;
Index: UnitDefHandler.cpp
===================================================================
--- UnitDefHandler.cpp (revision 4832)
+++ UnitDefHandler.cpp (working copy)
@@ -290,6 +290,7 @@
}
ud.selfDCountdown = udTable.GetInt("selfDestructCountdown", 5);
+ ud.canSelfDestruct = udTable.GetBool("canSelfDestruct", 1);
ud.speed = udTable.GetFloat("maxVelocity", 0.0f) * 30.0f;
ud.maxAcc = udTable.GetFloat("acceleration", 0.5f);