X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_weapons.pas;h=96c46c8d4fc0cad7a2d0e36eeaf88b431addbaf9;hb=a2ba3b4f4ea42350560a7670f3be97a55f6d3ab5;hp=922f8dc66042557ad4d2ce360fc6091eef5e4b18;hpb=6cdd36d2fb73f13be7b6ea1870a8b3b0817b37f1;p=d2df-sdl.git diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 922f8dc..96c46c8 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; @@ -114,10 +115,16 @@ implementation {$IFDEF ENABLE_GFX} g_gfx, {$ENDIF} + {$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, - g_language, g_netmsg, g_grid, + g_language, g_netmsg, g_grid, g_window, geom, binheap, hashtable, utils, xstreams ; @@ -517,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); @@ -574,6 +589,8 @@ begin SetLength(Shots, find_id + 64) end; + shots[find_id].time := gTime; + case ShotType of WEAPON_ROCKETLAUNCHER: begin @@ -584,7 +601,6 @@ begin Obj.Rect.Width := SHOT_ROCKETLAUNCHER_WIDTH; Obj.Rect.Height := SHOT_ROCKETLAUNCHER_HEIGHT; - Animation := nil; Triggers := nil; ShotType := WEAPON_ROCKETLAUNCHER; end; @@ -601,7 +617,6 @@ begin Triggers := nil; ShotType := WEAPON_PLASMA; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table end; end; @@ -616,7 +631,6 @@ begin Triggers := nil; ShotType := WEAPON_BFG; - Animation := TAnimationState.Create(True, 6, 2); // !!! put values into table end; end; @@ -631,7 +645,6 @@ begin Triggers := nil; ShotType := WEAPON_FLAMETHROWER; - // Animation := TAnimationState.Create(True, 6, 0); // drawed as gfx end; end; @@ -646,7 +659,6 @@ begin Triggers := nil; ShotType := WEAPON_IMP_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -661,7 +673,6 @@ begin Triggers := nil; ShotType := WEAPON_CACO_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -676,7 +687,6 @@ begin Triggers := nil; ShotType := WEAPON_MANCUB_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -691,7 +701,6 @@ begin Triggers := nil; ShotType := WEAPON_BARON_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -706,7 +715,6 @@ begin Triggers := nil; ShotType := WEAPON_BSP_FIRE; - Animation := TAnimationState.Create(True, 4, 2); // !!! put values into table end; end; @@ -722,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; @@ -775,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 @@ -855,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 // Êàìïàíèÿ: @@ -989,9 +1003,13 @@ var end; end; -var - i, h, dx, dy, m, mm: Integer; - _angle: SmallInt; + 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; @@ -1028,55 +1046,56 @@ 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} - h := High(gGibs); - - if gAdvGibs and (h <> -1) then - for i := 0 to h do - if gGibs[i].alive then - with gGibs[i] do - 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 + {$IFDEF ENABLE_GIBS} + h := High(gGibs); + if gAdvGibs and (h <> -1) then + for i := 0 to h do + if gGibs[i].alive then + with gGibs[i] do begin - m := PointToRect(X, Y, Obj.X+Obj.Rect.X, Obj.Y+Obj.Rect.Y, - Obj.Rect.Width, Obj.Rect.Height); - _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), - Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y); - - g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle); - positionChanged(); // this updates spatial accelerators + 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); + _angle := GetAngle(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2), + Obj.Y+Obj.Rect.Y+(Obj.Rect.Height div 2), X, Y); + g_Obj_PushA(@Obj, Round(15*(rad-m)/rad), _angle); + positionChanged(); // this updates spatial accelerators + end; end; - end; + {$ENDIF} end; procedure g_Weapon_Init(); @@ -1085,24 +1104,15 @@ 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; procedure g_Weapon_LoadData(); begin e_WriteLog('Loading weapons data...', TMsgType.Notify); + g_Game_SetLoadingText(_lc[I_LOAD_WEAPONS_DATA], 0, False); g_Sound_CreateWADEx('SOUND_WEAPON_HITPUNCH', GameWAD+':SOUNDS\HITPUNCH'); g_Sound_CreateWADEx('SOUND_WEAPON_MISSPUNCH', GameWAD+':SOUNDS\MISSPUNCH'); @@ -1636,8 +1646,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; @@ -1676,7 +1686,7 @@ begin triggers := nil; target := TargetUID; - Animation := TAnimationState.Create(True, 5, 2); // !!! put values into table + time := gTime; end; Shots[find_id].SpawnerUID := SpawnerUID; @@ -1717,7 +1727,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; @@ -1758,7 +1768,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; @@ -1799,7 +1809,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; @@ -1840,7 +1850,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; @@ -1881,7 +1891,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; @@ -1922,8 +1932,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; @@ -1964,8 +1973,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; @@ -2006,7 +2014,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; @@ -2165,10 +2173,6 @@ begin end; end; - // Àíèìàöèÿ ñíàðÿäà: - if Animation <> nil then - Animation.Update(); - // Äâèæåíèå: spl := (ShotType <> WEAPON_PLASMA) and (ShotType <> WEAPON_BFG) and @@ -2190,7 +2194,7 @@ begin begin // Íà êëèåíòå ñêîðåå âñåãî è òàê óæå âûïàë. ShotType := 0; - Animation.Free(); + time := 0; Continue; end; @@ -2464,11 +2468,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 @@ -2574,42 +2574,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; @@ -2694,7 +2659,6 @@ begin end; // case ShotType of... ShotType := 0; - Animation.Free(); end; end;