hedgewars/GSHandlers.inc
changeset 5025 ac1691d35cf2
parent 5024 1e332947147c
child 5041 3dc6ad20cbfe
equal deleted inserted replaced
5024:1e332947147c 5025:ac1691d35cf2
   139                             Gear^.doStep := @doStepDrowningGear;
   139                             Gear^.doStep := @doStepDrowningGear;
   140                             Gear^.State := Gear^.State and (not gstHHDriven);
   140                             Gear^.State := Gear^.State and (not gstHHDriven);
   141                             AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
   141                             AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
   142                             end
   142                             end
   143                         end
   143                         end
   144                     else
   144                     else if Gear^.Kind = gtFlake then
   145                         Gear^.doStep := @doStepDrowningGear
   145                         begin
       
   146                         DeleteGear(Gear);
       
   147                         exit
       
   148                         end
       
   149                     else Gear^.doStep := @doStepDrowningGear
   146             end;
   150             end;
   147             if ((not isSubmersible) and (hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius)) or
   151             if ((not isSubmersible) and (hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius)) or
   148                (isSubmersible and (hwRound(Gear^.Y) < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01))) then
   152                (isSubmersible and (hwRound(Gear^.Y) < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01))) then
   149                 // don't play splash if they are already way past the surface
   153                 // don't play splash if they are already way past the surface
   150                 PlaySound(sndSplash)
   154                 PlaySound(sndSplash)
   566         end
   570         end
   567 end;
   571 end;
   568 
   572 
   569 procedure doStepSnowflake(Gear: PGear);
   573 procedure doStepSnowflake(Gear: PGear);
   570 var xx, yy, px, py, i: LongInt;
   574 var xx, yy, px, py, i: LongInt;
   571     move, draw, allpx: Boolean;
   575     move, draw, allpx, gun: Boolean;
   572     s: PSDL_Surface;
   576     s: PSDL_Surface;
   573     p: PLongwordArray;
   577     p: PLongwordArray;
   574     oAlpha, nAlpha: byte;
   578     oAlpha, nAlpha: byte;
   575 begin
   579 begin
       
   580 gun:= (Gear^.State and gstTmpFlag) <> 0;
   576 move:= false;
   581 move:= false;
   577 draw:= false;
   582 draw:= false;
   578 if (Gear^.State and gstTmpFlag) <> 0 then
   583 if gun then
   579     begin
   584     begin
   580     doStepFallingGear(Gear);
   585     doStepFallingGear(Gear);
   581     CheckCollision(Gear);
   586     CheckCollision(Gear);
   582     if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then draw:= true;
   587     if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then draw:= true;
   583     xx:= hwRound(Gear^.X);
   588     xx:= hwRound(Gear^.X);
   650         // we've collided with land. draw some stuff and get back into the clouds
   655         // we've collided with land. draw some stuff and get back into the clouds
   651         move:= true;
   656         move:= true;
   652         if (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope) then
   657         if (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope) then
   653             begin
   658             begin
   654 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
   659 ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS ////////////////////////////////////
   655             if (State and gstTmpFlag) = 0 then
   660             if not gun then
   656                 begin
   661                 begin
   657                 dec(yy,3);
   662                 dec(yy,3);
   658                 dec(xx,1)
   663                 dec(xx,1)
   659                 end;
   664                 end;
   660             s:= SpritesData[sprSnow].Surface;
   665             s:= SpritesData[sprSnow].Surface;
   663             for py:= 0 to Pred(s^.h) do
   668             for py:= 0 to Pred(s^.h) do
   664                 begin
   669                 begin
   665                 for px:= 0 to Pred(s^.w) do
   670                 for px:= 0 to Pred(s^.w) do
   666                     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
   671                     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
   667                         begin
   672                         begin
       
   673                         if gun then
       
   674                             begin
       
   675                             // try to avoid speckles. might need disabling
       
   676                             LandDirty[yy div 32, xx div 32]:= 1;
       
   677                             Land[yy + py, xx + px]:= Land[yy + py, xx + px] or lfDamaged;
       
   678                             end;
   668                         Land[yy + py, xx + px]:= Land[yy + py, xx + px] or lfObject;
   679                         Land[yy + py, xx + px]:= Land[yy + py, xx + px] or lfObject;
   669                         if (cReducedQuality and rqBlurryLand) = 0 then
   680                         if (cReducedQuality and rqBlurryLand) = 0 then
   670                             begin
   681                             begin
   671                             if (State and gstTmpFlag) <> 0 then
   682                             if gun then
   672                                 LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000))
   683                                 LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
   673                             else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]);
   684                             else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]);
   674                             end
   685                             end
   675                         else
   686                         else
   676                             begin
   687                             begin
   677                             if (State and gstTmpFlag) <> 0 then
   688                             if gun then
   678                                 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))
   689                                 LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and $00FFFFFF) or (p^[px] and $FF000000)
   679                             else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]);
   690                             else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]);
   680                             end;
   691                             end;
   681                         end
   692                         end
   682                     else allpx:= false;
   693                     else allpx:= false;
   683                 p:= @(p^[s^.pitch shr 2])
   694                 p:= @(p^[s^.pitch shr 2])
   700             end
   711             end
   701         end;
   712         end;
   702 
   713 
   703 if move then
   714 if move then
   704     begin
   715     begin
   705     if ((Gear^.State and gstTmpFlag) <> 0) then
   716     if gun then
   706         begin
   717         begin
   707         DeleteGear(Gear);
   718         DeleteGear(Gear);
   708         exit
   719         exit
   709         end;
   720         end;
   710     Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512);
   721     Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512);
  4408             
  4419             
  4409             end;
  4420             end;
  4410         Gear^.Timer:= Gear^.Tag
  4421         Gear^.Timer:= Gear^.Tag
  4411         end;
  4422         end;
  4412 
  4423 
  4413     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then
  4424     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) or ((HHGear^.Message and gmAttack) <> 0) then
  4414         begin
  4425         begin
       
  4426         HHGear^.Message:= HHGear^.Message and not gmAttack;
  4415         DeleteGear(Gear);
  4427         DeleteGear(Gear);
  4416         AfterAttack
  4428         AfterAttack
  4417         end
  4429         end
  4418     else
  4430     else
  4419         begin
  4431         begin
  4431 procedure doStepLandGun(Gear: PGear);
  4443 procedure doStepLandGun(Gear: PGear);
  4432 var 
  4444 var 
  4433     HHGear: PGear;
  4445     HHGear: PGear;
  4434 begin
  4446 begin
  4435     HHGear := Gear^.Hedgehog^.Gear;
  4447     HHGear := Gear^.Hedgehog^.Gear;
  4436     HHGear^.Message := HHGear^.Message and not (gmUp or gmDown or gmLeft or gmRight);
  4448     HHGear^.Message := HHGear^.Message and not (gmUp or gmDown or gmLeft or gmRight or gmAttack);
  4437     HHGear^.State := HHGear^.State or gstNotKickable;
  4449     HHGear^.State := HHGear^.State or gstNotKickable;
  4438     Gear^.doStep := @doStepLandGunWork
  4450     Gear^.doStep := @doStepLandGunWork
  4439 end;
  4451 end;
  4440 
  4452 
  4441 procedure doStepPoisonCloud(Gear: PGear);
  4453 procedure doStepPoisonCloud(Gear: PGear);