362 var x, y, i, distL, distR, distB, minDist, maxDrops: LongInt; |
362 var x, y, i, distL, distR, distB, minDist, maxDrops: LongInt; |
363 splash, particle: PVisualGear; |
363 splash, particle: PVisualGear; |
364 speed, hwTmp: hwFloat; |
364 speed, hwTmp: hwFloat; |
365 vi, vs, tmp: real; // impact speed and sideways speed |
365 vi, vs, tmp: real; // impact speed and sideways speed |
366 isImpactH, isImpactRight: boolean; |
366 isImpactH, isImpactRight: boolean; |
367 const dist2surf = 6; |
367 const dist2surf = 4; |
368 begin |
368 begin |
369 x:= hwRound(Gear^.X); |
369 x:= hwRound(Gear^.X); |
370 y:= hwRound(Gear^.Y); |
370 y:= hwRound(Gear^.Y); |
371 |
371 |
372 splash:= AddVisualGear(x, y, vgtSplash); |
372 // find position for splash and impact speed |
373 if splash = nil then |
|
374 exit; |
|
375 |
|
376 // correct position and angle |
|
377 |
373 |
378 distB:= cWaterline - y; |
374 distB:= cWaterline - y; |
379 |
375 |
380 if WorldEdge <> weSea then |
376 if WorldEdge <> weSea then |
381 minDist:= distB |
377 minDist:= distB |
389 isImpactH:= (minDist <> distB); |
385 isImpactH:= (minDist <> distB); |
390 |
386 |
391 if not isImpactH then |
387 if not isImpactH then |
392 begin |
388 begin |
393 y:= cWaterline - dist2surf; |
389 y:= cWaterline - dist2surf; |
394 splash^.Y:= y; |
|
395 speed:= hwAbs(Gear^.dY); |
390 speed:= hwAbs(Gear^.dY); |
396 vs:= abs(hwFloat2Float(Gear^.dX)); |
|
397 end |
391 end |
398 else |
392 else |
399 begin |
393 begin |
400 isImpactRight := minDist = distR; |
394 isImpactRight := minDist = distR; |
401 if isImpactRight then |
395 if isImpactRight then |
402 begin |
396 x:= rightX - dist2surf |
403 x := rightX - dist2surf;; |
|
404 splash^.Angle:= -90; |
|
405 end |
|
406 else |
397 else |
407 begin |
398 x:= leftX + dist2surf; |
408 x := leftX + dist2surf;; |
|
409 splash^.Angle:= 90; |
|
410 end; |
|
411 splash^.X:= x; |
|
412 speed:= hwAbs(Gear^.dX); |
399 speed:= hwAbs(Gear^.dX); |
413 vs:= abs(hwFloat2Float(Gear^.dY)); |
400 end; |
414 end; |
|
415 |
|
416 vi:= hwFloat2Float(speed); |
|
417 |
401 |
418 // splash sound |
402 // splash sound |
419 |
403 |
420 if justSkipping then |
404 if justSkipping then |
421 PlaySound(sndSkip) |
405 PlaySound(sndSkip) |
429 else if hwTmp > _0_5 then |
413 else if hwTmp > _0_5 then |
430 PlaySound(sndSkip) |
414 PlaySound(sndSkip) |
431 else |
415 else |
432 PlaySound(sndDroplet2); |
416 PlaySound(sndDroplet2); |
433 end; |
417 end; |
|
418 |
|
419 |
|
420 // splash visuals |
|
421 |
|
422 if ((cReducedQuality and rqPlainSplash) <> 0) then |
|
423 exit; |
|
424 |
|
425 splash:= AddVisualGear(x, y, vgtSplash); |
|
426 if splash = nil then |
|
427 exit; |
|
428 |
|
429 if not isImpactH then |
|
430 vs:= abs(hwFloat2Float(Gear^.dX)) |
|
431 else |
|
432 begin |
|
433 if isImpactRight then |
|
434 splash^.Angle:= -90 |
|
435 else |
|
436 splash^.Angle:= 90; |
|
437 vs:= abs(hwFloat2Float(Gear^.dY)); |
|
438 end; |
|
439 |
|
440 |
|
441 vi:= hwFloat2Float(speed); |
434 |
442 |
435 with splash^ do |
443 with splash^ do |
436 begin |
444 begin |
437 Scale:= abs(hwFloat2Float(Gear^.Density / _3 * speed)); |
445 Scale:= abs(hwFloat2Float(Gear^.Density / _3 * speed)); |
438 if Scale > 1 then Scale:= power(Scale,0.3333) |
446 if Scale > 1 then Scale:= power(Scale,0.3333) |
594 AddCaption(FormatA(GetEventString(eidDrowned), s), cWhiteColor, capgrpMessage); |
602 AddCaption(FormatA(GetEventString(eidDrowned), s), cWhiteColor, capgrpMessage); |
595 end |
603 end |
596 end |
604 end |
597 else |
605 else |
598 DrownGear(Gear); |
606 DrownGear(Gear); |
599 if (dist2Water < -1) or (Gear^.Kind = gtFlake) then |
607 if Gear^.Kind = gtFlake then |
600 exit(true); // skip splashes |
608 exit(true); // skip splashes |
601 end |
609 end |
602 else // submersible |
610 else // submersible |
603 begin |
611 begin |
604 // drown submersible grears if far below map |
612 // drown submersible grears if far below map |
627 begin |
635 begin |
628 tmp:= hwRound(Gear^.Y - Gear^.dY); |
636 tmp:= hwRound(Gear^.Y - Gear^.dY); |
629 tmp:= abs(cWaterLine - tmp); |
637 tmp:= abs(cWaterLine - tmp); |
630 end; |
638 end; |
631 |
639 |
632 // there was an impact if distance was same as radius |
640 // there was an impact if distance was >= radius |
633 isImpact:= (tmp = Gear^.Radius) |
641 isImpact:= (tmp >= Gear^.Radius) |
634 end; |
642 end; |
635 end; // end of submersible |
643 end; // end of submersible |
636 end; // end of not skipping |
644 end; // end of not skipping |
637 |
645 |
638 // splash sound animation and droplets |
646 // splash sound animation and droplets |