# HG changeset patch # User nemo # Date 1300571367 14400 # Node ID 1e332947147c83a88e01f03b145880914d981573 # Parent 8c16c0534b3c2ded6122525da6cb88637ff20072 Landgun, first pass. At sdw's request. diff -r 8c16c0534b3c -r 1e332947147c QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Sat Mar 19 16:00:10 2011 -0400 +++ b/QTfrontend/hwconsts.cpp.in Sat Mar 19 17:49:27 2011 -0400 @@ -38,10 +38,10 @@ int cMinServerVersion = 0; QString * cDefaultAmmoStore = new QString( - "93919294221991210322351110012010000002111101010111299" - "04050405416006555465544647765766666661555101011154111" - "00000000000002055000000400070040000000002000000006000" - "13111103121111111231141111111111111112111111011111211" + "939192942219912103223511100120100000021111010101112991" + "040504054160065554655446477657666666615551010111541111" + "000000000000020550000004000700400000000020000000060000" + "131111031211111112311411111111111111121111110111112111" ); int cAmmoNumber = cDefaultAmmoStore->size() / 4; @@ -50,40 +50,40 @@ << qMakePair(QString("Default"), *cDefaultAmmoStore) << qMakePair(QString("Crazy"), QString( // TODO: Remove Piano's unlimited uses! - "99999999999999999929999999999999992999999999099999922" - "11111101111111111111111111111111111111111111011111111" - "00000000000000000000000000000000000000000000000000000" - "13111103121111111231141111111111111112111101011111111" + "999999999999999999299999999999999929999999990999999229" + "111111011111111111111111111111111111111111110111111111" + "000000000000000000000000000000000000000000000000000000" + "131111031211111112311411111111111111121111010111111111" )) << qMakePair(QString("Pro Mode"), QString( - "90900090000000000000090000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000" - "00000000000002055000000400070040000000002000000000000" - "11111111111111111111111111111111111111111001011111111" + "909000900000000000000900000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000" + "000000000000020550000004000700400000000020000000000000" + "111111111111111111111111111111111111111110010111111111" )) << qMakePair(QString("Shoppa"), QString( - "00000099000000000000000000000000000000000000000000000" - "44444100442444022101121212224220000000020004000100111" - "00000000000000000000000000000000000000000000000000000" - "11111111111111111111111111111111111111111011011111111" + "000000990000000000000000000000000000000000000000000000" + "444441004424440221011212122242200000000200040001001111" + "000000000000000000000000000000000000000000000000000000" + "111111111111111111111111111111111111111110110111111111" )) << qMakePair(QString("Clean Slate"),QString( - "10100090000100000110000000000000000000000000000010000" - "04050405416006555465544647765766666661555101011154111" - "00000000000000000000000000000000000000000000000000000" - "13111103121111111231141111111111111112111111011111111" + "101000900001000001100000000000000000000000000000100000" + "040504054160065554655446477657666666615551010111541111" + "000000000000000000000000000000000000000000000000000000" + "131111031211111112311411111111111111121111110111111111" )) << qMakePair(QString("Minefield"), QString( - "00000099000900000003000000000000000000000000000000000" - "00000000000000000000000000000000000000000000000000000" - "00000000000002055000000400070040000000002000000006000" - "11111111111111111111111111111111111111111111011111111" + "000000990009000000030000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000" + "000000000000020550000004000700400000000020000000060000" + "111111111111111111111111111111111111111111110111111111" )) << qMakePair(QString("Thinking with Portals"), QString( - "90000090020000000021000000000000001100000900000000000" - "04050405416006555465544647765766666661555101011154111" - "00000000000002055000000400070040000000002000000006000" - "13111103121111111231141111111111111112111111011111111" + "900000900200000000210000000000000011000009000000000000" + "040504054160065554655446477657666666615551010111541111" + "000000000000020550000004000700400000000020000000060000" + "131111031211111112311411111111111111121111110111111111" )); QColor *colors[] = { diff -r 8c16c0534b3c -r 1e332947147c hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/GSHandlers.inc Sat Mar 19 17:49:27 2011 -0400 @@ -568,12 +568,22 @@ procedure doStepSnowflake(Gear: PGear); var xx, yy, px, py, i: LongInt; - move, allpx: Boolean; + move, draw, allpx: Boolean; s: PSDL_Surface; p: PLongwordArray; oAlpha, nAlpha: byte; begin -if GameTicks and $7 = 0 then +move:= false; +draw:= false; +if (Gear^.State and gstTmpFlag) <> 0 then + begin + doStepFallingGear(Gear); + CheckCollision(Gear); + if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then draw:= true; + xx:= hwRound(Gear^.X); + yy:= hwRound(Gear^.Y); + end +else if GameTicks and $7 = 0 then begin with Gear^ do begin @@ -595,8 +605,6 @@ inc(Timer); if Timer = vobFramesCount then Timer:= 0 end; - - move:= false; // move back to cloud layer if yy > cWaterLine then move:= true else if ((yy and LAND_HEIGHT_MASK) <> 0) or ((xx and LAND_WIDTH_MASK) <> 0) then move:=true @@ -632,60 +640,75 @@ // if there's an hog/object below do nothing else if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((Land[yy+1, xx] and $FF) <> 0)) then move:=true + else draw:= true + end + end + end; +if draw then + with Gear^ do + begin + // we've collided with land. draw some stuff and get back into the clouds + move:= true; + if (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope) then + begin +////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// + if (State and gstTmpFlag) = 0 then + begin + dec(yy,3); + dec(xx,1) + end; + s:= SpritesData[sprSnow].Surface; + p:= s^.pixels; + allpx:= true; + for py:= 0 to Pred(s^.h) do + begin + for px:= 0 to Pred(s^.w) do + if ((((yy + py) and LAND_HEIGHT_MASK) = 0) and (((xx + px) and LAND_WIDTH_MASK) = 0)) and ((Land[yy + py, xx + px] and $FF) = 0) then + begin + Land[yy + py, xx + px]:= Land[yy + py, xx + px] or lfObject; + if (cReducedQuality and rqBlurryLand) = 0 then + begin + if (State and gstTmpFlag) <> 0 then + LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)) + else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]); + end + else + begin + if (State and gstTmpFlag) <> 0 then + LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)) + else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]); + end; + end + else allpx:= false; + p:= @(p^[s^.pitch shr 2]) + end; + + + Land[py, px+1]:= lfBasic; + + if allpx then UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w)) else begin - // we've collided with land. draw some stuff and get back into the clouds - move:= true; - if (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope) then - begin - ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// - dec(yy,3); - dec(xx,1); - s:= SpritesData[sprSnow].Surface; - p:= s^.pixels; - allpx:= true; - for py:= 0 to Pred(s^.h) do - begin - for px:= 0 to Pred(s^.w) do - if ((((yy + py) and LAND_HEIGHT_MASK) = 0) and (((xx + px) and LAND_WIDTH_MASK) = 0)) and ((Land[yy + py, xx + px] and $FF) = 0) then - begin - Land[yy + py, xx + px]:= Land[yy + py, xx + px] or lfObject; - if (cReducedQuality and rqBlurryLand) = 0 then - begin - LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]); - end - else - begin - LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]); - end; - end - else allpx:= false; - p:= @(p^[s^.pitch shr 2]) - end; - - - Land[py, px+1]:= lfBasic; - - if allpx then UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w)) - else - begin - UpdateLandTexture( - max(0, min(LAND_WIDTH, xx)), - min(LAND_WIDTH - xx, Pred(s^.w)), - max(0, min(LAND_WIDTH, yy)), - min(LAND_HEIGHT - yy, Pred(s^.h)) - ); - end; - ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// - end + UpdateLandTexture( + max(0, min(LAND_WIDTH, xx)), + min(LAND_WIDTH - xx, Pred(s^.w)), + max(0, min(LAND_WIDTH, yy)), + min(LAND_HEIGHT - yy, Pred(s^.h)) + ); end; - end; - if move then - begin - X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512); - Y:= int2hwFloat(750+(GetRandom(50)-25)) +////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// end - end + end; + +if move then + begin + if ((Gear^.State and gstTmpFlag) <> 0) then + begin + DeleteGear(Gear); + exit + end; + Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512); + Gear^.Y:= int2hwFloat(750+(GetRandom(50)-25)) end end; @@ -2113,23 +2136,23 @@ else begin if sticky then - begin + begin Gear^.Radius := 7; AmmoShove(Gear, 2, 30); Gear^.Radius := 1 - end; + end; if Gear^.Timer > 0 then - begin + begin dec(Gear^.Timer); inc(Gear^.Damage) - end + end else begin gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y); // Standard fire if not sticky then - begin + begin if ((GameTicks and $1) = 0) then begin Gear^.Radius := 7; @@ -2143,17 +2166,17 @@ AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); if Gear^.Health > 0 then dec(Gear^.Health); Gear^.Timer := 450 - Gear^.Tag * 8 - end + end else - begin + begin // Modified fire if ((GameTicks and $7FF) = 0) and ((GameFlags and gfSolidLand) = 0) then - begin + begin DrawExplosion(gX, gY, 4); for i:= 0 to Random(3) do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); - end; + end; // This one is interesting. I think I understand the purpose, but I wonder if a bit more fuzzy of kicking could be done with getrandom. Gear^.Timer := 100 - Gear^.Tag * 3; @@ -4341,6 +4364,80 @@ Gear^.doStep := @doStepFlamethrowerWork end; +procedure doStepLandGunWork(Gear: PGear); +var + HHGear: PGear; + rx, ry, speed: hwFloat; + i, gX, gY: LongInt; + Flake: PGear; +begin + AllInactive := false; + HHGear := Gear^.Hedgehog^.Gear; + HedgehogChAngle(HHGear); + gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle); + gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle); + + if (GameTicks and $FF) = 0 then + begin + if (HHGear^.Message and gmRight) <> 0 then + begin + if HHGear^.dX.isNegative and (Gear^.Tag < 20) then inc(Gear^.Tag) + else if Gear^.Tag > 5 then dec(Gear^.Tag); + end + else if (HHGear^.Message and gmLeft) <> 0 then + begin + if HHGear^.dX.isNegative and (Gear^.Tag > 5) then dec(Gear^.Tag) + else if Gear^.Tag < 20 then inc(Gear^.Tag); + end + end; + + dec(Gear^.Timer); + if Gear^.Timer = 0 then + begin + dec(Gear^.Health); + if (Gear^.Health mod 5) = 0 then + begin + rx := rndSign(getRandom * _0_1); + ry := rndSign(getRandom * _0_1); + speed := (_3 / Gear^.Tag); + + Flake := AddGear(gx, gy, gtFlake, 0, _0, _0, 0); + Flake^.dX:= SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx; + Flake^.dY:= AngleCos(HHGear^.Angle) * ( - speed) + ry; + Flake^.State := Flake^.State or gsttmpFlag; + + end; + Gear^.Timer:= Gear^.Tag + end; + + if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then + begin + DeleteGear(Gear); + AfterAttack + end + else + begin + i:= Gear^.Health div 10; + if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then + begin + Gear^.Damage:= i; + if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + + '%', cWhiteColor, fntSmall) + end + end +end; + +procedure doStepLandGun(Gear: PGear); +var + HHGear: PGear; +begin + HHGear := Gear^.Hedgehog^.Gear; + HHGear^.Message := HHGear^.Message and not (gmUp or gmDown or gmLeft or gmRight); + HHGear^.State := HHGear^.State or gstNotKickable; + Gear^.doStep := @doStepLandGunWork +end; + procedure doStepPoisonCloud(Gear: PGear); begin if Gear^.Timer = 0 then diff -r 8c16c0534b3c -r 1e332947147c hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/HHHandlers.inc Sat Mar 19 17:49:27 2011 -0400 @@ -308,6 +308,7 @@ PauseMusic end; amFlamethrower: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); + amLandGun: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); amResurrector: begin CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0); diff -r 8c16c0534b3c -r 1e332947147c hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/uAIAmmoTests.pas Sat Mar 19 17:49:27 2011 -0400 @@ -106,7 +106,8 @@ (proc: nil; flags: 0), // amDrillStrike (proc: @TestSnowball; flags: 0), // amSnowball (proc: nil; flags: 0), // amTardis - (proc: nil; flags: 0) // amStructure + (proc: nil; flags: 0), // amStructure + (proc: nil; flags: 0) // amLandGun ); const BadTurn = Low(LongInt) div 4; diff -r 8c16c0534b3c -r 1e332947147c hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/uGears.pas Sat Mar 19 17:49:27 2011 -0400 @@ -129,7 +129,8 @@ @doStepNapalmBomb, @doStepSnowball, @doStepSnowflake, - @doStepPlaceStructure + @doStepPlaceStructure, + @doStepLandGun ); procedure InsertGearToList(Gear: PGear); @@ -263,6 +264,7 @@ gtFlake: begin with Gear^ do begin + Radius:= 1; DirAngle:= random * 360; dx.isNegative:= GetRandom(2) = 0; dx.QWordValue:= GetRandom(100000000); @@ -497,6 +499,12 @@ gear^.Health:= 500; gear^.Damage:= 100; end; + gtLandGun: begin + gear^.Tag:= 10; + gear^.Timer:= 10; + gear^.Health:= 1000; + gear^.Damage:= 100; + end; gtPoisonCloud: begin gear^.Timer:= 5000; gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; diff -r 8c16c0534b3c -r 1e332947147c hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/uGearsRender.pas Sat Mar 19 17:49:27 2011 -0400 @@ -489,6 +489,7 @@ DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex) end; + gtLandGun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle); end; case CurAmmoGear^.Kind of @@ -605,6 +606,7 @@ end; amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle); amFlamethrower: DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); + amLandGun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle); amResurrector: DrawCircle(ox, oy, 98, 4, $F5, $DB, $35, $AA); // I'd rather not like to hardcode 100 here end; @@ -1034,15 +1036,22 @@ Tint($FF, $FF, $FF, $FF); end; gtNapalmBomb: DrawRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); - gtFlake: if not isInLag then - begin + gtFlake: if (Gear^.State and gstTmpFlag) <> 0 then + //DrawRotatedTextureF(SpritesData[sprSnowBall].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle) + begin + Tint(cExplosionBorderColor); + DrawRotated(sprSnow, x, y, 0, Gear^.DirAngle); + Tint($FF, $FF, $FF, $FF); + end + else if not isInLag then + begin if vobVelocity = 0 then - //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer) - DrawSprite(sprFlake, x, y, Gear^.Timer) - else - //DrawRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle); - DrawRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle) - end; + DrawSprite(sprFlake, x, y, Gear^.Timer) + else + DrawRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle) +//DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer) +//DrawRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle); + end; gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0); end; diff -r 8c16c0534b3c -r 1e332947147c hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/uTypes.pas Sat Mar 19 17:49:27 2011 -0400 @@ -89,7 +89,7 @@ gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives, gtBirdy, // 45 gtEgg, gtPortal, gtPiano, gtGasBomb, gtSineGunShot, gtFlamethrower, // 51 gtSMine, gtPoisonCloud, gtHammer, gtHammerHit, gtResurrector, // 56 - gtNapalmBomb, gtSnowball, gtFlake, gtStructure); // 60 + gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun); // 61 // Gears that are _only_ of visual nature (e.g. background stuff, visual effects, speechbubbles, etc.) TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire, @@ -134,7 +134,7 @@ amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, // 35 amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov, amBirdy, amPortalGun, // 42 amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer, // 48 - amResurrector, amDrillStrike, amSnowball, amTardis, amStructure); + amResurrector, amDrillStrike, amSnowball, amTardis, amStructure, amLandGun); // 54 TCrateType = (HealthCrate, AmmoCrate, UtilityCrate); @@ -371,7 +371,7 @@ sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack, sidMolotov, sidBirdy, sidPortalGun, sidPiano, sidGasBomb, sidSineGun, sidFlamethrower, - sidSMine, sidHammer, sidResurrector, sidDrillStrike, sidSnowball, sidNothing, sidTardis, sidStructure); + sidSMine, sidHammer, sidResurrector, sidDrillStrike, sidSnowball, sidNothing, sidTardis, sidStructure, sidLandGun); TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, diff -r 8c16c0534b3c -r 1e332947147c hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Sat Mar 19 16:00:10 2011 -0400 +++ b/hedgewars/uVariables.pas Sat Mar 19 17:49:27 2011 -0400 @@ -2080,7 +2080,29 @@ PosCount: 2; PosSprite: sprAmTeleport; ejectX: 0; - ejectY: 0) + ejectY: 0), +// Land Gun + (NameId: sidLandGun; + NameTex: nil; + Probability: 20; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; + Count: 1; + NumPerTurn: 0; + Timer: 5001; + Pos: 0; + AmmoType: amLandGun; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater; + ejectX: 0; //20; + ejectY: -3) ); var diff -r 8c16c0534b3c -r 1e332947147c share/hedgewars/Data/Locale/en.txt --- a/share/hedgewars/Data/Locale/en.txt Sat Mar 19 16:00:10 2011 -0400 +++ b/share/hedgewars/Data/Locale/en.txt Sat Mar 19 17:49:27 2011 -0400 @@ -55,6 +55,7 @@ 00:52=No weapon selected 00:53=TARDIS 00:54=Structure +00:55=Land Gun 01:00=Let's fight! 01:01=Round draw