hedgewars/GSHandlers.inc
changeset 4790 4cb3f7890fbd
parent 4778 1565a553d200
child 4791 458d9854c679
equal deleted inserted replaced
4789:7036abbaf3bb 4790:4cb3f7890fbd
  3562     end;
  3562     end;
  3563 end;
  3563 end;
  3564 
  3564 
  3565 ////////////////////////////////////////////////////////////////////////////////
  3565 ////////////////////////////////////////////////////////////////////////////////
  3566 procedure doPortalColorSwitch();
  3566 procedure doPortalColorSwitch();
  3567 var flags: LongWord;
  3567 var CurWeapon: PAmmo;
  3568     CurWeapon: PAmmo;
       
  3569 begin
  3568 begin
  3570     if (CurrentHedgehog <> nil)
  3569     if (CurrentHedgehog <> nil)
  3571        and (CurrentHedgehog^.Gear <> nil)
  3570        and (CurrentHedgehog^.Gear <> nil)
  3572        and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then
  3571        and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then
  3573         With CurrentHedgehog^ do
  3572         With CurrentHedgehog^ do
  3574             if (CurAmmoType = amPortalGun) then
  3573             if (CurAmmoType = amPortalGun) then
  3575             begin
  3574             begin
  3576                 CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gmSwitch;
  3575                 CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gmSwitch;
  3577                 
  3576                 
  3578                 CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
  3577                 CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
  3579                 flags := CurWeapon^.Timer and not 2;
  3578                 if CurWeapon^.Pos <> 0 then
  3580                 if (flags and 1) = 0 then
  3579                     CurWeapon^.Pos := 0
  3581                     CurWeapon^.Timer := flags or 1
       
  3582                 else
  3580                 else
  3583                     CurWeapon^.Timer := flags and not 1;
  3581                     CurWeapon^.Pos := 1;
  3584             end;
  3582             end;
  3585 end;
  3583 end;
  3586 
  3584 
  3587 procedure doStepPortal(Gear: PGear);
  3585 procedure doStepPortal(Gear: PGear);
  3588 var 
  3586 var 
  3847 var 
  3845 var 
  3848     x, y, tx, ty: LongInt;
  3846     x, y, tx, ty: LongInt;
  3849     s: hwFloat;
  3847     s: hwFloat;
  3850 
  3848 
  3851 procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean);
  3849 procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean);
  3852 var 
  3850 var
  3853     flags: LongWord;
       
  3854     CurWeapon: PAmmo;
  3851     CurWeapon: PAmmo;
  3855 begin
  3852 begin
  3856     if CurrentHedgehog <> nil then
  3853     if CurrentHedgehog <> nil then
  3857         with CurrentHedgehog^ do
  3854         with CurrentHedgehog^ do
  3858             begin
  3855             begin
  3859             CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
  3856             CurWeapon:= GetAmmoEntry(CurrentHedgehog^);
  3860             if (CurAmmoType = amPortalGun) then
  3857             if (CurAmmoType = amPortalGun) then
  3861                 begin
  3858                 begin
  3862                 flags := CurWeapon^.Timer;
  3859                 if not destroyGear then
  3863 
  3860                     begin
  3864                 if destroyGear xor ((oldPortal^.Tag and 2) = 0) then
  3861                     // switch color of ball to opposite of oldPortal
  3865                     flags := flags or 1
  3862                     if (oldPortal^.Tag and 2) = 0 then
  3866                 else
  3863                         CurWeapon^.Pos:= 1
  3867                     flags := flags and not 1;
  3864                     else
  3868 
  3865                         CurWeapon^.Pos:= 0;
  3869                 CurWeapon^.Timer := flags and not 2;
  3866                     end;
       
  3867 
  3870                 // make the ball visible
  3868                 // make the ball visible
       
  3869                 CurWeapon^.Timer := 0;
  3871                 end
  3870                 end
  3872             end;
  3871             end;
  3873 
       
  3874     if destroyGear then oldPortal^.Timer:= 0;
  3872     if destroyGear then oldPortal^.Timer:= 0;
  3875 end;
  3873 end;
  3876 
  3874 
  3877 begin
  3875 begin
  3878     x := hwRound(Gear^.X);
  3876     x := hwRound(Gear^.X);
  3953             // when doing a backjump the dx is the opposite of the facing direction
  3951             // when doing a backjump the dx is the opposite of the facing direction
  3954             if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then
  3952             if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then
  3955                 newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative;
  3953                 newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative;
  3956 
  3954 
  3957             // make portal gun look unloaded
  3955             // make portal gun look unloaded
  3958             CurWeapon^.Timer := CurWeapon^.Timer or 2;
  3956             if (CurWeapon <> nil) and (CurAmmoType = amPortalGun) then
  3959 
  3957                 CurWeapon^.Timer := CurWeapon^.Timer or 2;
  3960             // set portal to the currently chosen color
       
  3961             if ((CurWeapon^.Timer and 1) <> 0) then
       
  3962                 newPortal^.Tag := newPortal^.Tag or 2;
       
  3963 
  3958 
  3964             iterator := GearsList;
  3959             iterator := GearsList;
  3965             while iterator <> nil do
  3960             while iterator <> nil do
  3966             begin
  3961             begin
  3967                 if (iterator^.Kind = gtPortal) then
  3962                 if (iterator^.Kind = gtPortal) then