hedgewars/GSHandlers.inc
changeset 8751 4609823efc94
parent 8744 6c87486fd89b
child 8773 7d3af949dd34
child 8774 39754516eee6
equal deleted inserted replaced
8749:1b9f026e9fc6 8751:4609823efc94
   678                         ry:= ly;
   678                         ry:= ly;
   679                         if cReducedQuality and rqBlurryLand <> 0 then
   679                         if cReducedQuality and rqBlurryLand <> 0 then
   680                             begin
   680                             begin
   681                             rx:= rx div 2;ry:= ry div 2;
   681                             rx:= rx div 2;ry:= ry div 2;
   682                             end;
   682                             end;
   683                         if Land[yy + py, xx + px] and $FF00 = 0 then
   683                         if Land[yy + py, xx + px] <= lfAllObjMask then
   684                             if gun then
   684                             if gun then
   685                                 begin
   685                                 begin
   686                                 LandDirty[yy div 32, xx div 32]:= 1;
   686                                 LandDirty[yy div 32, xx div 32]:= 1;
   687                                 if LandPixels[ry, rx] = 0 then
   687                                 if LandPixels[ry, rx] = 0 then
   688                                     Land[ly, lx]:=  lfDamaged or lfObject
   688                                     Land[ly, lx]:=  lfDamaged or lfObject
  1018         y := hwRound(Gear^.Y);
  1018         y := hwRound(Gear^.Y);
  1019         
  1019         
  1020         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
  1020         if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then
  1021             inc(Gear^.Damage);
  1021             inc(Gear^.Damage);
  1022         // let's interrupt before a collision to give portals a chance to catch the bullet
  1022         // let's interrupt before a collision to give portals a chance to catch the bullet
  1023         if (Gear^.Damage = 1) and (Gear^.Tag = 0) and not(CheckLandValue(x, y, $FF00)) then
  1023         if (Gear^.Damage = 1) and (Gear^.Tag = 0) and not(CheckLandValue(x, y, lfLandMask)) then
  1024             begin
  1024             begin
  1025             Gear^.Tag := 1;
  1025             Gear^.Tag := 1;
  1026             Gear^.Damage := 0;
  1026             Gear^.Damage := 0;
  1027             Gear^.X := Gear^.X - Gear^.dX;
  1027             Gear^.X := Gear^.X - Gear^.dX;
  1028             Gear^.Y := Gear^.Y - Gear^.dY;
  1028             Gear^.Y := Gear^.Y - Gear^.dY;
  1240         SetLittle(HHGear^.dX);
  1240         SetLittle(HHGear^.dX);
  1241         HHGear^.dY := _0;
  1241         HHGear^.dY := _0;
  1242         end
  1242         end
  1243     else
  1243     else
  1244         begin
  1244         begin
  1245         if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), $FF00) then
  1245         if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), lfLandMask) then
  1246             begin
  1246             begin
  1247             Gear^.dY := Gear^.dY + cGravity;
  1247             Gear^.dY := Gear^.dY + cGravity;
  1248             Gear^.Y := Gear^.Y + Gear^.dY
  1248             Gear^.Y := Gear^.Y + Gear^.dY
  1249             end;
  1249             end;
  1250         if hwRound(Gear^.Y) > cWaterLine then
  1250         if hwRound(Gear^.Y) > cWaterLine then
  1251             Gear^.Timer := 1
  1251             Gear^.Timer := 1
  1252         end;
  1252         end;
  1253 
  1253 
  1254     Gear^.X := Gear^.X + HHGear^.dX;
  1254     Gear^.X := Gear^.X + HHGear^.dX;
  1255     if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)-cHHRadius, $FF00) then
  1255     if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)-cHHRadius, lfLandMask) then
  1256         begin
  1256         begin
  1257         HHGear^.X := Gear^.X;
  1257         HHGear^.X := Gear^.X;
  1258         HHGear^.Y := Gear^.Y - int2hwFloat(cHHRadius)
  1258         HHGear^.Y := Gear^.Y - int2hwFloat(cHHRadius)
  1259         end;
  1259         end;
  1260 
  1260 
  2751 begin
  2751 begin
  2752     AllInactive := false;
  2752     AllInactive := false;
  2753 
  2753 
  2754     HHGear := Gear^.Hedgehog^.Gear;
  2754     HHGear := Gear^.Hedgehog^.Gear;
  2755     HHGear^.Message := HHGear^.Message and (not gmAttack);
  2755     HHGear^.Message := HHGear^.Message and (not gmAttack);
  2756     Gear^.CollisionMask:= lfCurrentMask;
  2756     Gear^.CollisionMask:= lfNotCurrentMask;
  2757 
  2757 
  2758     FollowGear := Gear;
  2758     FollowGear := Gear;
  2759 
  2759 
  2760     Gear^.doStep := @doStepCakeFall
  2760     Gear^.doStep := @doStepCakeFall
  2761 end;
  2761 end;
  3023         begin
  3023         begin
  3024         rx := rndSign(getRandomf * _0_1);
  3024         rx := rndSign(getRandomf * _0_1);
  3025         ry := rndSign(getRandomf * _0_1);
  3025         ry := rndSign(getRandomf * _0_1);
  3026 
  3026 
  3027         ball:= AddGear(gx, gy, gtBall, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0);
  3027         ball:= AddGear(gx, gy, gtBall, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0);
  3028         ball^.CollisionMask:= lfCurrentMask;
  3028         ball^.CollisionMask:= lfNotCurrentMask;
  3029 
  3029 
  3030         PlaySound(sndGun);
  3030         PlaySound(sndGun);
  3031         end;
  3031         end;
  3032 
  3032 
  3033     if (Gear^.Timer = 0) or ((HHGear^.State and gstHHDriven) = 0) then
  3033     if (Gear^.Timer = 0) or ((HHGear^.State and gstHHDriven) = 0) then
  3593     hasdxy, isbullet, iscake, isCollision: Boolean;
  3593     hasdxy, isbullet, iscake, isCollision: Boolean;
  3594 begin
  3594 begin
  3595     doPortalColorSwitch();
  3595     doPortalColorSwitch();
  3596 
  3596 
  3597     // destroy portal if ground it was attached too is gone
  3597     // destroy portal if ground it was attached too is gone
  3598     if ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)] and $FF00) = 0)
  3598     if (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] <= lfAllObjMask)
  3599     or (Gear^.Timer < 1)
  3599     or (Gear^.Timer < 1)
  3600     or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team)
  3600     or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team)
  3601     or (hwRound(Gear^.Y) > cWaterLine) then
  3601     or (hwRound(Gear^.Y) > cWaterLine) then
  3602         begin
  3602         begin
  3603         deleteGear(Gear);
  3603         deleteGear(Gear);
  4374             speed := _0_5 * (_10 / Gear^.Tag);
  4374             speed := _0_5 * (_10 / Gear^.Tag);
  4375     
  4375     
  4376             flame:= AddGear(gx, gy, gtFlame, gstTmpFlag,
  4376             flame:= AddGear(gx, gy, gtFlame, gstTmpFlag,
  4377                     SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4377                     SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4378                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4378                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4379             flame^.CollisionMask:= lfCurrentMask;
  4379             flame^.CollisionMask:= lfNotCurrentMask;
  4380             
  4380             
  4381             if (Gear^.Health mod 30) = 0 then
  4381             if (Gear^.Health mod 30) = 0 then
  4382                 begin
  4382                 begin
  4383                 flame:= AddGear(gx, gy, gtFlame, 0,
  4383                 flame:= AddGear(gx, gy, gtFlame, 0,
  4384                         SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4384                         SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4385                         AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4385                         AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4386                 flame^.CollisionMask:= lfCurrentMask;
  4386                 flame^.CollisionMask:= lfNotCurrentMask;
  4387                 end
  4387                 end
  4388             end;
  4388             end;
  4389         Gear^.Timer:= Gear^.Tag
  4389         Gear^.Timer:= Gear^.Tag
  4390         end;
  4390         end;
  4391 
  4391 
  4458         speed := (_3 / Gear^.Tag);
  4458         speed := (_3 / Gear^.Tag);
  4459 
  4459 
  4460         land:= AddGear(gx, gy, gtFlake, gstTmpFlag, 
  4460         land:= AddGear(gx, gy, gtFlake, gstTmpFlag, 
  4461                 SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, 
  4461                 SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, 
  4462                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4462                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4463         land^.CollisionMask:= lfCurrentMask;
  4463         land^.CollisionMask:= lfNotCurrentMask;
  4464             
  4464             
  4465         Gear^.Timer:= Gear^.Tag
  4465         Gear^.Timer:= Gear^.Tag
  4466         end;
  4466         end;
  4467 
  4467 
  4468     if (Gear^.Health = 0) or ((HHGear^.State and gstHHDriven) = 0) or ((HHGear^.Message and gmAttack) <> 0) then
  4468     if (Gear^.Health = 0) or ((HHGear^.State and gstHHDriven) = 0) or ((HHGear^.Message and gmAttack) <> 0) then
  5062 WIP. The ice gun will have the following effects.  It has been proposed by sheepluva that it take the appearance of a large freezer
  5062 WIP. The ice gun will have the following effects.  It has been proposed by sheepluva that it take the appearance of a large freezer
  5063 spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
  5063 spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
  5064 For now we assume a "ray" like a deagle projected out from the gun.
  5064 For now we assume a "ray" like a deagle projected out from the gun.
  5065 All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".  
  5065 All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".  
  5066   * When fired at water a layer of ice textured land is added above the water.
  5066   * When fired at water a layer of ice textured land is added above the water.
  5067   * When fired at non-ice land (land and $FF00 and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
  5067   * When fired at non-ice land (land and lfLandMask and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
  5068   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.  As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.  If the effect is interrupted before reaching the top, the freezing state is cleared.
  5068   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.  As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.  If the effect is interrupted before reaching the top, the freezing state is cleared.
  5069 A frozen hog will animate differently.  To be decided, but possibly in a similar fashion to a grave when it comes to explosions.  The hog might (possibly) not be damaged by explosions.  This might make freezing potentially useful for friendlies in a bad position.  It might be better to allow damage though.
  5069 A frozen hog will animate differently.  To be decided, but possibly in a similar fashion to a grave when it comes to explosions.  The hog might (possibly) not be damaged by explosions.  This might make freezing potentially useful for friendlies in a bad position.  It might be better to allow damage though.
  5070 A frozen hog stays frozen for a certain number of turns. Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again.
  5070 A frozen hog stays frozen for a certain number of turns. Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again.
  5071 *)
  5071 *)
  5072 
  5072 
  5458     gx:= hwRound(Gear^.X);
  5458     gx:= hwRound(Gear^.X);
  5459     gy:= hwRound(Gear^.Y);
  5459     gy:= hwRound(Gear^.Y);
  5460     if Gear^.State and gstDrowning <> 0 then exit;
  5460     if Gear^.State and gstDrowning <> 0 then exit;
  5461     with Gear^ do
  5461     with Gear^ do
  5462         begin
  5462         begin
  5463         if CheckLandValue(gx, gy, $FF00) then
  5463         if CheckLandValue(gx, gy, lfLandMask) then
  5464             begin
  5464             begin
  5465             t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); 
  5465             t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); 
  5466 
  5466 
  5467             if t < 0 then inc(t, 4096)
  5467             if t < 0 then inc(t, 4096)
  5468             else if 4095 < t then dec(t, 4096);
  5468             else if 4095 < t then dec(t, 4096);