Dude mine probability spinner
authornemo
Sun, 28 Feb 2010 16:03:33 +0000
changeset 2882 b9aceb3fe3d6
parent 2881 70d7976fa829
child 2883 140dc1ca9aeb
Dude mine probability spinner
QTfrontend/ammoSchemeModel.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uConsole.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
--- a/QTfrontend/ammoSchemeModel.cpp	Sun Feb 28 15:41:42 2010 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Sun Feb 28 16:03:33 2010 +0000
@@ -46,6 +46,7 @@
 		<< QVariant(5)             // case prob      20
 		<< QVariant(3)             //  mines time    21
 		<< QVariant(4)             //  landadds      22
+		<< QVariant(0)             // mine dud pct   23
 		;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -85,6 +86,7 @@
 		<< "caseprobability"  // 20
 		<< "minestime"        // 21
 		<< "landadds"         // 22
+		<< "minedudpct"       // 23
 		;
 
 	QList<QVariant> proMode;
@@ -112,6 +114,7 @@
 		<< QVariant(0)             // case prob      20
 		<< QVariant(3)             //  mines time    21
 		<< QVariant(4)             //  landadds      22
+		<< QVariant(0)             // mine dud pct   23
 		;
 
 	QList<QVariant> shoppa;
@@ -132,13 +135,14 @@
 		<< QVariant(false)         // king           13
 		<< QVariant(false)         // place hog      14
 		<< QVariant(true)          // shared ammo    15
-		<< QVariant(100)           // damage modfier 15
-		<< QVariant(30)            // turn time      16
-		<< QVariant(100)           // init health    17
-		<< QVariant(50)            // sudden death   18
-		<< QVariant(1)             // case prob      19
-		<< QVariant(3)             //  mines time    20
-		<< QVariant(4)             //  landadds      21
+		<< QVariant(100)           // damage modfier 16
+		<< QVariant(30)            // turn time      17
+		<< QVariant(100)           // init health    18
+		<< QVariant(50)            // sudden death   19
+		<< QVariant(1)             // case prob      20
+		<< QVariant(3)             //  mines time    21
+		<< QVariant(4)             //  landadds      22
+		<< QVariant(0)             // mine dud pct   23
 		;
 
 	QList<QVariant> basketball;
@@ -166,6 +170,7 @@
 		<< QVariant(0)             // case prob      20
 		<< QVariant(3)             //  mines time    21
 		<< QVariant(4)             //  landadds      22
+		<< QVariant(0)             // mine dud pct   23
 		;
 
 	QList<QVariant> minefield;
@@ -193,6 +198,7 @@
 		<< QVariant(0)             // case prob      20
 		<< QVariant(0)             //  mines time    21
 		<< QVariant(50)            //  landadds      22
+		<< QVariant(0)             // mine dud pct   23
 		;
 
 	schemes.append(defaultScheme);
--- a/QTfrontend/gamecfgwidget.cpp	Sun Feb 28 15:41:42 2010 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sun Feb 28 16:03:33 2010 +0000
@@ -148,6 +148,7 @@
 	sl.append(QString("e$landadds %1").arg(schemeData(22).toInt()));
 	sl.append(QString("e$sd_turns %1").arg(schemeData(19).toInt()));
 	sl.append(QString("e$casefreq %1").arg(schemeData(20).toInt()));
+	sl.append(QString("e$minedudpct %1").arg(schemeData(23).toInt()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
 
 	QString currentMap = pMapContainer->getCurrentMap();
--- a/QTfrontend/pages.cpp	Sun Feb 28 15:41:42 2010 +0000
+++ b/QTfrontend/pages.cpp	Sun Feb 28 16:03:33 2010 +0000
@@ -1215,6 +1215,20 @@
 	glBSLayout->addWidget(SB_Mines,6,2,1,1);
 
 	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("% Dud Mines"));
+	l->setWordWrap(true);
+	glBSLayout->addWidget(l,7,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconMine.png"));
+	glBSLayout->addWidget(l,7,1,1,1);
+	SB_MineDuds = new QSpinBox(gbBasicSettings);
+	SB_MineDuds->setRange(0, 100);
+	SB_MineDuds->setValue(0);
+	SB_MineDuds->setSingleStep(10);
+	glBSLayout->addWidget(SB_MineDuds,7,2,1,1);
+
+	l = new QLabel(gbBasicSettings);
 	l->setText(QLabel::tr("Scheme Name:"));
 
 	LE_name = new QLineEdit(this);
@@ -1265,6 +1279,7 @@
 	mapper->addMapping(SB_CaseProb, 20);
 	mapper->addMapping(SB_MinesTime, 21);
 	mapper->addMapping(SB_Mines, 22);
+	mapper->addMapping(SB_MineDuds, 23);
 
 	mapper->toFirst();
 }
--- a/QTfrontend/pages.h	Sun Feb 28 15:41:42 2010 +0000
+++ b/QTfrontend/pages.h	Sun Feb 28 16:03:33 2010 +0000
@@ -450,6 +450,7 @@
 	FreqSpinBox * SB_CaseProb;
 	QSpinBox * SB_MinesTime;
 	QSpinBox * SB_Mines;
+	QSpinBox * SB_MineDuds;
 	QLineEdit * LE_name;
 	QComboBox * selectScheme;
 
--- a/hedgewars/GSHandlers.inc	Sun Feb 28 15:41:42 2010 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Feb 28 16:03:33 2010 +0000
@@ -1190,7 +1190,7 @@
 	if ((GameTicks and $3F) = 25) then
 		doStepFallingGear(Gear);
 
-if ((Gear^.State and gsttmpFlag) <> 0) then
+if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
 	if ((Gear^.State and gstAttacking) = 0) then
 		begin
 		if ((GameTicks and $1F) = 0) then
@@ -1201,8 +1201,14 @@
 		if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick);
 		if Gear^.Timer = 0 then
 			begin
-			doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
-			DeleteGear(Gear);
+            if ((Gear^.State and gstWait) <> 0) or 
+               (cMineDudPercent = 0) or
+		       (getRandom(100) > cMineDudPercent) then
+               begin
+			   doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
+			   DeleteGear(Gear)
+               end
+            else Gear^.Health:= 0;
 			exit
 			end;
 		dec(Gear^.Timer);
--- a/hedgewars/HHHandlers.inc	Sun Feb 28 15:41:42 2010 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Feb 28 16:03:33 2010 +0000
@@ -152,7 +152,7 @@
                    amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
                          amSkip: ParseCommand('/skip', true);
                          amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
-                         amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000);
+                         amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
                        amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
                   amSniperRifle: begin
                                  PlaySound(sndSniperReload);
--- a/hedgewars/uConsole.pas	Sun Feb 28 15:41:42 2010 +0000
+++ b/hedgewars/uConsole.pas	Sun Feb 28 16:03:33 2010 +0000
@@ -240,6 +240,7 @@
 	RegisterVariable('casefreq', vtLongInt, @cCaseFactor    , false);
 	RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns  , false);
 	RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false);
+	RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false);
 	RegisterVariable('landadds', vtLongInt, @cLandAdditions , false);
 	RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
 	RegisterVariable('trflags' , vtLongInt, @TrainingFlags  , false);
--- a/hedgewars/uGears.pas	Sun Feb 28 15:41:42 2010 +0000
+++ b/hedgewars/uGears.pas	Sun Feb 28 16:03:33 2010 +0000
@@ -311,6 +311,7 @@
                 gear^.Y:= gear^.Y;
                 end;
         gtMine: begin
+                gear^.Health:= 10;
                 gear^.State:= gear^.State or gstMoving;
                 gear^.Radius:= 2;
                 gear^.Elasticity:= _0_55;
--- a/hedgewars/uMisc.pas	Sun Feb 28 15:41:42 2010 +0000
+++ b/hedgewars/uMisc.pas	Sun Feb 28 16:03:33 2010 +0000
@@ -48,6 +48,7 @@
 	TurnTimeLeft	: Longword;
 	cSuddenDTurns	: LongInt;
 	cDamagePercent	: LongInt;
+	cMineDudPercent	: LongInt;
 	cTemplateFilter	: LongInt;
 
 	cHedgehogTurnTime: Longword;
@@ -671,6 +672,7 @@
 	TurnTimeLeft		:= 0;
 	cSuddenDTurns		:= 15;
 	cDamagePercent		:= 100;
+	cMineDudPercent		:= 0;
 	cTemplateFilter		:= 0;
 
 	cHedgehogTurnTime	:= 45000;