2011-07-04 19:52:53 +00:00
unit Unit5;
{$MODE Delphi}
interface
uses
LCLIntf, Messages, SysUtils, Classes, Graphics, Controls, Forms,
2021-03-26 00:10:44 +01:00
Dialogs, StdCtrls, ExtCtrls, ComCtrls, math, Buttons, LResources, betterControls;
2011-07-04 19:52:53 +00:00
type
TForm5 = class( TForm)
Memo1: TMemo;
Button2: TButton;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Timer1: TTimer;
Label3: TLabel;
Label4: TLabel;
Button3: TButton;
Label5: TLabel;
Label6: TLabel;
SpeedButton1: TSpeedButton;
procedure Button2Click( Sender: TObject) ;
procedure FormCreate( Sender: TObject) ;
procedure Button1Click( Sender: TObject) ;
procedure Timer1Timer( Sender: TObject) ;
procedure Button3Click( Sender: TObject) ;
procedure FormClose( Sender: TObject; var Action: TCloseAction) ;
procedure FormCloseQuery( Sender: TObject; var CanClose: Boolean ) ;
procedure SpeedButton1Click( Sender: TObject) ;
private
{ Private declarations }
health: single ;
ammo: double ;
public
{ Public declarations }
end ;
var
Form5: TForm5;
implementation
2021-11-22 21:15:37 +01:00
uses Unit4, Unit6, frmHelpUnit, cetranslator;
2011-07-04 19:52:53 +00:00
2012-01-04 10:31:22 +00:00
resourcestring
rsStep4FloatingPointsPW = 'Step 4: Floating points (PW=' ;
rsOutOfAmmo = 'Out of ammo!%sPress ok to stock up on some ammo' ;
2012-05-19 13:36:23 +00:00
rsDead = 'I think you' 're dead!%sPress ok to become a brain eating zombie' ;
2012-01-04 10:31:22 +00:00
rsConfirmClose5 = 'Come on. This step is simple. For health do a float scan, and for ammo a double type. (don' 't forget to disable fastscan for double in '
+ 'this case) Just ignore the fact that it looks different because it has a "." in the value. You sure you want to quit?' ;
2015-12-24 19:26:48 +01:00
rsLOSER = 'BOO' ;
2012-01-04 10:31:22 +00:00
rsTutorialStep4=
'In the previous tutorial we used bytes to scan, but some games store information in so called ' 'floating point' ' notations. ' + #13 #10 +
'(probably to prevent simple memory scanners from finding it the easy way)' + #13 #10 +
'a floating point is a value with some digits behind the point. (like 5.12 or 11321.1)' + #13 #10 +
'' + #13 #10 +
2014-06-02 02:27:46 +00:00
'Below you see your health and ammo. Both are stored as Floating point notations, but health is stored as a float and ' +
2012-01-04 10:31:22 +00:00
'ammo is stored as a double.' + #13 #10 +
'Click on hit me to lose some health, and on shoot to decrease your ammo with 0.5' + #13 #10 +
' ' + #13 #10 +
'You have to set BOTH values to 5000 or higher to proceed.' + #13 #10 +
'' + #13 #10 +
'Exact value scan will work fine here, but you may want to experiment with other types too.' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'' + #13 #10 +
'Hint: It is recommended to disable "Fast Scan" for type double' ;
2011-07-04 19:52:53 +00:00
procedure TForm5. Button2Click( Sender: TObject) ;
begin
hide;
form6: = tform6. create( self) ;
2014-06-02 02:27:46 +00:00
form6. width: = width;
form6. height: = height;
form6. left: = left;
form6. top: = top;
2011-07-04 19:52:53 +00:00
form6. show;
end ;
procedure TForm5. FormCreate( Sender: TObject) ;
begin
health: = 100.0 ;
ammo: = 100.0 ;
2021-11-22 21:15:37 +01:00
caption: = altnamer( caption) ;
memo1. lines. text : = altnamer( rsTutorialStep4) ;
2012-01-04 10:31:22 +00:00
memo1. Lines. Insert( 0 , rsStep4FloatingPointsPW+ inttostr( 8 9 0 1 2 4 ) + ')' ) ;
2011-07-04 19:52:53 +00:00
memo1. SelStart: = 0 ;
2016-09-05 21:17:11 +02:00
font. size: = 1 2 ;
2019-07-19 11:36:12 +02:00
frmHelp. attach( self, '4' ) ;
2011-07-04 19:52:53 +00:00
end ;
procedure TForm5. Button1Click( Sender: TObject) ;
var temp: double ;
i: integer ;
begin
i: = 1 + random( 1 0 ) ;
if i= 0 then i: = 1 ;
temp: = 0.5 ;
ammo: = ammo- temp;
label1. caption: = FloatToStrF( ammo, ffGeneral, 4 , 4 ) ;
application. ProcessMessages;
if ammo< = 0 then
begin
2012-01-04 10:31:22 +00:00
showmessage( Format( rsOutOfAmmo, [ #13 #10 ] ) ) ;
2011-07-04 19:52:53 +00:00
ammo: = 1 0 0 ;
label1. caption: = FloatToStrF( ammo, ffGeneral, 4 , 4 ) ;
end ;
end ;
procedure TForm5. Timer1Timer( Sender: TObject) ;
begin
if ( health> = 5 0 0 0 ) and ( ammo> = 5 0 0 0 ) then
begin
button2. Enabled: = true ;
timer1. enabled: = false ;
end ;
end ;
procedure TForm5. Button3Click( Sender: TObject) ;
var temp: single ;
i, j: integer ;
begin
i: = 1 + random( 1 0 ) ;
if i= 0 then i: = 1 ;
temp: = random( 4 ) + ( 1 + random( 1 0 ) / i) ;
health: = health- temp;
label4. caption: = FloatToStrF( health, ffGeneral, 4 , 4 ) ;
if health< = 0 then
begin
2012-01-04 10:31:22 +00:00
showmessage( Format( rsDead, [ #13 #10 ] ) ) ;
2011-07-04 19:52:53 +00:00
health: = 4 0 0 0 ;
label4. caption: = FloatToStrF( health, ffGeneral, 4 , 4 ) ;
end ;
end ;
procedure TForm5. FormClose( Sender: TObject; var Action: TCloseAction) ;
begin
application. Terminate;
end ;
procedure TForm5. FormCloseQuery( Sender: TObject; var CanClose: Boolean ) ;
begin
2012-01-04 10:31:22 +00:00
canclose: = MessageDlg( rsConfirmClose5, mtconfirmation, [ mbyes, mbno] , 0 ) = mryes;
2011-07-04 19:52:53 +00:00
end ;
procedure TForm5. SpeedButton1Click( Sender: TObject) ;
begin
2012-01-04 10:31:22 +00:00
showmessage( rsLOSER) ;
2011-07-04 19:52:53 +00:00
button2. Click;
end ;
initialization
{$i Unit5.lrs}
{$i Unit5.lrs}
end .