hedgewars/uTypes.pas
branchwebgl
changeset 8833 c13ebed437cb
parent 8444 75db7bb8dce8
parent 8795 b5b79a8f9354
child 9127 e350500c4edb
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
    85             sprCheese, sprHandCheese, sprHandFlamethrower, sprChunk, sprNote,
    85             sprCheese, sprHandCheese, sprHandFlamethrower, sprChunk, sprNote,
    86             sprSMineOff, sprSMineOn, sprHandSMine, sprHammer,
    86             sprSMineOff, sprSMineOn, sprHandSMine, sprHammer,
    87             sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
    87             sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb,
    88             sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
    88             sprBulletHit, sprSnowball, sprHandSnowball, sprSnow,
    89             sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
    89             sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis,
    90             sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar
    90             sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar, sprIceTexture, sprIceGun, sprFrozenHog
    91             );
    91             );
    92 
    92 
    93     // Gears that interact with other Gears and/or Land
    93     // Gears that interact with other Gears and/or Land
    94     TGearType = ({-->}gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // <-- these are gears which should be avoided when searching a spawn place
    94     TGearType = ({-->}gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // <-- these are gears which should be avoided when searching a spawn place
    95             gtGrenade, gtShell, gtGrave, gtBee, // 8
    95             gtGrenade, gtShell, gtGrave, gtBee, // 8
   221     PHedgehog = ^THedgehog;
   221     PHedgehog = ^THedgehog;
   222     PTeam     = ^TTeam;
   222     PTeam     = ^TTeam;
   223     PClan     = ^TClan;
   223     PClan     = ^TClan;
   224 
   224 
   225     TGearStepProcedure = procedure (Gear: PGear);
   225     TGearStepProcedure = procedure (Gear: PGear);
       
   226 // So, you're here looking for variables you can (ab)use to store some gear state?
       
   227 // Not all members of this structure are created equal. Comments below are my take on what can be used for what in the gear structure.
   226     TGear = record
   228     TGear = record
   227             NextGear, PrevGear: PGear;
   229 // Don't ever override these.
   228             Active: Boolean;
   230             NextGear, PrevGear: PGear;  // Linked list
   229             AdvBounce: Longword;
   231             Z: Longword;                // Z index. For rendering. Sets order in list
   230             Invulnerable: Boolean;
   232             Active: Boolean;            // Is gear Active (running step code)
   231             RenderTimer: Boolean;
   233             Kind: TGearType;
   232             AmmoType : TAmmoType;
   234             doStep: TGearStepProcedure; // Code the gear is running
   233             State : Longword;
   235             AmmoType : TAmmoType;       // Ammo type associated with this kind of gear
   234             X : hwFloat;
   236             RenderTimer: Boolean;       // Will visually display Timer if true
       
   237             Target : TPoint;            // Gear target. Will render in uGearsRender unless a special case is added
       
   238             AIHints: LongWord;          // hints for ai.
       
   239             LastDamage: PHedgehog;      // Used to track damage source for stats
       
   240             CollisionIndex: LongInt;    // Position in collision array
       
   241             Message: LongWord;          // Game messages are stored here. See gm bitmasks in uConsts
       
   242             uid: Longword;              // Lua use this to reference gears
       
   243 // Strongly recommended not to override these.  Will mess up generic operations like portaling
       
   244             X : hwFloat;              // X/Y/dX/dY are position/velocity. People count on these having semi-normal values
   235             Y : hwFloat;
   245             Y : hwFloat;
   236             dX: hwFloat;
   246             dX: hwFloat;
   237             dY: hwFloat;
   247             dY: hwFloat;
   238             Target : TPoint;
   248             State : Longword;        // See gst bitmask values in uConsts
   239             Kind: TGearType;
   249             PortalCounter: LongWord; // Necessary to interrupt portal loops.  Not possible to avoid infinite loops without it.
   240             Pos: Longword;
   250 // Don't use these if you're using generic movement like doStepFallingGear and explosion shoves. Generally recommended not to use.
   241             doStep: TGearStepProcedure;
   251             Radius: LongInt;     // Radius. If not using uCollisions, is usually used to indicate area of effect
   242             Radius: LongInt;
   252             CollisionMask: Word; // Masking off Land impact  FF7F for example ignores current hog and crates
   243             Angle, Power : Longword;
   253             AdvBounce: Longword; // Triggers 45° bounces. Is a counter to avoid edge cases
   244             DirAngle: real;
       
   245             Timer : LongWord;
       
   246             Elasticity: hwFloat;
   254             Elasticity: hwFloat;
   247             Friction  : hwFloat;
   255             Friction  : hwFloat;
   248             Density   : hwFloat;
   256             Density   : hwFloat; // Density is kind of a mix of size and density. Impacts distance thrown, wind.
   249             Message, MsgParam : Longword;
   257             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
   250             Hedgehog: PHedgehog;
   258             nImpactSounds: Word; // count of ImpactSounds.
       
   259 // Don't use these if you want to take damage normally, otherwise health/damage are commonly used for other purposes
       
   260             Invulnerable: Boolean;
   251             Health, Damage, Karma: LongInt;
   261             Health, Damage, Karma: LongInt;
   252             CollisionIndex: LongInt;
   262 // DirAngle is a "real" - if you don't need it for rotation of sprite in uGearsRender, you can use it for any visual-only value
   253             Tag: LongInt;
   263             DirAngle: real;
   254             Tex: PTexture;
   264 // These are frequently overridden to serve some other purpose
   255             Z: Longword;
   265             Pos: Longword;           // Commonly overridden.  Example use is posCase values in uConsts.
   256             CollisionMask: Word;
   266             Angle, Power : Longword; // Used for hog aiming/firing.  Angle is rarely used as an Angle otherwise.
   257             LinkedGear: PGear;
   267             Timer : LongWord;        // Typically used for some sort of gear timer. Time to explosion, remaining fuel...
   258             FlightTime: Longword;
   268             Tag: LongInt;            // Quite generic. Variety of uses.
   259             uid: Longword;
   269             FlightTime: Longword;    // Initially added for batting of hogs to determine homerun. Used for some firing delays
   260             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
   270             MsgParam: LongWord;      // Initially stored a set of messages. So usually gm values like Message. Frequently overriden
   261             nImpactSounds: Word; // count of ImpactSounds
   271 // These are not used generically, but should probably be used for purpose intended. Definitely shouldn't override pointer type
   262             SoundChannel: LongInt;
   272             Tex: PTexture;          // A texture created by the gear. Shouldn't use for anything but textures
   263             PortalCounter: LongWord;  // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion.
   273             LinkedGear: PGear;      // Used to track a related gear. Portal pairs for example.
   264             AIHints: LongWord; // hints for ai. haha ^^^^^^ temporary, sure
   274             Hedgehog: PHedgehog;    // set to CurrentHedgehog on gear creation
   265             LastDamage: PHedgehog;
   275             SoundChannel: LongInt;  // Used to track a sound the gear started
   266             end;
   276             end;
   267     TPGearArray = array of PGear;
   277     TPGearArray = array of PGear;
   268     PGearArrayS = record
   278     PGearArrayS = record
   269         size: LongWord;
   279         size: LongWord;
   270         ar: ^TPGearArray;
   280         ar: ^TPGearArray;