hedgewars/uGearsHandlersMess.pas
changeset 13593 083733ec7941
parent 13572 a71e6856ffab
child 13602 0d920e370a78
equal deleted inserted replaced
13587:818134c33f54 13593:083733ec7941
  1028         end;
  1028         end;
  1029 
  1029 
  1030 
  1030 
  1031     if Gear^.Timer = 0 then
  1031     if Gear^.Timer = 0 then
  1032         begin
  1032         begin
  1033         // no "fuel"? just fall
  1033         // no energy? just fall
  1034         doStepFallingGear(Gear);
  1034         doStepFallingGear(Gear);
  1035         // if drowning, stop bee sound
  1035         // if drowning, stop bee sound
  1036         if (Gear^.State and gstDrowning) <> 0 then
  1036         if (Gear^.State and gstDrowning) <> 0 then
  1037             StopSoundChan(Gear^.SoundChannel);
  1037             StopSoundChan(Gear^.SoundChannel);
  1038         end
  1038         end
  4168     move:= _0_02;
  4168     move:= _0_02;
  4169     fuel:= 5;
  4169     fuel:= 5;
  4170     end;*)
  4170     end;*)
  4171     if HHGear^.Message and gmPrecise <> 0 then
  4171     if HHGear^.Message and gmPrecise <> 0 then
  4172         HedgehogChAngle(HHGear)
  4172         HedgehogChAngle(HHGear)
  4173     else if Gear^.Health > 0 then
  4173     else if (Gear^.Health > 0) or (Gear^.Health = JETPACK_FUEL_INFINITE) then
  4174         begin
  4174         begin
  4175         if HHGear^.Message and gmUp <> 0 then
  4175         if HHGear^.Message and gmUp <> 0 then
  4176             begin
  4176             begin
  4177             if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then
  4177             if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then
  4178                 begin
  4178                 begin
  4190                     begin
  4190                     begin
  4191                     PlaySound(sndJetpackBoost);
  4191                     PlaySound(sndJetpackBoost);
  4192                     HHGear^.dY := HHGear^.dY - move;
  4192                     HHGear^.dY := HHGear^.dY - move;
  4193                     end
  4193                     end
  4194                 end;
  4194                 end;
  4195             dec(Gear^.Health, fuel);
  4195             if Gear^.Health <> JETPACK_FUEL_INFINITE then
       
  4196                 dec(Gear^.Health, fuel);
  4196             Gear^.MsgParam := Gear^.MsgParam or gmUp;
  4197             Gear^.MsgParam := Gear^.MsgParam or gmUp;
  4197             Gear^.Timer := GameTicks
  4198             Gear^.Timer := GameTicks
  4198             end;
  4199             end;
  4199         move.isNegative := (HHGear^.Message and gmLeft) <> 0;
  4200         move.isNegative := (HHGear^.Message and gmLeft) <> 0;
  4200         if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  4201         if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  4216                         else bubble^.X := bubble^.X - 28;
  4217                         else bubble^.X := bubble^.X - 28;
  4217                         end;
  4218                         end;
  4218                     end
  4219                     end
  4219                 end
  4220                 end
  4220             else PlaySound(sndJetpackBoost);
  4221             else PlaySound(sndJetpackBoost);
  4221             dec(Gear^.Health, fuel div 5);
  4222             if Gear^.Health <> JETPACK_FUEL_INFINITE then
       
  4223                 dec(Gear^.Health, fuel div 5);
  4222             Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  4224             Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  4223             Gear^.Timer := GameTicks
  4225             Gear^.Timer := GameTicks
  4224             end
  4226             end
  4225         end;
  4227         end;
  4226 
  4228 
  4229         begin
  4231         begin
  4230         Gear^.Timer := 0;
  4232         Gear^.Timer := 0;
  4231         Gear^.MsgParam := 0
  4233         Gear^.MsgParam := 0
  4232         end;
  4234         end;
  4233 
  4235 
  4234     if Gear^.Health < 0 then
  4236     if (Gear^.Health < 0) and (Gear^.Health <> JETPACK_FUEL_INFINITE) then
  4235         Gear^.Health := 0;
  4237         Gear^.Health := 0;
  4236 
  4238 
  4237     i:= Gear^.Health div 20;
  4239     i:= Gear^.Health div 20;
  4238 
  4240 
  4239     if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
  4241     if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then
  4240         begin
  4242         begin
  4241         Gear^.Damage:= i;
  4243         Gear^.Damage:= i;
  4242         //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate);
       
  4243         FreeAndNilTexture(Gear^.Tex);
  4244         FreeAndNilTexture(Gear^.Tex);
  4244         Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ansistring(': ' + inttostr(i) + '%'), cWhiteColor, fntSmall)
  4245         if Gear^.Health <> JETPACK_FUEL_INFINITE then
       
  4246             Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ansistring(': ' + inttostr(i) + '%'), cWhiteColor, fntSmall)
  4245         end;
  4247         end;
  4246 
  4248 
  4247     if (HHGear^.Message and (gmAttack or gmUp or gmLeft or gmRight) <> 0) and
  4249     if (HHGear^.Message and (gmAttack or gmUp or gmLeft or gmRight) <> 0) and
  4248        (HHGear^.Message and gmPrecise = 0) then
  4250        (HHGear^.Message and gmPrecise = 0) then
  4249         Gear^.State := Gear^.State and (not gsttmpFlag);
  4251         Gear^.State := Gear^.State and (not gsttmpFlag);
  4332 end;
  4334 end;
  4333 
  4335 
  4334 procedure doStepBirdyFly(Gear: PGear);
  4336 procedure doStepBirdyFly(Gear: PGear);
  4335 var
  4337 var
  4336     HHGear: PGear;
  4338     HHGear: PGear;
  4337     fuel, i: LongInt;
  4339     energy, i: LongInt;
  4338     move: hwFloat;
  4340     move: hwFloat;
  4339     s: ansistring;
  4341     s: ansistring;
  4340 begin
  4342 begin
  4341     HHGear := Gear^.Hedgehog^.Gear;
  4343     HHGear := Gear^.Hedgehog^.Gear;
  4342     if HHGear = nil then
  4344     if HHGear = nil then
  4350         AfterAttack;
  4352         AfterAttack;
  4351         exit
  4353         exit
  4352         end;
  4354         end;
  4353 
  4355 
  4354     move := _0_2;
  4356     move := _0_2;
  4355     fuel := 50;
  4357     energy:= 50;
  4356 
  4358 
  4357     if Gear^.Pos > 0 then
  4359     if Gear^.Pos > 0 then
  4358         dec(Gear^.Pos, 1)
  4360         dec(Gear^.Pos, 1)
  4359     else if (HHGear^.Message and (gmLeft or gmRight or gmUp)) <> 0 then
  4361     else if (HHGear^.Message and (gmLeft or gmRight or gmUp)) <> 0 then
  4360             Gear^.Pos := 500;
  4362             Gear^.Pos := 500;
  4368         begin
  4370         begin
  4369         if (not HHGear^.dY.isNegative)
  4371         if (not HHGear^.dY.isNegative)
  4370         or (HHGear^.Y > -_256) then
  4372         or (HHGear^.Y > -_256) then
  4371             HHGear^.dY := HHGear^.dY - move;
  4373             HHGear^.dY := HHGear^.dY - move;
  4372 
  4374 
  4373         dec(Gear^.Health, fuel);
  4375         if (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
       
  4376             dec(Gear^.Health, energy);
  4374         Gear^.MsgParam := Gear^.MsgParam or gmUp;
  4377         Gear^.MsgParam := Gear^.MsgParam or gmUp;
  4375         end;
  4378         end;
  4376 
  4379 
  4377     if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true;
  4380     if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true;
  4378     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  4381     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  4379         begin
  4382         begin
  4380         HHGear^.dX := HHGear^.dX + (move * _0_1);
  4383         HHGear^.dX := HHGear^.dX + (move * _0_1);
  4381         dec(Gear^.Health, fuel div 5);
  4384         if (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
       
  4385             dec(Gear^.Health, energy div 5);
  4382         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  4386         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  4383         end;
  4387         end;
  4384 
  4388 
  4385     if Gear^.Health < 0 then
  4389     if (Gear^.Health < 0) and (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
  4386         Gear^.Health := 0;
  4390         Gear^.Health := 0;
  4387 
  4391 
  4388     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
  4392     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) and (Gear^.Health <> BIRDY_ENERGY_INFINITE) then
  4389         for i:= ((500-Gear^.Health) div 250) downto 0 do
  4393         for i:= ((500-Gear^.Health) div 250) downto 0 do
  4390             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
  4394             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
  4391 
  4395 
  4392     if (HHGear^.Message and gmAttack <> 0) then
  4396     if (HHGear^.Message and gmAttack <> 0) then
  4393         begin
  4397         begin