1320 var oX, oY: hwFloat; |
1320 var oX, oY: hwFloat; |
1321 fromX, fromY, toX, toY, dX, dY, bLength, stepLength: real; |
1321 fromX, fromY, toX, toY, dX, dY, bLength, stepLength: real; |
1322 VGear: PVisualGear; |
1322 VGear: PVisualGear; |
1323 i, steps: LongWord; |
1323 i, steps: LongWord; |
1324 begin |
1324 begin |
|
1325 if CurrentHedgehog^.Gear = nil then |
|
1326 begin |
|
1327 DeleteGear(Bullet); |
|
1328 exit |
|
1329 end; |
1325 if Bullet^.PortalCounter = 0 then |
1330 if Bullet^.PortalCounter = 0 then |
1326 begin |
1331 begin |
1327 ox:= CurrentHedgehog^.Gear^.X + Int2hwFloat(GetLaunchX(CurrentHedgehog^.CurAmmoType, hwSign(CurrentHedgehog^.Gear^.dX), CurrentHedgehog^.Gear^.Angle)); |
1332 ox:= CurrentHedgehog^.Gear^.X + Int2hwFloat(GetLaunchX(CurrentHedgehog^.CurAmmoType, hwSign(CurrentHedgehog^.Gear^.dX), CurrentHedgehog^.Gear^.Angle)); |
1328 oy:= CurrentHedgehog^.Gear^.Y + Int2hwFloat(GetLaunchY(CurrentHedgehog^.CurAmmoType, CurrentHedgehog^.Gear^.Angle)); |
1333 oy:= CurrentHedgehog^.Gear^.Y + Int2hwFloat(GetLaunchY(CurrentHedgehog^.CurAmmoType, CurrentHedgehog^.Gear^.Angle)); |
1329 end |
1334 end |
4995 |
5005 |
4996 //////////////////////////////////////////////////////////////////////////////// |
5006 //////////////////////////////////////////////////////////////////////////////// |
4997 procedure doPortalColorSwitch(); |
5007 procedure doPortalColorSwitch(); |
4998 var CurWeapon: PAmmo; |
5008 var CurWeapon: PAmmo; |
4999 begin |
5009 begin |
5000 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.State and gstHHDriven) <> 0) and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then |
5010 if (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.State and gstHHDriven) <> 0) and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then |
5001 with CurrentHedgehog^ do |
5011 with CurrentHedgehog^ do |
5002 if (CurAmmoType = amPortalGun) then |
5012 if (CurAmmoType = amPortalGun) then |
5003 begin |
5013 begin |
5004 PlaySound(sndPortalSwitch); |
5014 PlaySound(sndPortalSwitch); |
5005 CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch); |
5015 CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch); |
5326 iterator^.Angle:= DxDy2AttackAngle(iterator^.dX, iterator^.dY); |
5336 iterator^.Angle:= DxDy2AttackAngle(iterator^.dX, iterator^.dY); |
5327 iterator^.Angle:= 2048-iterator^.Angle; |
5337 iterator^.Angle:= 2048-iterator^.Angle; |
5328 if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; |
5338 if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; |
5329 end; |
5339 end; |
5330 |
5340 |
5331 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) |
5341 if (CurrentHedgehog^.Gear <> nil) |
5332 and (iterator = CurrentHedgehog^.Gear) |
5342 and (iterator = CurrentHedgehog^.Gear) |
5333 and (CurAmmoGear <> nil) |
5343 and (CurAmmoGear <> nil) |
5334 and (CurAmmoGear^.Kind = gtRope) |
5344 and (CurAmmoGear^.Kind = gtRope) |
5335 and (CurAmmoGear^.Elasticity <> _0) then |
5345 and (CurAmmoGear^.Elasticity <> _0) then |
5336 CurAmmoGear^.PortalCounter:= 1; |
5346 CurAmmoGear^.PortalCounter:= 1; |
5460 |
5475 |
5461 newPortal^.LinkedGear := nil; |
5476 newPortal^.LinkedGear := nil; |
5462 |
5477 |
5463 PlaySound(sndPortalShot); |
5478 PlaySound(sndPortalShot); |
5464 |
5479 |
5465 if CurrentHedgehog <> nil then |
5480 with CurrentHedgehog^ do |
5466 with CurrentHedgehog^ do |
5481 begin |
5467 begin |
5482 CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); |
5468 CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); |
5483 // let's save the HH's dX's direction so we can decide where the "top" of the portal hole |
5469 // let's save the HH's dX's direction so we can decide where the "top" of the portal hole |
5484 newPortal^.Elasticity.isNegative := CurrentHedgehog^.Gear^.dX.isNegative; |
5470 newPortal^.Elasticity.isNegative := CurrentHedgehog^.Gear^.dX.isNegative; |
5485 // when doing a backjump the dx is the opposite of the facing direction |
5471 // when doing a backjump the dx is the opposite of the facing direction |
5486 if ((Gear^.State and gstHHHJump) <> 0) and (Effects[heArtillery] = 0) then |
5472 if ((Gear^.State and gstHHHJump) <> 0) and (Effects[heArtillery] = 0) then |
5487 newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative; |
5473 newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative; |
5488 |
5474 |
5489 // make portal gun look unloaded |
5475 // make portal gun look unloaded |
5490 if (CurWeapon <> nil) and (CurAmmoType = amPortalGun) then |
5476 if (CurWeapon <> nil) and (CurAmmoType = amPortalGun) then |
5491 CurWeapon^.Timer := CurWeapon^.Timer or 2; |
5477 CurWeapon^.Timer := CurWeapon^.Timer or 2; |
5492 |
5478 |
5493 iterator := GearsList; |
5479 iterator := GearsList; |
5494 while iterator <> nil do |
5480 while iterator <> nil do |
5495 begin |
5481 begin |
5496 if (iterator^.Kind = gtPortal) then |
5482 if (iterator^.Kind = gtPortal) then |
5497 if (iterator <> newPortal) and (iterator^.Timer > 0) and (iterator^.Hedgehog = CurrentHedgehog) then |
5483 if (iterator <> newPortal) and (iterator^.Timer > 0) and (iterator^.Hedgehog = CurrentHedgehog) then |
5498 begin |
5484 begin |
5499 if ((iterator^.Tag and 2) = (newPortal^.Tag and 2)) then |
5485 if ((iterator^.Tag and 2) = (newPortal^.Tag and 2)) then |
5500 begin |
5486 begin |
5501 iterator^.Timer:= 0; |
5487 iterator^.Timer:= 0; |
5502 end |
5488 end |
5503 else |
5489 else |
5504 begin |
5490 begin |
5505 // link portals with each other |
5491 // link portals with each other |
5506 newPortal^.LinkedGear := iterator; |
5492 newPortal^.LinkedGear := iterator; |
5507 iterator^.LinkedGear := newPortal; |
5493 iterator^.LinkedGear := newPortal; |
5508 iterator^.Health := newPortal^.Health; |
5494 iterator^.Health := newPortal^.Health; |
5509 end; |
5495 end; |
5510 end; |
5496 end; |
5511 iterator^.PortalCounter:= 0; |
5497 iterator^.PortalCounter:= 0; |
5512 iterator := iterator^.NextGear |
5498 iterator := iterator^.NextGear |
5513 end; |
5499 end; |
5514 |
5500 |
5515 if newPortal^.LinkedGear <> nil then |
5501 if newPortal^.LinkedGear <> nil then |
5516 begin |
5502 begin |
5517 // This jiggles gears, to ensure a portal connection just placed under a gear takes effect. |
5503 // This jiggles gears, to ensure a portal connection just placed under a gear takes effect. |
5518 iterator:= GearsList; |
5504 iterator:= GearsList; |
5519 while iterator <> nil do |
5505 while iterator <> nil do |
5520 begin |
5506 begin |
5521 if not (iterator^.Kind in [gtPortal, gtAirAttack, gtKnife, gtSMine]) and ((iterator^.Hedgehog <> CurrentHedgehog) |
5507 if not (iterator^.Kind in [gtPortal, gtAirAttack, gtKnife, gtSMine]) and ((iterator^.Hedgehog <> CurrentHedgehog) |
5522 or ((iterator^.Message and gmAllStoppable) = 0)) then |
5508 or ((iterator^.Message and gmAllStoppable) = 0)) then |
5523 begin |
5509 begin |
5524 iterator^.Active:= true; |
5510 iterator^.Active:= true; |
5525 if iterator^.dY.QWordValue = 0 then |
5511 if iterator^.dY.QWordValue = 0 then |
5526 iterator^.dY.isNegative:= false; |
5512 iterator^.dY.isNegative:= false; |
5527 iterator^.State:= iterator^.State or gstMoving; |
5513 iterator^.State:= iterator^.State or gstMoving; |
5528 DeleteCI(iterator); |
5514 DeleteCI(iterator); |
5529 //inc(iterator^.dY.QWordValue,10); |
5515 //inc(iterator^.dY.QWordValue,10); |
5530 end; |
5516 end; |
5531 iterator:= iterator^.NextGear |
5517 iterator:= iterator^.NextGear |
5532 end |
5518 end |
5533 end |
5519 end |
5534 end; |
5520 end; |
|
5521 newPortal^.State := newPortal^.State and (not gstCollision); |
5535 newPortal^.State := newPortal^.State and (not gstCollision); |
5522 newPortal^.State := newPortal^.State or gstMoving; |
5536 newPortal^.State := newPortal^.State or gstMoving; |
5523 newPortal^.doStep := @doStepMovingPortal; |
5537 newPortal^.doStep := @doStepMovingPortal; |
5524 end; |
5538 end; |
5525 |
5539 |