david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
authornemo
Thu, 07 May 2009 02:04:07 +0000
changeset 2031 b6f3e56fb100
parent 2030 8eaf3d7c54b2
child 2032 29ee410071b9
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
QTfrontend/ammoSchemeModel.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
hedgewars/GSHandlers.inc
hedgewars/uConsole.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
--- a/QTfrontend/ammoSchemeModel.cpp	Wed May 06 22:35:31 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Thu May 07 02:04:07 2009 +0000
@@ -40,6 +40,8 @@
 		<< QVariant(100)           // init health    14
 		<< QVariant(15)            // sudden death   15
 		<< QVariant(5)             // case prob      16
+		<< QVariant(3)             //  mines time    17
+		<< QVariant(4)             //  landadds      18
 		;
 
 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
@@ -72,6 +74,8 @@
 		<< "health"           // 14
 		<< "suddendeath"      // 15
 		<< "caseprobability"  // 16
+		<< "minestime"        // 17
+		<< "landadds"         // 18
 		;
 
 	QList<QVariant> proMode;
@@ -93,6 +97,8 @@
 		<< QVariant(100)           // init health    14
 		<< QVariant(15)            // sudden death   15
 		<< QVariant(0)             // case prob      16
+		<< QVariant(3)             //  mines time    17
+		<< QVariant(4)             //  landadds      18
 		;
 
 	QList<QVariant> shoppa;
@@ -114,6 +120,8 @@
 		<< QVariant(100)           // init health    14
 		<< QVariant(50)            // sudden death   15
 		<< QVariant(1)             // case prob      16
+		<< QVariant(3)             //  mines time    17
+		<< QVariant(4)             //  landadds      18
 		;
 
 	QList<QVariant> basketball;
@@ -135,6 +143,8 @@
 		<< QVariant(100)           // init health    14
 		<< QVariant(15)            // sudden death   15
 		<< QVariant(0)             // case prob      16
+		<< QVariant(3)             //  mines time    17
+		<< QVariant(4)             //  landadds      18
 		;
 
 	schemes.append(defaultScheme);
--- a/QTfrontend/gamecfgwidget.cpp	Wed May 06 22:35:31 2009 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Thu May 07 02:04:07 2009 +0000
@@ -129,6 +129,8 @@
 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
 	sl.append(QString("e$damagepct %1").arg(schemeData(12).toInt()));
 	sl.append(QString("e$turntime %1").arg(schemeData(13).toInt() * 1000));
+	sl.append(QString("e$minestime %1").arg(schemeData(17).toInt() * 1000));
+	sl.append(QString("e$landadds %1").arg(schemeData(18).toInt()));
 	sl.append(QString("e$sd_turns %1").arg(schemeData(15).toInt()));
 	sl.append(QString("e$casefreq %1").arg(schemeData(16).toInt()));
 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
--- a/QTfrontend/pages.cpp	Wed May 06 22:35:31 2009 +0000
+++ b/QTfrontend/pages.cpp	Thu May 07 02:04:07 2009 +0000
@@ -1016,6 +1016,35 @@
 	SB_CaseProb->setValue(5);
 	glBSLayout->addWidget(SB_CaseProb,4,2,1,1);
 
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Mines Time"));
+	l->setWordWrap(true);
+	glBSLayout->addWidget(l,5,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon
+	glBSLayout->addWidget(l,5,1,1,1);
+	SB_MinesTime = new QSpinBox(gbBasicSettings);
+	SB_MinesTime->setRange(-1, 3);
+	SB_MinesTime->setValue(3);
+	SB_MinesTime->setSingleStep(1);
+	SB_MinesTime->setSpecialValueText(tr("Random"));
+	SB_MinesTime->setSuffix(" "+ tr("Seconds"));
+	glBSLayout->addWidget(SB_MinesTime,5,2,1,1);
+
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Mines"));
+	l->setWordWrap(true);
+	glBSLayout->addWidget(l,6,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon
+	glBSLayout->addWidget(l,6,1,1,1);
+	SB_Mines = new QSpinBox(gbBasicSettings);
+	SB_Mines->setRange(1, 25);
+	SB_Mines->setValue(1);
+	SB_Mines->setSingleStep(5);
+	glBSLayout->addWidget(SB_Mines,6,2,1,1);
 
 	l = new QLabel(gbBasicSettings);
 	l->setText(QLabel::tr("Scheme Name:"));
@@ -1062,6 +1091,8 @@
 	mapper->addMapping(SB_InitHealth, 14);
 	mapper->addMapping(SB_SuddenDeath, 15);
 	mapper->addMapping(SB_CaseProb, 16);
+	mapper->addMapping(SB_MinesTime, 17);
+	mapper->addMapping(SB_Mines, 18);
 
 	mapper->toFirst();
 }
--- a/QTfrontend/pages.h	Wed May 06 22:35:31 2009 +0000
+++ b/QTfrontend/pages.h	Thu May 07 02:04:07 2009 +0000
@@ -433,6 +433,8 @@
 	QSpinBox * SB_InitHealth;
 	QSpinBox * SB_SuddenDeath;
 	FreqSpinBox * SB_CaseProb;
+	QSpinBox * SB_MinesTime;
+	QSpinBox * SB_Mines;
 	QLineEdit * LE_name;
 	QComboBox * selectScheme;
 
--- a/hedgewars/GSHandlers.inc	Wed May 06 22:35:31 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Thu May 07 02:04:07 2009 +0000
@@ -471,7 +471,7 @@
       if Gear^.Ammo^.AmmoType = amDEagle then
           AmmoShove(Gear, 7, 20)
       else
-          AmmoShove(Gear, Gear^.Timer*2, 20);
+          AmmoShove(Gear, Gear^.Timer, 20);
   dec(i)
 until (i = 0) or (Gear^.Damage > Gear^.Health);
 if Gear^.Damage > 0 then
@@ -484,7 +484,12 @@
 if (Gear^.Health <= 0)
 	or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0)
 	or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
+    begin
+    if (GameFlags and gfLaserSight) = 0 then cLaserSighting:= false;
+    if (Gear^.Ammo^.NumPerTurn < CurrentHedgehog^.AttacksNum) and
+       ((GameFlags and gfArtillery) = 0) then cArtillery:= false;
 	Gear^.doStep:= @doStepShotIdle
+    end;
 end;
 
 procedure doStepDEagleShot(Gear: PGear);
@@ -494,27 +499,30 @@
 end;
 
 procedure doStepSniperRifleShot(Gear: PGear);
+var HHGear: PGear;
 begin
 cArtillery:= true;
+HHGear:=PHedgehog(Gear^.Hedgehog)^.Gear;
+HHGear^.State:= HHGear^.State or gstNotKickable;
 if not cLaserSighting then // game doesn't have default laser sight. turn it on and give them a chance to aim
     begin
     cLaserSighting:= true;
-	DeleteGear(Gear);
-	AfterAttack;
-    exit 
+    HHGear^.Message:= 0;
+    dec(HHGear^.Angle,32)
+    end;
+
+if (HHGear^.Message and gm_Attack) <> 0 then
+    begin
+	Gear^.State:= Gear^.State or gstAnimation;
+    Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
+    Gear^.dY:= -AngleCos(HHGear^.Angle) * _0_5;
+    PlaySound(sndGun, false, nil);
+    Gear^.doStep:= @doStepBulletWork;
     end
 else
-    inc(CurrentHedgehog^.AttacksNum); // burn up a shot, Tiy wants only a single shot
-
-if (PHedgehog(Gear^.Hedgehog)^.Gear^.Message and gm_Attack) <> 0 then
-    begin
-	Gear^.State:= Gear^.State or gstAnimation;
-    PlaySound(sndGun, false, nil);
-    Gear^.doStep:= @doStepBulletWork
-    end;
-
-if (Gear^.Ammo^.NumPerTurn < CurrentHedgehog^.AttacksNum) and
-   ((GameFlags and gfArtillery) = 0) then cArtillery:= false;
+    if (GameTicks mod 32) = 0 then
+        if (GameTicks mod 4096) < 2048 then inc(HHGear^.Angle)
+        else dec(HHGear^.Angle);
 
 end;
 
--- a/hedgewars/uConsole.pas	Wed May 06 22:35:31 2009 +0000
+++ b/hedgewars/uConsole.pas	Thu May 07 02:04:07 2009 +0000
@@ -245,6 +245,7 @@
 RegisterVariable('landadds', vtLongInt, @cLandAdditions , false);
 RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
 RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false);
+RegisterVariable('minestime', vtLongInt, @cMinesTime, false);
 RegisterVariable('fort'    , vtCommand, @chFort         , false);
 RegisterVariable('voicepack',vtCommand, @chVoicepack    , false);
 RegisterVariable('grave'   , vtCommand, @chGrave        , false);
--- a/hedgewars/uGears.pas	Wed May 06 22:35:31 2009 +0000
+++ b/hedgewars/uGears.pas	Thu May 07 02:04:07 2009 +0000
@@ -298,7 +298,10 @@
                 Result^.Radius:= 2;
                 Result^.Elasticity:= _0_55;
                 Result^.Friction:= _0_995;
-                Result^.Timer:= 3000;
+                if cMinesTime < 0 then
+                    Result^.Timer:= getrandom(3)*1000
+                else
+                    Result^.Timer:= cMinesTime*1;
                 end;
         gtCase: begin
                 Result^.Radius:= 16;
--- a/hedgewars/uMisc.pas	Wed May 06 22:35:31 2009 +0000
+++ b/hedgewars/uMisc.pas	Thu May 07 02:04:07 2009 +0000
@@ -48,6 +48,7 @@
 	cTemplateFilter : LongInt = 0;
 
 	cHedgehogTurnTime: Longword = 45000;
+	cMinesTime     : LongInt = 3000;
 	cMaxAIThinkTime  : Longword = 9000;
 
 	cCloudsNumber    : LongInt = 9;