hedgewars/uGearsList.pas
author unc0rr
Thu, 31 Dec 2015 16:26:21 +0300
changeset 11475 1d478892cf1c
parent 11468 2f6f8baa2a97
child 11532 bf86c6cb9341
permissions -rw-r--r--
AI is pretty good at using Bee weapon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     1
(*
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 11043
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     4
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     8
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    12
 * GNU General Public License for more details.
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    13
 *
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 10040
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    17
 *)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    18
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    19
{$INCLUDE "options.inc"}
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    20
unit uGearsList;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    21
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    22
interface
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
    23
uses uFloat, uTypes, SDLh;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    24
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    25
function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
11203
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
    26
function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer, newUid: LongWord): PGear;
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
    27
procedure DeleteGear(Gear: PGear);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    28
procedure InsertGearToList(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    29
procedure RemoveGearFromList(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    30
7395
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
    31
var curHandledGear: PGear;
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
    32
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    33
implementation
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    34
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    35
uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    36
    uTextures, uScript, uRenderUtils, uAI, uCollisions,
7395
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
    37
    uGearsRender, uGearsUtils, uDebug;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
    38
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    39
const
8795
b5b79a8f9354 merge correction, also what's with all those trailing whitespaces?
koda
parents: 8774
diff changeset
    40
    GearKindAmmoTypeMap : array [TGearType] of TAmmoType = (
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    41
(*          gtFlame *)   amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    42
(*       gtHedgehog *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    43
(*           gtMine *) , amMine
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    44
(*           gtCase *) , amNothing
10829
158b5dd6b3c9 avoid airmines too when spawning
nemo
parents: 10828
diff changeset
    45
(*        gtAirMine *) , amAirMine
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    46
(*     gtExplosives *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    47
(*        gtGrenade *) , amGrenade
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    48
(*          gtShell *) , amBazooka
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    49
(*          gtGrave *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    50
(*            gtBee *) , amBee
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    51
(*    gtShotgunShot *) , amShotgun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    52
(*     gtPickHammer *) , amPickHammer
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    53
(*           gtRope *) , amRope
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    54
(*     gtDEagleShot *) , amDEagle
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    55
(*       gtDynamite *) , amDynamite
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    56
(*    gtClusterBomb *) , amClusterBomb
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    57
(*        gtCluster *) , amClusterBomb
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    58
(*         gtShover *) , amBaseballBat  // Shover is only used for baseball bat right now
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    59
(*      gtFirePunch *) , amFirePunch
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    60
(*    gtATStartGame *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    61
(*   gtATFinishGame *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    62
(*      gtParachute *) , amParachute
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    63
(*      gtAirAttack *) , amAirAttack
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    64
(*        gtAirBomb *) , amAirAttack
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    65
(*      gtBlowTorch *) , amBlowTorch
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    66
(*         gtGirder *) , amGirder
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    67
(*       gtTeleport *) , amTeleport
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    68
(*       gtSwitcher *) , amSwitch
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    69
(*         gtTarget *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    70
(*         gtMortar *) , amMortar
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    71
(*           gtWhip *) , amWhip
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    72
(*       gtKamikaze *) , amKamikaze
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    73
(*           gtCake *) , amCake
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    74
(*      gtSeduction *) , amSeduction
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    75
(*     gtWatermelon *) , amWatermelon
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    76
(*     gtMelonPiece *) , amWatermelon
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    77
(*    gtHellishBomb *) , amHellishBomb
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    78
(*        gtWaterUp *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    79
(*          gtDrill *) , amDrill
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    80
(*        gtBallGun *) , amBallgun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    81
(*           gtBall *) , amBallgun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    82
(*        gtRCPlane *) , amRCPlane
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    83
(*gtSniperRifleShot *) , amSniperRifle
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    84
(*        gtJetpack *) , amJetpack
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    85
(*        gtMolotov *) , amMolotov
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    86
(*          gtBirdy *) , amBirdy
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    87
(*            gtEgg *) , amBirdy
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    88
(*         gtPortal *) , amPortalGun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    89
(*          gtPiano *) , amPiano
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    90
(*        gtGasBomb *) , amGasBomb
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    91
(*    gtSineGunShot *) , amSineGun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    92
(*   gtFlamethrower *) , amFlamethrower
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    93
(*          gtSMine *) , amSMine
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    94
(*    gtPoisonCloud *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    95
(*         gtHammer *) , amHammer
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    96
(*      gtHammerHit *) , amHammer
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    97
(*    gtResurrector *) , amResurrector
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    98
(*    gtPoisonCloud *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
    99
(*       gtSnowball *) , amSnowball
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   100
(*          gtFlake *) , amNothing
8161
0b8beacff8a5 GCI2012: Remove Structure Weapon Code
deepdog
parents: 8145
diff changeset
   101
//(*      gtStructure *) , amStructure  // TODO - This will undoubtedly change once there is more than one structure
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   102
(*        gtLandGun *) , amLandGun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   103
(*         gtTardis *) , amTardis
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   104
(*         gtIceGun *) , amIceGun
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   105
(*        gtAddAmmo *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   106
(*  gtGenericFaller *) , amNothing
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   107
(*          gtKnife *) , amKnife
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   108
    );
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   109
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   110
7093
2d7f1fb73335 Bit more freezer.
nemo
parents: 7077
diff changeset
   111
var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
   112
8145
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   113
const
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   114
    cUsualZ = 500;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   115
    cOnHHZ = 2000;
6408c0ba4ba1 Move global variables to units that use them
Joe Doyle (Ginto8) <ginto8@gmail.com>
parents: 7754
diff changeset
   116
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   117
procedure InsertGearToList(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   118
var tmp, ptmp: PGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   119
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   120
    tmp:= GearsList;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   121
    ptmp:= GearsList;
7366
e5a0856708dc Insert at front of same Z, not end. Saves a little time on insertion and lua lookup of recent adds.
nemo
parents: 7364
diff changeset
   122
    while (tmp <> nil) and (tmp^.Z < Gear^.Z) do
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   123
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   124
        ptmp:= tmp;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   125
        tmp:= tmp^.NextGear
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   126
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   127
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   128
    if ptmp <> tmp then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   129
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   130
        Gear^.NextGear:= ptmp^.NextGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   131
        Gear^.PrevGear:= ptmp;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   132
        if ptmp^.NextGear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   133
            ptmp^.NextGear^.PrevGear:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   134
        ptmp^.NextGear:= Gear
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   135
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   136
    else
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   137
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   138
        Gear^.NextGear:= GearsList;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   139
        if Gear^.NextGear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   140
            Gear^.NextGear^.PrevGear:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   141
        GearsList:= Gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   142
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   143
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   144
7395
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
   145
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   146
procedure RemoveGearFromList(Gear: PGear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   147
begin
10634
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   148
if (Gear <> GearsList) and (Gear <> nil) and (Gear^.NextGear = nil) and (Gear^.PrevGear = nil) then
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   149
    begin
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   150
    AddFileLog('Attempted to remove Gear #'+inttostr(Gear^.uid)+' from the list twice.');
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   151
    exit
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   152
    end;
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   153
TryDo((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true);
7395
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
   154
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   155
if Gear^.NextGear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   156
    Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   157
if Gear^.PrevGear <> nil then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   158
    Gear^.PrevGear^.NextGear:= Gear^.NextGear
11043
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   159
else
10634
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   160
    GearsList:= Gear^.NextGear;
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   161
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   162
Gear^.NextGear:= nil;
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   163
Gear^.PrevGear:= nil
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   164
end;
7395
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
   165
d0d38cd0d27c - Check for harmful gear deletions
unc0rr
parents: 7394
diff changeset
   166
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   167
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
11203
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   168
begin
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   169
AddGear:= AddGear(X, Y, Kind, State, dX, dY, Timer, 0);
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   170
end;
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   171
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer, newUid: LongWord): PGear;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   172
var gear: PGear;
10518
dbbe2f6c0a96 make gear ability to speak somewhat less ironic
sheepluva
parents: 10495
diff changeset
   173
    //c: byte;
10874
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   174
    cakeData: PCakeData;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   175
begin
11203
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   176
if newUid = 0 then
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   177
    inc(GCounter);
8026
4a4f21070479 merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents: 7754
diff changeset
   178
7028
0f60591f3a16 old typed const moved to their proper unit
koda
parents: 7010
diff changeset
   179
AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   180
8330
aaefa587e277 update branch with default
koda
parents: 8026 8161
diff changeset
   181
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   182
New(gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   183
FillChar(gear^, sizeof(TGear), 0);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   184
gear^.X:= int2hwFloat(X);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   185
gear^.Y:= int2hwFloat(Y);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   186
gear^.Target.X:= NoPointX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   187
gear^.Kind := Kind;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   188
gear^.State:= State;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   189
gear^.Active:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   190
gear^.dX:= dX;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   191
gear^.dY:= dY;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   192
gear^.doStep:= doStepHandlers[Kind];
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   193
gear^.CollisionIndex:= -1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   194
gear^.Timer:= Timer;
11203
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   195
if newUid = 0 then
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   196
     gear^.uid:= GCounter
2f4d0a387a02 Pass overridden uid into AddGear instead
nemo
parents: 11171
diff changeset
   197
else gear^.uid:= newUid;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   198
gear^.SoundChannel:= -1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   199
gear^.ImpactSound:= sndNone;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   200
gear^.Density:= _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   201
// Define ammo association, if any.
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   202
gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
7730
2013733f9ca9 A bit more on the knife. Also add missing files to CMakeLists
nemo
parents: 7726
diff changeset
   203
gear^.CollisionMask:= $FFFF;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   204
gear^.Tint:= $FFFFFFFF;
10874
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   205
gear^.Data:= nil;
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7176
diff changeset
   206
8795
b5b79a8f9354 merge correction, also what's with all those trailing whitespaces?
koda
parents: 8774
diff changeset
   207
if CurrentHedgehog <> nil then
7726
1137406bce12 Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents: 7721
diff changeset
   208
    begin
1137406bce12 Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents: 7721
diff changeset
   209
    gear^.Hedgehog:= CurrentHedgehog;
1137406bce12 Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents: 7721
diff changeset
   210
    if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
8751
4609823efc94 More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents: 8744
diff changeset
   211
        gear^.CollisionMask:= lfNotCurrentMask
7730
2013733f9ca9 A bit more on the knife. Also add missing files to CMakeLists
nemo
parents: 7726
diff changeset
   212
    end;
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7176
diff changeset
   213
7364
ee87ad50e18d Draw bombs behind plane
nemo
parents: 7337
diff changeset
   214
if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   215
    gear^.Z:= cHHZ+1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   216
else gear^.Z:= cUsualZ;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   217
11468
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   218
case Kind of
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   219
          gtFlame: Gear^.Boom := 2;  // some additional expl in there are x3, x4 this
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   220
       gtHedgehog: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   221
           gtMine: Gear^.Boom := 50;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   222
           gtCase: Gear^.Boom := 25;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   223
        gtAirMine: Gear^.Boom := 25;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   224
     gtExplosives: Gear^.Boom := 75;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   225
        gtGrenade: Gear^.Boom := 50;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   226
          gtShell: Gear^.Boom := 50;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   227
            gtBee: Gear^.Boom := 50;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   228
    gtShotgunShot: Gear^.Boom := 25;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   229
     gtPickHammer: Gear^.Boom := 6;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   230
//           gtRope: Gear^.Boom := 2; could be funny to have rope attaching to hog deal small amount of dmg?
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   231
     gtDEagleShot: Gear^.Boom := 7;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   232
       gtDynamite: Gear^.Boom := 75;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   233
    gtClusterBomb: Gear^.Boom := 20;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   234
     gtMelonPiece,
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   235
        gtCluster: Gear^.Boom := Timer;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   236
         gtShover: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   237
      gtFirePunch: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   238
        gtAirBomb: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   239
      gtBlowTorch: Gear^.Boom := 2;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   240
         gtMortar: Gear^.Boom := 20;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   241
           gtWhip: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   242
       gtKamikaze: Gear^.Boom := 30; // both shove and explosion
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   243
           gtCake: Gear^.Boom := cakeDmg; // why is cake damage a global constant
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   244
     gtWatermelon: Gear^.Boom := 75;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   245
    gtHellishBomb: Gear^.Boom := 90;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   246
          gtDrill: if Gear^.State and gsttmpFlag = 0 then
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   247
                        Gear^.Boom := 50
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   248
                   else Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   249
           gtBall: Gear^.Boom := 40;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   250
        gtRCPlane: Gear^.Boom := 25;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   251
// sniper rifle is distance linked, this Boom is just an arbitrary scaling factor applied to timer-based-damage
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   252
// because, eh, why not..
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   253
gtSniperRifleShot: Gear^.Boom := 100000;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   254
            gtEgg: Gear^.Boom := 10;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   255
          gtPiano: Gear^.Boom := 80;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   256
        gtGasBomb: Gear^.Boom := 20;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   257
    gtSineGunShot: Gear^.Boom := 35;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   258
          gtSMine: Gear^.Boom := 30;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   259
    gtSnowball: Gear^.Boom := 200000; // arbitrary scaling for the shove
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   260
         gtHammer: if cDamageModifier > _1 then // scale it based on cDamageModifier?
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   261
                         Gear^.Boom := 2
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   262
                    else Gear^.Boom := 3;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   263
    gtPoisonCloud: Gear^.Boom := 20;
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   264
          gtKnife: Gear^.Boom := 40000; // arbitrary scaling factor since impact-based
2f6f8baa2a97 Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents: 11203
diff changeset
   265
    end;
8795
b5b79a8f9354 merge correction, also what's with all those trailing whitespaces?
koda
parents: 8774
diff changeset
   266
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   267
case Kind of
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   268
     gtGrenade,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   269
     gtClusterBomb,
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   270
     gtGasBomb: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   271
                gear^.ImpactSound:= sndGrenadeImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   272
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   273
                gear^.AdvBounce:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   274
                gear^.Radius:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   275
                gear^.Elasticity:= _0_8;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   276
                gear^.Friction:= _0_8;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   277
                gear^.Density:= _1_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   278
                gear^.RenderTimer:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   279
                if gear^.Timer = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   280
                    gear^.Timer:= 3000
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   281
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   282
  gtWatermelon: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   283
                gear^.ImpactSound:= sndMelonImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   284
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   285
                gear^.AdvBounce:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   286
                gear^.Radius:= 6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   287
                gear^.Elasticity:= _0_8;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   288
                gear^.Friction:= _0_995;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   289
                gear^.Density:= _2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   290
                gear^.RenderTimer:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   291
                if gear^.Timer = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   292
                    gear^.Timer:= 3000
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   293
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   294
  gtMelonPiece: begin
9825
de0da12b7d0e more advbounce flagging
nemo
parents: 9824
diff changeset
   295
                gear^.AdvBounce:= 1;
10889
f7200e614295 give melon pieces a radius. is why they weren't bouncing.
nemo
parents: 10875
diff changeset
   296
                gear^.Density:= _2;
11036
6e866be63b1d oops. melon pieces need friction and elasticity to bounce right.
nemo
parents: 11002
diff changeset
   297
                gear^.Elasticity:= _0_8;
6e866be63b1d oops. melon pieces need friction and elasticity to bounce right.
nemo
parents: 11002
diff changeset
   298
                gear^.Friction:= _0_995;
10889
f7200e614295 give melon pieces a radius. is why they weren't bouncing.
nemo
parents: 10875
diff changeset
   299
                gear^.Radius:= 4
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   300
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   301
    gtHedgehog: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   302
                gear^.AdvBounce:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   303
                gear^.Radius:= cHHRadius;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   304
                gear^.Elasticity:= _0_35;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   305
                gear^.Friction:= _0_999;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   306
                gear^.Angle:= cMaxAngle div 2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   307
                gear^.Density:= _3;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   308
                gear^.Z:= cHHZ;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   309
                if (GameFlags and gfAISurvival) <> 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   310
                    if gear^.Hedgehog^.BotLevel > 0 then
7077
nemo
parents: 7069
diff changeset
   311
                        gear^.Hedgehog^.Effects[heResurrectable] := 1;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   312
                // this would presumably be set in the frontend
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   313
                // if we weren't going to do that yet, would need to reinit GetRandom
10040
koda
parents: 10015 10032
diff changeset
   314
                // oh, and, randomising slightly R and B might be nice too.
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   315
                //gear^.Tint:= $fa00efff or ((random(80)+128) shl 16)
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   316
                //gear^.Tint:= $faa4efff
10040
koda
parents: 10015 10032
diff changeset
   317
                //gear^.Tint:= (($e0+random(32)) shl 24) or
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   318
                //             ((random(80)+128) shl 16) or
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   319
                //             (($d5+random(32)) shl 8) or $ff
10495
6d61b44a5652 - Comment out getrandom in addgear for hedgehog, causes preview-game desync
unc0rr
parents: 10494
diff changeset
   320
                {c:= GetRandom(32);
10040
koda
parents: 10015 10032
diff changeset
   321
                gear^.Tint:= (($e0+c) shl 24) or
10494
0eb97cf4c78e Fix warnings given by 32-bit fpc
unC0Rr
parents: 10490
diff changeset
   322
                             ((GetRandom(90)+128) shl 16) or
10495
6d61b44a5652 - Comment out getrandom in addgear for hedgehog, causes preview-game desync
unc0rr
parents: 10494
diff changeset
   323
                             (($d5+c) shl 8) or $ff}
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   324
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   325
       gtShell: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   326
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   327
                gear^.Friction:= _0_8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   328
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   329
                gear^.Density:= _1;
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   330
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   331
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   332
       gtSnowball: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   333
                gear^.ImpactSound:= sndMudballImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   334
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   335
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   336
                gear^.Density:= _0_5;
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   337
                gear^.AdvBounce:= 1;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   338
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   339
                gear^.Friction:= _0_8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   340
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   341
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   342
     gtFlake: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   343
                with Gear^ do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   344
                    begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   345
                    Pos:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   346
                    Radius:= 1;
7069
bcf9d8e64e92 pas2c stuff again
unc0rr
parents: 7028
diff changeset
   347
                    DirAngle:= random(360);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   348
                    if State and gstTmpFlag = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   349
                        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   350
                        dx.isNegative:= GetRandom(2) = 0;
9809
1e32628eb167 Fix warnings
unC0Rr
parents: 9721
diff changeset
   351
                        dx.QWordValue:= QWord($40DA) * GetRandom(10000) * 8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   352
                        dy.isNegative:= false;
9809
1e32628eb167 Fix warnings
unC0Rr
parents: 9721
diff changeset
   353
                        dy.QWordValue:= QWord($3AD3) * GetRandom(7000) * 8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   354
                        if GetRandom(2) = 0 then
10645
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   355
                            dx := -dx;
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   356
                        Tint:= $FFFFFFFF
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   357
                        end
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   358
                    else
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   359
                        Tint:= (ExplosionBorderColor shr RShift and $FF shl 24) or
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   360
                               (ExplosionBorderColor shr GShift and $FF shl 16) or
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   361
                               (ExplosionBorderColor shr BShift and $FF shl 8) or $FF;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   362
                    State:= State or gstInvisible;
10625
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   363
                    // use health field to store current frameticks
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   364
                    if vobFrameTicks > 0 then
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   365
                        Health:= random(vobFrameTicks)
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   366
                    else
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   367
                        Health:= 0;
125e120165aa flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents: 10589
diff changeset
   368
                    // use timer to store currently displayed frame index
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   369
                    if gear^.Timer = 0 then Timer:= random(vobFramesCount);
10645
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10643
diff changeset
   370
                    Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   371
                    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   372
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   373
       gtGrave: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   374
                gear^.ImpactSound:= sndGraveImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   375
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   376
                gear^.Radius:= 10;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   377
                gear^.Elasticity:= _0_6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   378
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   379
         gtBee: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   380
                gear^.Radius:= 5;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   381
                if gear^.Timer = 0 then gear^.Timer:= 500;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   382
                gear^.RenderTimer:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   383
                gear^.Elasticity:= _0_9;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   384
                gear^.Tag:= 0;
9479
167dea42d7d7 move border back a bit from left/right bounds, bee tweak
nemo
parents: 9195
diff changeset
   385
                gear^.State:= Gear^.State or gstSubmersible
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   386
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   387
   gtSeduction: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   388
                gear^.Radius:= 250;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   389
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   390
 gtShotgunShot: begin
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   391
                if gear^.Timer = 0 then gear^.Timer:= 900;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   392
                gear^.Radius:= 2
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   393
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   394
  gtPickHammer: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   395
                gear^.Radius:= 10;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   396
                if gear^.Timer = 0 then gear^.Timer:= 4000
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   397
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   398
   gtHammerHit: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   399
                gear^.Radius:= 8;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   400
                if gear^.Timer = 0 then gear^.Timer:= 125
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   401
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   402
        gtRope: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   403
                gear^.Radius:= 3;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   404
                gear^.Friction:= _450 * _0_01 * cRopePercent;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   405
                RopePoints.Count:= 0;
10848
231d3e3d3267 Allow rope tinting
nemo
parents: 10829
diff changeset
   406
                gear^.Tint:= $D8D8D8FF;
231d3e3d3267 Allow rope tinting
nemo
parents: 10829
diff changeset
   407
                gear^.Tag:= 0; // normal rope render
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   408
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   409
        gtMine: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   410
                gear^.ImpactSound:= sndMineImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   411
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   412
                gear^.Health:= 10;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   413
                gear^.State:= gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   414
                gear^.Radius:= 2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   415
                gear^.Elasticity:= _0_55;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   416
                gear^.Friction:= _0_995;
7602
a620319d377e Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents: 7395
diff changeset
   417
                gear^.Density:= _1;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   418
                if gear^.Timer = 0 then
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   419
                    begin
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   420
                    if cMinesTime < 0 then
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   421
                        gear^.Timer:= getrandom(51)*100
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   422
                    else
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   423
                        gear^.Timer:= cMinesTime
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   424
                    end
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   425
                end;
10789
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   426
     gtAirMine: begin
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   427
                gear^.ImpactSound:= sndDenied;
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   428
                gear^.nImpactSounds:= 1;
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   429
                gear^.Health:= 30;
10827
2b717f687c72 make mines submersible
nemo
parents: 10805
diff changeset
   430
                gear^.State:= gear^.State or gstMoving or gstNoGravity or gstSubmersible;
10802
089e43d01f74 Use the larger scaled airmine sprite originally intended, add some antidickery measures.
nemo
parents: 10800
diff changeset
   431
                gear^.Radius:= 8;
10789
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   432
                gear^.Elasticity:= _0_55;
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   433
                gear^.Friction:= _0_995;
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   434
                gear^.Density:= _1;
10791
0311c9fa7498 tweak a few params. still something wtf going on when on rope
nemo
parents: 10789
diff changeset
   435
                gear^.Angle:= 175; // Radius at which air bombs will start "seeking". $FFFFFFFF = unlimited. check is skipped.
10800
3c71e5158519 more tweakery
nemo
parents: 10794
diff changeset
   436
                gear^.Power:= cMaxWindSpeed.QWordValue div 2; // hwFloat converted. 1/2 g default. defines the "seek" speed when a gear is in range.
10828
9867dd60a66a bit more friction. remove gstSubmersible clearing. was for the old "sea" thing that is totally gone now. As a general attribute, better to let other stuff clear it as needed.
nemo
parents: 10827
diff changeset
   437
                gear^.Pos:= cMaxWindSpeed.QWordValue * 3 div 2; // air friction. slows it down when not hitting stuff
10789
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   438
                gear^.Karma:= 30; // damage
10805
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   439
                if gear^.Timer = 0 then
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   440
                    begin
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   441
                    if cMinesTime < 0 then
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   442
                        gear^.Timer:= getrandom(13)*100
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   443
                    else
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   444
                        gear^.Timer:= cMinesTime div 4
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   445
                    end;
a96a69841653 inherit mines time div 4
nemo
parents: 10802
diff changeset
   446
                gear^.WDTimer:= gear^.Timer
10789
acbf69e2e5cf experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents: 10663
diff changeset
   447
                end;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   448
       gtSMine: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   449
                gear^.Health:= 10;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   450
                gear^.State:= gear^.State or gstMoving;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   451
                gear^.Radius:= 2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   452
                gear^.Elasticity:= _0_55;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   453
                gear^.Friction:= _0_995;
7602
a620319d377e Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents: 7395
diff changeset
   454
                gear^.Density:= _1_6;
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   455
                gear^.AdvBounce:= 1;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   456
                if gear^.Timer = 0 then gear^.Timer:= 500;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   457
                end;
7733
a1476c09403f Knife is still broken, but so koda can fix it...
nemo
parents: 7730
diff changeset
   458
       gtKnife: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   459
                gear^.AdvBounce:= 1;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   460
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   461
                gear^.Friction:= _0_8;
7754
e81dc9bef8b8 First pass at cleaver.
nemo
parents: 7733
diff changeset
   462
                gear^.Density:= _4;
8494
53b91a602955 Cleaver tweaks based on feedback. Nerf damage, shrink radius. This means cleaver will embed into ground quite a bit further.
nemo
parents: 8161
diff changeset
   463
                gear^.Radius:= 7
7733
a1476c09403f Knife is still broken, but so koda can fix it...
nemo
parents: 7730
diff changeset
   464
                end;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   465
        gtCase: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   466
                gear^.ImpactSound:= sndGraveImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   467
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   468
                gear^.Radius:= 16;
7168
8defaabce92e warp sound when AI survival hog respawns. attempt at a bit of a crate spawn animation (moar sparkles and a quick fadein)
nemo
parents: 7093
diff changeset
   469
                gear^.Elasticity:= _0_3;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   470
                if gear^.Timer = 0 then gear^.Timer:= 500
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   471
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   472
  gtExplosives: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   473
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   474
                gear^.ImpactSound:= sndGrenadeImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   475
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   476
                gear^.Radius:= 16;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   477
                gear^.Elasticity:= _0_4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   478
                gear^.Friction:= _0_995;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   479
                gear^.Density:= _6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   480
                gear^.Health:= cBarrelHealth;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   481
                gear^.Z:= cHHZ-1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   482
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   483
  gtDEagleShot: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   484
                gear^.Radius:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   485
                gear^.Health:= 50
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   486
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   487
  gtSniperRifleShot: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   488
                gear^.Radius:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   489
                gear^.Health:= 50
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   490
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   491
    gtDynamite: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   492
                gear^.Radius:= 3;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   493
                gear^.Elasticity:= _0_55;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   494
                gear^.Friction:= _0_03;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   495
                gear^.Density:= _2;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   496
                if gear^.Timer = 0 then gear^.Timer:= 5000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   497
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   498
     gtCluster: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   499
                gear^.AdvBounce:= 1;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   500
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   501
                gear^.Friction:= _0_8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   502
                gear^.Radius:= 2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   503
                gear^.Density:= _1_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   504
                gear^.RenderTimer:= true
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   505
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   506
      gtShover: gear^.Radius:= 20;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   507
       gtFlame: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   508
                gear^.Tag:= GetRandom(32);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   509
                gear^.Radius:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   510
                gear^.Health:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   511
                gear^.Density:= _1;
10589
98ea597e5cd9 expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents: 10518
diff changeset
   512
                gear^.FlightTime:= 9999999; // determines whether in-air flames do damage. disabled by default
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   513
                if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   514
                    begin
7001
89488f5b99ca GetRandom -> GetRandomf
unc0rr
parents: 6982
diff changeset
   515
                    gear^.dY:= (getrandomf - _0_8) * _0_03;
89488f5b99ca GetRandom -> GetRandomf
unc0rr
parents: 6982
diff changeset
   516
                    gear^.dX:= (getrandomf - _0_5) * _0_4
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   517
                    end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   518
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   519
   gtFirePunch: begin
9824
136e0708eda2 make punch usable with no gravity lua
nemo
parents: 9809
diff changeset
   520
                if gear^.Timer = 0 then gear^.Timer:= 3000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   521
                gear^.Radius:= 15;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   522
                gear^.Tag:= Y
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   523
                end;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   524
   gtAirAttack: begin
11171
546e75fdb879 Oups. 6, not 12 - was testing
nemo
parents: 11170
diff changeset
   525
                gear^.Health:= 6;
11170
22d8835beb4d Allow for arbitrary number of airstrike bombs and spacing.
nemo
parents: 11169
diff changeset
   526
                gear^.Damage:= 30;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   527
                gear^.Z:= cHHZ+2;
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   528
                gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   529
                end;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   530
     gtAirBomb: begin
10891
a4c454ef80a6 enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents: 10889
diff changeset
   531
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   532
                gear^.Radius:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   533
                gear^.Density:= _2;
10891
a4c454ef80a6 enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents: 10889
diff changeset
   534
                gear^.Elasticity:= _0_55;
a4c454ef80a6 enable bounce on rubber for air bombs. give them the missing elasticity they needed for the code there to work properly.
nemo
parents: 10889
diff changeset
   535
                gear^.Friction:= _0_995
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   536
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   537
   gtBlowTorch: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   538
                gear^.Radius:= cHHRadius + cBlowTorchC;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   539
                if gear^.Timer = 0 then gear^.Timer:= 7500
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   540
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   541
    gtSwitcher: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   542
                gear^.Z:= cCurrHHZ
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   543
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   544
      gtTarget: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   545
                gear^.ImpactSound:= sndGrenadeImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   546
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   547
                gear^.Radius:= 10;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   548
                gear^.Elasticity:= _0_3;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   549
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   550
      gtTardis: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   551
                gear^.Pos:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   552
                gear^.Z:= cCurrHHZ+1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   553
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   554
      gtMortar: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   555
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   556
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   557
                gear^.Elasticity:= _0_2;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   558
                gear^.Friction:= _0_08;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   559
                gear^.Density:= _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   560
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   561
        gtWhip: gear^.Radius:= 20;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   562
      gtHammer: gear^.Radius:= 20;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   563
    gtKamikaze: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   564
                gear^.Health:= 2048;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   565
                gear^.Radius:= 20
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   566
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   567
        gtCake: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   568
                gear^.Health:= 2048;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   569
                gear^.Radius:= 7;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   570
                gear^.Z:= cOnHHZ;
10875
67b92a09cded only display cake timer if it is low
sheepluva
parents: 10874
diff changeset
   571
                gear^.RenderTimer:= false;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   572
                gear^.DirAngle:= -90 * hwSign(Gear^.dX);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   573
                if not dX.isNegative then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   574
                    gear^.Angle:= 1
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   575
                else
10874
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   576
                    gear^.Angle:= 3;
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   577
                New(cakeData);
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   578
                gear^.Data:= Pointer(cakeData);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   579
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   580
 gtHellishBomb: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   581
                gear^.ImpactSound:= sndHellishImpact1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   582
                gear^.nImpactSounds:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   583
                gear^.AdvBounce:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   584
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   585
                gear^.Elasticity:= _0_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   586
                gear^.Friction:= _0_96;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   587
                gear^.Density:= _1_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   588
                gear^.RenderTimer:= true;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   589
                if gear^.Timer = 0 then gear^.Timer:= 5000
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   590
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   591
       gtDrill: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   592
                gear^.AdvBounce:= 1;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   593
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   594
                gear^.Friction:= _0_8;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   595
                if gear^.Timer = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   596
                    gear^.Timer:= 5000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   597
                // Tag for drill strike. if 1 then first impact occured already
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   598
                gear^.Tag := 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   599
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   600
                gear^.Density:= _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   601
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   602
        gtBall: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   603
                gear^.ImpactSound:= sndGrenadeImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   604
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   605
                gear^.AdvBounce:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   606
                gear^.Radius:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   607
                gear^.Tag:= random(8);
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   608
                if gear^.Timer = 0 then gear^.Timer:= 5000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   609
                gear^.Elasticity:= _0_7;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   610
                gear^.Friction:= _0_995;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   611
                gear^.Density:= _1_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   612
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   613
     gtBallgun: begin
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   614
                if gear^.Timer = 0 then gear^.Timer:= 5001;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   615
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   616
     gtRCPlane: begin
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   617
                if gear^.Timer = 0 then gear^.Timer:= 15000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   618
                gear^.Health:= 3;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   619
                gear^.Radius:= 8;
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   620
                gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   621
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   622
     gtJetpack: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   623
                gear^.Health:= 2000;
8987
47cf32305d99 some saucer thing for firing weps underwater and aiming and such. bit drunk and sleepy so testing I guess
nemo
parents: 8795
diff changeset
   624
                gear^.Damage:= 100;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   625
                gear^.State:= Gear^.State or gstSubmersible
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   626
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   627
     gtMolotov: begin
9825
de0da12b7d0e more advbounce flagging
nemo
parents: 9824
diff changeset
   628
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   629
                gear^.Radius:= 6;
9825
de0da12b7d0e more advbounce flagging
nemo
parents: 9824
diff changeset
   630
                gear^.Density:= _2
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   631
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   632
       gtBirdy: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   633
                gear^.Radius:= 16; // todo: check
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   634
                gear^.Health := 2000;
9825
de0da12b7d0e more advbounce flagging
nemo
parents: 9824
diff changeset
   635
                gear^.FlightTime := 2
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   636
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   637
         gtEgg: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   638
                gear^.AdvBounce:= 1;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   639
                gear^.Radius:= 4;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   640
                gear^.Elasticity:= _0_6;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   641
                gear^.Friction:= _0_96;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   642
                gear^.Density:= _1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   643
                if gear^.Timer = 0 then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   644
                    gear^.Timer:= 3000
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   645
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   646
      gtPortal: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   647
                gear^.ImpactSound:= sndMelonImpact;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   648
                gear^.nImpactSounds:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   649
                gear^.Radius:= 17;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   650
                // set color
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   651
                gear^.Tag:= 2 * gear^.Timer;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   652
                gear^.Timer:= 15000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   653
                gear^.RenderTimer:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   654
                gear^.Health:= 100;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   655
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   656
       gtPiano: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   657
                gear^.Radius:= 32;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   658
                gear^.Density:= _50;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   659
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   660
 gtSineGunShot: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   661
                gear^.Radius:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   662
                gear^.Health:= 6000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   663
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   664
gtFlamethrower: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   665
                gear^.Tag:= 10;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   666
                if gear^.Timer = 0 then gear^.Timer:= 10;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   667
                gear^.Health:= 500;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   668
                gear^.Damage:= 100;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   669
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   670
     gtLandGun: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   671
                gear^.Tag:= 10;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   672
                if gear^.Timer = 0 then gear^.Timer:= 10;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   673
                gear^.Health:= 1000;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   674
                gear^.Damage:= 100;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   675
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   676
 gtPoisonCloud: begin
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   677
                if gear^.Timer = 0 then gear^.Timer:= 5000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   678
                gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   679
                gear^.Tint:= $C0C000C0
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   680
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   681
 gtResurrector: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   682
                gear^.Radius := 100;
10032
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   683
                gear^.Tag := 0;
db65298717da This adds idle hog tinting. Active hog tinting still needed.
nemo
parents: 9998
diff changeset
   684
                gear^.Tint:= $F5DB35FF
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   685
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   686
     gtWaterUp: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   687
                gear^.Tag := 47;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   688
                end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   689
  gtNapalmBomb: begin
9721
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   690
                gear^.Elasticity:= _0_8;
1833dadcebf0 Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents: 9479
diff changeset
   691
                gear^.Friction:= _0_8;
9195
e653e96b0ec3 Many of the gears treat non-0 timer as overridden. Added that check in more places so that lua could use this a tiny bit more consistently. Also preserve state for jetpack.
nemo
parents: 9080
diff changeset
   692
                if gear^.Timer = 0 then gear^.Timer:= 1000;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   693
                gear^.Radius:= 5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   694
                gear^.Density:= _1_5;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   695
                end;
8161
0b8beacff8a5 GCI2012: Remove Structure Weapon Code
deepdog
parents: 8145
diff changeset
   696
{
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   697
   gtStructure: begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   698
                gear^.Elasticity:= _0_55;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   699
                gear^.Friction:= _0_995;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   700
                gear^.Density:= _0_9;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   701
                gear^.Radius:= 13;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   702
                gear^.Health:= 200;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   703
                gear^.Timer:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   704
                gear^.Tag:= TotalRounds + 3;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   705
                gear^.Pos:= 1;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   706
                end;
8161
0b8beacff8a5 GCI2012: Remove Structure Weapon Code
deepdog
parents: 8145
diff changeset
   707
}
8774
39754516eee6 Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGun-specific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents: 8751
diff changeset
   708
      gtIceGun: begin
39754516eee6 Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGun-specific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents: 8751
diff changeset
   709
                gear^.Health:= 1000;
39754516eee6 Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGun-specific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents: 8751
diff changeset
   710
                gear^.Radius:= 8;
39754516eee6 Try to document TGear a bit, so people know what is commonly overridden, and what stuff is used for. Remove gtIceGun-specific values from TGear and abuse a couple of commonly abused members instead.
nemo
parents: 8751
diff changeset
   711
                end;
7389
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   712
gtGenericFaller:begin
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   713
                gear^.AdvBounce:= 1;
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   714
                gear^.Radius:= 1;
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   715
                gear^.Elasticity:= _0_9;
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   716
                gear^.Friction:= _0_995;
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   717
                gear^.Density:= _1;
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   718
                end;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   719
    end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   720
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   721
InsertGearToList(gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   722
AddGear:= gear;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   723
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   724
ScriptCall('onGearAdd', gear^.uid);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   725
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   726
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   727
procedure DeleteGear(Gear: PGear);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   728
var team: PTeam;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   729
    t,i: Longword;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   730
    k: boolean;
10874
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   731
    cakeData: PCakeData;
11043
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   732
    iterator: PGear;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   733
begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   734
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   735
ScriptCall('onGearDelete', gear^.uid);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   736
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   737
DeleteCI(Gear);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   738
10634
35d059bd0932 Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents: 10625
diff changeset
   739
FreeAndNilTexture(Gear^.Tex);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   740
11043
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   741
// remove potential links to this gear
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   742
// currently relevant to: gears linked by hammer
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   743
if (Gear^.Kind = gtHedgehog) or (Gear^.Kind = gtMine) or (Gear^.Kind = gtExplosives) then
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   744
    begin
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   745
    // check all gears for stuff to port through
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   746
    iterator := nil;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   747
    while true do
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   748
        begin
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   749
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   750
        // iterate through GearsList
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   751
        if iterator = nil then
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   752
            iterator := GearsList
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   753
        else
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   754
            iterator := iterator^.NextGear;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   755
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   756
        // end of list?
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   757
        if iterator = nil then
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   758
            break;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   759
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   760
        if iterator^.LinkedGear = Gear then
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   761
            iterator^.LinkedGear:= nil;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   762
        end;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   763
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   764
    end;
79a77bef4c61 Hammer had been accessing dangling pointers under particular circumstances (e.g. when hitting a mine/barrel right when it exploded)
sheepluva
parents: 11036
diff changeset
   765
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   766
// make sure that portals have their link removed before deletion
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   767
if (Gear^.Kind = gtPortal) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   768
    begin
7272
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7176
diff changeset
   769
    if (Gear^.LinkedGear <> nil) then
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7176
diff changeset
   770
        if (Gear^.LinkedGear^.LinkedGear = Gear) then
71df899c4163 Second part of the change. Make collision check use the new mask bit.
nemo
parents: 7176
diff changeset
   771
            Gear^.LinkedGear^.LinkedGear:= nil;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   772
    end
10874
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   773
else if Gear^.Kind = gtCake then
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   774
    begin
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   775
        cakeData:= PCakeData(Gear^.Data);
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   776
        Dispose(cakeData);
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   777
        cakeData:= nil;
059a6492176e allow gear specific data (with gear type specific type). applied to cake
sheepluva
parents: 10848
diff changeset
   778
    end
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   779
else if Gear^.Kind = gtHedgehog then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   780
    (*
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   781
    This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS.  I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves.  I believe it should be removed
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   782
     if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   783
        begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   784
        AttackBar:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   785
        Gear^.Message:= gmDestroy;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   786
        CurAmmoGear^.Message:= gmDestroy;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   787
        exit
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   788
        end
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   789
    else*)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   790
        begin
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   791
        if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   792
            Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
10663
9bbb29d2bd68 remove a not that somehow magically appeared in a prior commit.
nemo
parents: 10646
diff changeset
   793
        if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   794
            begin
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   795
            t:= max(Gear^.Damage, Gear^.Health);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   796
            Gear^.Damage:= t;
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   797
            if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   798
                spawnHealthTagForHH(Gear, t);
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   799
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   800
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   801
        team:= Gear^.Hedgehog^.Team;
10636
aba9ae27ead0 meh. will persevere. DeleteGear can't call that much stuff...
nemo
parents: 10634
diff changeset
   802
        if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear = Gear) then
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   803
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   804
            AttackBar:= 0;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   805
            FreeActionsList; // to avoid ThinkThread on drawned gear
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   806
            if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   807
            and (CurrentHedgehog^.MultiShootAttacks > 0) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   808
                OnUsedAmmo(CurrentHedgehog^);
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   809
            end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   810
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   811
        Gear^.Hedgehog^.Gear:= nil;
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   812
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   813
        if Gear^.Hedgehog^.King then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   814
            begin
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   815
            // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   816
            k:= false;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   817
            for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   818
                if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   819
                    k:= true;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   820
            if not k then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   821
                for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
11002
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   822
                    with team^.Clan^.Teams[i]^ do
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   823
                        for t:= 0 to cMaxHHIndex do
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   824
                            if Hedgehogs[t].Gear <> nil then
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   825
                                Hedgehogs[t].Gear^.Health:= 0
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   826
                            else if (Hedgehogs[t].GearHidden <> nil) then
01c8e95d2265 remove teamgone. desyncs now. less interesting without the animation, perhaps something should be flagged to replace it
nemo
parents: 10891
diff changeset
   827
                                Hedgehogs[t].GearHidden^.Health:= 0  // hog is still hidden. if tardis should return though, lua, eh...
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   828
            end;
10646
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   829
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   830
        // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   831
        // same stand for CheckHHDamage
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   832
        if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   833
            uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   834
        else if CurrentHedgehog <> nil then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   835
            uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   836
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   837
        inc(KilledHHs);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   838
        RecountTeamHealth(team);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   839
        if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   840
        //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   841
        (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   842
            with CurrentHedgehog^ do
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   843
                begin
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   844
                inc(Team^.stats.AIKills);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   845
                FreeAndNilTexture(Team^.AIKillsTex);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   846
                Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
0be6442946b1 put back the old uteams cleanup, leaks and all, to worry about post-release since my attempt to use DeleteGear was running into the fact that that procedure does way more than just delete a gear. might need an explicit cleanup routine for both to call.
nemo
parents: 10645
diff changeset
   847
                end
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   848
        end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   849
with Gear^ do
7389
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   850
    begin
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   851
    AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
7389
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   852
    AddRandomness(X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac)
15c3fb4882df Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents: 7366
diff changeset
   853
    end;
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   854
if CurAmmoGear = Gear then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   855
    CurAmmoGear:= nil;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   856
if FollowGear = Gear then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   857
    FollowGear:= nil;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   858
if lastGearByUID = Gear then
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   859
    lastGearByUID := nil;
10638
99975e1860d2 oh, probably need nil checks here too
nemo
parents: 10636
diff changeset
   860
if (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.GearHidden <> Gear) then // hidden hedgehogs shouldn't be in the list
10639
992863acb2b7 sheepluva is right
nemo
parents: 10638
diff changeset
   861
     RemoveGearFromList(Gear)
992863acb2b7 sheepluva is right
nemo
parents: 10638
diff changeset
   862
else Gear^.Hedgehog^.GearHidden:= nil;
10638
99975e1860d2 oh, probably need nil checks here too
nemo
parents: 10636
diff changeset
   863
6581
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   864
Dispose(Gear)
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   865
end;
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   866
e510d1245bd7 fix line endings
nemo
parents: 6580
diff changeset
   867
end.