X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_weapons.pas;h=8fdde869c0bcda1b9a175a3805bc0c2bc528be53;hb=a0269440c6b9e8f1f0f578f26864804f9a412b13;hp=44cef05922d1b9b9303e8e4156271538b210faf4;hpb=abed90e42988669146ac1f2ecf2f9eef74f336c1;p=d2df-sdl.git diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 44cef05..8fdde86 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -20,7 +20,7 @@ interface uses SysUtils, Classes, mempool, - g_textures, g_basic, g_phys, xprofiler; + g_basic, g_phys, xprofiler; type @@ -30,7 +30,7 @@ type SpawnerUID: Word; Triggers: DWArray; Obj: TObj; - Animation: TAnimationState; + time: LongWord; Timeout: DWORD; Stopped: Byte; @@ -100,6 +100,7 @@ const WEAPON_BARON_FIRE = 24; WEAPON_MANCUB_FIRE = 25; WEAPON_SKEL_FIRE = 26; + WEAPON_LAST = WEAPON_SKEL_FIRE; WP_FIRST = WEAPON_KASTET; WP_LAST = WEAPON_FLAMETHROWER; @@ -117,6 +118,9 @@ implementation {$IFDEF ENABLE_GIBS} g_gibs, {$ENDIF} + {$IFDEF ENABLE_CORPSES} + g_corpses, + {$ENDIF} Math, g_map, g_player, g_sound, g_panel, g_console, g_options, g_game, g_triggers, MAPDEF, e_log, g_monsters, g_saveload, @@ -520,21 +524,29 @@ var begin //g_Sound_PlayEx('SOUND_WEAPON_EXPLODEBFG', 255); - h := High(gCorpses); - - if gAdvCorpses and (h <> -1) then - for i := 0 to h do - if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then - with gCorpses[i] do - if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), - Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and - g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), - Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then + {$IFDEF ENABLE_CORPSES} + h := High(gCorpses); + if gAdvCorpses and (h <> -1) then + begin + for i := 0 to h do + begin + if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then + begin + with gCorpses[i] do begin - Damage(50, SpawnerUID, 0, 0); - g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), - Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)); + if (g_PatchLength(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), + Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) <= SHOT_BFG_RADIUS) and + g_TraceVector(X, Y, Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), + Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)) then + begin + Damage(50, SpawnerUID, 0, 0); + g_Weapon_BFGHit(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)); + end; end; + end; + end; + end; + {$ENDIF} st := TEAM_NONE; pl := g_Player_Get(SpawnerUID); @@ -577,6 +589,8 @@ begin SetLength(Shots, find_id + 64) end; + shots[find_id].time := gTime; + case ShotType of WEAPON_ROCKETLAUNCHER: begin @@ -587,7 +601,6 @@ begin Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH; Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT; - Animation := nil; Triggers := nil; ShotType := WEAPON_ROCKETLAUNCHER; end; @@ -604,7 +617,6 @@ begin Triggers := nil; ShotType := WEAPON_PLASMA; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table end; end; @@ -619,7 +631,6 @@ begin Triggers := nil; ShotType := WEAPON_BFG; - Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table end; end; @@ -634,7 +645,6 @@ begin Triggers := nil; ShotType := WEAPON_FLAMETHROWER; - // Animation := TAnimationState.Create(True, 6, 0); // drawed as gfx end; end; @@ -649,7 +659,6 @@ begin Triggers := nil; ShotType := WEAPON_IMP_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -664,7 +673,6 @@ begin Triggers := nil; ShotType := WEAPON_CACO_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -679,7 +687,6 @@ begin Triggers := nil; ShotType := WEAPON_MANCUB_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -694,7 +701,6 @@ begin Triggers := nil; ShotType := WEAPON_BARON_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -709,7 +715,6 @@ begin Triggers := nil; ShotType := WEAPON_BSP_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -725,7 +730,6 @@ begin Triggers := nil; ShotType := WEAPON_SKEL_FIRE; target := TargetUID; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table end; end; end; @@ -778,8 +782,10 @@ begin end; function g_Weapon_Hit(obj: PObj; d: Integer; SpawnerUID: Word; t: Byte; HitCorpses: Boolean = True): Byte; -var - i, h: Integer; + {$IFDEF ENABLE_CORPSES} + var i: Integer; + {$ENDIF} + var h: Integer; function PlayerHit(Team: Byte = 0): Boolean; var @@ -858,21 +864,26 @@ var begin Result := 0; - if HitCorpses then - begin - h := High(gCorpses); - - if gAdvCorpses and (h <> -1) then - for i := 0 to h do - if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and - g_Obj_Collide(obj, @gCorpses[i].Obj) then + {$IFDEF ENABLE_CORPSES} + if HitCorpses then + begin + h := High(gCorpses); + if gAdvCorpses and (h <> -1) then + begin + for i := 0 to h do begin - // Ðàñïèëèâàåì òðóï: - gCorpses[i].Damage(d, SpawnerUID, (obj^.Vel.X+obj^.Accel.X) div 4, - (obj^.Vel.Y+obj^.Accel.Y) div 4); - Result := 1; + if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) and + g_Obj_Collide(obj, @gCorpses[i].Obj) then + begin + // Ðàñïèëèâàåì òðóï: + gCorpses[i].Damage(d, SpawnerUID, (obj^.Vel.X+obj^.Accel.X) div 4, + (obj^.Vel.Y+obj^.Accel.Y) div 4); + Result := 1; + end; end; - end; + end; + end; + {$ENDIF} case gGameSettings.GameMode of // Êàìïàíèÿ: @@ -992,10 +1003,13 @@ var end; end; - var i, h, dx, dy, m, mm: Integer; + var i, h, dx, dy, mm: Integer; {$IFDEF ENABLE_GIBS} var _angle: SmallInt; {$ENDIF} + {$IF DEFINED(ENABLE_GIBS) OR DEFINED(ENABLE_CORPSES)} + var m: Integer; + {$ENDIF} begin result := false; @@ -1032,30 +1046,33 @@ begin //g_Mons_ForEach(monsExCheck); g_Mons_ForEachAt(X-(rad+32), Y-(rad+32), (rad+32)*2, (rad+32)*2, monsExCheck); - h := High(gCorpses); - - if gAdvCorpses and (h <> -1) then - for i := 0 to h do - if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then - with gCorpses[i] do + {$IFDEF ENABLE_CORPSES} + h := High(gCorpses); + if gAdvCorpses and (h <> -1) then + begin + for i := 0 to h do + begin + if (gCorpses[i] <> nil) and (gCorpses[i].State <> CORPSE_STATE_REMOVEME) then begin - dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X; - dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y; - - if dx > 1000 then dx := 1000; - if dy > 1000 then dy := 1000; - - if dx*dx+dy*dy < r then + with gCorpses[i] do begin - m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, - Obj.Rect.Width, Obj.Rect.Height); - - mm := Max(abs(dx), abs(dy)); - if mm = 0 then mm := 1; - - Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm); + dx := Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)-X; + dy := Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2)-Y; + if dx > 1000 then dx := 1000; + if dy > 1000 then dy := 1000; + if dx*dx+dy*dy < r then + begin + m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, Obj.Rect.Width, Obj.Rect.Height); + mm := Max(abs(dx), abs(dy)); + if mm = 0 then + mm := 1; + Damage(Round(100*(rad-m)/rad), SpawnerUID, (dx*10) div mm, (dy*10) div mm); + end; end; end; + end; + end; + {$ENDIF} {$IFDEF ENABLE_GIBS} h := High(gGibs); @@ -1087,18 +1104,8 @@ begin end; procedure g_Weapon_Free(); -var - i: Integer; begin - if Shots <> nil then - begin - for i := 0 to High(Shots) do - if Shots[i].ShotType <> 0 then - Shots[i].Animation.Free(); - - Shots := nil; - end; - + Shots := nil; WaterMap := nil; end; @@ -1638,8 +1645,8 @@ begin ShotType := WEAPON_ROCKETLAUNCHER; throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 12); - Animation := nil; triggers := nil; + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1678,7 +1685,7 @@ begin triggers := nil; target := TargetUID; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1719,7 +1726,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1760,7 +1767,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := nil; + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1801,7 +1808,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1842,7 +1849,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1883,7 +1890,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1924,8 +1931,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1966,8 +1972,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -2008,7 +2013,7 @@ begin throw(find_id, x+dx, y+dy, xd+dx, yd+dy, 16); triggers := nil; - Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -2167,10 +2172,6 @@ begin end; end; - // Àíèìàöèÿ ñíàðÿäà: - if Animation <> nil then - Animation.Update(); - // Äâèæåíèå: spl := (ShotType <> WEAPON_PLASMA) and (ShotType <> WEAPON_BFG) and @@ -2192,7 +2193,7 @@ begin begin // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë. ShotType := 0; - Animation.Free(); + time := 0; Continue; end; @@ -2466,11 +2467,7 @@ begin begin if gGameSettings.GameType = GT_SERVER then MH_SEND_DeleteShot(i, Obj.X, Obj.Y, Loud); - if Animation <> nil then - begin - Animation.Free(); - Animation := nil; - end; + time := 0; end else if (ShotType <> WEAPON_FLAMETHROWER) and ((oldvx <> Obj.Vel.X) or (oldvy <> Obj.Vel.Y)) then if gGameSettings.GameType = GT_SERVER then @@ -2576,42 +2573,7 @@ begin // Êîñòûëèíà åáàíàÿ Shots[i].Stopped := utils.readByte(st); - // Óñòàíîâêà òåêñòóðû èëè àíèìàöèè - Shots[i].Animation := nil; - - case Shots[i].ShotType of - WEAPON_ROCKETLAUNCHER, WEAPON_SKEL_FIRE: - begin - end; - WEAPON_PLASMA: - begin - Shots[i].Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table - end; - WEAPON_BFG: - begin - Shots[i].Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table - end; - WEAPON_IMP_FIRE: - begin - Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table - end; - WEAPON_BSP_FIRE: - begin - Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table - end; - WEAPON_CACO_FIRE: - begin - Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table - end; - WEAPON_BARON_FIRE: - begin - Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table - end; - WEAPON_MANCUB_FIRE: - begin - Shots[i].Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table - end; - end; + Shots[i].time := gTime; // TODO save time? end; end; @@ -2696,7 +2658,6 @@ begin end; // case ShotType of... ShotType := 0; - Animation.Free(); end; end;