# HG changeset patch # User Wuzzy # Date 1554731502 -7200 # Node ID 185f07ec4d12c162df0bbcdd2b6e3c9684d2c4a2 # Parent 458a8c4e65ca47e0d78053785260367a7800cdf3 New callback: onCaseDrop (called when engine MIGHT drop a crate) diff -r 458a8c4e65ca -r 185f07ec4d12 ChangeLog.txt --- a/ChangeLog.txt Mon Apr 08 15:27:40 2019 +0200 +++ b/ChangeLog.txt Mon Apr 08 15:51:42 2019 +0200 @@ -96,6 +96,7 @@ + SetClanColor: Now accepts negative color argument for user clan color, like in AddTeam + Utils library: New calls: getReadableChallengeRecord, updateChallengeRecord + New callback: onGameResult(winningClan): Called when the game ends normally. winningClan = index of winning clan or -1 on draw + + New callback: onCaseDrop(gear): Called at the point where a crate MIGHT be dropped between turns. Gear is the crate gear or nil + SendStat extension: Option to use predefined modes with siPointType, like "!POINTS" or "!TIME" + SimpleMission: Add isMissionTeam attribute for teams + SpeedShoppa/TargetPractice libraries: Remove custom hog and team info settings diff -r 458a8c4e65ca -r 185f07ec4d12 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Mon Apr 08 15:27:40 2019 +0200 +++ b/hedgewars/uGears.pas Mon Apr 08 15:51:42 2019 +0200 @@ -222,7 +222,7 @@ end; procedure ProcessGears; -var t: PGear; +var t, tmpGear: PGear; i, j, AliveCount: LongInt; s: ansistring; prevtime: LongWord; @@ -477,7 +477,11 @@ begin if (not isInMultiShoot) then begin - SpawnBoxOfSmth; + tmpGear:= SpawnBoxOfSmth; + if tmpGear <> nil then + ScriptCall('onCaseDrop', tmpGear^.uid) + else + ScriptCall('onCaseDrop'); delay:= delayFinal; inc(step); end diff -r 458a8c4e65ca -r 185f07ec4d12 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Mon Apr 08 15:27:40 2019 +0200 +++ b/hedgewars/uGearsUtils.pas Mon Apr 08 15:51:42 2019 +0200 @@ -52,7 +52,8 @@ procedure AmmoShoveCache(Ammo: PGear; Damage, Power: LongInt); procedure AmmoShoveLine(Ammo: PGear; Damage, Power: LongInt; oX, oY, tX, tY: hwFloat); function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; -procedure SpawnBoxOfSmth; +function SpawnBoxOfSmth: PGear; +procedure PlayBoxSpawnTaunt(Gear: PGear); procedure ShotgunShot(Gear: PGear); function CanUseTardis(HHGear: PGear): boolean; @@ -1547,14 +1548,11 @@ GearsNear.ar:= @GearsNearArray end; -procedure SpawnBoxOfSmth; -const - // Max. distance between hog and crate for sndThisOneIsMine taunt - ThisOneIsMineDistance : LongInt = 130; -var t, aTot, uTot, a, h, d, minD: LongInt; +function SpawnBoxOfSmth: PGear; +var t, aTot, uTot, a, h: LongInt; i: TAmmoType; - gi, closestHog: PGear; begin +SpawnBoxOfSmth:= nil; if (PlacingHogs) or (cCaseFactor = 0) or (CountGears(gtCase) >= cMaxCaseDrops) @@ -1629,9 +1627,20 @@ if (FollowGear <> nil) then begin FindPlace(FollowGear, true, 0, LAND_WIDTH); + PlayBoxSpawnTaunt(FollowGear); + SpawnBoxOfSmth:= FollowGear; + end +end; +procedure PlayBoxSpawnTaunt(Gear: PGear); +const + // Max. distance between hog and crate for sndThisOneIsMine taunt + ThisOneIsMineDistance : LongInt = 130; +var d, minD: LongInt; + gi, closestHog: PGear; +begin // Taunt - if (FollowGear <> nil) then + if (Gear <> nil) then begin // Look for hog closest to the crate (on the X axis) gi := GearsList; @@ -1642,7 +1651,7 @@ if (gi^.Kind = gtHedgehog) then begin // Y axis is ignored to simplify calculations - d := hwRound(hwAbs(gi^.X - FollowGear^.X)); + d := hwRound(hwAbs(gi^.X - Gear^.X)); if d < minD then begin minD := d; @@ -1663,7 +1672,6 @@ // Default crate drop taunt AddVoice(sndReinforce, CurrentTeam^.voicepack); end; - end end;