UserAction: Add Sound

qteditor
Sven Eberhardt 2016-07-28 23:44:10 -04:00
parent 37885a2e4f
commit 77a4916383
3 changed files with 72 additions and 2 deletions

View File

@ -34,6 +34,7 @@ func Definition(def)
Evaluator.Player = { Name="$UserPlayer$", Type="enum", OptionKey="Function", Options = [ { Name="$Noone$" } ] };
Evaluator.PlayerList = { Name="$UserPlayerList$", Type="enum", OptionKey="Function", Options = [ { Name="$Noone$" } ] };
Evaluator.Boolean = { Name="$UserBoolean$", Type="enum", OptionKey="Function", Options = [] };
Evaluator.Integer = { Name="$UserInteger$", Type="enum", OptionKey="Function", Options = [] };
Evaluator.Condition = { Name="$UserCondition$", Type="enum", OptionKey="Function", Options = [ { Name="$None$" } ] };
// Action evaluators
EvaluatorCallbacks = {};
@ -49,6 +50,18 @@ func Definition(def)
AddEvaluator("Action", "$Sequence$", "$Wait$", "$WaitHelp$", "wait", [def, def.EvalAct_Wait], { Time=60 }, { Type="proplist", Display="{{Time}}", EditorProps = {
Time = { Name="$Time$", Type="int", Min=1 }
} } );
AddEvaluator("Action", "$Ambience$", "$Sound$", "$SoundHelp$", "sound", [def, def.EvalAct_Sound], { Pitch={Function="int_constant", Value=0}, Volume={Function="int_constant", Value=100}, TargetPlayers={Function="all_players"} }, { Type="proplist", Display="{{Sound}}", EditorProps = {
Sound = { Name="$SoundName$", EditorHelp="$SoundNameHelp$", Type="sound", AllowEditing=true },
Pitch = new Evaluator.Integer { Name="$SoundPitch$", EditorHelp="$SoundPitchHelp$" },
Volume = new Evaluator.Integer { Name="$SoundVolume$", EditorHelp="$SoundVolumeHelp$" },
Loop = { Name="$SoundLoop$", EditorHelp="$SoundLoopHelp$", Type="enum", Options=[
{ Name="$SoundLoopNone$" },
{ Name="$SoundLoopOn$", Value=+1 },
{ Name="$SoundLoopOff$", Value=-1 }
] },
TargetPlayers = new Evaluator.PlayerList { EditorHelp="$SoundTargetPlayersHelp$" },
SourceObject = new Evaluator.Object { Name="$SoundSourceObject$", EditorHelp="$SoundSourceObjectHelp$" }
} } );
// Object evaluators
AddEvaluator("Object", nil, "$ActionObject$", "$ActionObjectHelp$", "action_object", [def, def.EvalObj_ActionObject]);
AddEvaluator("Object", nil, "$TriggerClonk$", "$TriggerClonkHelp$", "triggering_clonk", [def, def.EvalObj_TriggeringClonk]);
@ -60,6 +73,8 @@ func Definition(def)
AddEvaluator("PlayerList", nil, "$AllPlayers$", "$AllPlayersHelp$", "all_players", [def, def.EvalPlrList_All]);
// Boolean (condition) evaluators
AddEvaluator("Boolean", nil, "$Constant$", "$ConstantHelp$", "bool_constant", [def, def.EvalConstant], { Value=true }, { Type="bool", Name="$Value$" });
// Integer evaluators
AddEvaluator("Integer", nil, "$Constant$", "$ConstantHelp$", "int_constant", [def, def.EvalConstant], { Value=0 }, { Type="int", Name="$Value$" });
// User action editor props
Prop = Evaluator.Action;
PropProgressMode = { Name="$UserActionProgressMode$", EditorHelp="$UserActionProgressModeHelp$", Type="enum", Options = [ { Name="$Session$", Value="session" }, { Name="$Player$", Value="player" }, { Name="$Global$" } ] };
@ -285,6 +300,25 @@ private func EvalAct_Wait(proplist props, proplist context)
ScheduleCall(context, UserAction.ResumeAction, props.Time, 1, context, props);
}
private func EvalAct_Sound(proplist props, proplist context)
{
if (!props.Sound) return;
var sound_context = props.SourceObject ?? Global;
var volume = EvaluateValue("Integer", props.Volume, context);
var pitch = EvaluateValue("Integer", props.Pitch, context);
if (props.TargetPlayers == "all_players")
{
sound_context->Sound(props.Sound, true, volume, nil, props.Loop, nil, pitch);
}
else
{
for (var plr in EvaluateValue("PlayerList", props.TargetPlayers, context))
{
sound_context->Sound(props.Sound, false, volume, plr, props.Loop, nil, pitch);
}
}
}
/* Context instance */

View File

@ -2,6 +2,7 @@ UserAction=Aktion
UserObject=Objekt
UserPlayer=Spieler
UserPlayerList=Spieler
UserInteger=Zahl
UserBoolean=Bedingung
UserCondition=Bedingung
None=Nichts
@ -40,4 +41,21 @@ TriggeringPlayerHelp=Der Spieler, der die Sequenz ausgeloest hat.
AllPlayersHelp=Alle menschlichen Spieler.
ConstantHelp=Wert direkt angeben.
UserActionProgressModeHelp=Legt fest, ob der Fortschritt in dieser Sequenz global, pro Spieler oder pro Ausfuehrung gespeichert wird. Wenn zum Beispiel in einem Dialog der Fortschritt global gespeichert wird und ein zweiter Spieler spricht den Clonk an, wahrend der erste gerade eine Nachricht liest, dann setzt der zweite Spieler den Dialog an Stelle des ersten fort. Bei Speicherung pro Spieler bekommt jeder Spieler einen eigenen Dialog.
ParallelActionHelp=Gibt an, ob die Aktion mehrmals parallel gestartet werden kann. Dies ist relevant wenn die Aktion laenger andauert (zum Beispiel wegen eines Dialoges oder einer Wartezeit in der Sequenz) und in dieser Zeit zum Beispiel durch einen anderen Spieler ein weiteres Mal ausgeloest wird.
ParallelActionHelp=Gibt an, ob die Aktion mehrmals parallel gestartet werden kann. Dies ist relevant wenn die Aktion laenger andauert (zum Beispiel wegen eines Dialoges oder einer Wartezeit in der Sequenz) und in dieser Zeit zum Beispiel durch einen anderen Spieler ein weiteres Mal ausgeloest wird.
Ambience=Ambiente
Sound=Sound
SoundHelp=Spielt ein Geraeusch ab.
SoundName=Soundname
SoundNameHelp=Name der Geraeuschdatei
SoundPitch=Pitch
SoundPitchHelp=Modulation der Tonhoehe. -90 bis +1000. Bei 0 wird der Ton normal abgespielt. Kleinere Werte machen ihn tiefer und langsamer. Grosse Werte machen ihn schneller und hoeher.
SoundVolume=Lautstaerke
SoundVolumeHelp=Relative Lautstaerke. Werte 0-100. 100 ist Standard.
SoundLoop=Schleife
SoundLoopHelp=Auf 'Schleife an' wird das Geraeusch dauerhaft wiederholt, bis der gleiche Ton mit der Einstellung 'Schleife aus' gestoppt wird. Bei 'Aus' wird das Geraeusch genau einmal abgespielt.
SoundLoopNone=Aus
SoundLoopOn=Schleife an
SoundLoopOff=Schleife aus
SoundTargetPlayersHelp=Spieler, bei denen das Geraeusch abgespielt wird.
SoundSourceObject=Quellobjekt
SoundSourceObjectHelp=Objekt, das als Geraeuschquelle dient. Toene mit Geraeuschquelle werden nur abgespielt, wenn das Objekt in der Naehe ist und die Position (linker versus rechter Lautsprecher) wird automatisch moduliert. Bei Nichtangabe wird der Ton global abespielt.

View File

@ -2,6 +2,7 @@ UserAction=Action
UserObject=Object
UserPlayer=Player
UserPlayerList=Players
UserInteger=Integer
UserBoolean=Condition
UserCondition=Condition
None=Nothing
@ -40,4 +41,21 @@ TriggeringPlayerHelp=The player who has triggered this action.
AllPlayersHelp=All human players.
ConstantHelp=Specify a value directly.
UserActionProgressModeHelp=Specifies whether progress in this sequence is stored globally, per player or only per execution. For instance if progress of a dialogue is stored globally and a second player talks to the same clonk while another player is reading a message, the second player would continue the dialogue where the first player stopped. If progress is stored per player, each player gets an independent dialogue.
ParallelActionHelp=Specifies whether the action can be started multiple times in parallel. This is relevant if the action duration is long (for example because a dialogue message or a wait time in the sequence) and the same event is triggered by another player during the wait time.
ParallelActionHelp=Specifies whether the action can be started multiple times in parallel. This is relevant if the action duration is long (for example because a dialogue message or a wait time in the sequence) and the same event is triggered by another player during the wait time.
Ambience=Ambience
Sound=Sound
SoundHelp=Plays a sound file.
SoundName=Sound name
SoundNameHelp=Name of the sound file to play.
SoundPitch=Pitch
SoundPitchHelp=Modulation of pitch. Valid values are -90 to +1000. At 0, the sound will be played normally. Smaller values mean lower-pitched and slower sound. Larger values mean higher-pitched and faster sound.
SoundVolume=Volume
SoundVolumeHelp=Relative sound volume. Values 0-100. Default is 100.
SoundLoop=Loop
SoundLoopHelp=On 'Loop on', the sound will play over an over until a sound with the same name and source object is played with the 'Loop off' setting. If 'None', the sound is played exactly once.
SoundLoopNone=None
SoundLoopOn=Loop on
SoundLoopOff=Loop off
SoundTargetPlayersHelp=Players, for whom the sound is played.
SoundSourceObject=Source object
SoundSourceObjectHelp=Object used as the source of the sound. Object sounds are only played if the object is nearby and are panned depending on object position relative to the screen.