Unit EngineUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, TPlayerUnit, TmonsterUnit, TRoamingMonsterUnit; Var Player : TPlayer; Monsters : Array [0..15] Of TMonster; RoamingMonster : TRoamingMonster; SpriteBufferY, Level2GrabY, Level2GrabX, SpriteBufferX, Backimage1, backimage2, backimage3 : TBitmap; SpriteBufferXRect : TRect; MonsterCount : Integer; PeopleCount : Integer; People : Array [1..15] Of TMonster; SpriteBlendingType : Integer; TSpriteFileType : Record NumberOfMasksLine : Integer; End; ClearMonsterBMP : TBitmap; ShowingText : Boolean; BloodMonster : TMonster; Procedure InitMonsters; Procedure DoMonsters; Procedure DoPeople; Procedure DoRoamMonster; Implementation Uses Unit1; Procedure InitMonsters; Var loop, loop2 : Integer; Begin RoamingMonster := TRoamingMonster.Create; ClearMonsterBMP := TBitmap.Create; ClearMonsterBMP.PixelFormat := pf24bit; ClearMonsterBMP.Width := 40; ClearMonsterBMP.Height := 40; MonsterCount := 0; PeopleCount := 0; TSpriteFileType.NumberOfMasksLine := 1; Level2GrabX := TBitmap.Create; Level2GrabX.Width := 45; Level2GrabX.Height := 40; Level2GrabX.PixelFormat := pf24bit; Level2GrabX.TransparentColor := rgb(1, 0, 1); Level2GrabX.Transparent := True; Level2GrabY := TBitmap.Create; Level2GrabY.Width := 40; Level2GrabY.Height := 45; Level2GrabY.PixelFormat := pf24bit; Level2GrabY.TransparentColor := rgb(1, 0, 1); Level2GrabY.Transparent := True; SpriteBufferX := TBitmap.Create; SpriteBufferX.Width := 40; SpriteBufferX.Height := 40; SpriteBufferXRect := rect(0, 0, 40, 40); SpriteBufferX.PixelFormat := pf24bit; SpriteBufferY := TBitmap.Create; SpriteBufferY.Width := 40; SpriteBufferY.Height := 45; SpriteBufferY.PixelFormat := pf24bit; backimage1 := TBitmap.Create; backimage1.Width := 5; backimage1.Height := 40; backimage3 := TBitmap.Create; backimage3.Width := 5; backimage3.Height := 40; backimage2 := TBitmap.Create; backimage2.Width := 40; backimage2.Height := 5; backimage1.PixelFormat := pf24bit; backimage2.PixelFormat := pf24bit; backimage3.PixelFormat := pf24bit; For loop := 0 To 15 Do Begin Monsters[loop] := Tmonster.Create; For loop2 := 1 To 8 Do Monsters[loop].FrameImage[loop2] := TBitmap.Create; For loop2 := 1 To 8 Do Monsters[loop].FrameImage[loop2].PixelFormat := pf24bit; Monsters[loop].StonedFrame := TBitmap.Create; Monsters[loop].StonedFrame.PixelFormat := pf24bit; Monsters[loop].StonedFrame.TransparentColor := rgb(5, 255, 255); Monsters[loop].StonedFrame.Transparent := True; Monsters[loop].StonedFrame.Width := 40; Monsters[loop].StonedFrame.Height := 40; Monsters[loop].Stoned := False; End; BloodMonster := Tmonster.Create; For loop2 := 1 To 8 Do BloodMonster.FrameImage[loop2] := TBitmap.Create; For loop2 := 1 To 8 Do BloodMonster.FrameImage[loop2].PixelFormat := pf24bit; BloodMonster.StonedFrame := TBitmap.Create; BloodMonster.StonedFrame.PixelFormat := pf24bit; BloodMonster.StonedFrame.TransparentColor := rgb(5, 255, 255); BloodMonster.StonedFrame.Transparent := True; BloodMonster.StonedFrame.Width := 40; BloodMonster.StonedFrame.Height := 40; BloodMonster.Stoned := False; For loop := 1 To 15 Do Begin People[loop] := Tmonster.Create; For loop2 := 1 To 8 Do People[loop].FrameImage[loop2] := TBitmap.Create; For loop2 := 1 To 8 Do People[loop].FrameImage[loop2].PixelFormat := pf24bit; People[loop].WhoIAm := loop; People[loop].Walking := True; End; RoamingMonster.Active := False; RoamingMonster.MonsterType := 'helldemon'; RoamingMonster.ChanceToSpawn := 1000000; For loop2 := 1 To 8 Do RoamingMonster.FrameImage[loop2] := TBitmap.Create; For loop2 := 1 To 8 Do RoamingMonster.FrameImage[loop2].PixelFormat := pf24bit; End; Procedure DoMonsters; Var Loop : Integer; Begin For loop := 1 To MonsterCount Do Begin If (Not monsters[loop].Hit) And (Monsters[loop].Life > 0) Then Monsters[loop].AI(Monsters[loop]) Else If monsters[loop].life > 0 Then monsters[loop].GetHit(Monsters[loop].hittype); End; If player.STRExp + Player.MagExp + Player.WisExp >= player.NextExp Then Begin End; End; Procedure DoRoamMonster; Begin If Not RoamingMonster.Active Then Begin If (random(roamingmonster.ChanceToSpawn) = 0) And (random(roamingmonster.ChanceToSpawn) = 0) Then Begin RoamingMonster.WhoIAm := -69; RoamingMonster.LoadMonster('Sprites\' + Roamingmonster.MonsterType + '.mon'); Roamingmonster.Active := True; RoamingMonster.Delay := 0; RoamingMonster.WalkAroundObject := 0; RoamingMonster.HitFlash := 0; RoamingMonster.FrameCount := 1; RoamingMonster.Life := 5 * Player.Level; RoamingMonster.def := 2 * Player.Level; RoamingMonster.Atk := 3 * (Player.Level * 2 - 1); End; End Else Begin If RoamingMonster.Delay > 0 Then dec(RoamingMonster.Delay) Else Begin If roamingmonster.FrameCount = 1 Then roamingmonster.FrameCount := 2 Else roamingmonster.FrameCount := 1; If (Not Roamingmonster.Hit) And (Roamingmonster.Life > 0) Then Begin RoamingMonster.Erase(Form1.DXDraw1.Surface.Canvas); roamingmonster.AI(RoamingMonster); Case roamingmonster.Direction Of 1 : roamingmonster.Moveup; 2 : roamingmonster.MoveRight; 3 : roamingmonster.MoveDown; 4 : roamingmonster.MoveLeft; End; End Else If Roamingmonster.life > 0 Then Roamingmonster.GetHit(Roamingmonster.hittype); End; End; End; Procedure DoPeople; Var Loop : Integer; Begin For loop := 1 To PeopleCount Do If people[loop].Walking Then People[loop].AI(People[Loop]) Else Case People[loop].Direction Of 1 : People[loop].SpriteUp; 2 : People[loop].SpriteUp; 3 : People[loop].SpriteUp; 4 : People[loop].SpriteUp; End; End; End. Unit TileUnit; Interface Uses SysUtils, Windows, Graphics, GraphicFX, Classes, dialogs, TMonsterUnit, TAreaNameUnit, INIUnit, TSpeakUnit; Type THyperLinks = Record MapX, MapY : Integer; Area : TRect; LeadsTo : String; TargetMapX, TargetMapY : Integer; InTargetX, InTargetY, InTargetDirection : Integer; Movie : String; End; TAnimatedTile = Record X, Y : Integer; Number_Of_Frames : Integer; Frames : Array Of TBitmap; StepsPerFrame : Integer; Steps : Integer; Frame : Integer; EbbFlow : Boolean; End; TRooms = Record Name : String; Monsters : Integer; MonsterTimer : Integer; BloodArray : Array Of TPoint; End; TMap = Record Name : String; MagicBonus, LifeBonus : Integer; Width, Height : Integer; TileSet : String; BKOs : Array Of String; Rooms : Array Of Array Of TRooms; NumberOfHyperLinks : Integer; HyperLinks : Array Of THyperLinks; End; TBKO = Record X, Y, Image : Integer; End; TRoomInfo = Record CanAttack : Boolean; Lighting : Array[1..4] Of Integer; Level1 : Array [0..15, 0..9] Of Integer; Level2 : Array [0..37, 0..33] Of Byte; BKOs : Array Of TBKO; NumberofBKOs : Integer; Number_of_Animated_Tile : Integer; AnimatedTiles : Array Of TAnimatedTile; Closed : Boolean; LightMap : TBitmap; LightMapOn : Boolean; Name : String; End; Var TileArray, Tile2Array, BackgroundObjectsArray : Array Of TBitmap; BackgroundObjectsLoaded, TileCount, Tile2Count, AnimatedTileCount, AnimatedTimer, AnimatedFrameCount, AnimatedDirection : Integer; Level2Buffer, RoomBuffer, TempTile : TBitmap; CurrentRoom : TRoomInfo; AnimatedSwap, BackGroundBlendingType, SwapBackground : Integer; Level2Enabled, ShowName : Boolean; CurrentMap : Tmap; BeginEvent, ShowingEvent : Boolean; EventInRoom : TSpeak; AreaName : TAreaName; Procedure AddBKO(X, Y, Number : Integer); Procedure LoadRoom(RoomName : String); Procedure ShowAnimatedTiles; Procedure InitTiles; Procedure LoadAnimatedTile(Filename : String; X, Y : Integer); Procedure LoadBackgroundObject(Filename : String); Procedure ShowAllAnimatedTiles; Procedure LoadBMPasRoom(Name : String); Procedure ShowLevel1Tiles(OverAllLight, ShadowLevel, SourceX, SourceY : Integer); Procedure ShowLevel2Tiles(OverAllLight, ShadowLevel, SourceX, SourceY : Integer); Procedure ReleaseRoom; Procedure LoadMap(MapName : String); Procedure LoadBigTile(Filename : String); Implementation Uses unit1, EngineUnit, TPlayerUnit, EventUnit, MusicUnit, bass, MoveToUnit; Function ExtractHyperLink(AString : String) : THyperLinks; Var X, Y, X2, Y2 : Integer; Count : Integer; Begin Result.MapX := StrToInt(Copy(AString, 1, 2)); Result.MapY := StrToInt(Copy(AString, 4, 2)); X := StrToInt(Copy(AString, 7, 3)); Y := StrToInt(Copy(AString, 11, 3)); X2 := StrToInt(Copy(AString, 15, 3)); Y2 := StrToInt(Copy(AString, 19, 3)); Result.Area := rect(x, y, x2, y2); Result.TargetMapX := StrToInt(Copy(AString, 23, 2)); Result.TargetMapY := StrToInt(Copy(AString, 26, 2)); Result.InTargetX := StrToInt(Copy(AString, 29, 3)); Result.InTargetY := StrToInt(Copy(AString, 33, 3)); Result.InTargetDirection := StrToInt(Copy(AString, 37, 1)); Count := 38; Repeat inc(Count); Until (AString[Count] = '-') Or (Count = length(AString)); Result.LeadsTo := Copy(AString, 39, Count - 39); Result.Movie := copy(AString, Count + 1, length(AString) - Count); End; Procedure Send(Data : String); Begin MessageDlg(Data, mtInformation, [mbOK], 0); End; Procedure Releaseroom; Var loop, loop2 : Integer; Begin If CurrentRoom.Number_of_Animated_Tile > 0 Then For loop := 0 To CurrentRoom.Number_Of_Animated_Tile - 1 Do For loop2 := 0 To 2 Do Begin CurrentRoom.AnimatedTiles[loop].Frames[loop2].FreeImage; CurrentRoom.AnimatedTiles[loop].Frames[loop2].Free; End; End; Procedure AddBKO(x, y, Number : Integer); Begin Inc(CurrentRoom.NumberofBKOs); setlength(Currentroom.bkos, CurrentRoom.NumberofBKOs); CurrentRoom.BKOs[CurrentRoom.NumberofBKOs - 1].X := x; CurrentRoom.BKOs[CurrentRoom.NumberofBKOs - 1].y := y; CurrentRoom.BKOs[CurrentRoom.NumberofBKOs - 1].Image := Number; End; Procedure LoadBMPasRoom(Name : String); Begin RoomBuffer.LoadFromFile(Name); End; Procedure LoadAnimatedTile(Filename : String; X, Y : Integer); Var loop, loop2 : Integer; LightX, LightY : Integer; TotalLight : Integer; Begin Form1.Spritememo.Lines.LoadFromFile(Filename); Inc(CurrentRoom.Number_of_Animated_Tile); setlength(Currentroom.AnimatedTiles, CurrentRoom.Number_of_Animated_Tile); Setlength(Currentroom.animatedtiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames, StrToInt(form1.Spritememo.Lines[0])); Currentroom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].StepsPerFrame := StrToInt(form1.SpriteMemo.Lines[1]); LightX := CurrentRoom.Lighting[3] - x; If LightX < 0 Then LightX := 0 - LightX; Lighty := CurrentRoom.Lighting[4] - y; If Lighty < 0 Then Lighty := 0 - Lighty; LightX := LightX + LightY; TotalLight := CurrentRoom.Lighting[1] - LightX * Currentroom.Lighting[2]; For loop := 0 To StrToInt(form1.Spritememo.Lines[0]) - 1 Do Begin CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop] := TBitmap.Create; CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop].LoadFromFile(ExtractFilePath(filename) + IntToStr(loop + 1) + '.bmp'); CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop].PixelFormat := pf24bit; If TotalLight > 0 Then Lighten(CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop], TotalLight) Else Darken(CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop], 0 - TotalLight); If ShowScanlines Then Scanlines(CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop], 1); If AnimatedSwap > 0 Then For loop2 := 1 To AnimatedSwap Do Swapcolors(CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop]); {Blur(CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Frames[loop],0); } {grayscale(currentroom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile-1].Frames[loop]); } End; CurrentRoom.AnimatedTiles[CurrentRoom.Number_of_Animated_Tile - 1].Number_Of_Frames := StrToInt(form1.Spritememo.Lines[0]); End; Function StripTextOfSimiColons(Instring : String) : TTextStrings; Var Counter, LastCounter : Integer; Tempstrings : TTextStrings; Begin Counter := 0; Repeat Setlength(Tempstrings, length(tempstrings) + 1); LastCounter := Counter; Repeat Inc(Counter); Until (instring[counter] = ';') Or (Counter = length(Instring)); Tempstrings[Length(TempStrings) - 1] := copy(InString, LastCounter + 1, counter - lastcounter - 1); Until counter = length(Instring); StripTextOfSimiColons := Tempstrings; End; Procedure StripEventText(StringIn : String); Var Tempstr : String; Index, LastIndex : Integer; Begin TempStr := StringIn; EventinRoom.NumberOfEvents := 0; LastIndex := 0; Index := 0; EventinRoom.NumberOfLines := 0; While Index < length(Tempstr) Do Begin Repeat Inc(Index); Until (Index = length(Tempstr)) Or (tempstr[index] = ';'); Inc(EventinRoom.NumberOfLines); setlength(EventinRoom.Lines, EventinRoom.NumberOfLines); EventinRoom.Lines[EventinRoom.NumberOfLines - 1] := copy(StringIn, LastIndex + 1, Index - lastindex); If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#AddEvent:'))) = '#addevent:' Then Begin inc(EventinRoom.NumberOfEvents); SetLength(EventinRoom.TriggerEvents, EventinRoom.NumberOfEvents); EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].AddEvent := True; EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].EventName := copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], length('#AddEvent: '), length(EventinRoom.Lines[EventinRoom.NumberOfLines - 1]) - length('#AddEvent: ')); Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#ClosedRoom:'))) = '#closedroom:' Then Begin CurrentRoom.Closed := True; Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#ShowMovie:'))) = '#showmovie:' Then Begin Form1.ShowMovie( //ShowMessage( copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], length('#ShowMovie: '), length(EventinRoom.Lines[EventinRoom.NumberOfLines - 1]) - length('#ShowMovie: '))); Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#SetEvent:'))) = '#setevent:' Then Begin inc(EventinRoom.NumberOfEvents); SetLength(EventinRoom.TriggerEvents, EventinRoom.NumberOfEvents); EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].AddEvent := False; EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].EventName := copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], length('#SetEvent: '), length(EventinRoom.Lines[EventinRoom.NumberOfLines - 1]) - length('#SetEvent: ')); Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#SetclosedRoomEvent:'))) = '#setclosedroomevent:' Then Begin inc(EventinRoom.NumberOfEvents); SetLength(EventinRoom.TriggerEvents, EventinRoom.NumberOfEvents); EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].AddEvent := False; EventInRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].OnRoomClosed := True; EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].EventName := copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], length('#setclosedroomevent: '), length(EventinRoom.Lines[EventinRoom.NumberOfLines - 1]) - length('#setclosedroomevent: ')); Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], 1, length('#EventLevel:'))) = '#eventlevel:' Then Begin EventinRoom.TriggerEvents[EventinRoom.NumberOfEvents - 1].EventLevel := StrToInt(copy(EventinRoom.Lines[EventinRoom.NumberOfLines - 1], length('#EventLevel: '), length(EventinRoom.Lines[EventinRoom.NumberOfLines - 1]) - length('#EventLevel: '))); Dec(EventinRoom.NumberOfLines); End; LastIndex := index; End; End; Procedure LoadRoom(RoomName : String); Var Loop, Loop2, TempX, TempY, AnimatedTileCount, MonsterCountX : Integer; RoomEvent : String; Begin If MoveTo.Enabled Then Moveto.RemoveItem; CurrentRoom.Name := roomname; AnimatedTileCount := 0; form1.MainGameTimer.Enabled := False; RoamingMonster.X := player.X; RoamingMonster.Y := Player.Y; RoamingMonster.Direction := Player.Direction; ChDir(ExtractFilePath(ParamStr(0))); If fileexists(Roomname + '.event') Then Begin form1.LoadMemo.Lines.LoadFromFile(Roomname + '.event'); If form1.LoadMemo.Lines.Count = 2 Then Begin If eventlog.EventLevel(form1.LoadMemo.Lines[0]) < StrToInt(form1.LoadMemo.Lines[0 + 1]) Then EventLog.SetEvent(form1.LoadMemo.Lines[0], StrToInt(form1.LoadMemo.Lines[0 + 1])); End Else For loop := 0 To (form1.LoadMemo.Lines.Count Div 2) - 1 Do If eventlog.EventLevel(form1.LoadMemo.Lines[Loop * 2]) < StrToInt(form1.LoadMemo.Lines[Loop * 2 + 1]) Then EventLog.SetEvent(form1.LoadMemo.Lines[Loop * 2], StrToInt(form1.LoadMemo.Lines[Loop * 2 + 1])); End; ChDir(ExtractFilePath(ParamStr(0))); If FileExists(Roomname + '.eventmap') Then Begin form1.LoadMemo.Lines.LoadFromFile(Roomname + '.eventmap'); RoomEvent := form1.LoadMemo.Lines[0]; End Else roomevent := '-1'; If fileexists(Roomname + '.LoadEvent') Then Begin form1.LoadMemo.Lines.LoadFromFile(Roomname + '.LoadEvent'); For loop := 0 To form1.LoadMemo.Lines.Count - 1 Do eventlog.AddEvent(form1.LoadMemo.Lines[loop]); End; If FileExists(roomname + '.light') Then Begin CurrentRoom.LightMap.LoadFromFile(roomname + '.light'); CurrentRoom.LightMapOn := True; CurrentRoom.LightMap.PixelFormat := pf24bit; End Else CurrentRoom.LightMapOn := False; For loop := 1 To 15 Do monsters[loop].HitFlash := 0; If Not FileExists(roomname) Then Begin form1.MainGameTimer.Enabled := False; Messagedlg('Sorry, you wondered into a room that wasn''t desiged yet.', mtWarning, [mbOK], 0); exit; End Else Begin CurrentRoom.Number_of_Animated_Tile := 0; setlength(Currentroom.animatedtiles, 0); For loop2 := 0 To currentmap.Height - 1 Do For loop := 0 To currentmap.Width - 1 Do If currentmap.Rooms[loop, loop2].MonsterTimer > 0 Then dec(currentmap.Rooms[loop, loop2].MonsterTimer); If currentmap.Rooms[player.MapX, player.mapy].MonsterTimer = 0 Then currentmap.Rooms[player.MapX, player.MapY].Monsters := -1; CurrentRoom.Number_of_Animated_Tile := 0; Setlength(CurrentRoom.BKOs, 0); CurrentRoom.NumberofBKOs := 0; ChDir(ExtractFilePath(ParamStr(0))); If RoomEvent = '-1' Then form1.LoadMemo.Lines.LoadFromFile(RoomName) Else Begin form1.LoadMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room'); // MessageDlg(IntToStr(EventLog.EventLevel(roomevent)) + '.room '+roomevent,mtWarning,[mbok],0); End; CurrentRoom.Lighting[1] := StrToInt(copy(form1.LoadMemo.Lines[0], length('Room Light: '), 3)); CurrentRoom.Lighting[2] := StrToInt(copy(form1.LoadMemo.Lines[0], length('Room Light: 000- '), 2)); CurrentRoom.Lighting[3] := StrToInt(copy(form1.LoadMemo.Lines[0], length('Room Light: 000- '), 2)); CurrentRoom.Lighting[4] := StrToInt(copy(form1.LoadMemo.Lines[0], length('Ro om Light: 000- '), 2)); If lowercase(form1.LoadMemo.Lines[form1.LoadMemo.Lines.Count - 1]) = 'no monsters' Then Currentroom.CanAttack := False Else currentroom.CanAttack := True; If morphed Then CurrentRoom.CanAttack := Not CurrentRoom.CanAttack; For loop2 := 0 To 9 Do For loop := 0 To 15 Do CurrentRoom.Level1[loop, Loop2] := StrToInt(Copy(form1.LoadMemo.Lines[2 + Loop2], Loop * 4 + 1, 3)); For loop2 := 0 To 9 Do For loop := 0 To 15 Do CurrentRoom.Level2[loop, Loop2] := StrToInt(Copy(form1.LoadMemo.Lines[13 + Loop2], Loop * 3 + 1, 2)); (***********************) Level2enabled := False; Level2Buffer.Canvas.Brush.Color := rgb(0, 0, 0); Level2Buffer.Canvas.FillRect(rect(0, 0, 640, 400)); (***********************) If StrToInt(form1.LoadMemo.Lines[24]) > 0 Then For loop := 0 To StrToInt(form1.LoadMemo.Lines[24]) - 1 Do AddBKO(StrToInt(Copy(form1.LoadMemo.Lines[25 + Loop], 1, 3)), StrToInt(Copy(form1.LoadMemo.Lines[25 + Loop], 5, 3)), StrToInt(Copy(form1.LoadMemo.Lines[25 + Loop], 9, 2))); If animatedtilecount > 0 Then For loop := 0 To animatedtilecount - 1 Do For loop2 := 0 To 2 Do currentroom.AnimatedTiles[loop].Frames[loop2].FreeImage; AnimatedTileCount := StrToInt(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 26]); If StrToInt(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 26]) > 0 Then For loop := 0 To AnimatedTileCount - 1 Do Begin Tempx := StrToInt(copy(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 27 + Loop], 1, 3)); Tempy := StrToInt(copy(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 27 + Loop], 5, 3)); LoadAnimatedTile('tile sets\Animated\' + copy(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 27 + Loop], 12, 5) + '\' + copy(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 27 + Loop], 12, 5) + '.ani', Tempx Div 40, TempY Div 40); CurrentRoom.AnimatedTiles[loop].X := Tempx; CurrentRoom.AnimatedTiles[loop].Y := Tempy; CurrentRoom.AnimatedTiles[loop].Steps := StrToInt(copy(form1.LoadMemo.Lines[StrToInt(form1.LoadMemo.Lines[24]) + 27 + Loop], 9, 2)); CurrentRoom.AnimatedTiles[loop].Frame := 0; CurrentRoom.AnimatedTiles[loop].EbbFlow := True; End; MonsterCount := 0; PeopleCount := 0; MonsterCountx := StrToInt(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28]); For loop := 1 To MonsterCountx Do Begin If CurrentRoom.CanAttack Then Begin Monsters[loop].LoadMonster('Sprites\' + copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 9, length(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop]) - 8) + '.mon'); Monsters[loop].X := StrToInt(copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 1, 3)); Monsters[loop].Y := StrToInt(copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 5, 3)); End Else Begin People[loop].Loadperson('Sprites\' + copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 9, length(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop]) - 8) + '.per'); People[loop].X := StrToInt(copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 1, 3)); People[loop].Y := StrToInt(copy(form1.LoadMemo.Lines[AnimatedTileCount + StrToInt(form1.LoadMemo.Lines[24]) + 28 + Loop], 5, 3)); If fileexists(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.RoomText.txt') Then form1.SpriteMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.RoomText.txt') Else If fileexists(ExtractFilePath(roomname) + '1.txt') Then form1.SpriteMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + '1.txt') Else Form1.SpriteMemo.Lines.LoadFromFile('Maps\' + CurrentMap.Name + '\Text.txt'); For loop2 := 1 To 3 Do People[loop].StripText(Form1.SpriteMemo.Lines[random(Form1.SpriteMemo.Lines.Count)], loop2); If fileexists(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.AssignText.txt') Or FileExists(Roomname + '.AssignText.txt') Then Begin If roomevent = '-1' Then Form1.SpriteMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + '1.room.AssignText.txt') Else Form1.SpriteMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.AssignText.txt'); For loop2 := 0 To form1.SpriteMemo.Lines.Count - 1 Do Begin People[StrToInt(copy(Form1.SpriteMemo.Lines[loop2], 1, 1))].StripText(copy(Form1.SpriteMemo.Lines[Loop2], 2, length(Form1.SpriteMemo.Lines[Loop2]) - 1), 1); People[StrToInt(copy(Form1.SpriteMemo.Lines[loop2], 1, 1))].StripText(copy(Form1.SpriteMemo.Lines[Loop2], 2, length(Form1.SpriteMemo.Lines[Loop2]) - 1), 2); People[StrToInt(copy(Form1.SpriteMemo.Lines[loop2], 1, 1))].StripText(copy(Form1.SpriteMemo.Lines[Loop2], 2, length(Form1.SpriteMemo.Lines[Loop2]) - 1), 3); End; End; End; End; End; If currentmap.Rooms[Player.MapX, player.MapY].Monsters >= 0 Then Begin MonsterCount := currentmap.Rooms[Player.MapX, player.MapY].Monsters; End; If CurrentRoom.Closed Then Begin If RoomEvent = '-1' Then Begin If FileExists(RoomName + '.script') Then Begin BeginEvent := False; Form1.LoadMemo.Lines.LoadFromFile(RoomName + '.script'); StripEventText(form1.LoadMemo.Lines[0]); ShowingEvent := True; form1.MainGameTimer.OnTimer := form1.ShowEvent; EventCounter := 0; TextSpeed := 20; End; End Else Begin If FileExists(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.script') Then Begin BeginEvent := False; form1.LoadMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.script'); StripEventText(form1.LoadMemo.Lines[0]); ShowingEvent := True; form1.MainGameTimer.OnTimer := form1.ShowEvent; EventCounter := 0; TextSpeed := 20; End; End; End Else If RoomEvent = '-1' Then Begin If FileExists(RoomName + '.script') Then Begin BeginEvent := False; Form1.LoadMemo.Lines.LoadFromFile(RoomName + '.script'); StripEventText(form1.LoadMemo.Lines[0]); ShowingEvent := True; form1.MainGameTimer.OnTimer := form1.ShowEvent; EventCounter := 0; TextSpeed := 20; End; End Else Begin If FileExists(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.script') Then Begin BeginEvent := False; form1.LoadMemo.Lines.LoadFromFile(ExtractFilePath(roomname) + IntToStr(EventLog.EventLevel(roomevent)) + '.room.script'); StripEventText(form1.LoadMemo.Lines[0]); ShowingEvent := True; form1.MainGameTimer.OnTimer := form1.ShowEvent; EventCounter := 0; TextSpeed := 20; End; End; form1.MainGameTimer.Enabled := True; End; Procedure InitTiles; Begin BackgroundObjectsLoaded := 0; TileCount := 0; AnimatedTileCount := 0; Tile2Count := 0; AnimatedTimer := 1; AnimatedDirection := 1; TempTile := TBitmap.Create; TempTile.Width := 40; TempTile.Height := 40; TempTile.PixelFormat := pf24bit; RoomBuffer := TBitmap.Create; RoomBuffer.Width := 40 * 16; RoomBuffer.Height := 40 * 10; RoomBuffer.PixelFormat := pf24bit; Level2Buffer := TBitmap.Create; Level2Buffer.Width := 40 * 16; Level2Buffer.Height := 40 * 10; Level2Buffer.PixelFormat := pf24bit; Level2Buffer.TransparentColor := rgb(1, 0, 1); Level2Buffer.Transparent := True; Level2Buffer.Canvas.Brush.Color := rgb(1, 0, 1); Level2Buffer.Canvas.FloodFill(10, 10, rgb(4, 2, 6), fsBorder); CurrentRoom.LightMap := TBitmap.Create; End; { Procedure LoadTile(Filename: String; Tilenumber: Integer); Begin If TileNumber = TileCount Then Begin Inc(TileCount); SetLength(TileArray, TileCount); TileArray[TileNumber] := TBitmap.Create; End; TileArray[TileNumber].LoadFromFile(ExtractFilepath(ParamStr(0)) + '\' + Filename); TileArray[TileNumber].PixelFormat := pf24bit; End; Procedure Load2Tile(Filename: String; Tilenumber: Integer); Begin If TileNumber = Tile2Count - 1 Then Begin Inc(Tile2Count); SetLength(Tile2Array, Tile2Count); Tile2Array[TileNumber + 1] := TBitmap.Create; End; Tile2Array[TileNumber + 1].LoadFromFile(Filename); End; } Procedure LoadBackgroundObject(Filename : String); Begin { Inc(BackgroundObjectsLoaded);} BackgroundObjectsLoaded := 1; SetLength(BackgroundObjectsArray, BackgroundObjectsLoaded); BackgroundObjectsArray[BackgroundObjectsLoaded - 1] := TBitmap.Create; BackgroundObjectsArray[BackgroundObjectsLoaded - 1].TransparentColor := rgb(1, 0, 1); BackgroundObjectsArray[BackgroundObjectsLoaded - 1].Transparent := True; BackgroundObjectsArray[BackgroundObjectsLoaded - 1].LoadFromFile(Filename); End; Procedure ShowLevel1Tiles(OverAllLight, ShadowLevel, SourceX, SourceY : Integer); Var LocationX, LocationY, loop, Loop2, TileLight : Integer; Begin For loop := 0 To 9 Do For loop2 := 0 To 15 Do Begin Temptile.Canvas.Draw(0, 0, TileArray[CurrentRoom.level1[loop2, loop]]); LocationX := Sourcex - Loop2; If LocationX < 0 Then LocationX := 0 - LocationX; LocationY := SourceY - Loop; If LocationY < 0 Then LocationY := 0 - LocationY; TileLight := overalllight - ((LocationY + LocationX) * ShadowLevel); If TileLight > 0 Then Lighten(TempTile, TileLight) Else Darken(TempTile, 0 - TileLight); RoomBuffer.Canvas.Draw(loop2 * 40, loop * 40, TempTile); End; If CurrentRoom.NumberofBKOs > 0 Then Begin For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do RoomBuffer.Canvas.Draw(CurrentRoom.bkos[loop].x, CurrentRoom.bkos[loop].y, BackgroundObjectsArray[CurrentRoom.bkos[loop].Image]); End; If Length(currentmap.Rooms[Player.MapX, player.MapY].BloodArray) > 0 Then For loop := 0 To length(currentmap.Rooms[Player.MapX, player.MapY].BloodArray) - 1 Do Begin BloodMonster.X := currentmap.Rooms[Player.MapX, player.MapY].BloodArray[loop].x; BloodMonster.Y := currentmap.Rooms[Player.MapX, player.MapY].BloodArray[loop].Y; BloodMonster.LeaveBlood; End; If CurrentRoom.LightMapOn Then LightMap(RoomBuffer, Currentroom.LightMap, RoomBuffer); If BackGroundBlendingType = 2 Then MotionBlurLeft(RoomBuffer) Else If BackGroundBlendingType = 1 Then Blur(Roombuffer, 1); If swapbackground > 0 Then For loop := 1 To SwapBackground Do Swapcolors(roombuffer); If ShowScanlines Then Scanlines(Roombuffer, 1); { grayscale(Roombuffer); } End; Procedure ShowLevel2Tiles(OverAllLight, ShadowLevel, SourceX, SourceY : Integer); Var LocationX, LocationY, loop, Loop2, TileLight : Integer; Begin Level2Buffer.Canvas.FloodFill(10, 10, rgb(4, 2, 6), fsBorder); For Loop := 0 To 9 Do For Loop2 := 0 To 15 Do If CurrentRoom.level2[loop2, loop] > 0 Then Begin Temptile.Canvas.Draw(0, 0, Tile2Array[CurrentRoom.level2[loop2, loop]]); LocationX := Sourcex - round(Loop2); If LocationX < 0 Then LocationX := 0 - LocationX; LocationY := SourceY - round(Loop); If LocationY < 0 Then LocationY := 0 - LocationY; TileLight := overalllight - ((LocationY + LocationX) * ShadowLevel); If TileLight > 0 Then Lighten(TempTile, TileLight, IgnoreColor(1, 0, 1)) Else Darken(TempTile, 0 - TileLight, IgnoreColor(1, 0, 1)); Level2Buffer.Canvas.Draw(Loop2 * 40, Loop * 40, TempTile); End; End; Procedure ShowAnimatedTiles; Var loop : Integer; Begin If currentroom.Number_of_Animated_Tile > 0 Then For loop := 0 To CurrentRoom.Number_of_Animated_Tile - 1 Do Begin Inc(CurrentRoom.AnimatedTiles[loop].Steps); If CurrentRoom.AnimatedTiles[loop].Steps > CurrentRoom.AnimatedTiles[loop].StepsPerFrame Then Begin Form1.DXDraw1.Surface.Canvas.Draw(CurrentRoom.animatedTiles[loop].X + 16 + BorderOffset, CurrentRoom.animatedTiles[loop].y + 16 + BorderOffset, Currentroom.animatedtiles[loop].Frames[CurrentRoom.AnimatedTiles[loop].Frame]); CurrentRoom.AnimatedTiles[Loop].Steps := 0; If CurrentRoom.AnimatedTiles[loop].EbbFlow Then inc(CurrentRoom.AnimatedTiles[loop].Frame) Else inc(CurrentRoom.AnimatedTiles[loop].Frame, - 1); If CurrentRoom.AnimatedTiles[loop].Frame > CurrentRoom.AnimatedTiles[loop].Number_Of_Frames - 1 Then Begin CurrentRoom.AnimatedTiles[loop].Frame := CurrentRoom.AnimatedTiles[loop].Number_Of_Frames - 1; CurrentRoom.AnimatedTiles[loop].EbbFlow := False; End Else If CurrentRoom.AnimatedTiles[loop].Frame < 0 Then Begin CurrentRoom.AnimatedTiles[loop].Frame := 0; CurrentRoom.AnimatedTiles[loop].EbbFlow := True; End; End; End; End; Procedure ShowALLAnimatedTiles; Var loop : Integer; Begin If currentroom.Number_of_Animated_Tile > 0 Then For loop := 0 To CurrentRoom.Number_of_Animated_Tile - 1 Do Form1.DXDraw1.Surface.Canvas.Draw(CurrentRoom.animatedTiles[loop].X + 16 + BorderOffset, CurrentRoom.animatedTiles[loop].y + 16 + BorderOffset, Currentroom.animatedtiles[loop].Frames[CurrentRoom.AnimatedTiles[loop].Frame]); End; Procedure LoadBigTile(Filename : String); Var temp : TBitmap; loop, loop2 : Integer; Begin Temp := TBitmap.Create; Temp.LoadFromFile('tile sets\' + Filename + '\tile.set'); TileCount := (temp.Width Div 40) * (temp.Height Div 40); SetLength(Tilearray, tilecount); For loop2 := 0 To (temp.Height Div 40) - 1 Do For loop := 0 To (temp.Width Div 40) - 1 Do Begin TileArray[loop + (loop2 * (temp.Width Div 40))] := TBitmap.Create; TileArray[loop + (loop2 * (temp.Width Div 40))].Width := 40; TileArray[loop + (loop2 * (temp.Width Div 40))].Height := 40; TileArray[loop + (loop2 * (temp.Width Div 40))].PixelFormat := pf24bit; tilearray[loop + (loop2 * (temp.Width Div 40))].Canvas.CopyRect(rect(0, 0, 40, 40), temp.Canvas, rect(loop * 40, loop2 * 40, (loop + 1) * 40, (Loop2 + 1) * 40)); End; temp.freeimage; temp.Free; End; Procedure LoadBigLevel2Tile(Filename : String); Var temp : TBitmap; loop, loop2 : Integer; Begin Temp := TBitmap.Create; Temp.LoadFromFile('tile sets\' + Filename + '\tile2.set'); Tile2Count := (temp.Width Div 40) * (temp.Height Div 40); SetLength(tile2array, tile2count); For loop2 := 0 To (temp.Height Div 40) - 1 Do For loop := 0 To (temp.Width Div 40) - 1 Do Begin tile2Array[loop + (loop2 * (temp.Width Div 40))] := TBitmap.Create; tile2Array[loop + (loop2 * (temp.Width Div 40))].Width := 40; tile2Array[loop + (loop2 * (temp.Width Div 40))].Height := 40; tile2Array[loop + (loop2 * (temp.Width Div 40))].PixelFormat := pf24bit; tile2array[loop + (loop2 * (temp.Width Div 40))].Canvas.CopyRect(rect(0, 0, 40, 40), temp.Canvas, rect(loop * 40, loop2 * 40, (loop + 1) * 40, (Loop2 + 1) * 40)); End; temp.freeimage; temp.Free; End; Procedure LoadMap(MapName : String); Var loop, loop2 : Integer; path : String; HyperLinksLine : Integer; Begin If fullscreen Then Form1.DXDraw1.Surface.Canvas.Rectangle(0, 0, 640, 400) Else Form1.DXDraw1.Surface.Canvas.Rectangle(16, 16, 640 + 16, 400 + 16); EmeraldFont.Write(28, 130, 'Please Wait For Map To Load', Form1.DXDraw1.Surface.Canvas); If Not FileExists('Maps\' + Mapname + '\' + MapName + '.map') Then Begin form1.MainGameTimer.Enabled := False; Messagedlg('Map ' + mapname + ' Not Found', mtWarning, [mbOK], 0); exit; End Else Begin SetLength(Currentmap.hyperlinks, 0); setlength(Currentmap.BKOs, 0); For loop := 0 To Currentmap.Width - 1 Do Begin For Loop2 := 0 To Currentmap.Height - 1 Do SetLength(CurrentMap.Rooms[Loop, Loop2].BloodArray, 0); setlength(Currentmap.rooms[loop], 0); End; setlength(currentmap.rooms, 0); For loop := 0 To TileCount - 1 Do TileArray[loop].FreeImage; For loop := 0 To TileCount - 1 Do TileArray[loop].Free; TileCount := 0; Tile2Count := 0; Currentmap.Name := Mapname; Form1.LoadMemo.Lines.LoadFromFile('Maps\' + Mapname + '\' + MapName + '.map'); ///// Do I need this line? HyperLinksLine := 0; With Form1.LoadMemo Do For loop := 0 To Lines.Count - 1 Do Begin If Lines[loop] = 'HyperLinks' Then HyperLinksLine := loop + 1; End; Currentmap.MagicBonus := StrToInt(Form1.LoadMemo.Lines[2]); Currentmap.LifeBonus := StrToInt(form1.LoadMemo.Lines[3]); CurrentMap.Width := StrToInt(Form1.LoadMemo.Lines[5]); CurrentMap.Height := StrToInt(Form1.LoadMemo.Lines[7]); CurrentMap.NumberOfHyperLinks := StrToInt(Form1.LoadMemo.Lines[12 + (Currentmap.Height * Currentmap.Width)]); setlength(Currentmap.hyperlinks, currentmap.NumberOfHyperLinks); For loop := 0 To CurrentMap.NumberOfHyperLinks - 1 Do Begin CurrentMap.HyperLinks[loop] := ExtractHyperLink(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop]); { Currentmap.HyperLinks[loop].MapX := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 1, 2)); Currentmap.HyperLinks[loop].MapY := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 4, 2)); X := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 7, 3)); Y := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 11, 3)); X2 := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 15, 3)); Y2 := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 19, 3)); Currentmap.HyperLinks[loop].Area := rect(x, y, x2, y2); Currentmap.HyperLinks[loop].TargetMapX := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 23, 2)); Currentmap.HyperLinks[loop].TargetMapY := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 26, 2)); Currentmap.HyperLinks[loop].InTargetX := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 29, 3)); Currentmap.HyperLinks[loop].InTargetY := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 33, 3)); Currentmap.HyperLinks[loop].InTargetDirection := StrToInt(Copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 37, 1)); Currentmap.HyperLinks[loop].LeadsTo := copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], 39, Length(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop]) - 47); Currentmap.HyperLinks[loop].movie := copy(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop], Length(Form1.LoadMemo.Lines[HyperLinksLine + 1 + loop]) - 7, 8); } End; LoadBackgroundObject(Form1.LoadMemo.Lines[10 + (Currentmap.Height * Currentmap.Width)]); setlength(Currentmap.rooms, CurrentMap.Width); For loop := 0 To Currentmap.Width - 1 Do setlength(Currentmap.rooms[loop], Currentmap.Height); For loop2 := 0 To Currentmap.Height - 1 Do For loop := 0 To currentmap.Width - 1 Do currentmap.Rooms[loop, Loop2].Name := Form1.LoadMemo.Lines[9 + loop + (Loop2 * Currentmap.Width)]; For loop2 := 0 To Currentmap.Height - 1 Do For loop := 0 To currentmap.Width - 1 Do CurrentMap.Rooms[loop, loop2].Monsters := -1; For loop2 := 0 To Currentmap.Height - 1 Do For loop := 0 To currentmap.Width - 1 Do CurrentMap.Rooms[loop, loop2].MonsterTimer := 0; ChDir(ExtractFilePath(ParamStr(0))); Path := 'tile sets\' + Form1.LoadMemo.Lines[1] + '\'; { Form1.LoadMemo.Lines.LoadFromFile('tile sets\' + Form1.LoadMemo.Lines[1] + '\' + Form1.LoadMemo.Lines[1] + '.tileset'); { For loop := 0 To StrToInt(Form1.LoadMemo.Lines[1]) - 1 Do LoadTile(path + IntToStr(loop + 1) + '.bmp', loop); { LoadBackgroundObject('tile sets\' + Mapname + '\bko.bmp');} LoadBigTile(Form1.LoadMemo.Lines[1]); { LoadBigLevel2Tile(Form1.LoadMemo.Lines[1]); } { LoadRoom('maps\' + Mapname + '\' + currentmap.rooms[Player.mapx, player.mapy].Name + '\1.room');} If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; If fileexists('maps\' + Currentmap.Name + '\marquee.bmp') Then Begin AreaName.Load('maps\' + Currentmap.Name + '\marquee.bmp'); ShowName := True; End Else ShowName := False; With form1 Do If (fileexists('maps\' + Currentmap.Name + '\1.mp3')) And musicmode Then Begin If music.FileName <> 'maps\' + Currentmap.Name + '\1.mp3' Then Begin Music.Open('maps\' + Currentmap.Name + '\1.mp3'); Music.Play; End; End; End; End; End. //Started Thursday, March 4th, 2004 at 8:40 AM Unit Unit1; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, TileUnit, ExtCtrls, StdCtrls, EngineUnit, graphicFX, Menus, ComCtrls, DXInput, DXSounds, TPlayerUnit, TInfoscreenUnit, jpeg, LMDStarter, LMDSysInfo, LMDTrayIcon, LMDWndProcComponent, LMDCustomComponent, MPlayer, DXDraws, MoveToUnit, TEffectsUnit; Type TForm1 = Class (TForm) MainGameTimer : TTimer; LoadMemo : TMemo; DXInput1 : TDXInput; SpriteMemo : TMemo; DXSound1 : TDXSound; DXWaveListPlayer : TDXWaveList; MsgTimer : TTimer; IntroTimer : TTimer; introstagetimer : TTimer; LMDStarter1 : TLMDStarter; StartTimer : TTimer; Button1rrr : TButton; Label1 : TLabel; Label2 : TLabel; LMDSysInfo1 : TLMDSysInfo; LMDTrayIcon1 : TLMDTrayIcon; PopupMenu2 : TPopupMenu; Restore1 : TMenuItem; ShowMovies1 : TMenuItem; LoadMusic1 : TMenuItem; OpenDialog1 : TOpenDialog; Animate1 : TMenuItem; SaveGame1 : TMenuItem; LoadGame1 : TMenuItem; N2 : TMenuItem; N3 : TMenuItem; N4 : TMenuItem; Close2 : TMenuItem; About1 : TMenuItem; OpenDialog2 : TOpenDialog; SaveDialog1 : TSaveDialog; PopupMenu3 : TPopupMenu; MenuItem1 : TMenuItem; MenuItem2 : TMenuItem; MenuItem3 : TMenuItem; MenuItem4 : TMenuItem; MenuItem5 : TMenuItem; MenuItem6 : TMenuItem; MenuItem7 : TMenuItem; MenuItem8 : TMenuItem; MenuItem9 : TMenuItem; MenuItem10 : TMenuItem; MenuItem11 : TMenuItem; LogMemo : TMemo; N5 : TMenuItem; LoadBorder1 : TMenuItem; OpenDialog3 : TOpenDialog; BlendBackground1 : TMenuItem; BlendType0 : TMenuItem; BlendType1 : TMenuItem; BlendType2 : TMenuItem; ChangeOutfits1 : TMenuItem; OutfitPurple : TMenuItem; Greed1 : TMenuItem; Red1 : TMenuItem; RecolorOutfit1 : TMenuItem; RedChannel1 : TMenuItem; GreenChannel1 : TMenuItem; BlueChannel1 : TMenuItem; N504 : TMenuItem; N01 : TMenuItem; N505 : TMenuItem; N506 : TMenuItem; N02 : TMenuItem; N507 : TMenuItem; N1003 : TMenuItem; N1004 : TMenuItem; N1005 : TMenuItem; N1006 : TMenuItem; GrayScaleOutfit1 : TMenuItem; Animate2 : TAnimate; MediaPlayer2 : TMediaPlayer; Timer1 : TTimer; SwapBackground1 : TMenuItem; SwapBackground11 : TMenuItem; N1001 : TMenuItem; N501 : TMenuItem; N03 : TMenuItem; N502 : TMenuItem; N1002 : TMenuItem; N6 : TMenuItem; Cheat1 : TMenuItem; Level9spark1 : TMenuItem; N250MP1 : TMenuItem; N250HP1 : TMenuItem; N150Mag1 : TMenuItem; oggleScanLines1 : TMenuItem; Level9Holy1 : TMenuItem; SetRoamingMonsterSpawn1 : TMenuItem; N100default1 : TMenuItem; N101 : TMenuItem; N11 : TMenuItem; N250Wis1 : TMenuItem; Morph1 : TMenuItem; AddLevel1 : TMenuItem; MAGLevel1 : TMenuItem; STRLevel1 : TMenuItem; WISLevel1 : TMenuItem; MoveWindow1 : TMenuItem; DXDraw1 : TDXDraw; FullScreen1 : TMenuItem; Volume1 : TMenuItem; Raise1 : TMenuItem; Lower1 : TMenuItem; DXDraw2 : TDXDraw; test1 : TMenuItem; sdsa1 : TMenuItem; EnableBoss1 : TMenuItem; Procedure Button1Click(Sender : TObject); Procedure FormPaint(Sender : TObject); Procedure MainGameLoop(Sender : TObject); Procedure Close1Click(Sender : TObject); Procedure Minamize1Click(Sender : TObject); Procedure Timer3Timer(Sender : TObject); Procedure MsgTimerTimer(Sender : TObject); Procedure StartTimerTimer(Sender : TObject); Procedure LMDStarter1Finished(Sender : TObject); Procedure Button1rrrClick(Sender : TObject); Procedure FormCreate(Sender : TObject); Procedure ray1Click(Sender : TObject); Procedure Restore1Click(Sender : TObject); Procedure ShowMovies1Click(Sender : TObject); Procedure LoadMusic1Click(Sender : TObject); Procedure Animate1Click(Sender : TObject); Procedure LoadGame1Click(Sender : TObject); Procedure Close2Click(Sender : TObject); Procedure PauseMainGameLoopTimer(Sender : TObject); Procedure MenuItem5Click(Sender : TObject); Procedure MenuItem10Click(Sender : TObject); Procedure LoadBorder1Click(Sender : TObject); Procedure BlendType0Click(Sender : TObject); Procedure BlendType1Click(Sender : TObject); Procedure BlendType2Click(Sender : TObject); Procedure OutfitPurpleClick(Sender : TObject); Procedure Greed1Click(Sender : TObject); Procedure Red1Click(Sender : TObject); Procedure N501Click(Sender : TObject); Procedure N502Click(Sender : TObject); Procedure N503Click(Sender : TObject); Procedure N504Click(Sender : TObject); Procedure N01Click(Sender : TObject); Procedure N505Click(Sender : TObject); Procedure N506Click(Sender : TObject); Procedure N02Click(Sender : TObject); Procedure N507Click(Sender : TObject); Procedure N1001Click(Sender : TObject); Procedure N1002Click(Sender : TObject); Procedure N1003Click(Sender : TObject); Procedure N1004Click(Sender : TObject); Procedure N1005Click(Sender : TObject); Procedure N1006Click(Sender : TObject); Procedure GrayScaleOutfit1Click(Sender : TObject); Procedure ShowEvent(Sender : TObject); Procedure Timer1Timer(Sender : TObject); Procedure SwapBackground1Click(Sender : TObject); Procedure SwapBackground11Click(Sender : TObject); Procedure Level9spark1Click(Sender : TObject); Procedure N250MP1Click(Sender : TObject); Procedure N150Mag1Click(Sender : TObject); Procedure oggleScanLines1Click(Sender : TObject); Procedure Level9Holy1Click(Sender : TObject); Procedure N11Click(Sender : TObject); Procedure N101Click(Sender : TObject); Procedure N100default1Click(Sender : TObject); Procedure N250HP1Click(Sender : TObject); Procedure N250Wis1Click(Sender : TObject); Procedure Morph1Click(Sender : TObject); Procedure MAGLevel1Click(Sender : TObject); Procedure STRLevel1Click(Sender : TObject); Procedure WISLevel1Click(Sender : TObject); Procedure MoveWindow1Click(Sender : TObject); Procedure FullScreen1Click(Sender : TObject); Procedure Raise1Click(Sender : TObject); Procedure ShowMovie(MovieName : String); Procedure DXDraw1Click(Sender : TObject); Procedure FadeOut; Procedure test1Click(Sender : TObject); Procedure FadeProcedure(Sender : TObject); Procedure sdsa1Click(Sender : TObject); Procedure EnableBoss1Click(Sender : TObject); Procedure Die(Sender : TObject); End; Var Form1 : TForm1; Border, Bottom : TBitmap; MusicMode : Boolean; EmeraldFont : TBitmapFont; InfoScreen : TStatScreen; Bars, MBars : TBars; Panal : TBitmap; Animated : Boolean; screeni : TJpegimage; Blood, IntroScreen, introscreen2, TextScreen, TextScreenImage : TBitmap; introstage : Integer; Done : Boolean; ShowScanlines : Boolean; CurrentBorder : Integer; ShowMovies : Boolean; EventCounter, TextSpeed : Integer; ImageCounter : Integer; SaveImage : TBitmap; SetButtons : Array[1..12] Of TDXInputState; Morphed, Morphing : Boolean; MorphStage : Integer; FullScreen : Boolean; BackBuffer : TBitmap; BorderOffset : Integer; MagOrRegen : Boolean; Talking : Boolean; StatusWaitTimer : Integer; ShowIngCursor : Boolean; Function IntToState(InputInt : Integer) : TDXInputState; Implementation Uses AboutUnit, EventUnit, TMonsterUnit, MusicUnit, bass, Unit2, TAreaNameUnit, TBossUnit; {$R *.dfm} Function IntToState(InputInt : Integer) : TDXInputState; Begin Case InputInt Of 1 : IntTostate := isButton1; 2 : IntTostate := isButton2; 3 : IntTostate := isButton3; 4 : IntTostate := isButton4; 5 : IntTostate := isButton5; 6 : IntTostate := isButton6; 7 : IntTostate := isButton7; 8 : IntTostate := isButton8; 9 : IntTostate := isButton9; 10 : IntTostate := isButton10; 11 : IntTostate := isButton11; 12 : IntTostate := isButton12; 13 : IntTostate := isButton13; 14 : IntTostate := isButton14; 15 : IntTostate := isButton15; 16 : IntTostate := isButton16; 17 : IntTostate := isButton17; 18 : IntTostate := isButton18; 19 : IntTostate := isButton19; 20 : IntTostate := isButton20; 21 : IntTostate := isButton21; 22 : IntTostate := isButton22; 23 : IntTostate := isButton23; 24 : IntTostate := isButton24; 25 : IntTostate := isButton25; 26 : IntTostate := isButton26; 27 : IntTostate := isButton27; 28 : IntTostate := isButton28; 29 : IntTostate := isButton29; 30 : IntTostate := isButton30; 31 : IntTostate := isButton31; 32 : IntTostate := isButton32; Else Inttostate := isButton1 End; End; Procedure TForm1.Button1Click(Sender : TObject); Begin ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.Lighting[2], CurrentRoom.Lighting[3], CurrentRoom.Lighting[4]); If Level2Enabled Then ShowLevel2Tiles(CurrentRoom.lighting[1], CurrentRoom.Lighting[2], CurrentRoom.Lighting[3], CurrentRoom.Lighting[4]); FormPaint(self); End; Procedure TForm1.MainGameLoop(Sender : TObject); Var loop : Integer; DeadMonsters : Boolean; Begin If StatusWaitTimer > 0 Then dec(StatusWaitTimer); If MoveWindow1.Checked Then MoveWindow1Click(self); If Boss[1].Life > 0 Then Boss[1].Erase(DXDraw1.Surface.Canvas); Player.Erase(Form1.DXDraw1.Surface.Canvas); For Loop := 0 To MonsterCount Do Monsters[loop].Erase(Form1.DXDraw1.Surface.Canvas); For Loop := 1 To PeopleCount Do People[loop].Erase(Form1.DXDraw1.Surface.Canvas); If RoamingMonster.Active Then RoamingMonster.Erase(Form1.DXDraw1.Surface.Canvas); Spark.Erase(Form1.DXDraw1.Surface.Canvas); If animated Then ShowAnimatedTiles; If Morphing Then Morph1Click(self); If Not Focused Then Begin MainGameTimer.OnTimer := PauseMainGameLoopTimer; Visible := False; End; If MainGameTimer.Interval <> 25 Then repaint; MainGameTimer.Interval := 25; If Player.HP > 0 Then Begin If currentroom.Closed Then Begin DeadMonsters := True; For loop := 1 To MonsterCount Do If Monsters[loop].Life > 0 Then DeadMonsters := False; If deadmonsters Then Begin If EventInRoom.NumberOfEvents > 0 Then For loop := 0 To EventInRoom.NumberOfEvents - 1 Do If EventInRoom.TriggerEvents[loop].OnRoomClosed Then Begin If eventlog.EventLevel(EventInRoom.TriggerEvents[loop].EventName) < EventInRoom.TriggerEvents[loop].EventLevel Then eventlog.SetEvent(EventInRoom.TriggerEvents[loop].EventName, EventInRoom.TriggerEvents[loop].EventLevel); End; ReleaseRoom; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.Lighting[2], CurrentRoom.Lighting[3], CurrentRoom.Lighting[4]); Currentroom.Closed := False; Repaint; End; End; If CurrentRoom.CanAttack Then Begin If MonsterCount > 0 Then DoMonsters End Else If PeopleCount > 0 Then DoPeople; If CurrentRoom.CanAttack Then DoRoamMonster Else RoamingMonster.Active := False; Player.Input; If Not showingtext Then Begin If fullscreen Then Begin bars.ShowLife(Player.HP, Player.MaxHP, DXDraw1.Surface.Canvas, 20 + BorderOffset, 455 + BorderOffset - 13); Bars.ShowMagic(Player.mp, Player.maxmp, DXDraw1.Surface.Canvas, 20 + BorderOffset, 490 + BorderOffset - 13); End Else Begin bars.ShowLife(Player.HP, Player.MaxHP, DXDraw1.Surface.Canvas, 20 + BorderOffset, 455 + BorderOffset); Bars.ShowMagic(Player.mp, Player.maxmp, DXDraw1.Surface.Canvas, 20 + BorderOffset, 490 + BorderOffset); End; End; End Else Begin MainGameTimer.Enabled := False; GrayScale(Border); If fullscreen Then DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset - 13, border) Else DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset, border); Effect.Start; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; MainGameTimer.OnTimer := die; MainGameTimer.Interval := 75; MainGameTimer.Enabled := True; End; If ShowName Then Begin AreaName.Run; If fullscreen Then DXDraw1.Surface.Canvas.Draw(0, 325, AreaName.TempBack) Else DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 325 + 16 + BorderOffset, AreaName.TempBack); If AreaName.Stage = 4 Then ShowName := False; End; If Boss[1].Life > 0 Then Boss[1].Show; If Boss[2].Life > 0 Then Boss[2].Show; // Player.Erase(DXDraw1.Surface.Canvas); DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; End; (********************Show Info Screen**************) Procedure TForm1.Timer3Timer(Sender : TObject); Var loop : Integer; ChangeAttack : Boolean; Begin DXInput1.Update; If StatusWaitTimer > 0 Then dec(StatusWaitTimer); ChangeAttack := False; For loop := 1 To 6 Do If (IntToState(loop) In DXInput1.States) And ((isUp In DXInput1.States) Or (isDown In DXInput1.States)) Then Begin ChangeAttack := True; If isup In DXInput1.States Then Begin AssignAttack(Loop, Player.attacks[loop].Spell + 1); Heal.SetStats; Spark.SetStats; Darkspark[1].SetStats; HolyShower.SetStats; Regen.SetStats; MagicRegen.SetStats; InfoScreen.MainScreen; End Else If isdown In DXInput1.States Then Begin AssignAttack(Loop, Player.attacks[loop].Spell - 1); Heal.SetStats; Spark.SetStats; Darkspark[1].SetStats; HolyShower.SetStats; Regen.SetStats; MagicRegen.SetStats; InfoScreen.MainScreen; End; End; If Not ChangeAttack Then Begin If isleft In DXInput1.States Then Begin dec(InfoScreen.Pointer); If infoscreen.Pointer = 0 Then infoscreen.Pointer := 6; InfoScreen.MainScreen; End; If isRight In DXInput1.States Then Begin Inc(InfoScreen.Pointer); If infoscreen.Pointer = 7 Then infoscreen.Pointer := 1; InfoScreen.MainScreen; End; If isUp In DXInput1.States Then Begin RaiseLevel(InfoScreen.Pointer); InfoScreen.MainScreen; End; If isdown In DXInput1.States Then Begin LowerLevel(InfoScreen.Pointer); InfoScreen.MainScreen; End; For loop := 1 To 6 Do If (IntToState(loop) In DXInput1.States) And (InfoScreen.Pointer <> loop) Then Begin InfoScreen.Pointer := Loop; InfoScreen.MainScreen; End; End; DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 16 + BorderOffset, InfoScreen.Image); If (setbuttons[7] In DXInput1.States) And (StatusWaitTimer <= 0) Then Begin MainGameTimer.OnTimer := MainGameLoop; infoscreen.Image.Free; InfoScreen.Free; Button1Click(self); StatusWaitTimer := 20; End; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; End; (***********************************************************) (***********************************************************) (*********************System Procedures*********************) (***********************************************************) (***********************************************************) Procedure TForm1.Close1Click(Sender : TObject); Begin Close; End; Procedure TForm1.Minamize1Click(Sender : TObject); Begin Application.Minimize; End; Procedure TForm1.FormPaint(Sender : TObject); Begin If fullscreen Then DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset - 13, border) Else DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset, border); DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 16 + BorderOffset, RoomBuffer); ShowallAnimatedTiles; If Level2Enabled Then DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 16 + BorderOffset, Level2Buffer); End; Procedure TForm1.MsgTimerTimer(Sender : TObject); Begin MsgTimer.Enabled := False; MainGameTimer.Enabled := True; Button1Click(self); End; Procedure TForm1.StartTimerTimer(Sender : TObject); Var loop : Integer; Begin ShowIngCursor := False; StatusWaitTimer := 20; FullScreen := False; BorderOffset := 0; DXDraw1.Initialize; For loop := 1 To 2 Do Boss[loop] := TBoss.Create; Boss[1].Load('sprites\Boss1'); Boss[2].Load('sprites\Boss1'); Boss[2].life := 0; For loop := 1 To 4 Do SwapColors(Boss[2].frames[loop]); Effect := TFadeOut.Create; OpenDialog2.InitialDir := ExtractFiledir(ParamStr(0)) + '\saves'; Morphing := False; MorphStage := 0; If FileExists('Config.ini') Then LoadMemo.Lines.LoadFromFile('Config.ini') Else Begin StartTimer.Enabled := False;Label1.Caption := 'Config.ini not found. Please run config.exe'; label2.Caption := ''; exit; End; If LoadMemo.Lines[0] = 'DivX=Enabled' Then ShowMovies := True Else ShowMovies := False; If LoadMemo.Lines[1] = 'Music=mp3' Then MusicMode := True Else musicmode := False; For loop := 1 To length(Setbuttons) Do SetButtons[loop] := inttostate(StrToInt(LoadMemo.Lines[loop + 1])); If musicmode Then Begin Music := TMusic.Create; Music.Init; End; StartTimer.Enabled := False; Done := False; Randomize; introstage := 0; BorderBevil := TBitmap.Create; BorderBevil.LoadFromFile('BorderBevil.bmp'); GenerateAlphaArray(5); AnimatedSwap := 0; LMDStarter1.Command := 'LotMDB.exe'; { If FileExists('NoDecompress') Then done := True; LMDStarter1.Parameters := ' x -y -pLOTMBeta Data.dat'; If (Not FileExists('LotM.db')) And (Not FileExists('data.dat')) And (Not done) Then Begin MessageDlg('Data.dat or LotM.db not found. Game can not load without them.', mtError, [mbOK], 1); End Else Begin If Not done Then Begin CopyFile(PChar('LotMDB.db'), PChar('LotMDB.exe'), True); LMDStarter1.Execute; End; Repeat Application.ProcessMessages; Until Done; If FileExists('LotMDB.exe') Then DeleteFile('LotMDB.exe'); } Button1rrr.Visible := False; Tile2Count := 0; TextScreen := TBitmap.Create; TextScreen.Width := 640; TextScreen.Height := 80; TextScreen.PixelFormat := pf24bit; TextScreen.TransparentColor := rgb(0, 0, 0); TextScreen.Canvas.Brush.Color := rgb(0, 0, 0); TextScreenImage := TBitmap.Create; TextScreenImage.LoadFromFile('Artwork\textbackground.bmp'); TextScreen.Canvas.Draw(0, 0, TextScreenImage); blood := TBitmap.Create; blood.LoadFromFile('sprites\blood.bmp'); blood.TransparentColor := rgb(5, 255, 255); blood.Transparent := True; If lowercase(ParamStr(1)) <> '-noanimate' Then Animated := True Else animated := False; ShowScanLines := False; CurrentBorder := 1; IntroScreen := TBitmap.Create; IntroScreen.Width := 640; IntroScreen.Height := 400; IntroScreen2 := TBitmap.Create; IntroScreen2.Width := 640; IntroScreen2.Height := 400; IntroScreen.PixelFormat := pf24bit; IntroScreen2.PixelFormat := pf24bit; Panal := TBitmap.Create; EmeraldFont := TBitmapFont.Create; EmeraldFont.LoadFromFile('Font\Cracked Emerald\jh.ds', 640, 800); Border := TBitmap.Create; Border.LoadfromFile('Artwork\Boarders\' + IntToStr(currentborder) + '.bmp'); Border.PixelFormat := pf24bit; border.TransparentColor := rgb(0, 255, 255); border.Transparent := True; border.Canvas.Pen.Style := psClear; border.Canvas.Brush.Color := rgb(0, 255, 255); If fullscreen Then border.Canvas.Rectangle(0, 0, border.Width, 430); Height := Border.Height; BackBuffer := TBitmap.Create; Backbuffer.Width := Width; Backbuffer.Height := Height; Backbuffer.PixelFormat := pf24bit; If fullscreen Then DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset - 13, border) Else DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset, border); MagOrRegen := True; Player := TPlayer.Create; InitTiles; Player.Init; InitMonsters; Player.LoadFromFile('Sprites\Player.player'); Bars := TBars.Create; Bars.LoadFromFile('Artwork\life.bmp'); player.MaxHP := 100; MBars := TBars.Create; MBars.LoadFromFile('Artwork\life.bmp'); player.MaxHP := 35; SpriteBlendingType := 2; BackGroundBlendingType := 2; EventLog := TEventlog.Create; EventLog.NumberOfEvents := 0; EventLog.AddEvent('Talk to Sanders'); AreaName := TAreaName.Create; AreaName.Init(Form1.DXDraw1.Surface.Canvas, RoomBuffer); MoveTo := TMoveTo.Create; MoveTo.MoveTo(0, 0); MoveTo.MoveTo(176, 250); MoveTo.MoveTo(600, 250); MoveTo.MoveTo(600, 250); MoveTo.MoveTo(600, 250); MoveTo.MoveTo(600, 200); MoveTo.MoveTo(600, 200); MoveTo.MoveTo(600, 200); MoveTo.MoveTo(300, 200); MoveTo.MoveTo(350, 400); MoveTo.MoveTo(350, 120); MoveTo.MoveTo(60, 120); MoveTo.MoveTo(60, 0); LoadMap('City'); Button1Click(self); Label1.Visible := False; label2.Visible := False; StartTimer.Enabled := False; MainGameTimer.Enabled := True; IntroTimer.Enabled := False; MainGameTimer.Enabled := True; introstagetimer.Enabled := False; Visible := True; LMDTrayIcon1.Active := False; LMDTrayIcon1.Active := True; If showMovies Then Begin ShowMovie('movies\teleport.avi'); Refresh; ShowMovie('movies\town.avi'); End; Form1.DXDraw2.Visible := False; form1.MainGameTimer.Enabled := True; Button1Click(self); End; Procedure TForm1.ShowMovie(MovieName : String); Begin Form1.MainGameTimer.Enabled := False; form1.MediaPlayer2.FileName := MovieName; If FullScreen Then Begin Form1.DXDraw2.Top := 0; Form1.DXDraw2.Left := 0; End Else Begin Form1.DXDraw2.Top := 16; Form1.DXDraw2.Left := 16; End; form1.MediaPlayer2.Open; Form1.DXDraw2.Visible := True; LMDTrayIcon1.Active := False; LMDTrayIcon1.Active := True; form1.MediaPlayer2.Play; Repeat Application.ProcessMessages; Until form1.mediaplayer2.Length = form1.mediaplayer2.Position; Form1.DXDraw2.Visible := False; form1.MainGameTimer.Enabled := True; // LMDTrayIcon1.Active := False; // LMDTrayIcon1.Active := True; Refresh; End; Procedure TForm1.LMDStarter1Finished(Sender : TObject); Begin done := True; End; Procedure TForm1.Button1rrrClick(Sender : TObject); Begin Close; End; Procedure TForm1.FormCreate(Sender : TObject); Var loop : Integer; Begin DXDraw2.Top := 16; DXDraw2.Left := 16; DXDraw2.Width := 640; DXDraw2.Height := 400; ImageCounter := 0; saveimage := tbitmap.Create; Saveimage.Width := 640; saveimage.Height := 480; saveimage.PixelFormat := pf24bit; LogMemo.Lines.Clear; Logmemo.Lines.Add('File name and path: ' + ParamStr(0)); LogMemo.Lines.Add('Was started on: ' + formatdatetime('hh:mm:ssAM/PM', time) + ' on ' + FormatDateTime('mmmm, dd, yyyy', date)); LogMemo.Lines.Add('Was ran by: ' + LMDSysInfo1.CurrentUser); If paramcount = 0 Then LogMemo.Lines.Add('No Params') Else For loop := 1 To paramcount Do Logmemo.Lines.Add('Param ' + IntToStr(loop) + ': ' + ParamStr(loop)); LogMemo.Lines.Add('******************System Info******************'); LogMemo.Lines.Add('Operating System Is: ' + LMDSysInfo1.Platform + LMDSysInfo1.VersionWIN + ' Build: ' + IntToStr(LMDSysInfo1.BuildNumber)); LogMemo.Lines.add('Total Mem: ' + IntToStr(LMDSysInfo1.MemPhysTotal) + ' (' + IntToStr(LMDSysInfo1.MemPhysTotal Div 1024) + 'MB)'); LogMemo.Lines.add('Free Mem: ' + IntToStr(LMDSysInfo1.MemPhysFree) + ' (' + IntToStr(LMDSysInfo1.MemPhysFree Div 1024) + 'MB)'); LogMemo.Lines.add('Total Virtual Mem: ' + IntToStr(LMDSysInfo1.MemvirtTotal) + ' (' + IntToStr(LMDSysInfo1.MemvirtTotal Div 1024) + 'MB)'); LogMemo.Lines.add('Free Virtual Mem: ' + IntToStr(LMDSysInfo1.MemvirtFree) + ' (' + IntToStr(LMDSysInfo1.MemvirtFree Div 1024) + 'MB)'); Logmemo.Lines.Add('Cpu Info: ' + IntToStr(LMDSysInfo1.ProcessorInfo.Model) + ' ' + IntToStr(LMDSysInfo1.ProcessorInfo.Family) + ' ' + LMDSysInfo1.ProcessorInfo.CPUName); LogMemo.Lines.Add('******************Display Info******************'); LogMemo.Lines.Add('Screen Size: ' + IntToStr(Screen.Width) + 'x' + IntToStr(Screen.Height)); LogMemo.Lines.Add('********************File Info*******************'); If FileExists('lotmdb.db') Then LogMemo.Lines.Add('File lotmdb.db found') Else logmemo.Lines.Add('lotmdb.db NOT FOUND!'); If FileExists('data.dat') Then LogMemo.Lines.Add('File data.dat found') Else Begin logmemo.Lines.Add('data.dat NOT FOUND!'); If Fileexists('NoDecompress') Then logmemo.Lines.Add('No Decompress file was found to replace data.dat'); End; LogMemo.Lines.Add('******************Finish Intro******************'); LogMemo.Lines.SaveToFile('Logfile.txt'); End; Procedure TForm1.Animate1Click(Sender : TObject); Begin Animated := Not animated; End; Procedure TForm1.LoadGame1Click(Sender : TObject); Begin OpenDialog2.InitialDir := ExtractFileDir(ParamStr(0)) + '\saves'; If OpenDialog2.Execute Then player.Load(OpenDialog2.FileName); ChDir(ExtractFileDir(ParamStr(0))); End; Procedure TForm1.Close2Click(Sender : TObject); Begin Close; End; Procedure TForm1.PauseMainGameLoopTimer(Sender : TObject); Begin If Focused Then Begin MainGameTimer.OnTimer := MainGameLoop; End; End; Procedure TForm1.MenuItem5Click(Sender : TObject); Begin If SaveDialog1.Execute Then player.Save(SaveDialog1.FileName); End; Procedure TForm1.MenuItem10Click(Sender : TObject); Begin AboutForm.Visible := True; End; Procedure TForm1.LoadBorder1Click(Sender : TObject); Begin If OpenDialog3.Execute Then Begin border.LoadFromFile(OpenDialog3.FileName); Refresh; ChDir(extractfiledir(ParamStr(0))); End; End; Procedure TForm1.BlendType0Click(Sender : TObject); Begin BlendType0.Checked := True; BlendType1.Checked := False; BlendType2.Checked := False; BackGroundBlendingType := 0; End; Procedure TForm1.BlendType1Click(Sender : TObject); Begin BlendType1.Checked := True; BlendType0.Checked := False; BlendType2.Checked := False; BackGroundBlendingType := 1; End; Procedure TForm1.BlendType2Click(Sender : TObject); Begin BlendType2.Checked := True; BlendType0.Checked := False; BlendType1.Checked := False; BackGroundBlendingType := 2; End; Procedure TForm1.OutfitPurpleClick(Sender : TObject); Begin player.SwappedColors := 3; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.Greed1Click(Sender : TObject); Begin player.SwappedColors := 2; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.Red1Click(Sender : TObject); Begin player.SwappedColors := 1; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N501Click(Sender : TObject); Begin player.color[3] := -50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N502Click(Sender : TObject); Begin player.color[3] := 0; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N503Click(Sender : TObject); Begin player.color[3] := 50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N504Click(Sender : TObject); Begin player.color[2] := -50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N01Click(Sender : TObject); Begin player.color[2] := 0; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N505Click(Sender : TObject); Begin player.color[2] := 50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N506Click(Sender : TObject); Begin player.color[1] := -50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N02Click(Sender : TObject); Begin player.color[1] := 0; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N507Click(Sender : TObject); Begin player.color[1] := 50; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1001Click(Sender : TObject); Begin player.color[3] := -100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1002Click(Sender : TObject); Begin player.color[3] := 100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1003Click(Sender : TObject); Begin player.color[2] := -100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1004Click(Sender : TObject); Begin player.color[2] := 100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1005Click(Sender : TObject); Begin player.color[1] := -100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.N1006Click(Sender : TObject); Begin player.color[3] := 100; Player.LoadFromFile('Sprites\Player.player'); End; Procedure TForm1.GrayScaleOutfit1Click(Sender : TObject); Begin If player.Color[4] = 0 Then player.Color[4] := 1 Else player.Color[4] := 0; Player.LoadFromFile('Sprites\Player.player'); End; Procedure ShowEventMain; Var loop2 : Integer; Begin If Not BeginEvent Then Begin ScrollTalk := False; TalkOffset := 5; Textscreen.Canvas.Draw(0, 0, TextScreenImage); EmeraldFont.ClearOverLay; For loop2 := 1 To EventInRoom.NumberOfLines Do EmeraldFont.Write(5, (Loop2 - 1) * 25, EventInRoom.Lines[loop2 - 1], 22); If EventInRoom.NumberOfEvents > 0 Then For loop2 := 0 To EventInRoom.NumberOfEvents - 1 Do If EventInRoom.TriggerEvents[loop2].OnRoomClosed Then Begin End Else If EventInRoom.TriggerEvents[loop2].AddEvent Then Begin EventLog.AddEvent(EventInRoom.TriggerEvents[loop2].EventName); End Else If eventlog.EventLevel(EventInRoom.TriggerEvents[loop2].EventName) < EventInRoom.TriggerEvents[loop2].EventLevel Then eventlog.SetEvent(EventInRoom.TriggerEvents[loop2].EventName, EventInRoom.TriggerEvents[loop2].EventLevel); TextScreen.Canvas.Draw(0, TalkOffset, EmeraldFont.OverLay); If EventInRoom.NumberOfLines > 3 Then EmeraldFont.Write(610, 60, '<', Textscreen.Canvas); blur(TextScreen, 9); If fullscreen Then form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset - 13, TextScreen) Else form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset, TextScreen); BeginEvent := True; CurrentNumberOfLines := EventInRoom.NumberOfLines; End Else Begin If ScrollTalk Then Begin Textscreen.Canvas.Draw(0, 0, TextScreenImage); TextScreen.Canvas.Draw(0, TalkOffset, EmeraldFont.OverLay); EmeraldFont.Write(610, 60, '<', Textscreen.Canvas); blur(TextScreen, 9); If fullscreen Then form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset - 13, TextScreen) Else form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset, TextScreen); ScrollTalk := False; End; End; End; Procedure TForm1.ShowEvent(Sender : TObject); Begin DXInput1.Update; If (EventCounter > 10) Then Begin If isDown In Form1.DXInput1.States Then Begin If EventInRoom.NumberOfLines > 3 Then ScrollTalk := True; If TalkOffset > 0 - (EventInRoom.NumberOfLines - 3) * 25 + 5 Then dec(TalkOffset, 10); End; If isup In Form1.DXInput1.States Then Begin If EventInRoom.NumberOfLines > 3 Then ScrollTalk := True; If TalkOffset < 5 Then inc(TalkOffset, 10); End; End; ShowEventMain; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; inc(EventCounter); If (EventCounter > textspeed) And ((SetButtons[1] In DXInput1.States) Or (SetButtons[2] In DXInput1.States) Or (SetButtons[3] In DXInput1.States)) Then Begin Button1Click(self); MainGameTimer.OnTimer := MainGameLoop; End; End; Procedure TForm1.Timer1Timer(Sender : TObject); Begin SaveImage.Canvas.CopyRect(rect(0, 0, 640, 480), DXDraw1.Surface.Canvas, rect(16 + BorderOffset, 16 + BorderOffset, 640 + 16 + BorderOffset, 400 + 16 + BorderOffset)); SaveImage.SaveToFile(IntToStr(ImageCounter) + '.bmp'); inc(Imagecounter); End; Procedure TForm1.SwapBackground1Click(Sender : TObject); Begin AnimatedSwap := 2; SwapBackground := 2; End; Procedure TForm1.SwapBackground11Click(Sender : TObject); Begin AnimatedSwap := 1; SwapBackground := 1; End; Procedure TForm1.Level9spark1Click(Sender : TObject); Begin spark.Level := 9; End; Procedure TForm1.N250MP1Click(Sender : TObject); Begin player.MaxMP := 250; player.MP := 250; Bars.LoadFromFile('Artwork\life.bmp'); ChDir(extractfiledir(ParamStr(0))); form1.Repaint; End; Procedure TForm1.N150Mag1Click(Sender : TObject); Begin player.Mag := 250; End; Procedure TForm1.oggleScanLines1Click(Sender : TObject); Begin If showscanlines Then Begin ShowScanLines := False; ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.lighting[2], CurrentRoom.lighting[3], CurrentRoom.lighting[4]); DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 16 + BorderOffset, roombuffer); End Else Begin ShowScanlines := True; ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.lighting[2], CurrentRoom.lighting[3], CurrentRoom.lighting[4]); DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 16 + BorderOffset, roombuffer) End; End; Procedure TForm1.Level9Holy1Click(Sender : TObject); Begin HolyShower.Level := 9; haste.Level := 9; End; Procedure TForm1.N11Click(Sender : TObject); Begin RoamingMonster.ChanceToSpawn := 1; N100default1.Checked := False; n101.Checked := False; End; Procedure TForm1.N101Click(Sender : TObject); Begin RoamingMonster.ChanceToSpawn := 10; N100default1.Checked := False; n11.Checked := False; End; Procedure TForm1.N100default1Click(Sender : TObject); Begin RoamingMonster.ChanceToSpawn := 100; N101.Checked := False; n11.Checked := False; End; Procedure TForm1.N250HP1Click(Sender : TObject); Begin player.HP := 250; player.maxhp := 250; End; Procedure TForm1.N250Wis1Click(Sender : TObject); Begin player.Wis := 250; End; Procedure TForm1.Morph1Click(Sender : TObject); Var Loop, loop2 : Integer; Begin Morphing := True; inc(MorphStage); If morphstage < 10 Then For loop := 0 To Morphstage Do Begin For loop2 := 1 To 8 Do Begin blur(player.FrameImage[loop2], 0); darken(Player.frameimage[loop2], 5);End; End Else If (MorphStage > 9) And (Morphstage < 20) Then Begin If morphed Then player.Loadfromfile('sprites\Player.player') Else player.Loadfromfile('sprites\Player2.player'); For loop := 0 To 20 - morphstage Do For loop2 := 1 To 8 Do darken(player.FrameImage[loop2], 10, ignorecolor(5, 255, 255)); End Else If MorphStage = 20 Then Begin morphing := False; Morphed := Not morphed; MorphStage := 0; If Not morphed Then player.Loadfromfile('sprites\Player.player') Else player.Loadfromfile('sprites\Player2.player'); If PeopleCount > 0 Then Begin loadroom(CurrentRoom.Name); repaint; End; End; End; Procedure TForm1.MAGLevel1Click(Sender : TObject); Begin player.MagExp := player.NextExp; End; Procedure TForm1.STRLevel1Click(Sender : TObject); Begin player.STRExp := player.NextExp; End; Procedure TForm1.WISLevel1Click(Sender : TObject); Begin player.WisExp := player.NextExp; End; Procedure TForm1.MoveWindow1Click(Sender : TObject); Begin If MoveWindow1.Checked Then Begin top := Mouse.CursorPos.Y; left := mouse.CursorPos.X; End; End; Procedure TForm1.ray1Click(Sender : TObject); Begin MainGameTimer.Enabled := False; Visible := False; End; Procedure TForm1.Restore1Click(Sender : TObject); Begin Visible := True; LMDTrayIcon1.Active := False; LMDTrayIcon1.Active := True; MainGameTimer.Enabled := True; End; Procedure TForm1.ShowMovies1Click(Sender : TObject); Begin Showmovies := Not showmovies; End; Procedure TForm1.LoadMusic1Click(Sender : TObject); Begin If musicmode Then Begin If OpenDialog1.Execute Then Begin Music.Open(OpenDialog1.Filename); Music.Play; End; End Else MessageDlg('Music is not enabled. Please enable using config.exe', mtError, [mbOK], 1); End; Procedure TForm1.FullScreen1Click(Sender : TObject); Var TempBorder : TBitmap; Begin If FullScreen Then Begin ShowCursor(True); ShowIngCursor := False; FullScreen := False; Border.LoadfromFile('Artwork\Boarders\' + IntToStr(currentborder) + '.bmp'); BorderOffset := 0; DXDraw1.Options := DXDraw1.Options - [dofullscreen]; Width := border.Width; Height := border.Height; DXDraw1.Initialize; left := (screen.Width - Width) Div 2; top := (Screen.Height - Height) Div 2; Areaname.Canvas := DXDraw1.Surface.Canvas; LMDTrayIcon1.Active := False; LMDTrayIcon1.Active := True; Refresh; End Else Begin ShowIngCursor := False; ShowCursor(False); border.Canvas.Rectangle(0, 0, border.Width, 430); FullScreen := True; BorderOffset := -16; TempBorder := TBitmap.Create; TempBorder.Width := 640; TempBorder.Height := 80; TempBorder.PixelFormat := pf24bit; TempBorder.Canvas.CopyRect(rect(0, 0, 640, 80), Border.Canvas, rect(0 + 16, 400 + 16 + 16, 640 + 16, 480 + 16 + 16)); LightMap(TempBorder, BorderBevil, TempBorder); Border.Canvas.Draw(0 + 16, 400 + 16 + 16, TempBorder); TempBorder.Free; DXDraw1.Options := DXDraw1.Options + [dofullscreen]; DXDraw1.Initialize; Areaname.Canvas := DXDraw1.Surface.Canvas; Refresh; End; End; Procedure TForm1.Raise1Click(Sender : TObject); Begin BASS_SetVolume(BASS_getVolume); form2.ScrollBar1.Position := BASS_GetVolume; form2.Visible := True; ShowCursor(True); End; Procedure TForm1.DXDraw1Click(Sender : TObject); Var TestPoint : TPoint; Begin TestPoint := ScreenToClient(Mouse.CursorPos); Dec(TestPoint.X, 16 + 20); Dec(TestPoint.Y, 16 + 20); With TestPoint Do If X > 0 Then If X < 640 Then If Y > -10 Then If Y < 400 Then Begin Player.ShowSprite; MoveTo.MoveTo(TestPoint.X, TestPoint.Y); End; End; Procedure TForm1.FadeOut; Begin //fdfd End; Procedure TForm1.test1Click(Sender : TObject); Begin Effect.Start; MainGameTimer.OnTimer := FadeProcedure; End; Procedure TForm1.FadeProcedure(Sender : TObject); Begin Effect.Work; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; If Effect.Stage = 26 Then Begin Effect.Finish; MainGameTimer.Ontimer := MainGameLoop; End; End; Procedure TForm1.sdsa1Click(Sender : TObject); Begin MainGameTimer.Enabled := False; Effect.Start; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; MainGameTimer.OnTimer := FadeProcedure; MainGameTimer.Interval := 75; MainGameTimer.Enabled := True; End; Procedure TForm1.EnableBoss1Click(Sender : TObject); Begin Boss[1].Life := 250; End; Procedure TForm1.Die(Sender : TObject); Begin Effect.Work; DXDraw1.Surface.Canvas.Release; DXDraw1.Flip; If Effect.Stage = 26 Then Begin Effect.Finish; Music.Pause; MainGameTimer.Enabled := False; End; End; End. Unit Unit2; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; Type TForm2 = Class (TForm) ScrollBar1 : TScrollBar; Timer1 : TTimer; Procedure ScrollBar1Change(Sender : TObject); Procedure FormCreate(Sender : TObject); Procedure FormClose(Sender : TObject; Var Action : TCloseAction); Procedure Timer1Timer(Sender : TObject); Private { Private declarations } Public { Public declarations } End; Var Form2 : TForm2; Implementation Uses bass, unit1; {$R *.dfm} Procedure TForm2.ScrollBar1Change(Sender : TObject); Begin BASS_SetVolume(ScrollBar1.Position); End; Procedure TForm2.FormCreate(Sender : TObject); Begin ScrollBar1.Position := 10; End; Procedure TForm2.FormClose(Sender : TObject; Var Action : TCloseAction); Begin If fullscreen Then showcursor(False); End; Procedure TForm2.Timer1Timer(Sender : TObject); Begin If (Not Visible) And (fullscreen) Then ShowCursor(False); End; End. Unit MovieUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, jpeg; Type TMovie = Class Moviejpg : TJPEGImage; Movie : TBitmap; Frames : Int64; MovieRect : TRect; Frame : Int64; Finished : Boolean; XFrames, YFrames, YFrame : Int64; ReverseType, Reverse, mv640 : Boolean; Procedure LoadMovie(FileName : String); Procedure ShowFrame; Procedure Clear; End; Var movie : TMovie; Implementation Uses Unit1, graphicfx; Procedure TMovie.LoadMovie(FileName : String); Var tempstr : String; Begin Reverse := False; tempstr := ExtractFileExt(filename); If (tempstr = '.mvr') Or (Tempstr = '.mvr640') Then ReverseType := True Else ReverseType := False; If (Tempstr = '.mv640') Or (tempstr = '.mvr640') Then mv640 := True Else mv640 := False; Moviejpg := TJPEGImage.Create; Moviejpg.LoadFromFile(Filename); Movie := TBitmap.Create; Movie.Width := moviejpg.Width; Movie.Height := moviejpg.Height; Movie.PixelFormat := pf16bit; Movie.Canvas.Draw(0, 0, moviejpg); Moviejpg.Free; If Not mv640 Then Begin Frames := (movie.Width Div 600) {* (Movie.Height div 400)}; XFrames := (movie.Width Div 600); YFrames := (Movie.Height Div 400) - 1; End Else Begin Frames := (movie.Width Div 640) * (Movie.Height Div 400); XFrames := (movie.Width Div 640); YFrames := (Movie.Height Div 400) - 1; End; YFrame := 0; Frame := 0; { YFrames := 2; } Finished := False; End; Procedure TMovie.ShowFrame; Begin If Not mv640 Then form1.Canvas.CopyRect(rect(0 + 16, 0 + 16, 640 + 16, 400 + 16), movie.Canvas, rect(Frame * 600, 400 * YFrame, (Frame + 1) * 600, 400 * (YFrame + 1))) Else form1.Canvas.CopyRect(rect(0 + 16, 0 + 16, 640 + 16, 400 + 16), movie.Canvas, rect(Frame * 640, 400 * YFrame, (Frame + 1) * 640, 400 * (YFrame + 1))); If Not reverse Then Begin If Frame < frames Then inc(frame); End Else If frame > -1 Then dec(Frame); If frame = frames Then If YFrame < YFrames Then Begin inc(YFrame); Frame := 0; End; If frames = frame Then If ReverseType Then Reverse := True Else If YFrame = YFrames Then finished := True; If ReverseType And (Frame = -1) Then Begin If yframe = 0 Then finished := True Else Begin dec(YFrame); frame := Frames; End; End; If finished Then Begin Frame := 0; YFrame := 0; End; End; Procedure TMovie.Clear; Begin Reverse := False; movie.FreeImage; movie.Free; End; End. Unit Unit1; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, jpeg, JvComponent, JvTransparentForm, Menus; Type TForm1 = Class (TForm) Timer1 : TTimer; OpenDialog1 : TOpenDialog; Image1 : TImage; JvTransparentForm1 : TJvTransparentForm; Image2 : TImage; Image3 : TImage; PopupMenu1 : TPopupMenu; Close1 : TMenuItem; Procedure FormCreate(Sender : TObject); Procedure Timer1Timer(Sender : TObject); Procedure Button1Click(Sender : TObject); Procedure Button2Click(Sender : TObject); Procedure Close1Click(Sender : TObject); Private { Private declarations } Public { Public declarations } End; Var Form1 : TForm1; Implementation Uses MovieUnit; {$R *.dfm} Procedure TForm1.FormCreate(Sender : TObject); Begin Movie := TMovie.Create; If ParamCount > 0 Then Begin movie.LoadMovie(ParamStr(1)); Timer1.Enabled := True; End; End; Procedure TForm1.Timer1Timer(Sender : TObject); Begin If movie.Reverse And (movie.Frame = movie.Frames) And (movie.YFrame = movie.YFrames) Then sleep(1500); movie.ShowFrame; { if movie.Frame > 1 then timer1.Interval := 100 else timer1.Interval := 1500;} If movie.Finished Then timer1.Enabled := False; End; Procedure TForm1.Button1Click(Sender : TObject); Begin If OpenDialog1.Execute Then Begin If movie.Finished Then movie.Clear; Movie.LoadMovie(OpenDialog1.FileName); timer1.Enabled := True; End; End; Procedure TForm1.Button2Click(Sender : TObject); Begin If movie.Finished Then Begin movie.frame := 0; Movie.Reverse := False; movie.Finished := False; Timer1.Enabled := True; End; End; Procedure TForm1.Close1Click(Sender : TObject); Begin Close; End; End. Unit AboutUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, LMDControl, LMDBaseControl, LMDBaseGraphicControl, LMDBaseLabel, LMDCustomLabel, LMDLabel; Type TAboutForm = Class (TForm) LMDLabel2 : TLMDLabel; LMDLabel3 : TLMDLabel; LMDLabel1 : TLMDLabel; Private { Private declarations } Public { Public declarations } End; Var AboutForm : TAboutForm; Implementation {$R *.dfm} End. Unit AIUnit; Interface Implementation End. Unit EventUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, forms; Type TEventLinkLoad = Record EventToLoad : String; LevelToLoad : Integer; End; TEvent = Class Stage : Integer; Max : Integer; EventName : String; StageName : Array Of String; EventLinkLoads : Array Of TEventLinkLoad; Procedure Load(Filename : String); End; TEventLog = Class NumberOfEvents : Integer; Events : Array Of TEvent; Procedure AddEvent(Filename : String); Procedure SetEvent(Event : Integer; Level : Integer); OverLoad; Procedure SetEvent(Event : String; Level : Integer); OverLoad; Function EventLevel(Event : Integer) : Integer; Overload; Function EventLevel(Event : String) : Integer; Overload; Function EventStatus(Event : Integer) : String; Overload; Function EventStatus(Event : String) : String; Overload; Procedure Clear; End; Var EventLog : TEventLog; Implementation Uses Unit1; Procedure TEvent.Load(Filename : String); Var Loop : Integer; Begin Form1.logmemo.Lines.LoadFromFile('Quest\' + Filename + '.event'); Stage := 0; Max := StrToInt(form1.logmemo.Lines[0]); EventName := form1.logmemo.Lines[1]; SetLength(StageName, Max); For loop := 0 To max - 1 Do StageName[loop] := form1.logmemo.Lines[2 + loop]; If form1.logmemo.Lines.Count > max - 1 Then For loop := max - 1 To form1.logmemo.Lines.Count - 1 Do Begin If copy(form1.logmemo.Lines[loop], 1, length('LoadEvent:')) = 'LoadEvent:' Then exit; End; End; Procedure TEventLog.AddEvent(Filename : String); Begin Inc(NumberOfEvents); Setlength(Events, NumberOfEvents); Events[NumberOfEvents - 1] := TEvent.Create; Events[NumberOfEvents - 1].Load(Filename); End; Procedure TEventLog.SetEvent(Event : Integer; Level : Integer); Begin Events[Event].Stage := Level; End; Procedure TEventLog.SetEvent(Event : String; Level : Integer); Var loop : Integer; Begin Loop := -1; Repeat Inc(Loop); Until (Events[loop].EventName = event) Or (loop = NumberOfEvents - 1); Events[loop].Stage := Level; End; Function TEventLog.EventLevel(Event : Integer) : Integer; Begin EventLevel := Events[Event].Stage; End; Function TEventlog.Eventlevel(Event : String) : Integer; Var loop : Integer; Begin Loop := -1; Repeat Inc(Loop); Until (Events[loop].EventName = event) Or (loop = NumberOfEvents - 1); If (loop = numberofevents - 1) And (Events[loop].EventName <> event) Then EventLevel := 1 Else EventLevel := Events[loop].Stage; End; Function TEventLog.EventStatus(Event : Integer) : String; Begin Eventstatus := EventLog.Events[event].StageName[EventLog.Events[event].Stage]; End; Function TEventLog.EventStatus(Event : String) : String; Var loop : Integer; Begin Loop := -1; Repeat Inc(Loop); Until (Events[loop].EventName = event) Or (loop = NumberOfEvents - 1); Eventstatus := EventLog.Events[loop].StageName[EventLog.Events[loop].Stage]; End; Procedure TEventLog.Clear; Var Loop : Integer; Begin For loop := 0 To NumberOfEvents - 1 Do events[loop].Free; NumberOfEvents := 0; setlength(Events, 0); End; End. Unit FileCompressUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; Const LoadCommand = 'program.dat x -pPassword Data.dat '; Function Load(FileName : String) : String; Implementation Function Load(FileName : String) : String; Begin If Not (FileExists(FileName)) Then Begin WinExec(PChar(LoadCommand + Filename), 0); Repeat sleep(100) Until FileExists(Filename); End; Result := FileName; End; End. Unit GameDialogUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX; End. Unit INIUnit; Interface Function INIType(StringIn : String) : String; Function INIData(StringIn : String) : String; Implementation Function IniType(StringIn : String) : String; Var Counter : Integer; TempStr : String; Begin TempStr := ''; Counter := 0; Repeat Inc(Counter) Until (Counter = length(Stringin)) Or (Stringin[Counter] = ':'); IniType := Copy(Stringin, 1, Counter); End; Function IniData(StringIn : String) : String; Var Counter : Integer; TempStr : String; Begin TempStr := ''; Counter := 0; Repeat Inc(Counter) Until (Counter = length(Stringin)) Or (Stringin[Counter] = ':'); IniData := Copy(Stringin, Counter + 1, Length(StringIn) - Counter); End; End. Unit MoveToUnit; Interface Uses Windows, dialogs, sysutils; Type TMoveTo = Class //X,Y : Integer; Enabled : Boolean; Constructor Create; Procedure MoveTo(SetX, SetY : Integer); Procedure Move; Procedure RemoveItem; Private Location : Array Of TPoint; End; Var MoveTo : TMoveTo; Implementation Uses TPlayerUnit, EngineUnit, Unit1; Constructor TmoveTo.Create; Begin Enabled := False; SetLength(Location, 1); End; Procedure Tmoveto.MoveTo(SetX, SetY : Integer); Begin SetLength(Location, Length(Location) + 1); Location[Length(Location) - 1].X := SetX; Location[Length(Location) - 1].Y := SetY; Enabled := True; End; Procedure TMoveTo.Move; Var loop : Integer; Begin With Location[1] Do Begin If player.X < X Then For loop := 0 To Player.DashSpeed Do Player.MoveRight(False) Else If player.X - 10 > X Then For loop := 0 To Player.DashSpeed Do Player.MoveLeft(False); If player.Y < Y Then For loop := 0 To Player.DashSpeed Do Player.MoveDown(False) Else If player.Y - 10 > Y Then For loop := 0 To Player.DashSpeed Do Player.MoveUp(False); If (Player.Y >= Y) And (Player.X >= X) And (Player.Y - 10 <= Y) And (Player.X - 10 <= x) Then RemoveItem; Case Player.Direction Of 1 : Player.SpriteUp; 2 : Player.SpriteRight; 3 : Player.SpriteDown; 4 : Player.SpriteLeft; End; For loop := 1 To PeopleCount Do Case People[loop].Direction Of 1 : People[Loop].SpriteUp; 2 : People[Loop].SpriteRight; 3 : People[Loop].SpriteDown; 4 : People[Loop].SpriteLeft; End; End; End; Procedure Tmoveto.RemoveItem; Var Loop : Integer; Begin For Loop := 1 To Length(Location) - 1 Do Location[Loop - 1] := Location[Loop]; SetLength(Location, Length(Location) - 1); If Length(Location) = 1 Then Enabled := False; End; End. Unit MusicUnit; Interface Uses windows, Forms; Type TMusic = Class FileName : String; MusicChannel : DWord; Procedure Init; Procedure Open(Filename : String); Procedure Play; Procedure Pause; End; Var Music : TMusic; Implementation Uses Bass; Procedure TMusic.Init; Begin BASS_Init(1, 44100, 0, Application.Handle, Nil); End; Procedure TMusic.Open(Filename : String); Begin BASS_StreamFree(MusicChannel); Self.FileName := Filename; MusicChannel := BASS_StreamCreateFile(False, PChar(Filename), 0, 0, BASS_SAMPLE_LOOP); End; Procedure TMusic.Play; Begin BASS_ChannelPlay(Musicchannel, True); End; Procedure TMusic.Pause; Begin BASS_ChannelPause(MusicChannel); End; End. Unit TAIUnit; Interface Uses TMonsterBaseUnit; Type TAIBase = Class Procedure Think(Monster : TMonsterBase); Virtual; Abstract; End; TAIRandom30 = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIDown = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIDontMove_Up = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIDontMove_Right = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIDontMove_Down = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIDontMove_Left = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIHoming = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIHoming2 = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; TAIUnthinking = Class (TAIBase) Procedure Think(Monster : TMonsterBase); Override; End; Implementation Uses TPlayerUnit, EngineUnit; Procedure TAIRandom30.Think(Monster : TMonsterBase); Begin With Monster Do Begin Inc(FrameTimer); If Monster.frameTimer > Monster.frameMaxTimer Then Begin If Monster.FrameCount = 1 Then Monster.FrameCount := 2 Else Monster.FrameCount := 1; Monster.frameTimer := 0; End; If random(25) = 4 Then Direction := random(4) + 1; If (Direction = 1) And (y < 40) Then Direction := 3; If (Direction = 2) And (X > 580) Then Direction := 4; If (Direction = 3) And (Y > 340) Then Direction := 1; If (Direction = 4) And (X < 40) Then Direction := 2; End; End; Procedure TAIDown.Think(Monster : TMonsterBase); Begin Inc(Monster.FrameTimer); If Monster.frameTimer > Monster.frameMaxTimer Then Begin If Monster.FrameCount = 1 Then Monster.FrameCount := 2 Else Monster.FrameCount := 1; Monster.frameTimer := 0; End; Monster.Direction := 3; End; Procedure TAIDontMove_Up.Think(Monster : TMonsterBase); Begin With Monster Do Begin Direction := 1; End; End; Procedure TAIDontMove_Right.Think(Monster : TMonsterBase); Begin With Monster Do Begin Direction := 2; End; End; Procedure TAIDontMove_Down.Think(Monster : TMonsterBase); Begin With Monster Do Begin Direction := 3; End; End; Procedure TAIDontMove_Left.Think(Monster : TMonsterBase); Begin With Monster Do Begin Direction := 4; End; End; Procedure TAIHoming2.Think(Monster : TMonsterBase); Begin With Monster Do Begin Inc(FrameTimer); If Monster.frameTimer > Monster.frameMaxTimer Then Begin If Monster.FrameCount = 1 Then Monster.FrameCount := 2 Else Monster.FrameCount := 1; Monster.frameTimer := 0; End; If random(2) = 1 Then Begin If (X > Player.X + 40) Then direction := 4 Else If x < Player.X Then Direction := 2; End Else Begin If (y > Player.y + 40) Then direction := 1 Else If y < Player.y Then Direction := 3; End; End; End; Procedure TAIHoming.Think(Monster : TMonsterBase); Var AbleToMove : Boolean; TempX, TempY : Integer; Begin With Monster Do Begin Inc(FrameTimer); If Monster.frameTimer > Monster.frameMaxTimer Then Begin If Monster.FrameCount = 1 Then Monster.FrameCount := 2 Else Monster.FrameCount := 1; Monster.frameTimer := 0; End; AbleToMove := True; If WalkAroundObject = 0 Then Begin TempX := x - player.X; If tempX < 0 Then tempX := 0 - tempX; tempY := y - player.Y; If tempY < 0 Then tempY := 0 - TempY; If tempY > TempX + 10 Then Begin If player.Y > Y Then direction := 3 Else direction := 1; End Else If tempy < TempX Then Begin If player.X > X Then direction := 2 Else direction := 4; End; End; Case Direction Of 1 : If Not DetectUp Then AbleToMove := False; 2 : If Not Detectright Then AbleToMove := False; 3 : If Not Detectdown Then AbleToMove := False; 4 : If Not Detectleft Then AbleToMove := False; End; If Not abletomove Then Case direction Of 1 : If player.X < X Then direction := 4 Else direction := 2; 2 : If player.Y < Y Then direction := 1 Else direction := 3; 3 : If player.X < X Then direction := 4 Else direction := 2; 4 : If player.Y < Y Then direction := 1 Else direction := 3; End; If (Not AbleToMove) And (WalkAroundObject = 0) Then WalkAroundObject := 180 Div (MoveRatio * speed) Else If WalkAroundObject > 0 Then dec(WalkAroundObject); End; End; Procedure TAIUnthinking.Think(Monster : TMonsterBase); Begin //Nothing End; End. Unit TAreaNameUnit; (**************************************************** **************************************************** *********************Slight Mem Leak!!!************* **************************************************** ***************************************************) Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls; Type TAreaName = Class TempBack : TBitmap; Stage : Integer; Canvas : TCanvas; Procedure Run; Procedure Load(Filename : String); Procedure Init(SetCanvas : TCanvas; SetBackground : TBitmap); Procedure Closeup; Procedure Erase; Private Background, ToScroll, ShowName : TBitmap; XScroll : Array Of Integer; Delay, Counter : Integer; Procedure Stage0; Procedure Stage1; Procedure Stage2; Procedure Stage4; End; Implementation Uses GraphicFX, EngineUnit, unit1, TileUnit; Procedure TAreaName.Erase; Begin TempBack.Canvas.CopyRect(Rect(0, 0, tempback.Width, tempback.Height), BackBuffer.Canvas, rect(0, 325, 640, 325 + 75)); If fullscreen Then Form1.DXDraw1.Surface.Canvas.Draw(0, 325, TempBack) Else Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 325 + 16 + BorderOffset, TempBack); End; Procedure TAreaName.Init(SetCanvas : TCanvas; SetBackground : TBitmap); Begin Stage := 0; TempBack := TBitmap.Create; TempBack.Width := 640; TempBack.Height := 75; TempBack.PixelFormat := pf24bit; TempBack.TransparentColor := rgb(0, 0, 0); TempBack.Transparent := False; ToScroll := TBitmap.Create; ShowName := TBitmap.Create; ShowName.Width := 640; ShowName.Height := 75; ShowName.PixelFormat := pf24bit; ShowName.TransparentColor := rgb(0, 0, 0); ShowName.Transparent := False; Background := SetBackground; Delay := 70; Canvas := SetCanvas; End; Procedure TAreaname.Closeup; Begin ToScroll.FreeImage; TempBack.FreeImage; ShowName.FreeImage; ToScroll.Free; TempBack.Free; ShowName.Free; End; Procedure TAreaName.Run; Begin Case Stage Of 0 : Stage0; 1 : Stage1; 2 : Stage2; 3 : Stage1; 4 : Stage4; End; TempBack.Canvas.CopyRect(Rect(0, 0, tempback.Width, tempback.Height), RoomBuffer.Canvas, rect(0, 325, 640, 325 + 75)); If Player.Y > 325 - 45 Then TempBack.Canvas.Draw(Player.X, Player.Y - 325, Player.frameimage[Player.Direction * 2 + Player.FrameCount - 2]); Lightmap(TempBack, ShowName, TempBack); End; Procedure TAreaName.Stage4; Var Loop : Integer; Begin Stage := 1; Counter := 0; For Loop := 0 To ToScroll.Height - 1 Do XScroll[loop] := -640; End; Procedure TAreaName.Stage0; Begin ShowName.Canvas.Pen.Style := psClear; ShowName.Canvas.Brush.Color := rgb(128, 128, 128); ShowName.Canvas.Rectangle(0, 0, ToScroll.Width + 1, ToScroll.Height + 1); Stage := 1; End; Procedure TAreaName.Load(Filename : String); Var Loop : Integer; Begin Counter := 0; Stage := 0; ToScroll.LoadFromFile(FileName); SetLength(XScroll, ToScroll.Height); For Loop := 0 To ToScroll.Height - 1 Do XScroll[loop] := -640; End; Procedure TAreaName.Stage1; Var Loop : Integer; Begin Canvas.Brush.Color := rgb(128, 128, 128); ShowName.Canvas.Rectangle(0, 0, ToScroll.Width + 1, ToScroll.Height + 1); If (XScroll[ToScroll.Height - 1] = 0) And (Stage = 1) Then Stage := 2 Else If (XScroll[ToScroll.Height - 1] = 640) And (Stage = 3) Then Stage := 4; For loop := 0 To ToScroll.Height - 1 Do Begin ShowName.canvas.CopyRect(Rect(XScroll[Loop], loop, 640 + XScroll[Loop], loop + 1), ToScroll.Canvas, rect(0, Loop, 640, Loop + 1)); Inc(XScroll[loop], 100 - loop); If Stage = 1 Then Begin If XScroll[loop] > 0 Then XScroll[loop] := 0 End Else If Stage = 3 Then If XScroll[loop] > 640 Then XScroll[loop] := 640 End; End; Procedure TAreaName.Stage2; Begin Inc(Counter); If Counter = Delay Then Stage := 3; End; End. Unit TBossUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, TileUnit; Type TBoss = Class X, Y, Frame : Integer; AITarget : Array[1..2] Of Integer; Frames, Shadows : Array[1..4] Of TBitmap; Temp : TBitmap; Def : Integer; FlashCounter : Integer; AIType : Integer; AIChangeChance : Integer; Life, MaxLife : Integer; Speed : Integer; LightSource : Record X, Y : Integer; End; AttackRegions, MagicHitRegions, ReflectRegions, HitRegions : Array Of TRect; Procedure Load(Filename : String); Procedure Show; Procedure AI1; Procedure AI2; Procedure Hit(Damage, Direction : Integer); Procedure Erase(ACanvas : TCanvas); End; Var Boss : Array[1..2] Of TBoss; Implementation Uses engineunit, GraphicFX, Unit1, TPlayerUnit; Procedure TBoss.Erase; Begin ACanvas.CopyRect(rect(X + 16 + BorderOffset - 13, Y + 16 + BorderOffset - 13, 16 + BorderOffset + X + Temp.Width - 13, 16 + BorderOffset + Y + Temp.Height - 13), RoomBuffer.Canvas, rect(x - 13, y - 13, x + Temp.Width - 13, y + Temp.Height - 13)); End; Procedure TBoss.Load(Filename : String); Var Loop : Integer; Begin Speed := 3; LightSource.X := 5; LightSource.Y := 5; x := 100; Y := 100; AITarget[1] := random(395) + 65; AITarget[2] := Random(200) + 65; AIType := 2; Maxlife := 255; Life := 0; Def := 100; For loop := 1 To 4 Do Begin frames[loop] := TBitmap.Create; Frames[loop].LoadFromFile(Filename + '\' + IntToStr(loop) + '.bmp'); Frames[loop].TransparentColor := rgb(0, 0, 0); Frames[loop].Transparent := True; End; For loop := 1 To 4 Do Begin shadows[loop] := Tbitmap.Create; shadows[loop].LoadFromFile(Filename + '\' + IntToStr(loop) + '.bmp'); shadows[loop].TransparentColor := rgb(5, 5, 5); shadows[loop].Transparent := True; invert(shadows[loop]); Darken(shadows[loop], 250); shadows[loop].Canvas.Brush.Color := rgb(5, 5, 5); shadows[loop].Canvas.FloodFill(shadows[loop].Width - 2, shadows[loop].Height - 2, shadows[loop].canvas.Pixels[shadows[loop].Width - 2, shadows[loop].Height - 2], fsSurface); End; temp := TBitmap.Create; temp.LoadFromFile(Filename + '\' + '1.bmp'); temp.Width := temp.Width + 26; temp.Height := temp.Height + 26; Frame := 1; AIChangeChance := 500; SetLength(MagicHitRegions, 1); MagicHitRegions[0] := Rect(30, 5, 105, 55); SetLength(ReflectRegions, 2); ReflectRegions[0] := Rect(9, 5, 36, 66); ReflectRegions[1] := Rect(100, 5, 110, 66); End; Procedure TBoss.Show; Var CurrentX, CurrentY, loop : Integer; TempRect : TRect; Begin If flashCounter > 0 Then Begin Dec(FlashCounter); For loop := 1 To 4 Do invert(Frames[loop], ignorecolor(0, 0, 0)); End; CurrentX := (x Div 40) - LightSource.X; CurrentY := (Y Div 40) - LightSource.Y; temp.Canvas.CopyRect(rect(0, 0, temp.Width, temp.Height), Form1.DXDraw1.Surface.Canvas, rect(16 + BorderOffset + x - 13, 16 + BorderOffset + y - 13, 16 + BorderOffset + x + temp.Width - 13, 16 + BorderOffset + y + temp.Height - 13)); AlphaBlendFX(temp, shadows[frame], temp, 5, ignorecolor(5, 5, 5), CurrentX * 2 + 13, CurrentY * 2 + 14); Temp.Canvas.Draw(13, 13, Frames[frame]); motionBlurup(temp); //Form1.Canvas.Draw(x-13+16,y-13+16,temp); If fullscreen Then Form1.DXDraw1.Surface.Canvas.Draw(x - 13, y - 13, temp) Else Form1.DXDraw1.Surface.Canvas.Draw(x - 13 + 16, y - 13 + 16, temp); Case AIType Of 1 : AI1; 2 : AI2; End; If player.HitFlashCount = 0 Then Begin If IntersectRect(TempRect, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40), Rect(x, y, x + 10, y + Frames[1].Height)) Then Begin If player.Direction = 2 Then Begin Player.Impact := 'Face'; End Else Begin Player.Impact := 'Side'; Player.Direction := 2; End; Player.GetHit; End; If IntersectRect(TempRect, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40), Rect(x + Frames[1].Width - 1, y, x + Frames[1].Width, y + Frames[1].Height)) Then Begin If player.Direction = 4 Then Begin Player.Impact := 'Face'; End Else Begin Player.Impact := 'Side'; Player.Direction := 4; End; Player.GetHit; End; If FlashCounter = 0 Then If IntersectRect(TempRect, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40), Rect(x + 10, y, x + Frames[1].Width - 10, y + 10)) Then Begin Erase(Form1.DXDraw1.Surface.Canvas); Hit(Player.Atk - Def, Player.Direction); Player.Impact := 'Face'; Player.Direction := 3; Player.Erase(Form1.DXDraw1.Surface.Canvas); For loop := 1 To 6 Do player.MoveUp(False); End; End; End; Procedure TBoss.Hit(Damage, Direction : Integer); Var loop : Integer; CurrentX, CurrentY : Integer; TempRect : TRect; Begin Form1.DXWaveListPlayer.Items[1].Play(False); If Damage > 0 Then Dec(Life, Damage); MBars.ShowLife(round(((life / maxlife) * 100) - 1), 100, Form1.DXDraw1.Surface.Canvas, 16 + BorderOffset, 399 - 18 + 15 + BorderOffset); For loop := 1 To 5 Do Begin Case Direction Of 1 : Dec(Y, 10); 2 : Inc(X, 10); 3 : Inc(Y, 10); 4 : Dec(X, 10); Else Begin Y := 0; X := 0; End; End; If y > 400 - Frames[1].Height - 30 Then y := 400 - Frames[1].Height - 30; If x > 600 - Frames[1].Width - 30 Then X := 600 - Frames[1].Width - 30; If Y < 20 Then y := 20; If X < 20 Then X := 20; End; CurrentX := (x Div 40) - LightSource.X; CurrentY := (Y Div 40) - LightSource.Y; temp.Canvas.CopyRect(rect(0, 0, temp.Width, temp.Height), RoomBuffer.Canvas, rect(x - 13, y - 13, x + temp.Width - 13, y + temp.Height - 13)); If IntersectRect(TempRect, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40), Rect(x - 13, y - 13, x + temp.Width, y + temp.Height)) Then Begin Temp.Canvas.Draw(Player.X - X + 13, Player.Y - y + 13, Player.frameimage[Player.Direction * 2 + Player.FrameCount - 2]); End; AlphaBlendFX(temp, shadows[frame], temp, 5, ignorecolor(5, 5, 5), CurrentX * 2 + 13, CurrentY * 2 + 14); Temp.Canvas.Draw(13, 13, Frames[frame]); motionBlurup(temp); If fullscreen Then Form1.DXDraw1.Surface.Canvas.Draw(x - 13, y - 13, temp) Else Form1.DXDraw1.Surface.Canvas.Draw(x - 13 + 16, y - 13 + 16, temp); // end; FlashCounter := 12; AITarget[1] := random(395) + 65; AITarget[2] := Random(190) + 65; AIType := 2; If Life < 1 Then Begin Erase(Form1.DXDraw1.Surface.Canvas); MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; Procedure TBoss.AI1; Begin inc(frame); inc(x, random(7) - 3); Inc(y, random(7) - 3); If frame > 4 Then frame := 3; If random(12) = 1 Then frame := 1; If random(AIChangeChance) = 3 Then AIType := 2; End; Procedure TBoss.AI2; Begin inc(frame); If frame > 4 Then frame := 3; If random(12) = 1 Then frame := 1; If x < AITarget[1] - Speed Then inc(x, Speed) Else If x > AITarget[1] + Speed Then dec(x, Speed); If y < AITarget[2] - Speed Then Inc(y, Speed) Else If y > AITarget[2] + Speed Then dec(y, Speed); If (x > AITarget[1] - 12) And (x < AITarget[1] + 12) And (Y > AITarget[2] - 12) And (Y < AITarget[2] + 12) Then Begin AITarget[1] := random(395) + 65; AITarget[2] := Random(190) + 65; AIType := 1; End; End; End. Unit TEffectsUnit; Interface Uses Graphics, Classes, GraphicFX; Type TEffect = Class Stage : Integer; WorkingArea : TBitmap; Procedure Start; Virtual; Procedure Work; Virtual; Procedure Finish; Virtual; End; TFadeOut = Class (TEffect) Frames : Array[1..25] Of TBitmap; Constructor Create; Procedure Start; Override; Procedure Work; OverRide; Procedure Finish; OverRide; End; Var Effect : TEffect; Implementation Uses Unit1; Procedure TEffect.Start; Begin //fdfd End; Procedure TEffect.Work; Begin //dsds End; Procedure TEffect.Finish; Begin //ds End; Constructor TFadeOut.Create; Begin Stage := 0; End; Procedure TFadeOut.Start; Var Loop : Integer; Begin WorkingArea := TBitmap.Create; WorkingArea.Width := 640; WorkingArea.Height := 400; WorkingArea.PixelFormat := pf24bit; Stage := 1; WorkingArea.Canvas.CopyRect(Rect(0, 0, Workingarea.Width, WorkingArea.Height), Form1.DXDraw1.Surface.Canvas, Rect(16, 16, 16 + Workingarea.Width, 16 + WorkingArea.Height)); For loop := 1 To 25 Do Begin Frames[loop] := TBitmap.Create; Frames[loop].Width := 640; Frames[loop].Height := 400; Frames[loop].PixelFormat := pf24bit; Frames[Loop].Canvas.Draw(0, 0, WorkingArea); Darken(Frames[loop], loop * 10); End; End; Procedure TFadeOut.Work; Begin Form1.DXDraw1.Surface.Canvas.Draw(16, 16, Frames[Stage]); Inc(Stage); End; Procedure TFadeOut.Finish; Var Loop : Integer; Begin For Loop := 1 To 25 Do frames[loop].Free; End; End. Unit TInfoScreenUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TPlayerUnit, EngineUnit; Type TStatScreen = Class Image : TBitmap; Pointer : Integer; Procedure LoadFromFile(Filename : String); Procedure MainScreen; Procedure EventScreen; Procedure LevelUp(StrUp, MagUp, WisUp, LifeUp, MagicUp : Integer); End; TBars = Class Life, Magic, EmptyLife, EmptyMagic, FullLife, FullMagic, BlankLife : TBitmap; Procedure LoadFromFile(Filename : String); Procedure ShowLife(Current, Max : Integer; Target : TCanvas; X, Y : Integer); Procedure ShowMagic(Current, Max : Integer; Target : TCanvas; X, Y : Integer); End; Var StatPressed, StatReleased : Boolean; BorderBevil : TBitmap; Implementation Uses unit1, TPlayerspriteUnit, tileunit, EventUnit; Procedure TStatScreen.LoadFromFile(Filename : String); Begin If Image = Nil Then Image := TBitmap.Create; Image.LoadFromFile(Filename); Image.PixelFormat := pf24bit; End; Procedure TBars.LoadFromFile(FileName : String); Begin If Life = Nil Then Begin Life := TBitmap.Create; Magic := TBitmap.Create; EmptyLife := TBitmap.Create; EmptyMagic := TBitmap.Create; FullLife := TBitmap.Create; FullMagic := TBitmap.Create; BlankLife := TBitmap.Create; End; life.LoadFromFile(Filename); FullLife.LoadFromFile(Filename); FullLife.Width := Player.MaxHP; EmptyLife.LoadFromFile(Filename); Blanklife.LoadFromFile(filename); Blanklife.Width := player.MaxHP; BlankLife.PixelFormat := pf24bit; EmptyLife.Width := player.MaxHP; Life.Width := Player.MaxHP; Magic.LoadFromFile(Filename); FullMagic.LoadFromFile(Filename); FullMagic.Width := Player.MaxMP; EmptyMagic.LoadFromFile(Filename); EmptyMagic.Width := Player.MaxMP; Magic.Width := Player.MaxMP; life.PixelFormat := pf24bit; Fulllife.PixelFormat := pf24bit; EmptyLife.PixelFormat := pf24bit; Magic.PixelFormat := pf24bit; FullMagic.PixelFormat := pf24bit; EmptyMagic.PixelFormat := pf24bit; Swapcolors(EmptyMagic); SwapColors(EmptyMagic); Swapcolors(Emptylife); SwapColors(EmptyLife); SwapColors(FullMagic); End; Procedure TBars.ShowLife(Current, Max : Integer; Target : TCanvas; X, Y : Integer); Begin life.Width := max; life.Canvas.CopyRect(rect(0, 0, Current, life.Height), FullLife.Canvas, rect(0, 0, Current, life.Height)); Life.Canvas.CopyRect(rect(Current + 1, 0, max, Life.Height), EmptyLife.Canvas, Rect(current + 1, 0, Max, Life.Height)); Target.Draw(X, Y, Life); End; Procedure TBars.ShowMagic(Current, Max : Integer; Target : TCanvas; X, Y : Integer); Begin Magic.Canvas.CopyRect(rect(0, 0, Current, Magic.Height), FullMagic.Canvas, rect(0, 0, Current, Magic.Height)); Magic.Canvas.CopyRect(rect(Current + 1, 0, Max, Magic.Height), EmptyMagic.Canvas, Rect(current + 1, 0, Max, Magic.Height)); Target.Draw(X, Y, Magic); End; Procedure TStatScreen.MainScreen; Var tempdef, Loop : Integer; Begin If player.ShieldCounter > 0 Then tempdef := Player.Def + Player.Level * 2 Else tempdef := player.Def; InfoScreen.LoadFromFile('Artwork\background.bmp'); InfoScreen.Image.PixelFormat := pf24bit; Unit1.emeraldFont.Write(17, 15, 'HP ' + IntToStr(Player.HP) + '\' + IntToStr(Player.MaxHP), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(15, 45, 'MP ' + IntToStr(Player.MP) + '\' + IntToStr(Player.maxmp), InfoScreen.Image.Canvas, 25); Unit1.emeraldFont.Write(15, 225, 'Defense ' + IntToStr(Tempdef) + ' Attack ' + IntToStr(Player.atk), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(15, 90, 'Level ' + IntToStr(Player.Level), InfoScreen.Image.Canvas, 25); Unit1.EmeraldFont.Write(15, 120, 'Exp ' + IntToStr((player.wisexp + player.strexp + player.magexp) Div 10) + '\' + IntToStr(Player.NextExp Div 10), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(15, 150, 'Str ' + IntToStr(Player.STRExp Div 10) + ' Mag ' + IntToStr(Player.MagExp Div 10) + ' Wis ' + IntToStr(Player.WisExp Div 10), infoscreen.Image.Canvas, 25); unit1.emeraldFont.Write(15, 195, 'Str ' + IntToStr(Player.Str), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(240, 195, 'Mag ' + IntToStr(Player.mag), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(450, 195, 'Wis ' + IntToStr(Player.Wis), InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(305, 15, currentmap.Name, InfoScreen.Image.Canvas, 25); unit1.emeraldFont.Write(305, 45, 'X ' + IntToStr(Player.MapX) + ' Y ' + IntToStr(Player.MapY), InfoScreen.Image.Canvas, 25); If pointer < 4 Then For Loop := 1 To 3 Do Begin Unit1.EmeraldFont.Write(65 + 225 * (Loop - 1), 250, IntToStr(loop), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 1), 275, player.attacks[Loop].Name + ' ' + IntToStr(Player.attacks[Loop].Level), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 1), 300, 'Damage ' + IntToStr(Player.attacks[Loop].Damage), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 1), 325, 'Exp: ' + IntToStr(Player.Attacks[Loop].Exp), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 1), 350, 'Next: ' + IntToStr(Player.Attacks[Loop].NextLevelEXP), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 1), 375, 'MP ' + IntToStr(Player.Attacks[Loop].cost), InfoScreen.Image.Canvas, 20); End Else For Loop := 4 To 6 Do Begin Unit1.EmeraldFont.Write(65 + 225 * (Loop - 4), 250, IntToStr(loop), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 4), 275, player.attacks[Loop].Name + ' ' + IntToStr(Player.attacks[Loop].Level), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 4), 300, 'Damage ' + IntToStr(Player.attacks[Loop].Damage), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 4), 325, 'Exp: ' + IntToStr(Player.Attacks[Loop].Exp), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 4), 350, 'Next: ' + IntToStr(Player.Attacks[Loop].NextLevelEXP), InfoScreen.Image.Canvas, 20); Unit1.EmeraldFont.Write(15 + 225 * (Loop - 4), 375, 'MP ' + IntToStr(Player.Attacks[Loop].cost), InfoScreen.Image.Canvas, 20); End; Unit1.EmeraldFont.Write(-5, 312, '{', InfoScreen.Image.Canvas); Unit1.EmeraldFont.Write(625, 312, '}', InfoScreen.Image.Canvas); If Pointer < 4 Then Unit1.EmeraldFont.Write (225 * (Pointer - 1) + 65, 250, '<', InfoScreen.Image.Canvas) Else Unit1.EmeraldFont.Write (225 * (Pointer - 4) + 65, 250, '<', InfoScreen.Image.Canvas); Blur(InfoScreen.Image, 7); form1.MainGameTimer.OnTimer := form1.Timer3Timer; End; Procedure TStatScreen.EventScreen; Var Loop, YOffset : Integer; Begin InfoScreen.LoadFromFile('Artwork\eventbackground.bmp'); InfoScreen.Image.PixelFormat := pf24bit; yOffset := 0; For loop := 0 To eventlog.NumberOfEvents - 1 Do If lowercase(copy(EventLog.Events[Loop].EventName, 1, length('Hidden:'))) <> 'hidden:' Then Begin Unit1.emeraldFont.Write(15, 15 + (YOffset * 20), EventLog.Events[Loop].EventName, InfoScreen.Image.Canvas, 15); Unit1.emeraldFont.Write(305, 15 + (YOffset * 20), EventLog.events[Loop].StageName[EventLog.events[Loop].Stage], InfoScreen.Image.Canvas, 15); INC(YOffset); End; Blur(InfoScreen.Image, 7); form1.MainGameTimer.OnTimer := form1.Timer3Timer; End; Procedure TStatScreen.LevelUP(StrUp, MagUp, WisUp, LifeUp, MagicUp : Integer); Begin InfoScreen.LoadFromFile('Artwork\Image2.bmp'); InfoScreen.Image.PixelFormat := pf24bit; unit1.EmeraldFont.Write(150, 20, 'Level is now ' + IntToStr(Player.Level), InfoScreen.image.Canvas, 35); unit1.EmeraldFont.Write(130, 75, 'Life up ' + IntToStr(lifeup) + ' Magic up ' + IntToStr(Magicup), InfoScreen.image.Canvas, 25); unit1.EmeraldFont.Write(50, 115, 'Str up ' + IntToStr(Strup) + ' Mag up ' + IntToStr(Magup) + ' Wis up ' + IntToStr(Wisup), InfoScreen.image.Canvas, 25); unit1.EmeraldFont.Write(50, 155, 'Attack ' + IntToStr(player.Atk) + ' Defence ' + IntToStr(Player.Def) + ' Run ' + IntToStr(Player.DashSpeed), InfoScreen.image.Canvas, 25); unit1.EmeraldFont.Write(50, 320, 'Game has been AutoSaved', InfoScreen.image.Canvas, 25); unit1.EmeraldFont.Write(70, 360, 'Press Space To Return', InfoScreen.image.Canvas, 25); Blur(InfoScreen.Image, 7); form1.MainGameTimer.OnTimer := form1.Timer3Timer; End; End. Unit TItemUnit; Interface Uses Graphics; Type TBackgroundItem = Class X, Y : Integer; Active : Boolean; Image : TBitmap; Name : String; Kind : String; End; TItem = Class Name : String; Kind : String; Bonus : Integer; End; TPotion = Class Name : String; Effect : Integer; End; Var MagicPotions, LifPotions : Array [1..3] Of Integer; Implementation End. Unit TMagicRegenUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TRegenUnit; Type TMagicRegen = Class (TRegen) Procedure Base; Procedure SetStats; End; Implementation Uses unit1, TPlayerUnit, TMonsterUnit, EngineUnit; Procedure TMagicRegen.SetStats; Begin Cost := 0; Damage := (Currentmap.Magicbonus * ActiveLevel + ActiveLevel); End; Procedure TMagicRegen.Base; Var loop, loop2, index : Integer; Begin If (player.MP < Player.MaxMP) Then Begin Inc(HealExpCounter); inc(Player.MPReg, Currentmap.Magicbonus * ActiveLevel + ActiveLevel); If HealExpCounter > (player.MaxHP Div (20 - ActiveLevel)) Then Begin HealExpCounter := 0; End; End; If Stage1 And (Not stage2) Then Begin stage2 := True; Inc(Exp, 1); FrameCount := 0; MaxFrame := 300 + 50 * ActiveLevel; Player.FrameImage[player.direction * 2 - 1].Transparent := False; Bitmap.Canvas.Draw(0, 0, player.frameimage[player.direction * 2 - 1]); Player.FrameImage[player.direction * 2 - 1].Transparent := True; Player.FrameImage[player.direction * 2].Transparent := False; Bitmap2.Canvas.Draw(0, 0, player.frameimage[player.direction * 2]); Player.FrameImage[player.direction * 2].Transparent := True; Form1.DXWaveListPlayer.Items[4].Play(False); LastDirection := Player.Direction; End; If LastDirection <> player.Direction Then Begin Player.FrameImage[player.direction * 2 - 1].Transparent := False; Bitmap.Canvas.Draw(0, 0, player.frameimage[player.direction * 2 - 1]); Player.FrameImage[player.direction * 2 - 1].Transparent := True; Player.FrameImage[player.direction * 2].Transparent := False; Bitmap2.Canvas.Draw(0, 0, player.frameimage[player.direction * 2]); Player.FrameImage[player.direction * 2].Transparent := True; LastDirection := Player.Direction; End; Inc(FrameCount); If FrameCount > MaxFrame Then Begin stage1 := False; Stage2 := False; End; For loop := 0 To bitmap.Height - 2 Do For loop2 := 1 To bitmap.Width - 2 Do Begin index := loop2 * 3; If Not (pixels[loop, index] = 255) Then pixels[loop, index] := pixels[loop + random(2), index + (random(3) - 1) * 3] - loop; If Not (pixels2[loop, index] = 255) Then pixels2[loop, index] := pixels2[loop + random(2), index + (random(3) - 1) * 3] - loop; End; MotionBlurUp(bitmap); If Player.FrameCount = 2 Then Form1.DXDraw1.Surface.Canvas.Draw(Player.x + 16 + BorderOffset, Player.y + 16 + BorderOffset, Bitmap2) Else Form1.DXDraw1.Surface.Canvas.Draw(Player.x + 16 + BorderOffset, Player.y + 16 + BorderOffset, Bitmap); Player.Regenerating := True; End; End. Unit TMonsterBaseUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, DXinput, TSpeakUnit; Type TMonsterBase = Class WhoIAm : Integer; X, Y : Integer; FrameCount, FrameTimer, FrameMaxTimer, Direction : Integer; Speed, Life, MaxLife : Integer; Exp : Integer; FrameImage : Array[1..8] Of TBitmap; StonedFrame : TBitmap; StonedCounter : Integer; Attacking, Hit : Boolean; HitFrame : Integer; Def, Atk : Integer; MoveRatio : Integer; Walking : Boolean; WalkAroundObject : Integer; HitType : String; Text : Array[1..3] Of TSpeak; HitFlash : Integer; SquareMonster, GodMonster, NoAttack : Boolean; AIType : Integer; Stoned : Boolean; Procedure LoadMonsterSprite(Filename : String); Function DetectUp : Boolean; Procedure SpriteLeft; Procedure SpriteRight; Procedure SpriteUp; Procedure SpriteDown; Procedure ShowDown; Procedure Moveup; Procedure MoveDown; Procedure MoveLeft; Procedure MoveRight; Function DetectDown : Boolean; Function DetectLeft : Boolean; Function DetectRight : Boolean; Procedure GetHit(HitType : String); Procedure StripText(Stringin : String; WhatText : Integer); Procedure LeaveBlood; Procedure Erase(ACanvas : TCanvas); End; Implementation Uses unit1, TileUnit, EngineUnit, MovetoUnit, TAIUnit; Procedure TMonsterBase.Erase(ACanvas : TCanvas); Begin ACanvas.CopyRect(rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, 16 + X + 40 + BorderOffset, Y + 16 + 40 + BorderOffset), RoomBuffer.Canvas, rect(x, y, x + 40, y + 40)); End; Procedure TMonsterBase.LoadMonsterSprite(Filename : String); Var Temp : TBitmap; loop : Integer; Begin FrameMaxTimer := 2; FrameCount := 1; FrameTimer := 2; Temp := TBitmap.Create; Temp.LoadFromFile(Filename); For loop := 1 To 8 Do Begin FrameImage[loop].PixelFormat := pf24bit; FrameImage[loop].Width := 40; FrameImage[loop].Height := Temp.Height; FrameImage[loop].Canvas.CopyRect(rect(0, 0, 40, temp.Height), temp.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp.Height)); FrameImage[loop].TransparentColor := rgb(5, 255, 255); FrameImage[loop].Transparent := True; End; Temp.FreeImage; temp.Free; End; Procedure TMonsterBase.SpriteRight; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not stoned Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; StonedFrame.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; Grayscale(StonedFrame, ignorecolor(5, 255, 255)); SpriteBufferX.Canvas.Draw(0, 0, StonedFrame); If StonedCounter = 1 Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurRight(SpriteBufferX); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TMonsterBase.SpriteUp; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not Stoned Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; StonedFrame.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; Grayscale(StonedFrame, ignorecolor(5, 255, 255)); SpriteBufferX.Canvas.Draw(0, 0, StonedFrame); If StonedCounter = 1 Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; //MotionblurUp(SpriteBufferY); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TMonsterBase.SpriteDown; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not stoned Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; StonedFrame.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; Grayscale(StonedFrame, ignorecolor(5, 255, 255)); SpriteBufferX.Canvas.Draw(0, 0, StonedFrame); If StonedCounter = 1 Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurDown(SpriteBufferY); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TMonsterBase.ShowDown; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not stoned Then SpriteBufferY.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; StonedFrame.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; Grayscale(StonedFrame, ignorecolor(5, 255, 255)); SpriteBufferY.Canvas.Draw(0, 0, StonedFrame); If StonedCounter = 1 Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TMonsterBase.SpriteLeft; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not stoned Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; StonedFrame.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; Grayscale(StonedFrame, ignorecolor(5, 255, 255)); SpriteBufferX.Canvas.Draw(0, 0, StonedFrame); If StonedCounter = 1 Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurLeft(SpriteBufferX); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Function TMonsterBase.DetectUp : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; People[peoplecount + 1].X := player.X; People[PeopleCount + 1].Y := player.Y; If SquareMonster Then Begin For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y - 5, x + 40, y + 35), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then Begin If IntersectRect(temprect, rect(x + 5, y - 5, x + 35, y + 35), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False Else x := round(x / 5) * 5; End; End Else For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y + 25, x + 40, y + 36), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then Begin If IntersectRect(temprect, rect(x + 5, y + 25, x + 35, y + 36), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False Else x := round(x / 5) * 5; End; If CurrentRoom.CanAttack Then Begin For loop := 1 To MonsterCount Do If (loop <> WhoIAm) And (Monsters[loop].Life > 0) Then If IntersectRect(TempRect, rect(x, Y - 5, X + 40, Y + 35), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then ok := False; End Else For loop := 1 To PeopleCount + 1 Do If loop <> WhoIAm Then If IntersectRect(TempRect, rect(x, Y - 5, X + 40, Y + 35), rect(People[loop].X, People[loop].Y, People[loop].X + 40, People[loop].Y + 40)) Then ok := False; If RoamingMonster.Active And (WhoIAm <> -69) Then If IntersectRect(TempRect, rect(x, Y - 5, X + 40, Y + 36), rect(RoamingMonster.X, RoamingMonster.Y, RoamingMonster.X + 40, RoamingMonster.Y + 40)) Then ok := False; If ok Then DetectUp := True Else DetectUp := False; End; Procedure TMonsterBase.MoveUp; Begin If stoned Then FrameCount := 1 Else Begin If DetectUp Then inc(y, - Speed) Else If Not Hit Then Direction := random(4) + 1; End; If Y < 3 Then Y := 3; // SpriteUp; End; Function TMonsterBase.DetectDown : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; People[peoplecount + 1].X := player.X; People[PeopleCount + 1].Y := player.Y; If SquareMonster Then Begin For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y + 5, x + 40, y + 45), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; End Else For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y + 39, x + 40, y + 45), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; If CurrentRoom.CanAttack Then Begin For loop := 1 To MonsterCount Do If (loop <> WhoIAm) And (Monsters[loop].Life > 0) Then If IntersectRect(TempRect, rect(x, Y + 5, X + 40, Y + 45), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then ok := False; End Else For loop := 1 To PeopleCount + 1 Do If loop <> WhoIAm Then If IntersectRect(TempRect, rect(x, Y + 5, X + 40, Y + 45), rect(People[loop].X, People[loop].Y, People[loop].X + 40, People[loop].Y + 40)) Then ok := False; If RoamingMonster.Active And (WhoIAm <> -69) Then If IntersectRect(TempRect, rect(x, Y + 5, X + 40, Y + 45), rect(RoamingMonster.X, RoamingMonster.Y, RoamingMonster.X + 40, RoamingMonster.Y + 40)) Then ok := False; If ok Then DetectDown := True Else DetectDown := False; End; Procedure TMonsterBase.MoveDown; Begin If stoned Then FrameCount := 1 Else Begin If DetectDown Then inc(Y, Speed) Else If Not Hit Then Direction := random(4) + 1; If Y > 355 Then Y := 355; End; // SpriteDown; End; Function TMonsterBase.DetectLeft : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; People[peoplecount + 1].X := player.X; People[PeopleCount + 1].Y := player.Y; If SquareMonster Then Begin For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x - 5, y, x + 35, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; End Else For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x - 5, y + 35, x + 5, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; If CurrentRoom.CanAttack Then Begin For loop := 1 To MonsterCount Do If (loop <> WhoIAm) And (Monsters[loop].Life > 0) Then If IntersectRect(TempRect, rect(x - 5, Y, X + 35, Y + 40), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then ok := False; End Else For loop := 1 To PeopleCount + 1 Do If loop <> WhoIAm Then If IntersectRect(TempRect, rect(x - 5, Y, X + 35, Y + 40), rect(People[loop].X, People[loop].Y, People[loop].X + 40, People[loop].Y + 40)) Then ok := False; If RoamingMonster.Active And (WhoIAm <> -69) Then If IntersectRect(TempRect, rect(x - 5, Y, X + 35, Y + 40), rect(RoamingMonster.X, RoamingMonster.Y, RoamingMonster.X + 40, RoamingMonster.Y + 40)) Then ok := False; If ok Then DetectLeft := True Else DetectLeft := False; End; Procedure TMonsterBase.MoveLeft; Begin If stoned Then FrameCount := 1 Else Begin If DetectLeft Then inc(X, - Speed) Else If Not Hit Then Direction := random(4) + 1; End; If X < 5 Then X := 5; //SpriteLeft; End; Procedure TMonsterBase.MoveRight; Begin If stoned Then FrameCount := 1 Else Begin If DetectRight Then inc(X, Speed) Else If Not Hit Then Direction := random(4) + 1; If X > 595 Then X := 595; End; // Spriteright; End; Procedure TMonsterBase.LeaveBlood; Var TempBMP : TBitmap; Begin TempBMP := TBitmap.Create; TempBMP.Width := 40; TempBMP.Height := 40; TempBMP.PixelFormat := pf24bit; Tempbmp.Canvas.CopyRect(rect(0, 0, 40, 40), RoomBuffer.Canvas, rect(x, y, x + 40, y + 40)); LightMap(TempBMP, Blood, TempBMP); roombuffer.Canvas.Draw(x, y, TempBMP); TempBMP.Free; End; Function TMonsterBase.DetectRight : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; People[peoplecount + 1].X := player.X; People[PeopleCount + 1].Y := player.Y; If SquareMonster Then Begin For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x + 5, y, x + 45, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; End Else For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x + 35, y + 35, x + 45, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; If CurrentRoom.CanAttack Then Begin For loop := 1 To MonsterCount Do If (loop <> WhoIAm) And (Monsters[loop].Life > 0) Then If IntersectRect(TempRect, rect(x + 5, Y, X + 45, Y + 40), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then ok := False; End Else For loop := 1 To PeopleCount + 1 Do If loop <> WhoIAm Then If IntersectRect(TempRect, rect(x + 5, Y, X + 45, Y + 40), rect(People[loop].X, People[loop].Y, People[loop].X + 40, People[loop].Y + 40)) Then ok := False; If RoamingMonster.Active And (WhoIAm <> -69) Then If IntersectRect(TempRect, rect(x + 5, Y, X + 45, Y + 40), rect(RoamingMonster.X, RoamingMonster.Y, RoamingMonster.X + 40, RoamingMonster.Y + 40)) Then ok := False; If ok Then DetectRight := True Else DetectRight := False; End; Procedure TMonsterBase.GetHit(HitType : String); Var loop, knockback : Integer; Begin If maxlife < 1 Then maxlife := 1; MBars.ShowLife(round(((life / maxlife) * 100) - 1), 100, Form1.DXDraw1.Surface.Canvas, 16 + BorderOffset, 399 - 18 + 15 + BorderOffset); If HitFlash > 0 Then Begin For loop := 1 To 8 Do invert(frameimage[loop], ignorecolor(5, 255, 255)); dec(HitFlash); End; If Not hit Then Begin If Player.Direction = 4 Then Direction := 2 Else If Player.Direction = 3 Then Direction := 1 Else If Player.Direction = 2 Then Direction := 4 Else If Player.Direction = 1 Then Direction := 3; Hit := True; If GodMonster Then hit := False; HitFrame := 0; If player.Impact = 'Monster Side' Then Begin Form1.DXWaveListPlayer.Items.Find('Get Hit').Play(False); End Else Begin If Player.Impact = 'Face' Then form1.DXWaveListPlayer.Items[2].Play(False); End; End; Inc(HitFrame); If life < 1 Then Begin LeaveBlood; Begin SetLength(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray, Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray) + 1); Currentmap.Rooms[Player.mapx, player.MapY].BloodArray[Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray) - 1].X := Self.X; Currentmap.Rooms[Player.mapx, player.MapY].BloodArray[Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray) - 1].Y := Self.Y; End; ClearMonsterBMP.Canvas.CopyRect(rect(0, 0, 40, 40), RoomBuffer.Canvas, rect(x, y, x + 40, y + 40)); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, ClearMonsterBMP); If WhoIAm = -69 Then RoamingMonster.Active := False; End Else Begin knockback := 3; If HitType = 'Hand' Then knockback := 3; Erase(Form1.DXDraw1.Surface.Canvas); If Direction = 1 Then For loop := 1 To knockback Do MoveDown Else If Direction = 2 Then For loop := 1 To knockback Do MoveLeft Else If Direction = 3 Then For loop := 1 To knockback Do MoveUp Else If Direction = 4 Then For loop := 1 To knockback Do MoveRight; Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; If (HitFrame > 10) Then Hit := False; End; If Not hit Or (Life < 1) Then Begin MBars.BlankLife.Width := 100; MBars.blankLife.Canvas.CopyRect(rect(0, 0, 100, 18), roombuffer.Canvas, rect(0, 399 - 18, 100, 399)); Form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 399 - 18 + 15 + BorderOffset, mbars.BlankLife); End; End; Function StripTextOfSimiColons(Instring : String) : TTextStrings; Var Counter, LastCounter : Integer; Tempstrings : TTextStrings; Begin Counter := 0; Repeat Setlength(Tempstrings, length(tempstrings) + 1); LastCounter := Counter; Repeat Inc(Counter); Until (instring[counter] = ';') Or (Counter = length(Instring)); Tempstrings[Length(TempStrings) - 1] := copy(InString, LastCounter + 1, counter - lastcounter - 1); Until counter = length(Instring); StripTextOfSimiColons := Tempstrings; End; Procedure TMonsterBase.StripText(StringIn : String; WhatText : Integer); Var Tempstr : String; Index, LastIndex : Integer; Begin TempStr := StringIn; Text[WhatText].NumberOfEvents := 0; LastIndex := 0; Index := 0; Text[WhatText].NumberOfLines := 0; Text[WhatText].Movie := ''; While Index < length(Tempstr) Do Begin Repeat Inc(Index); Until (Index = length(Tempstr)) Or (tempstr[index] = ';'); Inc(Text[whattext].NumberOfLines); setlength(Text[whattext].Lines, Text[whattext].NumberOfLines); Text[WhatText].Lines[Text[whattext].NumberOfLines - 1] := copy(StringIn, LastIndex + 1, Index - lastindex); If Lowercase(copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], 1, length('#AddEvent:'))) = '#addevent:' Then Begin inc(Text[WhatText].NumberOfEvents); SetLength(Text[WhatText].TriggerEvents, Text[WhatText].NumberOfEvents); Text[WhatText].TriggerEvents[Text[WhatText].NumberOfEvents - 1].AddEvent := True; Text[WhatText].TriggerEvents[Text[WhatText].NumberOfEvents - 1].EventName := copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], length('#AddEvent: '), length(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1]) - length('#AddEvent: ')); Dec(Text[whattext].NumberOfLines); End; If Lowercase(copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], 1, length('#ShowMovie:'))) = '#showmovie:' Then Begin Text[WhatText].Movie := (copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], length('#ShowMovie: '), length(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1]) - length('#ShowMovie: '))); Dec(EventinRoom.NumberOfLines); End; If Lowercase(copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], 1, length('#SetEvent:'))) = '#setevent:' Then Begin inc(Text[WhatText].NumberOfEvents); SetLength(Text[WhatText].TriggerEvents, Text[WhatText].NumberOfEvents); Text[WhatText].TriggerEvents[Text[WhatText].NumberOfEvents - 1].AddEvent := False; Text[WhatText].TriggerEvents[Text[WhatText].NumberOfEvents - 1].EventName := copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], length('#SetEvent: '), length(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1]) - length('#SetEvent: ')); Dec(Text[whattext].NumberOfLines); End; If Lowercase(copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], 1, length('#EventLevel:'))) = '#eventlevel:' Then Begin Text[WhatText].TriggerEvents[Text[WhatText].NumberOfEvents - 1].EventLevel := StrToInt(copy(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1], length('#EventLevel: '), length(Text[WhatText].Lines[Text[whattext].NumberOfLines - 1]) - length('#EventLevel: '))); Dec(Text[whattext].NumberOfLines); End; LastIndex := index; End; End; End. Unit TMonsterUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, DXinput, TSpeakUnit, TMonsterBaseUnit, TAIUnit; Type TMonster = Class (TMonsterBase) AIClass : TAIBase; Constructor Create; Procedure LoadMonster(Filename : String); Procedure AI(Monster : TMonsterBase); Procedure LoadPerson(Filename : String); End; Implementation Uses unit1, TileUnit, EngineUnit, MovetoUnit; Procedure TMonster.LoadPerson(Filename : String); Var Temp, Temp2 : TBitmap; loop, Loop2, Swaps : Integer; TempFrameImage, Masks : Array [1..8] Of TBitmap; Begin Inc(PeopleCount); Temp := TBitmap.Create; Temp2 := TBitmap.Create; ChDir(ExtractFiledir(ParamStr(0))); form1.SpriteMemo.Lines.LoadFromFile(Filename); Temp.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[3]); Temp2.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[5]); LoadMonsterSprite('sprites\' + Form1.SpriteMemo.Lines[7]); Swaps := StrToInt(Form1.SpriteMemo.Lines[8]); For loop := 1 To 8 Do Begin TempFrameImage[loop] := TBitmap.Create; Masks[loop] := TBitmap.Create; TempFrameImage[loop].PixelFormat := pf24bit; TempFrameImage[loop].Width := 40; TempFrameImage[loop].Height := Temp.Height; TempFrameImage[loop].Canvas.CopyRect(rect(0, 0, 40, temp.Height), temp.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp.Height)); TempFrameImage[loop].TransparentColor := rgb(5, 255, 255); TempFrameImage[loop].Transparent := True; Masks[loop].PixelFormat := pf24bit; Masks[loop].Width := 40; Masks[loop].Height := temp2.Height; Masks[loop].Canvas.CopyRect(rect(0, 0, 40, temp2.Height), temp2.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp2.Height)); Masks[loop].TransparentColor := rgb(0, 0, 0); Masks[loop].Transparent := True; For loop2 := 1 To Swaps Do SwapColors(TempFrameImage[loop]); TempFrameImage[Loop].Canvas.Draw(0, 0, Masks[loop]); FrameImage[loop].Canvas.Draw(0, 0, TempFrameImage[loop]); End; For loop := 1 To 8 Do Begin Masks[loop].FreeImage; Masks[loop].Free; TempFrameImage[loop].FreeImage; TempFrameImage[loop].Free; End; Temp.FreeImage; Temp2.FreeImage; Temp.Free; Temp2.Free; FrameCount := 1; Hit := False; WhoIAm := PeopleCount; Speed := StrToInt(Form1.SpriteMemo.Lines[16]); MoveRatio := StrToInt(Form1.SpriteMemo.Lines[20]); Direction := random(4) + 1; AIType := StrToInt(Form1.SpriteMemo.Lines[22]); AIClass.Free; Case aitype Of 1 : AIClass := TAIRandom30.Create; 2 : AIClass := TAIHoming.Create; 3 : AIClass := TAIDown.Create; 4 : AIClass := TAIHoming2.Create; 5 : AIClass := TAIDontMove_Up.Create; 6 : AIClass := TAIDontMove_Right.Create; 7 : AIClass := TAIDontMove_Down.Create; 8 : AIClass := TAIDontMove_Left.Create; 9 : AIClass := TAIUnthinking.Create; Else Begin AIClass := TAIRandom30.Create; End; End; End; Constructor TMonster.Create; Begin AIClass := TAIRandom30.Create; End; Procedure TMonster.LoadMonster(Filename : String); Var Temp, Temp2 : TBitmap; loop, Loop2, Swaps : Integer; TempFrameImage, Masks : Array [1..8] Of TBitmap; Begin If whoIam <> -69 Then Inc(MonsterCount); Temp := TBitmap.Create; Temp2 := TBitmap.Create; ChDir(ExtractFiledir(ParamStr(0))); form1.SpriteMemo.Lines.LoadFromFile(Filename); If form1.SpriteMemo.Lines[form1.SpriteMemo.Lines.Count - 1] = 'SquareMonster' Then SquareMonster := True Else SquareMonster := False; If form1.SpriteMemo.Lines[form1.SpriteMemo.Lines.Count - 2] = 'Indestructable' Then GodMonster := True Else GodMonster := False; Temp.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[3]); Temp2.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[5]); LoadMonsterSprite('sprites\' + Form1.SpriteMemo.Lines[7]); Swaps := StrToInt(Form1.SpriteMemo.Lines[8]); For loop := 1 To 8 Do Begin TempFrameImage[loop] := TBitmap.Create; Masks[loop] := TBitmap.Create; TempFrameImage[loop].PixelFormat := pf24bit; TempFrameImage[loop].Width := 40; TempFrameImage[loop].Height := Temp.Height; TempFrameImage[loop].Canvas.CopyRect(rect(0, 0, 40, temp.Height), temp.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp.Height)); TempFrameImage[loop].TransparentColor := rgb(5, 255, 255); TempFrameImage[loop].Transparent := True; Masks[loop].PixelFormat := pf24bit; Masks[loop].Width := 40; Masks[loop].Height := temp2.Height; Masks[loop].Canvas.CopyRect(rect(0, 0, 40, temp2.Height), temp2.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp2.Height)); Masks[loop].TransparentColor := rgb(0, 0, 0); Masks[loop].Transparent := True; For loop2 := 1 To Swaps Do SwapColors(TempFrameImage[loop]); TempFrameImage[Loop].Canvas.Draw(0, 0, Masks[loop]); FrameImage[loop].Canvas.Draw(0, 0, TempFrameImage[loop]); End; For loop := 1 To 8 Do Begin Masks[loop].FreeImage; Masks[loop].Free; TempFrameImage[loop].FreeImage; TempFrameImage[loop].Free; End; Temp.FreeImage; Temp2.FreeImage; Temp.Free; Temp2.Free; FrameCount := 0; Hit := False; If whoIam <> -69 Then WhoIAm := MonsterCount; Life := StrToInt(form1.SpriteMemo.Lines[10]); Atk := StrToInt(Form1.SpriteMemo.Lines[12]); Def := StrToInt(Form1.SpriteMemo.Lines[14]); Speed := StrToInt(Form1.SpriteMemo.Lines[16]); Exp := StrToInt(Form1.SpriteMemo.Lines[18]); MoveRatio := StrToInt(Form1.SpriteMemo.Lines[20]); Direction := random(4) + 1; MaxLife := Life; AIType := StrToInt(Form1.SpriteMemo.Lines[22]); StonedCounter := 0; AIClass.Free; Case aitype Of 1 : AIClass := TAIRandom30.Create; 2 : AIClass := TAIHoming.Create; 3 : AIClass := TAIDown.Create; 4 : AIClass := TAIHoming2.Create; 5 : AIClass := TAIDontMove_Up.Create; 6 : AIClass := TAIDontMove_Right.Create; 7 : AIClass := TAIDontMove_Down.Create; 8 : AIClass := TAIDontMove_Left.Create; 9 : AIClass := TAIUnthinking.Create; End; End; Procedure TMonster.AI(Monster : TMonsterBase); Var loop : Integer; Begin If StonedCounter > 0 Then Begin dec(StonedCounter); Stoned := True; End Else Stoned := False; If Not stoned And Not MoveTo.Enabled Then Begin AIClass.Think(Monster); Case Direction Of 1 : Moveup; 2 : MoveRight; 3 : MoveDown; 4 : MoveLeft; End; Case Direction Of 1 : Spriteup; 2 : SpriteRight; 3 : SpriteDown; 4 : SpriteLeft; End; End Else If MoveTo.Enabled Then Begin FrameCount := 1; ShowDown; End; If stoned Then Case Direction Of 1 : Spriteup; 2 : SpriteRight; 3 : SpriteDown; 4 : SpriteLeft; End; If HitFlash > 0 Then Begin For loop := 1 To 8 Do invert(frameimage[loop], ignorecolor(5, 255, 255)); dec(HitFlash); End; End; End. Unit TPersonUnit; Interface Uses TMonsterUnit; Type TPerson = Class (TMonster) End; Implementation End. Unit TPlayerUnit; Interface Uses Windows, MPlayer, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, TItemUnit, Dialogs, types, graphicFX, TileUnit, DXinput, TSparkUnit, TDarkSparkUnit, THasteUnit, TPlayerSpriteUnit, THealingUnit, TShieldUnit, THolyShowerUnit, TWaveUnit, TRegenUnit, TMagicRegenUnit; {Spell Vales: 1 - Spark 2 - Dark Spark 3 - Heal 4 - Magic Regen 5 - Regen 6 - Holy 7 - Haste } Const MonsterRegen = 15; Type TPlayer = Class (TPlayerSprite) MapX, MapY : Integer; HP, MaxHP, HPReg, HPRegRate : Integer; MP, MaxMP, MPReg, MPRegRate : Integer; Str, Mag, Wis, Atk, Def, Level : Integer; DashSpeed : Integer; STRExp, MagExp, WisExp : Integer; NextExp : Integer; Attacking, Hit, healing, Regenerating : Boolean; SwappedColors : Integer; Impact : String; HitFlashCount : Integer; ShotCounter : Integer; Color : Array[1..4] Of Integer; Items : Array Of TItem; Attacks : Array[1..6] Of Record Name : String; Spell, Level, MaxLevel, Damage, EXP, NextLevelEXP, Cost : Integer; SparkAttack : Boolean; End; Public Procedure Init; Function Rectangle : TRect; Procedure MoveLeft(Button : Boolean); Procedure MoveRight(Button : Boolean); Procedure MoveUp(Button : Boolean); Procedure MoveDown(Button : Boolean); Procedure ShowSprite; Procedure LoadFromFile(FileName : String); Procedure LoadPlayerSprite(FileName : String); Procedure DarkSparkAttack(WhatOne : Integer); Procedure SparkAttack; Procedure HolyStorm; Procedure GetHit; Procedure CheckForHit; Procedure LevelUp; Procedure Regenerate; Procedure Input; Procedure Save(Filename : String); Procedure Load(Filename : String); Procedure ChangeMap(Link : Integer); Procedure CheckForTalk; Procedure RoamingMonsterDelay; Procedure FindAttack; Private Procedure FindDamage(Who : Integer); Function SideWalk : Boolean; End; Var Spark : TSpark; Heal : THealing; Shield : TShield; HolyShower : THolyShower; Haste : THaste; WaveAttack : TWave; Regen : TRegen; DarkSpark : Array [1..3] Of TDarkSpark; MagicRegen : TMagicRegen; TalkOffset, TalkWait : Integer; ScrollTalk : Boolean; Whatline : Integer; CurrentNumberOfLines : Integer; StartHealing : Boolean; Procedure RaiseLevel(WhatAttack : Integer); Procedure LowerLevel(WhatAttack : Integer); Procedure AssignAttack(WhatAttack, WhatSpell : Integer); Implementation Uses TBossUnit, EngineUnit, Unit1, TInfoscreenUnit, EventUnit, MusicUnit, MoveToUnit; Function TPlayer.SideWalk : Boolean; Var Loop : Integer; Begin Result := False; For loop := 1 To 6 Do If (Attacks[loop].Name = 'SideWalk') And (SetButtons[loop] In Form1.DXInput1.States) Then Result := True; End; Procedure LowerLevel(WhatAttack : Integer); Begin Case Player.Attacks[WhatAttack].Spell Of 1 : Begin Dec(Spark.ActiveLevel); If Spark.ActiveLevel = 0 Then Spark.ActiveLevel := Spark.Level; Spark.Cost := Round(Spark.ActiveLevel * 1.2); End; 2 : Begin Dec(DarkSpark[1].ActiveLevel); If DarkSpark[1].ActiveLevel = 0 Then DarkSpark[1].ActiveLevel := DarkSpark[1].Level; Darkspark[1].SetStats; End; 3 : Begin Dec(Heal.ActiveLevel); If Heal.ActiveLevel = 0 Then Heal.ActiveLevel := Heal.Level; Heal.SetStats; End; 4 : If Not MagicRegen.Stage1 Then Begin Dec(MagicRegen.ActiveLevel); If MagicRegen.ActiveLevel = 0 Then MagicRegen.ActiveLevel := MagicRegen.Level; MagicRegen.SetStats; End; 5 : Begin Dec(Regen.ActiveLevel); If Regen.ActiveLevel = 0 Then Regen.ActiveLevel := Regen.Level; Regen.SetStats; End; 6 : Begin Dec(HolyShower.ActiveLevel); If HolyShower.ActiveLevel = 0 Then HolyShower.ActiveLevel := HolyShower.Level; HolyShower.SetStats; End; 7 : Begin Dec(Haste.ActiveLevel); If Haste.ActiveLevel = 0 Then Haste.ActiveLevel := Haste.Level; Haste.SetStats; End; 8 : Begin Dec(Shield.ActiveLevel); If Shield.ActiveLevel = 0 Then Shield.ActiveLevel := Shield.Level; Shield.SetStats; End; End; AssignAttack(WhatAttack, Player.Attacks[WhatAttack].Spell); End; Procedure RaiseLevel(WhatAttack : Integer); Begin Case Player.Attacks[WhatAttack].Spell Of 1 : Begin Inc(Spark.ActiveLevel); If Spark.ActiveLevel > Spark.Level Then Spark.ActiveLevel := 1; Spark.Cost := Round(Spark.ActiveLevel * 1.2); End; 2 : Begin Inc(DarkSpark[1].ActiveLevel); If DarkSpark[1].ActiveLevel > DarkSpark[1].Level Then DarkSpark[1].ActiveLevel := 1; Darkspark[1].SetStats; End; 3 : Begin Inc(Heal.ActiveLevel); If Heal.ActiveLevel > Heal.Level Then Heal.ActiveLevel := 1; Heal.SetStats; End; 4 : If Not MagicRegen.Stage1 Then Begin Inc(MagicRegen.ActiveLevel); If MagicRegen.ActiveLevel > MagicRegen.Level Then MagicRegen.ActiveLevel := 1; MagicRegen.SetStats; End; 5 : Begin Inc(Regen.ActiveLevel); If Regen.ActiveLevel > Regen.Level Then Regen.ActiveLevel := 1; Regen.SetStats; End; 6 : Begin Inc(HolyShower.ActiveLevel); If HolyShower.ActiveLevel > HolyShower.Level Then HolyShower.ActiveLevel := 1; HolyShower.SetStats; End; 7 : Begin Inc(Haste.ActiveLevel); If Haste.ActiveLevel > Haste.Level Then Haste.ActiveLevel := 1; Haste.SetStats; End; 8 : Begin Inc(Shield.ActiveLevel); If Shield.ActiveLevel > Shield.Level Then Shield.ActiveLevel := 1; Shield.SetStats; End; End; AssignAttack(WhatAttack, Player.Attacks[WhatAttack].Spell); End; Procedure AssignAttack(WhatAttack, WhatSpell : Integer); Begin With Player.Attacks[WhatAttack] Do Case Whatspell Of 0 : Begin Name := 'SideWalk'; Spell := WhatSpell; Level := 1; MaxLevel := 1; Exp := 0; NextLevelEXP := 0; Damage := 0; Cost := 0; End; 1 : Begin Name := 'Spark'; Spell := WhatSpell; Level := Spark.ActiveLevel; MaxLevel := Spark.Level; Exp := Spark.Exp; NextLevelEXP := spark.Level * spark.Level * 50; Damage := Player.Mag Div (10 - Spark.Activelevel); Cost := Spark.Cost; End; 2 : Begin DarkSpark[1].SetStats; Name := 'Dark Spark'; Spell := WhatSpell; Level := darkspark[1].ActiveLevel; MaxLevel := DarkSpark[1].Level; Exp := DarkSpark[1].Exp; NextLevelEXP := DarkSpark[1].Level * DarkSpark[1].Level * 75; Damage := DarkSpark[1].Damage; Cost := DarkSpark[1].Cost; End; 3 : Begin Heal.SetStats; Name := 'Heal'; Spell := WhatSpell; Level := Heal.ActiveLevel; MaxLevel := Heal.Level; Exp := Heal.Exp; NextLevelEXP := Heal.Level * Heal.Level * 50; Damage := Heal.Damage; Cost := Heal.Cost; End; 4 : Begin MagicRegen.SetStats; Name := 'Magic Regen'; Spell := WhatSpell; Level := MagicRegen.ActiveLevel; MaxLevel := MagicRegen.Level; Exp := MagicRegen.Exp; NextLevelEXP := MagicRegen.Level * MagicRegen.Level * 50; Damage := MagicRegen.Damage; Cost := MagicRegen.Cost; End; 5 : Begin Regen.SetStats; Name := 'Regen'; Spell := WhatSpell; Level := Regen.ActiveLevel; MaxLevel := Regen.Level; Exp := Regen.Exp; NextLevelEXP := Regen.Level * Regen.Level * 50; Damage := Regen.Damage; Cost := Regen.Cost; End; 6 : Begin HolyShower.SetStats; Name := 'Radiance'; Spell := WhatSpell; Level := HolyShower.ActiveLevel; MaxLevel := HolyShower.Level; Exp := HolyShower.Exp; NextLevelEXP := HolyShower.Level * HolyShower.Level * 50; Damage := HolyShower.Damage; Cost := HolyShower.Cost; End; 7 : Begin Haste.SetStats; Name := 'Haste'; Spell := WhatSpell; Level := Haste.ActiveLevel; MaxLevel := Haste.Level; Exp := Haste.Exp; NextLevelEXP := Haste.Level * Haste.Level * 50; Damage := Haste.Damage; Cost := Haste.Cost; End; 8 : Begin Shield.SetStats; Name := 'Shield'; Spell := WhatSpell; Level := Shield.ActiveLevel; MaxLevel := Shield.Level; Exp := Shield.Exp; NextLevelEXP := Shield.Level * Shield.Level * 50; Damage := Shield.Damage; Cost := Shield.Cost; End; End; End; Function TPlayer.Rectangle : TRect; Begin Rectangle := Rect(X, Y, X + 40, Y + 40); End; Procedure TPlayer.Init; Var Loop, Loop2 : Integer; Begin FrameCountMax := 2; ShotCounter := 0; SwappedColors := 3; color[1] := 0; Color[2] := 0; Color[3] := 0; Color[4] := 0; Haste := THaste.Create; Haste.level := 1; Haste.ActiveLevel := 1; Haste.SpeedLevel := 0; Haste.Counter := 0; Haste.active := False; Haste.ShowHaste := TBitmap.Create; Haste.ClearHaste := TBitmap.Create; Haste.ShowHaste.Width := 100; Haste.ShowHaste.Height := 25; Haste.ShowHaste.PixelFormat := pf24bit; Haste.ClearHaste.Width := 100; Haste.ClearHaste.Height := 25; Haste.ClearHaste.PixelFormat := pf24bit; EmeraldFont.Write(0, 0, 'Haste', Haste.ShowHaste.Canvas, 25); Haste.ShowHaste.TransparentColor := rgb(255, 255, 255); Haste.ShowHaste.Transparent := True; Firstheal := True; Secondheal := False; healing := False; Hit := False; HitFrame := 0; ShieldFrame := 0; ShieldCounter := 00; Spark := TSpark.Create; For loop2 := 1 To 3 Do DarkSpark[Loop2] := TDarkSpark.Create; HolyShower := THolyShower.Create; Heal := THealing.Create; Regen := TRegen.Create; MagicRegen := TMagicRegen.Create; Shield := TShield.Create; For loop := 1 To 4 Do Begin Shield.Frames[loop] := TBitmap.Create; Shield.frames[loop].LoadFromFile('Attacks\Shield\' + IntToStr(loop) + '.bmp'); Shield.Frames[loop].PixelFormat := pf24bit; Shield.Frames[loop].TransparentColor := rgb(0, 255, 255); Shield.Frames[loop].Transparent := True; End; Shield.Level := 1; Shield.ActiveLevel := 1; WaveAttack := TWave.Create; WaveAttack.Load; Attacking := False; MapX := 0; MapY := 0; Direction := 3; X := 176; Y := 160; For loop := 1 To 8 Do FrameImage[loop] := TBitmap.Create; For loop := 1 To 8 Do FrameImage[loop].PixelFormat := pf24bit; For loop := 1 To 8 Do ShadowImage[loop] := TBitmap.Create; For loop := 1 To 8 Do ShadowImage[loop].PixelFormat := pf24bit; HP := 35; MaxHP := 35; HPReg := 0; HPRegRate := 200; MP := 35; MaxMP := 35; MPReg := 0; Str := 25; Wis := 25; Mag := 25; Level := 1; Strexp := 0; MagExp := 0; WisExp := 0; NextExp := 1500; Player.MPRegRate := 200; DashSpeed := 0; Def := (((Str + Wis) Div 2) * level) Div 10; Atk := (Str * Level Div 10); heal.Bitmap := TBitmap.Create; heal.Bitmap.Width := 40; heal.Bitmap.Height := 40; heal.Bitmap.PixelFormat := pf24bit; heal.Bitmap.TransparentColor := rgb(5, 255, 255); heal.Bitmap.Transparent := True; setlength(heal.Pixels, heal.bitmap.Height); For loop := 0 To heal.bitmap.Height - 1 Do heal.pixels[loop] := heal.bitmap.ScanLine[loop]; sLightMap := TBitmap.Create; sLightMap.Width := 40; sLightmap.Height := 40; sLightmap.PixelFormat := pf24bit; tempLightmap := TBitmap.Create; tempLightmap.Width := 40; tempLightmap.Height := 40; tempLightmap.PixelFormat := pf24bit; TempLightMap.TransparentColor := rgb(5, 255, 255); TempLightMap.Transparent := True; SetLength(TempLightScan, TempLightMap.Height); For Loop := 0 To TempLightMap.Height - 1 Do TempLightScan[loop] := TempLightMap.ScanLine[loop]; SetLength(sLightmapScan, sLightmap.Height); For Loop := 0 To sLightmap.Height - 1 Do sLightmapScan[loop] := sLightmap.ScanLine[loop]; Spark.Setstats; Heal.SetStats; darkspark[1].SetStats; Regen.SetStats; MagicRegen.SetStats; Shield.SetStats; HolyShower.SetStats; haste.SetStats; For loop := 1 To 6 Do AssignAttack(Loop, loop); End; Procedure TPlayer.ShowSprite; Begin If Direction = 1 Then ShowUp Else If Direction = 2 Then ShowRight Else If Direction = 3 Then ShowDown Else ShowLeft; End; Procedure TPlayer.MoveLeft(Button : Boolean); Var loop : Integer; MonstersLeft : Integer; Begin If Not Button Then Direction := 4; If DetectLeft Then inc(X, - 5); If (X < 10) And (Player.MapX > 0) And Not hit Then Begin RoamingMonsterDelay; X := 590; MonstersLeft := 0; Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer := MonsterRegen; // SetLength(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray,0); For loop := 1 To MonsterCount Do If Monsters[loop].Life > 0 Then Begin inc(monstersleft); End; {else begin SetLength(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray,Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray)+1); Currentmap.Rooms[Player.mapx, player.MapY].BloodArray[Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray)-1].X := Monsters[loop].X; Currentmap.Rooms[Player.mapx, player.MapY].BloodArray[Length(Currentmap.Rooms[Player.mapx, player.MapY].BloodArray)-1].Y := Monsters[loop].Y; end; } CurrentMap.Rooms[player.mapx, player.mapy].Monsters := MonstersLeft; If MonstersLeft > 0 Then inc(Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer, 5); Inc(Player.MapX, - 1); ReleaseRoom; If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); Inc(x, - 30); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; form1.Button1Click(form1); End; If X < 10 Then X := 10; // SpriteLeft; End; Procedure TPlayer.MoveRight(Button : Boolean); Var loop : Integer; MonstersLeft : Integer; Begin If Not Button Then Direction := 2; If Player.DetectRight Then inc(X, 5); If (X >= 590) And (Player.MapX < currentmap.Width - 1) And Not hit Then Begin RoamingMonsterDelay; X := 10; MonstersLeft := 0; Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer := MonsterRegen; For loop := 1 To MonsterCount Do If Monsters[loop].Life > 0 Then inc(monstersleft); CurrentMap.Rooms[player.mapx, player.mapy].Monsters := MonstersLeft; If MonstersLeft > 0 Then inc(Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer, 5); inc(Player.MapX); ReleaseRoom; If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); Inc(x, 30); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; form1.Button1Click(form1); End; If X > 590 Then X := 590; // Spriteright; End; Procedure TPlayer.MoveUp(Button : Boolean); Var loop, monstersleft : Integer; temprect : TRect; Begin If Not Button Then Direction := 1; If DetectUp Then inc(y, - 5); If (y <= 5) And (Player.Mapy > 0) And Not hit Then Begin RoamingMonsterDelay; Y := 350; MonstersLeft := 0; Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer := MonsterRegen; For loop := 1 To MonsterCount Do If Monsters[loop].Life > 0 Then inc(monstersleft); CurrentMap.Rooms[player.mapx, player.mapy].Monsters := MonstersLeft; If MonstersLeft > 0 Then inc(Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer, 5); inc(Player.MapY, - 1); ReleaseRoom; If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); Inc(y, - 30); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; form1.Button1Click(form1); End; For loop := 0 To currentmap.NumberOfHyperLinks Do If (MapX = Currentmap.HyperLinks[loop].MapX) And (MapY = Currentmap.HyperLinks[loop].MapY) And (direction = 1) And (IntersectRect(temprect, Currentmap.HyperLinks[loop].Area, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40))) Then ChangeMap(loop); If Y < 10 Then Y := 10; // SpriteUp; End; Procedure TPlayer.RoamingMonsterDelay; Var tempdelay, TempdelayY : Integer; Begin tempdelay := x - RoamingMonster.X; If tempdelay < 0 Then tempdelay := 0 - tempdelay; TempDelayY := y - RoamingMonster.Y; If tempdelayY < 0 Then tempdelayY := 0 - tempdelayY; If RoamingMonster.Active Then RoamingMonster.Delay := (tempdelay + TempdelayY) Div (RoamingMonster.MoveRatio * RoamingMonster.Speed); End; Procedure TPlayer.MoveDown(Button : Boolean); Var loop, monstersleft : Integer; temprect : TRect; Begin If Not Button Then Direction := 3; If DetectDown Then inc(Y, 5); If (y >= 350) And (Player.Mapy < Currentmap.Height - 1) And Not hit Then Begin RoamingMonsterDelay; Y := 10; MonstersLeft := 0; Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer := MonsterRegen; For loop := 1 To MonsterCount Do If Monsters[loop].Life > 0 Then inc(monstersleft); CurrentMap.Rooms[player.mapx, player.mapy].Monsters := MonstersLeft; If MonstersLeft > 0 Then inc(Currentmap.Rooms[Player.mapx, player.MapY].MonsterTimer, 5); Inc(Player.MapY); ReleaseRoom; If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); Inc(y, 10); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; form1.Button1Click(form1); End; For loop := 0 To currentmap.NumberOfHyperLinks - 1 Do If (MapX = Currentmap.HyperLinks[loop].MapX) And (MapY = Currentmap.HyperLinks[loop].MapY) And (direction = 3) And (IntersectRect(temprect, Currentmap.HyperLinks[loop].Area, rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40))) Then ChangeMap(loop); If Y > 350 Then Y := 350; // SpriteDown; End; Procedure TPlayer.LoadPlayerSprite(Filename : String); Var Temp : TBitmap; loop : Integer; Begin Temp := TBitmap.Create; Temp.LoadFromFile(Filename); For loop := 1 To 8 Do Begin FrameImage[loop].PixelFormat := pf24bit; FrameImage[loop].Width := 40; FrameImage[loop].Height := Temp.Height; FrameImage[loop].Canvas.CopyRect(rect(0, 0, 40, temp.Height), temp.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp.Height)); FrameImage[loop].TransparentColor := rgb(5, 255, 255); FrameImage[loop].Transparent := True; End; Temp.FreeImage; temp.Free; End; Procedure TPlayer.LoadFromFile(Filename : String); Var Temp, Temp2 : TBitmap; loop, Loop2 : Integer; TempFrameImage, Masks : Array [1..8] Of TBitmap; LightMask : TBitmap; Begin Temp := TBitmap.Create; Temp2 := TBitmap.Create; Lightmask := TBitmap.Create; Lightmask.Width := 40; LightMask.Height := 40; Lightmask.PixelFormat := pf24bit; ChDir(ExtractFiledir(ParamStr(0))); form1.SpriteMemo.Lines.LoadFromFile(Filename); Temp.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[3]); Temp2.LoadFromFile('sprites\' + Form1.SpriteMemo.Lines[5]); LoadPlayerSprite('sprites\' + Form1.SpriteMemo.Lines[7]); For loop := 1 To 8 Do Begin TempFrameImage[loop] := TBitmap.Create; Masks[loop] := TBitmap.Create; TempFrameImage[loop].PixelFormat := pf24bit; TempFrameImage[loop].Width := 40; TempFrameImage[loop].Height := Temp.Height; TempFrameImage[loop].Canvas.CopyRect(rect(0, 0, 40, temp.Height), temp.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp.Height)); TempFrameImage[loop].TransparentColor := rgb(5, 255, 255); TempFrameImage[loop].Transparent := True; Masks[loop].PixelFormat := pf24bit; Masks[loop].Width := 40; Masks[loop].Height := temp2.Height; Masks[loop].Canvas.CopyRect(rect(0, 0, 40, temp2.Height), temp2.Canvas, rect(40 * (loop - 1), 0, 40 * loop, temp2.Height)); Masks[loop].TransparentColor := rgb(0, 0, 0); Masks[loop].Transparent := True; For loop2 := 1 To SwappedColors Do SwapColors(TempFrameImage[loop]); If color[4] = 1 Then Begin lightmask.Canvas.Draw(0, 0, tempframeimage[loop]); grayscale(Lightmask); tempframeimage[loop].LoadFromFile('sprites\outfit.bmp'); LightMap(lightmask, tempframeimage[loop], tempframeimage[loop]); End; For loop2 := 1 To 3 Do If Color[loop2] < 0 Then darkenchannel(tempframeimage[loop], 0 - color[loop2], loop2) Else If color[loop2] > 0 Then LightenChannel(tempframeimage[loop], color[loop2], loop2); TempFrameImage[Loop].Canvas.Draw(0, 0, Masks[loop]); FrameImage[loop].Canvas.Draw(0, 0, TempFrameImage[loop]); End; For loop := 1 To 8 Do Begin Masks[loop].FreeImage; Masks[loop].Free; TempFrameImage[loop].FreeImage; TempFrameImage[loop].Free; End; Temp.FreeImage; Temp2.FreeImage; Temp.Free; Temp2.Free; End; Procedure TPlayer.GetHit; Var loop : Integer; Begin If HitFlashCount = 0 Then Begin Hit := True; HitFrame := 0; If Player.Impact = 'Player Side' Then Begin form1.DXWaveListPlayer.Items[3].Play(False); HitFlashCount := 34; End Else HitFlashCount := 18; End; Inc(HitFrame); Erase(Form1.DXDraw1.Surface.Canvas); If Direction = 1 Then For loop := 1 To 3 Do MoveDown(True) Else If Direction = 2 Then For loop := 1 To 3 Do MoveLeft(True) Else If Direction = 3 Then For loop := 1 To 3 Do MoveUp(True) Else If Direction = 4 Then For loop := 1 To 3 Do MoveRight(True); Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; If HitFrame > 4 Then Begin Hit := False; End; End; Procedure TPlayer.CheckForHit; Var loop, loop2 : Integer; temprect : TRect; Begin If HitFlashCount = 0 Then Begin For loop := 1 To MonsterCount Do If (IntersectRect(TempRect, rect(x, Y, X + 40, Y + 40), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40))) And (Monsters[loop].life > 0) Then Begin If ((Direction = 1) And (Monsters[loop].Direction = 3)) Or ((Direction = 2) And (Monsters[loop].Direction = 4)) Or ((Direction = 3) And (Monsters[loop].Direction = 1)) Or ((Direction = 4) And (Monsters[loop].Direction = 2)) Then Begin Impact := 'Face'; form1.DXWaveListPlayer.Items[2].Play(False); End Else Begin Impact := 'Side'; Case direction Of 1 : If Monsters[loop].Y < Player.Y Then Impact := 'Monster Side' Else Impact := 'Player Side'; 2 : If Monsters[Loop].X > Player.X {+ 34} Then Impact := 'Monster Side' Else Impact := 'Player Side'; 3 : If Monsters[Loop].Y > Y{ + 34} Then Impact := 'Monster Side' Else Impact := 'Player Side'; 4 : If Monsters[loop].X < X {- 30} Then Impact := 'Monster Side' Else Impact := 'Player Side'; End; End; FindDamage(loop); Monsters[loop].HitType := 'Hand'; Monsters[loop].GetHit(Monsters[loop].HitType); If Not (impact = 'Monster Side') Then gethit Else Begin Erase(Form1.DXDraw1.Surface.Canvas); If Direction = 1 Then For loop2 := 1 To 5 Do MoveDown(True) Else If Direction = 2 Then For loop2 := 1 To 5 Do MoveLeft(True) Else If Direction = 3 Then For loop2 := 1 To 5 Do MoveUp(True) Else If Direction = 4 Then For loop2 := 1 To 5 Do MoveRight(True); If Not attacking Then Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; End; End; (*********************************************************************) If (IntersectRect(TempRect, rect(x, Y, X + 40, Y + 40), rect(Roamingmonster.X, Roamingmonster.Y, Roamingmonster.X + 40, Roamingmonster.Y + 40))) And (Roamingmonster.life > 0) And (RoamingMonster.Delay = 0) And (RoamingMonster.Active) Then Begin If ((Direction = 1) And (Roamingmonster.Direction = 3)) Or ((Direction = 2) And (Roamingmonster.Direction = 4)) Or ((Direction = 3) And (Roamingmonster.Direction = 1)) Or ((Direction = 4) And (Roamingmonster.Direction = 2)) Then Begin Impact := 'Face'; form1.DXWaveListPlayer.Items[2].Play(False); End Else Begin Impact := 'Side'; Case direction Of 1 : If Roamingmonster.Y < Player.Y Then Impact := 'Monster Side' Else Impact := 'Player Side'; 2 : If Roamingmonster.X > Player.X {+ 34} Then Impact := 'Monster Side' Else Impact := 'Player Side'; 3 : If Roamingmonster.Y > Y{ + 34} Then Impact := 'Monster Side' Else Impact := 'Player Side'; 4 : If Roamingmonster.X < X {- 30} Then Impact := 'Monster Side' Else Impact := 'Player Side'; End; End; FindDamage(0); Roamingmonster.HitType := 'Hand'; Roamingmonster.GetHit(Roamingmonster.HitType); If Not (impact = 'Monster Side') Then gethit Else Begin Erase(Form1.DXDraw1.Surface.Canvas); If Direction = 1 Then For loop2 := 1 To 5 Do MoveDown(True) Else If Direction = 2 Then For loop2 := 1 To 5 Do MoveLeft(True) Else If Direction = 3 Then For loop2 := 1 To 5 Do MoveUp(True) Else If Direction = 4 Then For loop2 := 1 To 5 Do MoveRight(True); Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; End; End; End; End; Procedure TPlayer.FindDamage(Who : Integer); Var LifeLeft : Integer; Begin If Not Monsters[who].GodMonster Then Begin If who = 0 Then Begin Monsters[0].Atk := RoamingMonster.Atk; Monsters[0].Life := RoamingMonster.Life; Monsters[0].Def := RoamingMonster.Def; Monsters[0].Exp := RoamingMonster.Exp; End; If shieldcounter > 0 Then inc(Def, level * 2); If Impact = 'Face' Then Begin If Atk > Monsters[Who].Def Then Begin LifeLeft := 0 - (Monsters[Who].Def - Atk); If lifeleft <= Monsters[who].Life Then inc(STRExp, (0 - (Monsters[Who].Def - Atk)) * Monsters[who].exp) Else inc(Strexp, Monsters[who].life * Monsters[who].exp); inc(Monsters[Who].Life, Monsters[Who].Def - Atk); End; If Def < Monsters[who].Atk Then inc(hp, def - Monsters[who].Atk); If (Atk > Monsters[Who].Def) And (Not (Def < Monsters[who].Atk)) Then Impact := 'Monster Side'; End Else Begin If Impact = 'Player Side' Then Begin If (def Div 2) < Monsters[who].Atk Then inc(hp, (def Div 2) - Monsters[who].Atk) Else Impact := 'Face'; End Else If Impact = 'Monster Side' Then Begin If atk > (Monsters[who].Def Div 2) Then Begin LifeLeft := 0 - ((Monsters[Who].Def Div 2) - Atk); If lifeleft <= Monsters[who].Life Then inc(STRExp, (0 - ((Monsters[Who].Def Div 2) - Atk)) * Monsters[who].exp) Else inc(Strexp, Monsters[who].life * Monsters[who].exp); inc(Monsters[who].Life, (Monsters[who].Def Div 2) - atk); End Else impact := 'Face'; End; End; If who = 0 Then RoamingMonster.life := Monsters[who].Life; If ShieldCounter > 0 Then inc(Def, 0 - (level * 2)); End; End; Procedure TPlayer.CheckForTalk; Var loop, loop2 : Integer; temprect : TRect; ClearTalk : Boolean; Begin ClearTalk := True; If TalkWait < 0 Then inc(TalkWait) Else For loop := 1 To PeopleCount Do If (IntersectRect(TempRect, rect(x - 10, Y - 10, X + 50, Y + 50), rect(People[loop].X, People[loop].Y, People[loop].X + 40, People[loop].Y + 40))) And ((SetButtons[1] In form1.DXInput1.States) Or ShowIngText) Then If Not moveto.Enabled Then Begin If Not ShowingText Then Begin Haste.ClearHaste.Canvas.CopyRect(rect(0, 0, 100, 25), Border.Canvas, rect(560, 430 - BorderOffset, 660, 455 - BorderOffset)); Form1.DXDraw1.Surface.Canvas.Draw(560 + BorderOffset, 430 + BorderOffset, Haste.ClearHaste); TalkWait := 10; ScrollTalk := False; TalkOffset := 5; Textscreen.Canvas.Draw(0, 0, TextScreenImage); Whatline := Random(3) + 1; EmeraldFont.ClearOverLay; For loop2 := 1 To people[loop].Text[Whatline].NumberOfLines Do EmeraldFont.Write(5, (Loop2 - 1) * 25, People[loop].Text[Whatline].Lines[loop2 - 1], 22); If people[loop].Text[Whatline].NumberOfEvents > 0 Then For loop2 := 0 To people[loop].Text[Whatline].NumberOfEvents - 1 Do If people[loop].Text[Whatline].TriggerEvents[loop2].AddEvent Then Begin EventLog.AddEvent(people[loop].Text[Whatline].TriggerEvents[loop2].EventName); End Else If eventlog.EventLevel(people[loop].Text[Whatline].TriggerEvents[loop2].EventName) < people[loop].Text[Whatline].TriggerEvents[loop2].EventLevel Then eventlog.SetEvent(people[loop].Text[Whatline].TriggerEvents[loop2].EventName, people[loop].Text[Whatline].TriggerEvents[loop2].EventLevel); TextScreen.Canvas.Draw(0, TalkOffset, EmeraldFont.OverLay); If people[loop].Text[Whatline].NumberOfLines > 3 Then EmeraldFont.Write(610, 60, '<', Textscreen.Canvas); blur(TextScreen, 9); If fullscreen Then form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset - 13, TextScreen) Else form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset, TextScreen); People[loop].Walking := False; ShowingText := True; ClearTalk := False; CurrentNumberOfLines := people[loop].Text[Whatline].NumberOfLines; If People[loop].Text[Whatline].Movie <> '' Then Form1.ShowMovie(People[loop].Text[Whatline].Movie); End Else Begin If TalkWait > 0 Then Dec(TalkWait); people[loop].Walking := False; ClearTalk := False; If (TalkWait <= 0) And ((SetButtons[1] In form1.DXInput1.States)) Then Begin TalkWait := -10; ClearTalk := True; End; FrameCount := 1; Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; If ScrollTalk Then Begin Textscreen.Canvas.Draw(0, 0, TextScreenImage); TextScreen.Canvas.Draw(0, TalkOffset, EmeraldFont.OverLay); EmeraldFont.Write(610, 60, '<', Textscreen.Canvas); blur(TextScreen, 9); If fullscreen Then form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset - 13, TextScreen) Else form1.DXDraw1.Surface.Canvas.Draw(16 + BorderOffset, 432 + BorderOffset, TextScreen); ScrollTalk := False; FrameCount := 1; End; End; End; If ClearTalk And Showingtext Then Begin If fullscreen Then form1.DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset - 13, border) Else form1.DXDraw1.Surface.Canvas.Draw(0 + BorderOffset, 0 + BorderOffset, border); ShowingText := False; End; End; Procedure TPlayer.SparkAttack; Begin If Not attacking Then Begin If mp >= spark.Cost Then Begin inc(mp, - spark.Cost); Attacking := True; Spark.Frame := 0; Spark.FrameCount := 0; Spark.Base; End; End Else Begin Spark.Base; End; End; Procedure TPlayer.DarkSparkAttack(WhatOne : Integer); Begin DarkSpark[WhatOne].Cost := DarkSpark[WhatOne].ActiveLevel * 2; If Not DarkSpark[WhatOne].Active Then Begin If mp >= DarkSpark[WhatOne].Cost Then Begin inc(mp, - DarkSpark[WhatOne].Cost); DarkSpark[WhatOne].Frame := 0; DarkSpark[WhatOne].FrameCount := 0; DarkSpark[WhatOne].Base; DarkSpark[WhatOne].FirstShot := True; DarkSpark[WhatOne].Active := True; End; End Else Begin DarkSpark[WhatOne].Base; End; End; Procedure Tplayer.HolyStorm; Begin If (Not HolyShower.IsDone) And (mp > 6) Then Begin HolyShower.Frame := 0; HolyShower.FrameCount := 0; HolyShower.EndFrame := 150; HolyShower.Base; End Else Begin HolyShower.Base; End; End; Procedure TPlayer.LevelUp; Var StrUp, MagUp, WisUp : Integer; Begin Strup := (5 * ((StrExp * 100) Div NextExp)) Div 100; MagUp := (5 * ((MagExp * 100) Div NextExp)) Div 100; WisUp := (5 * ((WisExp * 100) Div NextExp)) Div 100; While StrUp + WisUp + MagUp < 5 Do inc(MagUp); inc(Level); Inc(Str, Strup); Inc(Wis, WisUp); Inc(Mag, MagUp); StrExp := 0; MagExp := 0; WisExp := 0; NextExp := NextExp + (NextExp Div 2); MaxHP := MaxHP + (Str - 20) Div 5 + (Wis - 20) Div 10; HP := HP + (Str - 20) Div 5 + (Wis - 20) Div 10; Inc(MaxMP, (Mag - 20) Div 5 + (Wis - 20) Div 10); inc(MP, (Mag - 20) Div 5 + (Wis - 20) Div 10); Def := (((Str * 3 + Wis * 3) Div 4) * level) Div 10; Atk := (Str * Level Div 10); Bars.LoadFromFile('Artwork\life.bmp'); InfoScreen := TStatscreen.Create; InfoScreen.LevelUp(Strup, MagUp, WisUp, (Str - 20) Div 5 + (Wis - 20) Div 10, (Mag - 20) Div 5 + (Wis - 20) Div 10); Save('Autosave - Level ' + IntToStr(Level) + '.sav'); End; Procedure TPlayer.Regenerate; Begin inc(Player.MPReg, Currentmap.Magicbonus); If player.MPReg > Player.MPRegrate Then Begin If player.mp < player.MaxMP Then inc(Player.MP); player.MPReg := 0; End; inc(Player.HPReg, Currentmap.LifeBonus); If player.HPReg > Player.HPRegrate Then Begin If player.HP < player.MaxHP Then inc(Player.HP); player.HPReg := 0; End; End; Procedure TPlayer.FindAttack; Var loop : Integer; Begin For loop := 1 To 6 Do If SetButtons[loop] In form1.DXInput1.States Then Begin Case Attacks[loop].Spell Of 1 : If CurrentRoom.CanAttack Then SparkAttack; 2 : If (shotcounter = 0) And CurrentRoom.CanAttack Then Begin If Not DarkSpark[1].Active Then DarkSparkAttack(1) Else If Not DarkSpark[2].Active Then DarkSparkAttack(2) Else If Not DarkSpark[3].Active Then DarkSparkAttack(3); ShotCounter := 12; End; 3 : Begin Heal.Base; If Not Firstheal Then firstheal := True; StartHealing := True; End; 4 : Begin MagicRegen.Stage1 := True; End; 5 : Begin Regen.Stage1 := True; End; 6 : If CurrentRoom.CanAttack Then HolyStorm; 7 : If (haste.SpeedLevel = 0) And (mp > Haste.ActiveLevel * 5) And (Haste.Counter = 0) Then Begin Haste.Counter := 300 + Haste.ActiveLevel * 30; Haste.SpeedLevel := haste.ActiveLevel; dec(player.MP, Haste.ActiveLevel * 5); inc(haste.Exp, 1); If haste.Exp > 50 Then Begin inc(haste.Level); haste.Exp := 0; End; End Else If haste.SpeedLevel > 0 Then Begin If haste.Counter < 280 + Haste.ActiveLevel * 30 Then Begin Haste.SpeedLevel := 0; Haste.Counter := -20; End; End; 8 : Begin inc(mp, - 15); inc(ShieldCounter, Level * 100); shieldframe := 1; End; End; End; End; Procedure TPlayer.Input; Var loop : Integer; Begin Player.Regenerate; If HitFlashCount > 0 Then Begin If (Not MagicRegen.Stage1) And (Not Regen.Stage1) Then For loop := 1 To 8 Do invert(frameimage[loop], ignorecolor(5, 255, 255)); dec(HitFlashCount); End; Form1.DXInput1.Update; If (Not Player.Attacking) And (Not Player.Hit) Then Begin (*********************************Haste************************************) If Not ShowingText Then Begin If (Haste.Counter > 0) Then Begin haste.active := True; dec(Haste.Counter); Form1.DXDraw1.Surface.Canvas.Draw(560 + BorderOffset, 430 + BorderOffset, Haste.ShowHaste); Haste.NeedsCleared := True; End Else If Haste.NeedsCleared Then Begin haste.speedlevel := 0; Haste.NeedsCleared := False; Haste.ClearHaste.Canvas.CopyRect(rect(0, 0, 100, 25), Border.Canvas, rect(560, 430 - BorderOffset, 660, 455 - BorderOffset)); Form1.DXDraw1.Surface.Canvas.Draw(560 + BorderOffset, 430 + BorderOffset, Haste.ClearHaste); End; If Haste.Counter < 0 Then inc(Haste.counter); End; (*********************************Heal**************************) If Not StartHealing Then Begin firstheal := True; Secondheal := False; End; If Not secondheal Then Begin If Not ShowingText Then Begin If isLeft In Form1.DXInput1.States Then Begin MoveTo.Enabled := False; If Not (SetButtons[12] In Form1.DXInput1.States) Then For loop := 0 To Player.DashSpeed + Haste.SpeedLevel Do Player.MoveLeft(SideWalk); End Else If isright In Form1.DXInput1.States Then Begin MoveTo.Enabled := False; If Not (SetButtons[12] In Form1.DXInput1.States) Then For loop := 0 To Player.DashSpeed + Haste.SpeedLevel Do Player.Moveright(SideWalk); End; If isup In Form1.DXInput1.States Then Begin MoveTo.Enabled := False; If Not (SetButtons[12] In Form1.DXInput1.States) Then For loop := 0 To Player.DashSpeed + Haste.SpeedLevel Do Player.MoveUp(SideWalk); End Else If isdown In Form1.DXInput1.States Then Begin MoveTo.Enabled := False; If Not (SetButtons[12] In Form1.DXInput1.States) Then For loop := 0 To Player.DashSpeed + Haste.SpeedLevel Do Player.MoveDown(SideWalk); End; If ((isleft In Form1.DXInput1.States) Or (isright In Form1.DXInput1.States) Or (isdown In Form1.DXInput1.States) Or (isup In Form1.DXInput1.States)) Then If Not attacking Then Case Direction Of 1 : SpriteUp; 2 : SpriteRight; 3 : spriteDown; 4 : SpriteLeft; End; End Else Begin If isDown In Form1.DXInput1.States Then Begin If CurrentNumberOfLines > 3 Then ScrollTalk := True; If TalkOffset > 0 - (CurrentNumberOfLines - 3) * 25 + 5 Then dec(TalkOffset, 10); End; If isup In Form1.DXInput1.States Then Begin If CurrentNumberOfLines > 3 Then ScrollTalk := True; If TalkOffset < 5 Then inc(TalkOffset, 10); End; End; End; End; If ShotCounter > 0 Then Dec(ShotCounter); For Loop := 1 To 3 Do If darkspark[Loop].Active Then Player.DarkSparkAttack(Loop); If (SetButtons[7] In Form1.DXInput1.States) And (StatusWaitTimer <= 0) Then Begin StatusWaitTimer := 10; InfoScreen := TStatscreen.Create; InfoScreen.Pointer := 1; For loop := 1 To 6 Do AssignAttack(Loop, Player.attacks[loop].Spell); InfoScreen.MainScreen; End; If SetButtons[8] In Form1.DXInput1.States Then Begin InfoScreen := TStatscreen.Create; InfoScreen.Pointer := 1; InfoScreen.EventScreen; End; If MoveTo.Enabled Then MoveTo.Move; If Not ((isleft In Form1.DXInput1.States) Or (isright In Form1.DXInput1.States) Or (isdown In Form1.DXInput1.States) Or (isup In Form1.DXInput1.States) Or (SetButtons[2] In form1.DXInput1.States) Or (MoveTo.Enabled)) Then Begin FrameCount := 1; If Not ((Regen.Stage1) Or (MagicRegen.Stage1) OR (Attacking)) Then ShowSprite; Regenerate; End; If Attacking Then Player.SparkAttack; If regen.Stage1 And MagicRegen.Stage1 Then Begin MagOrRegen := Not MagOrRegen; If MagorRegen Then Begin Regen.Base; MagicRegen.Base; End Else Begin MagicRegen.Base; Regen.Base;End; End Else If regen.Stage1 Then Regen.Base Else If MagicRegen.Stage1 Then MagicRegen.Base; inc(FrameCountTimer); If FrameCountTimer > FrameCountMax Then Begin If Player.FrameCount = 1 Then Player.FrameCount := 2 Else Player.FrameCount := 1; FrameCountTimer := 0; End; StartHealing := False; If player.Hit Then player.GetHit Else player.CheckForHit; CheckForTalk; If ShieldCounter > 0 Then Begin inc(ShieldFrame); inc(ShieldCounter, - 1); If ShieldFrame > 4 Then ShieldFrame := 1; End; If Not attacking Then FindAttack; If Player.MagExp + Player.STRExp + Player.WisExp >= Player.NextExp Then Player.LevelUp; If SetButtons[9] In form1.DXInput1.States Then save('QuickSave.sav'); If SetButtons[10] In form1.DXInput1.States Then load('QuickSave.sav'); If HolyShower.IsDone Then HolyStorm; healing := False; End; Procedure TPlayer.Save(Filename : String); Var loop : Integer; Begin Form1.LoadMemo.Lines.Clear; form1.LoadMemo.Lines.add(IntToStr(MapX)); form1.LoadMemo.Lines.add(IntToStr(MapY)); form1.LoadMemo.Lines.add(IntToStr(HP)); form1.LoadMemo.Lines.add(IntToStr(MaxHP)); form1.LoadMemo.Lines.add(IntToStr(HPReg)); form1.LoadMemo.Lines.add(IntToStr(HPRegRate)); form1.LoadMemo.Lines.add(IntToStr(MP)); form1.LoadMemo.Lines.add(IntToStr(MaxMP)); form1.LoadMemo.Lines.add(IntToStr(MPReg)); form1.LoadMemo.Lines.add(IntToStr(MPRegRate)); form1.LoadMemo.Lines.add(IntToStr(Str)); form1.LoadMemo.Lines.add(IntToStr(Mag)); form1.LoadMemo.Lines.add(IntToStr(Wis)); form1.LoadMemo.Lines.add(IntToStr(Atk)); form1.LoadMemo.Lines.add(IntToStr(Def)); form1.LoadMemo.Lines.add(IntToStr(Level)); form1.LoadMemo.Lines.add(IntToStr(DashSpeed)); form1.LoadMemo.Lines.add(IntToStr(STRExp)); form1.LoadMemo.Lines.add(IntToStr(MagExp)); form1.LoadMemo.Lines.add(IntToStr(WisExp)); form1.LoadMemo.Lines.add(IntToStr(NextExp)); (*******************Player Sprite***********) form1.LoadMemo.Lines.add(IntToStr(X)); form1.LoadMemo.Lines.add(IntToStr(Y)); form1.LoadMemo.Lines.add(IntToStr(FrameCount)); form1.LoadMemo.Lines.add(IntToStr(Direction)); form1.LoadMemo.Lines.add(IntToStr(HitFrame)); form1.LoadMemo.Lines.add(IntToStr(ShieldFrame)); form1.LoadMemo.Lines.add(IntToStr(ShieldCounter)); (****************Map**************************) Form1.LoadMemo.Lines.Add(Currentmap.Name); (****************Magic************************) Form1.LoadMemo.Lines.Add(IntToStr(spark.Level)); Form1.LoadMemo.Lines.Add(IntToStr(spark.Exp)); Form1.LoadMemo.Lines.Add(IntToStr(HolyShower.Level)); Form1.LoadMemo.Lines.Add(IntToStr(HolyShower.Exp)); Form1.LoadMemo.Lines.Add(IntToStr(Heal.Level)); Form1.LoadMemo.Lines.Add(IntToStr(Heal.Exp)); Form1.LoadMemo.Lines.Add(IntToStr(Haste.Level)); Form1.LoadMemo.Lines.Add(IntToStr(Haste.Exp)); Form1.LoadMemo.Lines.Add(IntToStr(Shield.Level)); Form1.LoadMemo.Lines.Add(IntToStr(Shield.Exp)); (***************Monsters*************************); form1.LoadMemo.Lines.Add(IntToStr(monstercount)); For loop := 1 To MonsterCount Do Begin With form1.LoadMemo.Lines Do Begin Add(IntToStr(Monsters[loop].X)); Add(IntToStr(Monsters[loop].Y)); Add(IntToStr(Monsters[loop].Direction)); Add(IntToStr(Monsters[loop].Life)); End; End; (***************Events*************************); Form1.LoadMemo.Lines.Add('Number of Events:'); form1.LoadMemo.Lines.Add(IntToStr(EventLog.NumberOfEvents)); For loop := 0 To eventlog.NumberOfEvents - 1 Do Begin form1.LoadMemo.Lines.Add(EventLog.Events[loop].EventName); form1.LoadMemo.Lines.Add(IntToStr(EventLog.events[loop].Stage)); End; (***************Done*************************); form1.MainGameTimer.Enabled := False; ChDir(ExtractFileDir(ParamStr(0))); CopyFile(PChar('lotmdb.db'), PChar('saves\lotmdb.exe'), True); ChDir(ExtractFileDir(ParamStr(0)) + '\Saves\'); form1.LoadMemo.Lines.SaveToFile('save1.temp'); If fileexists(Filename) Then DeleteFile(Filename); form1.LMDStarter1.Parameters := 'a -pSave1 "' + ExtractFileName(Filename) + '" save1.temp'; ChDir(ExtractFileDir(ParamStr(0)) + '\Saves\'); form1.LMDStarter1.Execute; Done := False; Repeat Application.ProcessMessages; Until done; ChDir(ExtractFileDir(ParamStr(0)) + '\Saves\'); DeleteFile('lotmdb.exe'); deletefile('save1.temp'); ChDir(ExtractFileDir(ParamStr(0))); Form1.MainGameTimer.Enabled := True; End; Procedure TPlayer.Load(Filename : String); Var loop, TempMonsterCount, numberofevents, LineForEvents : Integer; TempMon : Array[1..15] Of Record X, Y, Direction, Life : Integer; End; Begin ChDir(ExtractFileDir(ParamStr(0))); CopyFile(PChar('lotmdb.db'), PChar('saves\lotmdb.exe'), True); ChDir(ExtractFileDir(ParamStr(0)) + '\Saves\'); If fileexists('Save1.temp') Then DeleteFile('Save1.temp'); form1.LMDStarter1.Parameters := 'x -y -pSave1 "' + ExtractFileName(Filename) + '"'; form1.LMDStarter1.Execute; Done := False; form1.MainGameTimer.Enabled := False; Repeat Application.ProcessMessages; Until done; DeleteFile('lotmdb.exe'); form1.LoadMemo.Lines.LoadFromFile('save1.temp'); If FileExists('save1.temp') Then deletefile('save1.temp'); ChDir(ExtractFileDir(ParamStr(0))); Form1.MainGameTimer.Enabled := True; MapX := StrToInt(form1.loadmemo.Lines[0]); MapY := StrToInt(form1.loadmemo.Lines[1]); HP := StrToInt(form1.loadmemo.Lines[2]); MaxHP := StrToInt(form1.loadmemo.Lines[3]); HPReg := StrToInt(form1.loadmemo.Lines[4]); HPRegRate := StrToInt(form1.loadmemo.Lines[5]); MP := StrToInt(form1.loadmemo.Lines[6]); MaxMP := StrToInt(form1.loadmemo.Lines[7]); MPReg := StrToInt(form1.loadmemo.Lines[8]); MPRegRate := StrToInt(form1.loadmemo.Lines[9]); Str := StrToInt(form1.loadmemo.Lines[10]); Mag := StrToInt(form1.loadmemo.Lines[11]); Wis := StrToInt(form1.loadmemo.Lines[12]); Atk := StrToInt(form1.loadmemo.Lines[13]); Def := StrToInt(form1.loadmemo.Lines[14]); Level := StrToInt(form1.loadmemo.Lines[15]); DashSpeed := StrToInt(form1.loadmemo.Lines[16]); STRExp := StrToInt(form1.loadmemo.Lines[17]); MagExp := StrToInt(form1.loadmemo.Lines[18]); WisExp := StrToInt(form1.loadmemo.Lines[19]); NextExp := StrToInt(form1.loadmemo.Lines[20]); (******************************************) X := StrToInt(form1.loadmemo.Lines[21]); Y := StrToInt(form1.loadmemo.Lines[22]); FrameCount := StrToInt(form1.loadmemo.Lines[23]); Direction := StrToInt(form1.loadmemo.Lines[24]); HitFrame := StrToInt(form1.loadmemo.Lines[25]); ShieldFrame := StrToInt(form1.loadmemo.Lines[26]); ShieldCounter := StrToInt(form1.loadmemo.Lines[27]); ReleaseRoom; Spark.Level := StrToInt(form1.LoadMemo.Lines[29]); Spark.Exp := StrToInt(form1.LoadMemo.Lines[30]); HolyShower.Level := StrToInt(form1.LoadMemo.Lines[31]); HolyShower.Exp := StrToInt(form1.LoadMemo.Lines[32]); Heal.Level := StrToInt(form1.LoadMemo.Lines[33]); Heal.Exp := StrToInt(form1.LoadMemo.Lines[34]); Haste.Level := StrToInt(form1.LoadMemo.Lines[35]); Haste.Exp := StrToInt(form1.LoadMemo.Lines[36]); Shield.Level := StrToInt(form1.LoadMemo.Lines[37]); Shield.Exp := StrToInt(form1.LoadMemo.Lines[38]); TempMonsterCount := StrToInt(form1.LoadMemo.Lines[39]); For loop := 1 To TempMonsterCount Do Begin TempMon[Loop].X := StrToInt(form1.LoadMemo.Lines[36 + (Loop * 4)]); TempMon[Loop].Y := StrToInt(form1.LoadMemo.Lines[37 + (Loop * 4)]); TempMon[Loop].direction := StrToInt(form1.LoadMemo.Lines[38 + (Loop * 4)]); TempMon[Loop].life := StrToInt(form1.LoadMemo.Lines[39 + (Loop * 4)]); End; (***************Events*************************); For loop := 10 To form1.LoadMemo.Lines.Count - 1 Do If form1.LoadMemo.Lines[loop - 1] = 'Number of Events:' Then Begin NumberOfEvents := StrToInt(form1.LoadMemo.Lines[loop]); LineForEvents := Loop + 1; End; Eventlog.Clear; For loop := 0 To NumberOfEvents - 1 Do Begin Eventlog.AddEvent(form1.LoadMemo.Lines[LineForEvents + Loop * 2]); eventlog.Events[loop].Stage := StrToInt(form1.LoadMemo.Lines[LineForEvents + Loop * 2 + 1]); End; (*******************************************) LoadMap(form1.LoadMemo.Lines[28]); If (FileExists('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room')) And (Currentmap.Rooms[Player.Mapx, Player.MapY].Monsters <> 0) Then Begin CurrentRoom.Closed := True; loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\closed.room'); End Else Begin Currentroom.Closed := False; Loadroom('maps\' + Currentmap.Name + '\' + currentmap.rooms[Player.Mapx, Player.MapY].Name + '\1.room'); End; Monstercount := tempmonstercount; For loop := 1 To tempmonstercount Do Begin Monsters[loop].X := tempmon[loop].X; Monsters[loop].Y := tempmon[loop].Y; Monsters[loop].Direction := TempMon[loop].Direction; Monsters[loop].Life := tempmon[loop].Life; End; ChDir(extractfiledir(ParamStr(0))); ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.Lighting[2], CurrentRoom.Lighting[3], CurrentRoom.Lighting[4]); Bars.LoadFromFile('Artwork\life.bmp'); ChDir(extractfiledir(ParamStr(0))); form1.Repaint; End; Procedure TPlayer.ChangeMap(Link : Integer); Begin Save('Autosave - ' + CurrentMap.Name + '.sav'); x := CurrentMap.HyperLinks[link].InTargetX; y := currentMap.HyperLinks[link].InTargetY; Direction := CurrentMap.hyperlinks[link].InTargetDirection; MapX := CurrentMap.hyperlinks[Link].TargetMapX; MapY := CurrentMap.hyperlinks[Link].TargetMapY; If (currentmap.hyperlinks[link].movie[1] <> '-') And Showmovies Then Begin If musicmode Then Music.pause; Form1.MainGameTimer.Enabled := False; form1.MediaPlayer2.FileName := 'Movies\' + currentmap.hyperlinks[link].movie; If FullScreen Then Begin Form1.DXDraw2.Top := 0; Form1.DXDraw2.Left := 0; End Else Begin Form1.DXDraw2.Top := 16; Form1.DXDraw2.Left := 16; End; form1.MediaPlayer2.Open; Form1.DXDraw2.Visible := True; form1.MediaPlayer2.Play; Repeat Application.ProcessMessages; Until form1.mediaplayer2.Length = form1.mediaplayer2.Position; Form1.DXDraw2.Visible := False; form1.MainGameTimer.Enabled := True; End; ReleaseRoom; Loadmap(Currentmap.hyperlinks[link].LeadsTo); ShowLevel1Tiles(CurrentRoom.lighting[1], CurrentRoom.Lighting[2], CurrentRoom.Lighting[3], CurrentRoom.Lighting[4]); If MusicMode Then Music.Play; Form1.Repaint; End; End. Unit TRegenUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit; Type TRegen = Class (TSpell) HealExpCounter : Integer; Bitmap, Bitmap2 : TBitmap; Pixels, Pixels2 : PixelArray; Stage1, Stage2 : Boolean; MaxFrame, LastDirection : Integer; Constructor Create; Procedure Base; Procedure SetStats; End; Implementation Uses unit1, TPlayerUnit, TMonsterUnit, EngineUnit; Constructor TRegen.Create; Var Loop : Integer; Begin Bitmap := TBitmap.Create; Bitmap.Width := 40; Bitmap.Height := 40; Bitmap.PixelFormat := pf24bit; Bitmap.TransparentColor := rgb(5, 255, 255); Bitmap.Transparent := True; setlength(Pixels, bitmap.Height); For loop := 0 To bitmap.Height - 1 Do pixels[loop] := bitmap.ScanLine[loop]; Bitmap2 := TBitmap.Create; Bitmap2.Width := 40; Bitmap2.Height := 40; Bitmap2.PixelFormat := pf24bit; Bitmap2.TransparentColor := rgb(5, 255, 255); Bitmap2.Transparent := True; setlength(Pixels2, Bitmap2.Height); For loop := 0 To Bitmap2.Height - 1 Do pixels2[loop] := Bitmap2.ScanLine[loop]; Level := 9; ActiveLevel := 1; End; Procedure TRegen.SetStats; Begin Cost := 1; Damage := (currentmap.LifeBonus * ActiveLevel + ActiveLevel); End; Procedure TRegen.Base; Var loop, loop2, index : Integer; Begin If (player.MP > 1) Then Begin If Player.hp < Player.MaxHP Then Begin inc(player.hp, player.wis Div (20 - ActiveLevel * 2)); inc(player.mp, - 1); Inc(HealExpCounter); If HealExpCounter > (player.MaxHP Div (20 - ActiveLevel * 2)) Then Begin inc(exp); Inc(Player.WisExp, 10); HealExpCounter := 0; End; End; If Stage1 And (Not stage2) Then Begin stage2 := True; FrameCount := 0; MaxFrame := Level * 100; Player.FrameImage[player.direction * 2 - 1].Transparent := False; Bitmap.Canvas.Draw(0, 0, player.frameimage[player.direction * 2 - 1]); Player.FrameImage[player.direction * 2 - 1].Transparent := True; Player.FrameImage[player.direction * 2].Transparent := False; Bitmap2.Canvas.Draw(0, 0, player.frameimage[player.direction * 2]); Player.FrameImage[player.direction * 2].Transparent := True; Form1.DXWaveListPlayer.Items[4].Play(False); LastDirection := Player.Direction; End; If LastDirection <> player.Direction Then Begin Player.FrameImage[player.direction * 2 - 1].Transparent := False; Bitmap.Canvas.Draw(0, 0, player.frameimage[player.direction * 2 - 1]); Player.FrameImage[player.direction * 2 - 1].Transparent := True; Player.FrameImage[player.direction * 2].Transparent := False; Bitmap2.Canvas.Draw(0, 0, player.frameimage[player.direction * 2]); Player.FrameImage[player.direction * 2].Transparent := True; LastDirection := Player.Direction; End; Inc(FrameCount); If FrameCount > MaxFrame Then Begin stage1 := False; Stage2 := False; End; For loop := 0 To bitmap.Height - 2 Do For loop2 := 1 To bitmap.Width - 2 Do Begin index := loop2 * 3; If Not (pixels[loop, index + 1] = 255) Then pixels[loop, index + 1] := pixels[loop + random(2), index + (random(3) - 1) * 3 + 1] - loop; If Not (pixels2[loop, index + 1] = 255) Then pixels2[loop, index + 1] := pixels2[loop + random(2), index + (random(3) - 1) * 3 + 1] - loop; End; MotionBlurUp(bitmap); If Player.FrameCount = 2 Then Form1.DXDraw1.Surface.Canvas.Draw(Player.x + 16 + BorderOffset, Player.y + 16 + BorderOffset, Bitmap2) Else Form1.DXDraw1.Surface.Canvas.Draw(Player.x + 16 + BorderOffset, Player.y + 16 + BorderOffset, Bitmap); Player.Regenerating := True; End; End; End. Unit TRoamingMonster; Interface Implementation End. Unit TRoamingMonsterUnit; Interface Uses TMonsterUnit; Type TRoamingMonster = Class (TMonster) Active : Boolean; Delay : Integer; ChanceToSpawn : Integer; MonsterType : String; End; Implementation End. Unit TSpeakUnit; Interface Type TTextStrings = Array Of String; TSpeakEventTrigger = Record EventName : String; EventLevel : Integer; AddEvent : Boolean; OnRoomClosed : Boolean; End; TSpeak = Record NumberOfLines, NumberOfEvents : Integer; Lines : Array Of String; TriggerEvents : Array Of TSpeakEventTrigger; Movie : String; End; Implementation End. Unit HasteUnit; Interface Implementation End. Unit TDarkSparkUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSparkUnit; Type TDarkSpark = Class (TSpark) FirstShot, Active : Boolean; Constructor Create; Procedure Base; Procedure Levelup; Procedure SetStats; End; Implementation Uses TPlayerUnit, unit1, TMonsterUnit, EngineUnit; Constructor TDarkSpark.Create; Begin Inherited Create; Cost := 2; EndFrame := 15; End; Procedure TDarkSpark.base; Var loop : Integer; TempRect : TRect; Begin If Frame = 0 Then Begin Direction := Player.Direction; Form1.DXWaveListPlayer.Items.Find('Dark Spark').Play(False); FrameCount := 0; If Player.Direction = 1 Then Begin If isleft In form1.DXInput1.States Then Begin X := Player.X - 20; Y := Player.Y - 30; End Else If isRight In form1.DXInput1.States Then Begin X := Player.X + 35; Y := Player.Y - 30; End Else Begin X := Player.X + 5; Y := Player.Y - 30; End; End Else If Player.Direction = 2 Then Begin X := Player.X + 40; Y := Player.Y + 8; End Else If Player.Direction = 3 Then Begin If isleft In form1.DXInput1.States Then Begin X := Player.X - 20; Y := Player.Y + 40; End Else If isRight In form1.DXInput1.States Then Begin X := Player.X + 35; Y := Player.Y + 40; End Else Begin X := Player.X + 5; Y := Player.Y + 40; End; End Else Begin X := Player.X - 30; Y := Player.Y + 8; End; End; Inc(Framecount); Frames[5].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), RoomBuffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[6].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), Level2Buffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[5].Canvas.draw(0, 0, frames[6]); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]); Inc(Frame); If Framecount > 4 Then Framecount := 1; If Direction = 1 Then dec(Y, 10) Else If Direction = 2 Then Inc(X, 10) Else If Direction = 3 Then Inc(Y, 10) Else If Direction = 4 Then Dec(X, 10); inc(X, random(3) - 2); inc(y, random(3) - 2); If x > 595 Then Frame := EndFrame; If X < 5 Then Frame := EndFrame; If Y > 360 Then Frame := EndFrame; If Y < 5 Then Frame := EndFrame; If x > 595 Then X := 595; If X < 5 Then X := 5; If Y > 360 Then Y := 360; If Y < 5 Then Y := 5; For loop := 1 To MonsterCount Do If (monsters[loop].HitFlash = 0) And (Monsters[Loop].StonedCounter = 0) Then Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then If Not monsters[loop].Hit Then Begin Player.Impact := 'Side'; Monsters[Loop].StonedCounter := 30 * DarkSpark[1].ActiveLevel; If Player.Mag Div 5 * DarkSpark[1].ActiveLevel > Monsters[loop].Life Then inc(Player.MagExp, Monsters[loop].Life * Monsters[loop].Exp) Else inc(Player.MagExp, ((Player.Mag Div 5) * DarkSpark[1].ActiveLevel) * Monsters[loop].Exp); inc(Monsters[loop].Life, 0 - (Player.Mag Div 5) * DarkSpark[1].ActiveLevel); If Monsters[loop].Life < 1 Then Monsters[loop].StonedCounter := 0; If Monsters[Loop].Stonedcounter = 0 Then Begin Monsters[loop].HitType := 'Spark'; Monsters[loop].GetHit(Monsters[loop].HitType); Monsters[loop].HitFlash := 24; End; With Monsters[loop] Do If Life > 0 Then Begin If maxlife < 1 Then maxlife := 1; MBars.ShowLife(round(((life / maxlife) * 100) - 1), 100, Form1.DXDraw1.Surface.Canvas, 16 + BorderOffset, 399 - 18 + 15 + BorderOffset); End; DarkSpark[1].Exp := DarkSpark[1].Exp + 1; If (DarkSpark[1].Exp > Level * Level * 75) And (level < 9) Then Begin Inc(DarkSpark[1].level); DarkSpark[1].ActiveLevel := Level; DarkSpark[1].Exp := 0; levelup; sleep(3000); Form1.Button1Click(self); Player.Attacking := False; End; End; End; If Roamingmonster.HitFlash = 0 Then Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Roamingmonster.X, Roamingmonster.Y, Roamingmonster.X + 40, Roamingmonster.Y + 40)) Then If Not Roamingmonster.Hit Then Begin Player.Impact := 'Side'; If Player.Mag Div (11 - DarkSpark[1].ActiveLevel * 2) > Roamingmonster.Life Then inc(Player.MagExp, Roamingmonster.Life * Roamingmonster.Exp) Else inc(player.MagExp, (Player.Mag Div (11 - DarkSpark[1].ActiveLevel * 2)) * Roamingmonster.Exp); inc(Roamingmonster.Life, 0 - (Player.Mag Div (11 - DarkSpark[1].ActiveLevel * 2))); Roamingmonster.HitType := 'Spark'; Roamingmonster.GetHit(Roamingmonster.HitType); Roamingmonster.HitFlash := 24; DarkSpark[1].Exp := DarkSpark[1].Exp + 1; If (DarkSpark[1].Exp > Level * Level * 50) And (level < 9) Then Begin Inc(level); DarkSpark[1].ActiveLevel := Level; DarkSpark[1].Exp := 0; levelup; sleep(3000); Form1.Button1Click(self); Player.Attacking := False; End; End; End; If frame >= EndFrame Then Active := False; If Active Then Begin Frames[5].Canvas.Brush.color := rgb(5, 255, 255); Frames[5].Canvas.FillRect(rect(0, 0, frames[5].Width, frames[5].Height)); Frames[5].Canvas.draw(0, 0, Frames[Framecount]); Frames[6].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), Level2Buffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Lightmap(Frames[5], Frames[6], Frames[5], ignorecolor(5, 255, 255)); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]) End Else Begin frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[6].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), Level2Buffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[5].Canvas.draw(0, 0, frames[6]); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]); Active := False; End; End; Procedure TDarkSpark.SetStats; Begin Cost := Round(ActiveLevel * 2); Damage := (Player.Mag Div 5) * DarkSpark[1].ActiveLevel; End; Procedure TDarkSpark.Levelup; Begin Bars.LoadFromFile('Artwork\life.bmp'); unit1.Panal.LoadFromFile('Artwork\Panal.bmp'); Unit1.Panal.PixelFormat := pf24bit; unit1.EmeraldFont.Write(30, 30, 'DarkSpark Level is now ' + IntToStr(Level), Panal.Canvas); unit1.EmeraldFont.Write(30, 75, 'Current Damage', Panal.Canvas); unit1.EmeraldFont.Write(30, 120, IntToStr((Player.Mag Div 5) * DarkSpark[1].ActiveLevel), Panal.Canvas); form1.Button1Click(form1); Form1.DXDraw1.Surface.Canvas.Draw(100 + BorderOffset, 50 + BorderOffset, unit1.Panal); cost := round(level * 2); End; End. Unit TFireStormUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput; Type TSpark = Class X, Y : Integer; Frame, FrameCount : Integer; EndFrame : Integer; Frames : Array[1..5] Of TBitmap; Exp : Integer; Level : Integer; Direction : Integer; SparkRect : TRect; Procedure Base; Procedure Levelup; Private Procedure Level1; End; Implementation Uses TPlayerUnit, unit1, TMonsterUnit, EngineUnit; Procedure TSpark.base; Begin Level1; End; Procedure TSpark.Levelup; Begin Bars.LoadFromFile('Artwork\life.bmp'); unit1.Panal.LoadFromFile('Artwork\Panal.bmp'); Unit1.Panal.PixelFormat := pf24bit; unit1.EmeraldFont.Write(30, 30, 'Spark Level is now ' + IntToStr(Level), Panal.Canvas); unit1.EmeraldFont.Write(30, 75, 'Current Damage', Panal.Canvas); unit1.EmeraldFont.Write(30, 120, IntToStr(Player.Mag Div (10 - level)), Panal.Canvas); form1.Button1Click(form1); form1.Canvas.Draw(100, 50, unit1.Panal); End; Procedure TSpark.Level1; Var loop : Integer; TempRect : TRect; Begin If spark.Frame = 0 Then Begin Form1.DXWaveListPlayer.Items.Find('Spark - Level 1').Play(False); FrameCount := 0; If Player.Direction = 1 Then Begin If isleft In form1.DXInput1.States Then Begin Spark.X := Player.X - 20; Spark.Y := Player.Y - 30; End Else If isRight In form1.DXInput1.States Then Begin Spark.X := Player.X + 35; Spark.Y := Player.Y - 30; End Else Begin Spark.X := Player.X + 5; Spark.Y := Player.Y - 30; End; End Else If Player.Direction = 2 Then Begin Spark.X := Player.X + 40; Spark.Y := Player.Y + 8; End Else If Player.Direction = 3 Then Begin If isleft In form1.DXInput1.States Then Begin Spark.X := Player.X - 20; Spark.Y := Player.Y + 40; End Else If isRight In form1.DXInput1.States Then Begin Spark.X := Player.X + 35; Spark.Y := Player.Y + 40; End Else Begin Spark.X := Player.X + 5; Spark.Y := Player.Y + 40; End; End Else Begin Spark.X := Player.X - 30; Spark.Y := Player.Y + 8; End; End; Inc(Spark.Frame); frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); form1.Canvas.Draw(spark.X + 16, spark.Y + 16, frames[5]); If Player.Direction = 1 Then dec(Spark.Y, Level * 2 - 1) Else If Player.Direction = 2 Then Inc(Spark.X, level * 2 - 1) Else If Player.Direction = 3 Then Inc(Spark.Y, Level * 2 - 1) Else If Player.Direction = 4 Then Dec(Spark.X, Level * 2 - 1); If level > 2 Then Begin form1.DXInput1.Update; If (isleft In form1.DXInput1.States) And (Player.Direction <> 4) Then dec(Spark.x, Level) Else If (isup In form1.DXInput1.States) And (Player.Direction <> 1) Then dec(Spark.Y, level) Else If (isright In form1.DXInput1.States) And (Player.Direction <> 2) Then inc(Spark.X, level) Else If (isdown In form1.DXInput1.States) And (Player.Direction <> 3) Then Inc(Spark.Y, level); End; inc(spark.X, random(level * 2 + 1) - level); inc(spark.y, random(level * 2 + 1) - level); If spark.x > 595 Then spark.X := 595; If spark.X < 5 Then spark.X := 5; If spark.Y > 360 Then spark.Y := 360; If spark.Y < 5 Then spark.Y := 5; Inc(Framecount); If Framecount > 4 Then Framecount := 1; Player.FrameCount := 2; If Frame >= EndFrame Then Player.Attacking := False; For loop := 1 To MonsterCount Do Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then If Not monsters[loop].Hit Then Begin Player.Impact := 'Side'; If Player.Mag Div (10 - level) > Monsters[loop].Life Then inc(Player.MagExp, Monsters[loop].Life * Monsters[loop].Exp) Else inc(player.MagExp, (Player.Mag Div (10 - level)) * Monsters[loop].Exp); inc(Monsters[loop].Life, 0 - (Player.Mag Div (10 - level))); Monsters[loop].GetHit; exp := Exp + 1; If (exp > Level * Level * 50) And (level < 9) Then Begin Inc(level); exp := 0; levelup; sleep(3000); Form1.Button1Click(self); Player.Attacking := False; End; End; End; If player.Attacking Then Form1.Canvas.Draw(x + 16, y + 16, Frames[FrameCount]) Else Begin frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Form1.Canvas.Draw(x + 16, y + 16, Frames[5]); End; Player.ShowSprite; End; End. Unit THasteUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit; Type THaste = Class (TSpell) SpeedLevel : Integer; Active : Boolean; Counter : Integer; ShowHaste, ClearHaste : TBitmap; NeedsCleared : Boolean; Procedure SetStats; End; Implementation Procedure THaste.SetStats; Begin Cost := ActiveLevel * 5; Damage := 40 + ActiveLevel * 10; End; End. Unit THealingUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit; Type THealing = Class (TSpell) HealExpCounter : Integer; Bitmap : TBitmap; Pixels : PixelArray; Constructor Create; Procedure Base; Procedure SetStats; End; Var FirstHeal, Secondheal : Boolean; Implementation Uses unit1, TPlayerUnit, TMonsterUnit, EngineUnit; Constructor THealing.Create; Begin Level := 1; ActiveLevel := 1; End; Procedure THealing.SetStats; Begin Cost := ActiveLevel; Damage := player.wis Div (20 - ActiveLevel * 2); End; Procedure THealing.Base; Var loop, loop2, index, FirstColor : Integer; Begin If (player.MP > 1) Then Begin If Player.hp < Player.MaxHP Then Begin inc(player.hp, player.wis Div (20 - ActiveLevel * 2)); inc(player.mp, - 1); Inc(HealExpCounter); If HealExpCounter > player.wis Div (20 - ActiveLevel * 2) Then Begin inc(exp); Inc(Player.WisExp, 10); HealExpCounter := 0; End; End; If firstheal And (Not secondheal) Then Begin secondheal := True; Player.FrameImage[player.direction * 2 - 1].Transparent := False; Bitmap.Canvas.Draw(0, 0, player.frameimage[player.direction * 2 - 1]); Player.FrameImage[player.direction * 2 - 1].Transparent := True; Form1.DXWaveListPlayer.Items[4].Play(False); End; If Frame = 0 Then Begin FrameCount := 0; End; Inc(Frame); Inc(Framecount); If Framecount > 4 Then Framecount := 1; Player.FrameCount := 2; For loop := 0 To bitmap.Height - 2 Do For loop2 := 1 To bitmap.Width - 2 Do Begin index := loop2 * 3; If Not ((pixels[loop, index] = 255) And (pixels[loop, index + 1] = 255) And (pixels[loop, index + 2] = 5)) Then Begin FirstColor := pixels[loop, index]; pixels[loop, index] := pixels[loop, index + 1]; pixels[loop, index + 1] := pixels[loop, index + 2]; pixels[loop, index + 2] := FirstColor; pixels[loop, index + 2] := pixels[loop + random(2), index + (random(3) - 1) * 3 + 2] - loop; End; End; MotionBlurUp(bitmap); Form1.DXDraw1.Surface.Canvas.Draw(Player.x + 16 + BorderOffset, Player.y + 16 + BorderOffset, Bitmap); Player.healing := True; End; End; End. Unit THolyShowerUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit; Type THolyShower = Class (TSpell) Frames : Array[1..5] Of TBitmap; HolyShowerRect : TRect; IsDone : Boolean; Constructor Create; Procedure Base; Procedure Levelup; Procedure SetStats; End; Implementation Uses TPlayerUnit, unit1, TMonsterUnit, EngineUnit; Constructor THolyShower.Create; Var Loop : Integer; Begin Endframe := 48; isdone := False; For loop := 1 To 4 Do Begin Frames[loop] := TBitmap.Create; frames[loop].LoadFromFile('Attacks\HolyShower\' + IntToStr(1) + '.bmp'); Frames[loop].PixelFormat := pf24bit; Frames[loop].TransparentColor := rgb(5, 255, 255); Frames[loop].Transparent := True; End; Frames[5] := TBitmap.Create; Frames[5].LoadFromFile('Attacks\HolyShower\1.bmp'); Frames[5].PixelFormat := pf24bit; Level := 1; ActiveLevel := 1; Exp := 0; cost := 3; End; Procedure THolyShower.base; Var loop : Integer; TempRect : TRect; Begin If HolyShower.Frame = 0 Then Begin Form1.DXWaveListPlayer.Items.Find('Holy Shower').Play(False); FrameCount := 0; isDone := True; End; Inc(HolyShower.Frame); frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Form1.DXDraw1.Surface.Canvas.Draw(HolyShower.X + 16 + BorderOffset, HolyShower.Y + 16 + BorderOffset, frames[5]); x := Random(ActiveLevel * 20) + Player.X - ActiveLevel * 10; y := Random(ActiveLevel * 20) + Player.Y - ActiveLevel * 10; If x < Player.X Then dec(x, 40) Else inc(x, 40); If y < player.Y Then dec(y, 40) Else inc(y, 40); If HolyShower.x > 595 Then HolyShower.X := 595; If HolyShower.X < 5 Then HolyShower.X := 5; If HolyShower.Y > 360 Then HolyShower.Y := 360; If HolyShower.Y < 5 Then HolyShower.Y := 5; Inc(Framecount); If Framecount > 4 Then Framecount := 1; If Frame >= EndFrame Then IsDone := False; If player.MP > ActiveLevel Then For loop := 1 To MonsterCount Do Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then If Not monsters[loop].Hit Then Begin Player.Impact := 'Side'; If (Player.wis Div 10) * (ActiveLevel) > Monsters[loop].Life Then inc(Player.wisExp, Monsters[loop].Life * Monsters[loop].Exp) Else inc(player.wisExp, ((Player.wis Div 10) * (ActiveLevel)) * Monsters[loop].Exp); inc(Monsters[loop].Life, 0 - ((Player.wis Div 10) * (ActiveLevel))); Monsters[loop].HitType := 'Holy Shower'; Monsters[loop].GetHit(Monsters[loop].HitType); dec(Player.MP, ActiveLevel); exp := Exp + 1; If (exp > Level * Level * 50) And (Level < 9) Then Begin Inc(Level); ActiveLevel := Level; exp := 0; Levelup; sleep(3000); Form1.Button1Click(self); IsDone := False; End; End; End; If player.mp < 3 Then Begin Frame := endframe; isdone := True; End; If IsDone Then Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[FrameCount]) Else Begin frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]); End; End; Procedure THolyShower.SetStats; Begin Cost := ActiveLevel; Damage := (Player.wis Div 10) * (ActiveLevel); End; Procedure THolyShower.Levelup; Begin Bars.LoadFromFile('Artwork\life.bmp'); unit1.Panal.LoadFromFile('Artwork\Panal.bmp'); Unit1.Panal.PixelFormat := pf24bit; unit1.EmeraldFont.Write(30, 30, 'Holy Level is now ' + IntToStr(Level), Panal.Canvas); unit1.EmeraldFont.Write(30, 75, 'Current Damage', Panal.Canvas); unit1.EmeraldFont.Write(30, 120, IntToStr((Player.wis Div 10) * (Level * Player.Level)), Panal.Canvas); form1.Button1Click(form1); Form1.DXDraw1.Surface.Canvas.Draw(100 + BorderOffset, 50 + BorderOffset, unit1.Panal); End; End. Unit TShieldUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit; Type TShield = Class (Tspell) Frames : Array[1..4] Of TBitmap; Procedure SetStats; End; Implementation Uses EngineUnit, TPlayerUnit; Procedure TShield.SetStats; Begin Cost := 15 * ActiveLevel; Damage := Player.Level * ActiveLevel; End; End. Unit TSparkUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSpellUnit, TBossUnit; Type TSpark = Class (TSpell) Reflected : Boolean; Frames : Array[1..6] Of TBitmap; Procedure SetStats; Procedure Base; Procedure Levelup; Constructor Create; Procedure Erase(ACanvas : TCanvas); Private Procedure HitMonster; Procedure HitRoamingMonster; Procedure HitPlayer; Procedure HitBoss; End; Implementation Uses TPlayerUnit, unit1, TMonsterUnit, EngineUnit; Constructor TSpark.Create; Var Loop : Integer; Begin EndFrame := 40; For loop := 1 To 4 Do Begin Frames[loop] := TBitmap.Create; frames[loop].LoadFromFile('Attacks\Spark\' + IntToStr(loop) + '.bmp'); Frames[loop].PixelFormat := pf24bit; Frames[loop].TransparentColor := rgb(0, 255, 255); Frames[loop].Transparent := True; End; Frames[5] := TBitmap.Create; Frames[5].LoadFromFile('Attacks\Spark\1.bmp'); Frames[5].PixelFormat := pf24bit; Frames[5].TransparentColor := rgb(5, 255, 255); Frames[5].Transparent := True; Frames[6] := TBitmap.Create; Frames[6].LoadFromFile('Attacks\Spark\1.bmp'); Frames[6].PixelFormat := pf24bit; Frames[6].TransparentColor := rgb(0, 0, 0); Frames[6].Transparent := True; Level := 1; ActiveLevel := 1; Exp := 0; Cost := 1; End; Procedure TSpark.SetStats; Begin Cost := Round(ActiveLevel * 1.2); Damage := Player.Mag Div (10 - Activelevel); End; Procedure TSpark.HitMonster; Var Loop : Integer; TempRect : TRect; Begin For loop := 1 To MonsterCount Do If monsters[loop].HitFlash = 0 Then Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Monsters[loop].X, Monsters[loop].Y, Monsters[loop].X + 40, Monsters[loop].Y + 40)) Then If Not monsters[loop].Hit Then Begin Player.Impact := 'Side'; If Player.Mag Div (10 - Activelevel) > Monsters[loop].Life Then inc(Player.MagExp, Monsters[loop].Life * Monsters[loop].Exp) Else inc(player.MagExp, (Player.Mag Div (10 - Activelevel)) * Monsters[loop].Exp); inc(Monsters[loop].Life, 0 - (Player.Mag Div (10 - Activelevel))); Monsters[loop].HitType := 'Spark'; Monsters[loop].GetHit(Monsters[loop].HitType); Monsters[loop].HitFlash := 24; exp := Exp + 1; If (exp > Level * Level * 50) And (level < 9) Then Begin Inc(level); ActiveLevel := Level; exp := 0; levelup; sleep(3000); Form1.Button1Click(self); Player.Attacking := False; End; End; End; End; Procedure TSpark.HitRoamingMonster; Var TempRect : TRect; Begin If Roamingmonster.HitFlash = 0 Then Begin If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Roamingmonster.X, Roamingmonster.Y, Roamingmonster.X + 40, Roamingmonster.Y + 40)) Then If Not Roamingmonster.Hit Then Begin Player.Impact := 'Side'; If Player.Mag Div (10 - Activelevel) > Roamingmonster.Life Then inc(Player.MagExp, Roamingmonster.Life * Roamingmonster.Exp) Else inc(player.MagExp, (Player.Mag Div (10 - Activelevel)) * Roamingmonster.Exp); inc(Roamingmonster.Life, 0 - (Player.Mag Div (10 - Activelevel))); Roamingmonster.HitType := 'Spark'; Roamingmonster.GetHit(Roamingmonster.HitType); Roamingmonster.HitFlash := 24; exp := Exp + 1; If (exp > Level * Level * 50) And (level < 9) Then Begin Inc(level); ActiveLevel := Level; exp := 0; levelup; sleep(3000); Form1.Button1Click(self); Player.Attacking := False; End; End; End; End; Procedure TSpark.HitBoss; Var Loop : Integer; TempRect : TRect; Begin For Loop := 0 To length(Boss[1].ReflectRegions) - 1 Do If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Boss[1].ReflectRegions[loop].Left + Boss[1].x, Boss[1].ReflectRegions[loop].Top + Boss[1].Y, Boss[1].ReflectRegions[loop].Right + Boss[1].x, Boss[1].ReflectRegions[loop].Bottom + Boss[1].y)) Then Begin Reflected := True; Form1.DXWaveListPlayer.Items.Find('Reflected').Play(False); End; If boss[1].FlashCounter = 0 Then If Not reflected Then For Loop := 0 To length(Boss[1].MagicHitRegions) - 1 Do If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Boss[1].MagicHitRegions[loop].Left + Boss[1].x, Boss[1].MagicHitRegions[loop].Top + Boss[1].Y, Boss[1].MagicHitRegions[loop].Right + Boss[1].x, Boss[1].MagicHitRegions[loop].Bottom + Boss[1].y)) Then Begin Boss[1].Hit(Player.Mag Div (10 - Activelevel), Player.Direction); //Frame := EndFrame; End; End; Procedure TSpark.HitPlayer; Var TempRect : TRect; Begin If player.HitFlashCount = 0 Then If IntersectRect(TempRect, rect(x, Y, X + 30, Y + 30), rect(Player.X, Player.Y, Player.X + 40, Player.Y + 40)) Then If Not Player.Hit Then Begin Dec(Player.HP, Player.Mag Div (10 - Activelevel)); Player.GetHit; Player.HitFlashCount := 24; End; End; Function InvertDirection(Direction : Byte) : Byte; Begin Case Direction Of 1 : Result := 3; 2 : Result := 4; 3 : Result := 1; 4 : Result := 2; Else Result := 1; End; End; Procedure TSpark.Erase(ACanvas : TCanvas); Begin Frames[5].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), RoomBuffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); ACanvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]); End; Procedure TSpark.base; Var Direction : Integer; Begin If ActiveLevel = 0 Then activelevel := 1; If spark.Frame = 0 Then Begin Reflected := False; Form1.DXWaveListPlayer.Items.Find('Spark - Level 1').Play(False); FrameCount := 0; If Player.Direction = 1 Then Begin If isleft In form1.DXInput1.States Then Begin Spark.X := Player.X - 20; Spark.Y := Player.Y - 30; End Else If isRight In form1.DXInput1.States Then Begin Spark.X := Player.X + 35; Spark.Y := Player.Y - 30; End Else Begin Spark.X := Player.X + 5; Spark.Y := Player.Y - 30; End; End Else If Player.Direction = 2 Then Begin Spark.X := Player.X + 40; Spark.Y := Player.Y + 8; End Else If Player.Direction = 3 Then Begin If isleft In form1.DXInput1.States Then Begin Spark.X := Player.X - 20; Spark.Y := Player.Y + 40; End Else If isRight In form1.DXInput1.States Then Begin Spark.X := Player.X + 35; Spark.Y := Player.Y + 40; End Else Begin Spark.X := Player.X + 5; Spark.Y := Player.Y + 40; End; End Else Begin Spark.X := Player.X - 30; Spark.Y := Player.Y + 8; End; End; Inc(Framecount); Inc(Spark.Frame); If Framecount > 4 Then Framecount := 1; Player.FrameCount := 2; If Frame >= EndFrame Then Player.Attacking := False; If Reflected Then Direction := InvertDirection(Player.Direction) Else Direction := Player.Direction; If Direction = 1 Then dec(Spark.Y, ActiveLevel) Else If Direction = 2 Then Inc(Spark.X, Activelevel) Else If Direction = 3 Then Inc(Spark.Y, ActiveLevel) Else If Direction = 4 Then Dec(Spark.X, ActiveLevel); If Activelevel > 2 Then Begin If (isleft In form1.DXInput1.States) And (Direction <> 4) Then dec(Spark.x, ActiveLevel) Else If (isup In form1.DXInput1.States) And (Direction <> 1) Then dec(Spark.Y, Activelevel) Else If (isright In form1.DXInput1.States) And (Direction <> 2) Then inc(Spark.X, Activelevel) Else If (isdown In form1.DXInput1.States) And (Direction <> 3) Then Inc(Spark.Y, Activelevel); End; inc(spark.X, random(Activelevel * 2 + 1) - Activelevel); inc(spark.y, random(Activelevel * 2 + 1) - Activelevel); If spark.x > 595 Then spark.X := 595; If spark.X < 5 Then spark.X := 5; If spark.Y > 360 Then spark.Y := 360; If spark.Y < 5 Then spark.Y := 5; If Not Reflected Then Begin HitMonster; If RoamingMonster.Active Then HitRoamingMonster; If Boss[1].Life > 0 Then HitBoss; End Else HitPlayer; If player.Attacking Then Begin Frames[5].Canvas.Brush.color := rgb(5, 255, 255); Frames[5].Canvas.FillRect(rect(0, 0, frames[5].Width, frames[5].Height)); Frames[5].Canvas.draw(0, 0, Frames[Framecount]); // Frames[6].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), Level2Buffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); // Frames[5].Canvas.draw(0, 0, frames[6]); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]) End Else Begin frames[5].Canvas.CopyRect(rect(0, 0, Frames[5].Width, Frames[5].Height), RoomBuffer.Canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[6].Canvas.CopyRect(rect(0, 0, frames[5].Width, Frames[5].Height), Level2Buffer.canvas, rect(x, y, x + Frames[5].Width, y + Frames[5].Height)); Frames[5].Canvas.draw(0, 0, frames[6]); Form1.DXDraw1.Surface.Canvas.Draw(x + 16 + BorderOffset, y + 16 + BorderOffset, Frames[5]); End; If (Not Regen.Stage1) Or (MagicRegen.Stage1) Then Player.ShowSprite; End; Procedure TSpark.Levelup; Begin Bars.LoadFromFile('Artwork\life.bmp'); unit1.Panal.LoadFromFile('Artwork\Panal.bmp'); Unit1.Panal.PixelFormat := pf24bit; unit1.EmeraldFont.Write(30, 30, 'Spark Level is now ' + IntToStr(Level), Panal.Canvas); unit1.EmeraldFont.Write(30, 75, 'Current Damage', Panal.Canvas); unit1.EmeraldFont.Write(30, 120, IntToStr(Player.Mag Div (10 - level)), Panal.Canvas); form1.Button1Click(form1); Form1.DXDraw1.Surface.Canvas.Draw(100 + BorderOffset, 50 + BorderOffset, unit1.Panal); cost := round(level * 1.2); End; End. Unit TSpellUnit; Interface Uses Graphics, GraphicFX, Windows; Type TSpell = Class //Level Section Exp : Integer; Level, ActiveLevel : Integer; //Stats Cost : Integer; Damage : Integer; //Display Section X, Y : Integer; Frames : Array Of TBitmap; Frame, FrameCount : Integer; EndFrame : Integer; Direction : Integer; End; Implementation End. Unit TWaveUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSparkUnit; Type TWaves = Class X, Y, Direction, State : Integer; End; TWave = Class (TSpark) ImageSet : Array[1..4, 1..4] Of TBitmap; Waves : Array[1..4] Of TWaves; Procedure Load; End; Implementation Procedure TWave.load; Var loop, Loop2 : Integer; Temp : TBitmap; Begin Temp := TBitmap.Create; Temp.LoadFromFile('Attacks\waveattack\1.bmp'); For loop2 := 1 To 4 Do Begin Temp.LoadFromFile('Attacks\waveattack\' + IntToStr(loop2) + '.bmp'); For loop := 1 To 4 Do Begin ImageSet[Loop2, loop] := TBitmap.Create; ImageSet[Loop2, loop].Width := 40; ImageSet[Loop2, loop].Height := 40; ImageSet[Loop2, loop].Canvas.CopyRect(rect(0, 0, 40, 40), temp.Canvas, rect(40 * (Loop - 1), 0, 40 * loop, 40)); ImageSet[Loop2, Loop].TransparentColor := rgb(5, 255, 255); ImageSet[Loop2, Loop].Transparent := True; End; End; End; End. Unit TPlayerSpriteUnit; Interface Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, types, graphicFX, TileUnit, DXinput, TSparkUnit; Type TPlayerSprite = Class X, Y : Integer; FrameCount, Direction, HitFrame : Integer; FrameCountTimer, FrameCountMax : Integer; ShieldFrame, ShieldCounter : Integer; sLightMap, TempLightMap : TBitmap; FrameImage, ShadowImage : Array[1..8] Of TBitmap; sLightmapScan, TempLightScan : PixelArray; Procedure Showup; Procedure ShowDown; Procedure ShowLeft; Procedure ShowRight; Procedure SpriteUp; Procedure SpriteDown; Procedure SpriteLeft; Procedure SpriteRight; Procedure Erase(ACanvas : TCanvas); Function DetectUp : Boolean; Function DetectDown : Boolean; Function DetectLeft : Boolean; Function DetectRight : Boolean; End; Implementation Uses EngineUnit, Unit1, TPlayerUnit, MoveToUnit; Procedure TPlayerSprite.Erase(ACanvas : TCanvas); Begin ACanvas.CopyRect(rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, 16 + X + 40 + BorderOffset, Y + 16 + 40 + BorderOffset), RoomBuffer.Canvas, rect(x, y, x + 40, y + 40)); End; Procedure TPlayerSprite.ShowRight; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 40, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferx.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.ShowLeft; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferx.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.ShowDown; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferX.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.ShowUp; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferX.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.SpriteRight; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 40 + 16 + BorderOffset, Y + 40 + 16 + BorderOffset)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 40, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferX.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); // If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0); // Else If SpriteBlendingType = 2 Then MotionblurRight(SpriteBufferX); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.SpriteLeft; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferX.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurLeft(SpriteBufferX); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.SpriteDown; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBuffery.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurDown(SpriteBufferY); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Procedure TPlayerSprite.SpriteUp; Begin SpriteBufferX.Canvas.CopyRect(rect(0, 0, 40, 40), Form1.DXDraw1.Surface.Canvas, rect(X + 16 + BorderOffset, Y + 16 + BorderOffset, X + 16 + BorderOffset + 40, Y + 16 + BorderOffset + 40)); If Not currentroom.LightMapOn Then SpriteBufferX.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]) Else Begin frameimage[(direction - 1) * 2 + frameCount].Transparent := False; TempLightMap.Canvas.Draw(0, 0, frameimage[(direction - 1) * 2 + frameCount]); frameimage[(direction - 1) * 2 + frameCount].Transparent := True; sLightMap.Canvas.CopyRect(rect(0, 0, 40, 40), CurrentRoom.LightMap.Canvas, rect(x, y, x + 41, y + 40)); LightMap(TempLightMap, TemplightScan, sLightMapScan, TempLightScan); SpriteBufferX.Canvas.Draw(0, 0, templightmap); End; If shieldCounter > 0 Then SpriteBufferX.Canvas.Draw(0, 0, Shield.frames[ShieldFrame]); If SpriteBlendingType = 1 Then blur(SpriteBufferX, 0);// Else If SpriteBlendingType = 2 Then MotionblurDown(SpriteBufferX); Form1.DXDraw1.Surface.Canvas.Draw(X + 16 + BorderOffset, Y + 16 + BorderOffset, SpriteBufferX); End; Function TPlayerSprite.DetectUp : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y + 25, x + 40, y + 36), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then Begin If IntersectRect(temprect, rect(x + 5, y + 25, x + 35, y + 36), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False Else x := round(x / 5) * 5; End; For loop := 1 To PeopleCount Do If Not MoveTo.Enabled Then If IntersectRect(temprect, rect(x + 2, y - 10, x + 38, y + 30), rect(People[loop].X + 2, People[loop].y, People[loop].X + 38, People[loop].y + 40)) Then Begin ok := False; If Not MoveTo.Enabled Then People[loop].Walking := False; people[loop].Direction := 3; End Else people[loop].Walking := True; If ok Then DetectUp := True Else DetectUp := False; End; Function TPlayerSprite.DetectDown : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x, y + 39, x + 40, y + 45), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then Begin If IntersectRect(temprect, rect(x + 5, y + 39, x + 35, y + 45), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False Else x := round(x / 5) * 5; End; For loop := 1 To PeopleCount Do If Not MoveTo.Enabled Then If IntersectRect(temprect, rect(x, y + 10, x + 40, y + 50), rect(People[loop].X, People[loop].y, People[loop].X + 40, People[loop].y + 40)) Then Begin ok := False; If Not MoveTo.Enabled Then People[loop].Walking := False; people[loop].Direction := 1; People[loop].SpriteUp; End Else people[loop].Walking := True; If ok Then DetectDown := True Else DetectDown := False; End; Function TPlayerSprite.DetectLeft : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x - 5, y + 35, x + 5, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; For loop := 1 To PeopleCount Do If Not MoveTo.Enabled Then If IntersectRect(temprect, rect(x - 10, y, x + 30, y + 40), rect(People[loop].X, People[loop].y, People[loop].X + 40, People[loop].y + 40)) Then Begin ok := False; If Not MoveTo.Enabled Then People[loop].Walking := False; people[loop].Direction := 2; People[loop].SpriteRight; End Else people[loop].Walking := True; If ok Then DetectLeft := True Else DetectLeft := False; End; Function TPlayerSprite.DetectRight : Boolean; Var ok : Boolean; Loop : Integer; Temprect : TRect; Begin ok := True; For loop := 0 To CurrentRoom.NumberofBKOs - 1 Do If IntersectRect(temprect, rect(x + 35, y + 35, x + 45, y + 40), rect(Currentroom.bkos[loop].X, Currentroom.bkos[loop].y, Currentroom.bkos[loop].X + 40, Currentroom.bkos[loop].y + 40)) Then ok := False; For loop := 1 To PeopleCount Do If Not MoveTo.Enabled Then If IntersectRect(temprect, rect(x + 10, y, x + 50, y + 40), rect(People[loop].X, People[loop].y, People[loop].X + 40, People[loop].y + 40)) Then Begin ok := False; If Not MoveTo.Enabled Then People[loop].Walking := False; people[loop].Direction := 4; People[loop].Spriteleft; End Else people[loop].Walking := True; If ok Then DetectRight := True Else DetectRight := False; End; End.