# HG changeset patch # User Wuzzy # Date 1520532183 -3600 # Node ID d52d79f355583376dae31ec4df32b0c00e2b174a # Parent de07c8423bebbfdb75488f94fa173ab699072af3 Lua API: PlaySound: Add 3rd parameter instaVoice to instantly play voice diff -r de07c8423beb -r d52d79f35558 ChangeLog.txt --- a/ChangeLog.txt Thu Mar 08 18:15:06 2018 +0100 +++ b/ChangeLog.txt Thu Mar 08 19:03:03 2018 +0100 @@ -93,6 +93,7 @@ + New call: HealHog(gearUid, healthBoost[, showMessage[, tint]]): Heal hedgehog with graphical effects and message + New call: SetTeamLabel(teamname[, label]): Set an arbitrary label for a team, will be displayed next to the team bar + New call: SetSoundMask(soundId, isMasked): Allows to disable playing a sound effect from engine + + New param: PlaySound accepts 3rd parameter for voices: instaVoice: If true, sound plays instantly instead of being queued + New callback: onEndTurn(): Called at the end of a turn (when gears have settled) + New hedgehog effect: heArtillery: Per-hedgehog artillery mode (can't walk). Values: 1 = permanently active. 2 = temporarily active (sniper rifle). 0 = not active * AddAmmo now automatically unselects weapon if it would remove current ammo from current hedgehog diff -r de07c8423beb -r d52d79f35558 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Mar 08 18:15:06 2018 +0100 +++ b/hedgewars/uScript.pas Thu Mar 08 19:03:03 2018 +0100 @@ -2048,11 +2048,12 @@ function lc_playsound(L : Plua_State) : LongInt; Cdecl; var gear: PGear; n, s: LongInt; + instaVoice: boolean; const call = 'PlaySound'; - params = 'soundId [, hhGearUid]'; + params = 'soundId [, hhGearUid [, instaVoice]]'; begin - if CheckAndFetchParamCount(L, 1, 2, call, params, n) then + if CheckAndFetchParamCountRange(L, 1, 3, call, params, n) then begin s:= LuaToSoundOrd(L, 1, call, params); if s >= 0 then @@ -2064,7 +2065,15 @@ begin gear:= GearByUID(Trunc(lua_tonumber(L, 2))); if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then - AddVoice(TSound(s), gear^.Hedgehog^.Team^.Voicepack, true) + begin + instaVoice:= false; + if n = 3 then + instaVoice:= lua_toboolean(L, 3); + if instaVoice then + PlaySoundV(TSound(s), gear^.Hedgehog^.Team^.Voicepack, false, true) + else + AddVoice(TSound(s), gear^.Hedgehog^.Team^.Voicepack, true); + end; end; end; end;