hedgewars/uTypes.pas
changeset 8774 39754516eee6
parent 8557 18330b24b92c
child 8795 b5b79a8f9354
equal deleted inserted replaced
8771:ea6ee35d9434 8774:39754516eee6
   218     PHedgehog = ^THedgehog;
   218     PHedgehog = ^THedgehog;
   219     PTeam     = ^TTeam;
   219     PTeam     = ^TTeam;
   220     PClan     = ^TClan;
   220     PClan     = ^TClan;
   221 
   221 
   222     TGearStepProcedure = procedure (Gear: PGear);
   222     TGearStepProcedure = procedure (Gear: PGear);
       
   223 // So, you're here looking for variables you can (ab)use to store some gear state?
       
   224 // 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.
   223     TGear = record
   225     TGear = record
   224             NextGear, PrevGear: PGear;
   226 // Don't ever override these.
   225             Active: Boolean;
   227             NextGear, PrevGear: PGear;  // Linked list
   226             AdvBounce: Longword;
   228             Z: Longword;                // Z index. For rendering. Sets order in list
   227             Invulnerable: Boolean;
   229             Active: Boolean;            // Is gear Active (running step code)
   228             RenderTimer: Boolean;
   230             Kind: TGearType;
   229             AmmoType : TAmmoType;
   231             doStep: TGearStepProcedure; // Code the gear is running
   230             State : Longword;
   232             AmmoType : TAmmoType;       // Ammo type associated with this kind of gear
   231             X : hwFloat;
   233             RenderTimer: Boolean;       // Will visually display Timer if true
       
   234             Target : TPoint;            // Gear target. Will render in uGearsRender unless a special case is added
       
   235             AIHints: LongWord;          // hints for ai.
       
   236             LastDamage: PHedgehog;      // Used to track damage source for stats
       
   237             CollisionIndex: LongInt;    // Position in collision array
       
   238             Message: LongWord;          // Game messages are stored here. See gm bitmasks in uConsts
       
   239             uid: Longword;              // Lua use this to reference gears
       
   240 // Strongly recommended not to override these.  Will mess up generic operations like portaling
       
   241             X : hwFloat;              // X/Y/dX/dY are position/velocity. People count on these having semi-normal values
   232             Y : hwFloat;
   242             Y : hwFloat;
   233             dX: hwFloat;
   243             dX: hwFloat;
   234             dY: hwFloat;
   244             dY: hwFloat;
   235             Target : TPoint;
   245             State : Longword;        // See gst bitmask values in uConsts
   236             Kind: TGearType;
   246             PortalCounter: LongWord; // Necessary to interrupt portal loops.  Not possible to avoid infinite loops without it.
   237             Pos: Longword;
   247 // Don't use these if you're using generic movement like doStepFallingGear and explosion shoves. Generally recommended not to use.
   238             doStep: TGearStepProcedure;
   248             Radius: LongInt;     // Radius. If not using uCollisions, is usually used to indicate area of effect
   239             Radius: LongInt;
   249             CollisionMask: Word; // Masking off Land impact  FF7F for example ignores current hog and crates
   240             Angle, Power : Longword;
   250             AdvBounce: Longword; // Triggers 45° bounces. Is a counter to avoid edge cases
   241             DirAngle: real;
       
   242             Timer : LongWord;
       
   243             Elasticity: hwFloat;
   251             Elasticity: hwFloat;
   244             Friction  : hwFloat;
   252             Friction  : hwFloat;
   245             Density   : hwFloat;
   253             Density   : hwFloat; // Density is kind of a mix of size and density. Impacts distance thrown, wind.
   246             Message, MsgParam : Longword;
   254             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
   247             Hedgehog: PHedgehog;
   255             nImpactSounds: Word; // count of ImpactSounds.
       
   256 // Don't use these if you want to take damage normally, otherwise health/damage are commonly used for other purposes
       
   257             Invulnerable: Boolean;
   248             Health, Damage, Karma: LongInt;
   258             Health, Damage, Karma: LongInt;
   249             CollisionIndex: LongInt;
   259 // 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
   250             Tag: LongInt;
   260             DirAngle: real;
   251             Tex: PTexture;
   261 // These are frequently overridden to serve some other purpose
   252             Z: Longword;
   262             Pos: Longword;           // Commonly overridden.  Example use is posCase values in uConsts.
   253             CollisionMask: Word;
   263             Angle, Power : Longword; // Used for hog aiming/firing.  Angle is rarely used as an Angle otherwise.
   254             LinkedGear: PGear;
   264             Timer : LongWord;        // Typically used for some sort of gear timer. Time to explosion, remaining fuel...
   255             FlightTime: Longword;
   265             Tag: LongInt;            // Quite generic. Variety of uses.
   256             uid: Longword;
   266             FlightTime: Longword;    // Initially added for batting of hogs to determine homerun. Used for some firing delays
   257             ImpactSound: TSound; // first sound, others have to be after it in the sounds def.
   267             MsgParam: LongWord;      // Initially stored a set of messages. So usually gm values like Message. Frequently overriden
   258             nImpactSounds: Word; // count of ImpactSounds
   268 // These are not used generically, but should probably be used for purpose intended. Definitely shouldn't override pointer type
   259             SoundChannel: LongInt;
   269             Tex: PTexture;          // A texture created by the gear. Shouldn't use for anything but textures
   260             PortalCounter: LongWord;  // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion.
   270             LinkedGear: PGear;      // Used to track a related gear. Portal pairs for example.
   261             AIHints: LongWord; // hints for ai. haha ^^^^^^ temporary, sure
   271             Hedgehog: PHedgehog;    // set to CurrentHedgehog on gear creation
   262             IceTime: Longint; //time of ice beam with object some interaction  temporary
   272             SoundChannel: LongInt;  // Used to track a sound the gear started
   263             IceState: Longint; //state of ice gun temporary
       
   264             LastDamage: PHedgehog;
       
   265             end;
   273             end;
   266     TPGearArray = array of PGear;
   274     TPGearArray = array of PGear;
   267     PGearArrayS = record
   275     PGearArrayS = record
   268         size: LongWord;
   276         size: LongWord;
   269         ar: ^TPGearArray;
   277         ar: ^TPGearArray;