Frictional Games Forum (read-only)
[SCRIPT] Not all commands work in a function (EffectVoices) - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Not all commands work in a function (EffectVoices) (/thread-51867.html)

Pages: 1 2


Not all commands work in a function (EffectVoices) - Darkfire - 07-30-2016

So I'm trying to do some effects (radial blur and sepia) inbetween a series of effect voices. The problem is they don't work. The function (ContinueDialogue1) is called for sure, since the dialogue continues, but for some reason the effects put in the same func don't work. They work if I put them in the beggining (Dialogue2).

Any ideas ?

PHP Code:
void Dialogue2(string &in asEntity)
{
    
AddEffectVoice("Academy_Speech_1""""Dialogues""Academy_Speech_1"false"Player"0.0f25.0f);
    
PlayMusic("02_thegreatunderground.ogg"false1.0f0.4f2false);
    
AddEffectVoice("Academy_Speech_2""""Dialogues""Academy_Speech_2"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_3""""Dialogues""Academy_Speech_3"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_4""""Dialogues""Academy_Speech_4"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_5""""Dialogues""Academy_Speech_5"false"Player"0.0f25.0f);
    
SetEffectVoiceOverCallback("ContinueDialogue1");
}
void ContinueDialogue1()
{
    
FadeRadialBlurTo(0.05f0.1f);
    
FadeSepiaColorTo(1.0f0.5f);
    
ContinueDialogue();
}
void ContinueDialogue()
{
    
AddEffectVoice("Academy_Speech_6""""Dialogues""Academy_Speech_6"false"Player"0.0f25.0f);
///and so on...




RE: Not all commands work in a function (EffectVoices) - Mudbill - 07-31-2016

It might have something to do with the fact that AddEffectVoice queues up the voices, so the order of execution might not be what you expect. Perhaps another way to do this is to use timers?

If you add a timer at the start that is just as long as your first piece of dialogue, then it should trigger once it's done.


RE: Not all commands work in a function (EffectVoices) - Darkfire - 07-31-2016

Yeah, I guess it's down to timers again.
Although everything else besides visual effects works, so I'm kinda disappointed.


RE: Not all commands work in a function (EffectVoices) - Mudbill - 07-31-2016

So you mean that the PlayMusic function you have doesn't run unless it's at the top of Dialogue2 ?


RE: Not all commands work in a function (EffectVoices) - Spelos - 07-31-2016

I don't think PlayMusic counts as a "visual effect", though. So by what he said, it should work.


RE: Not all commands work in a function (EffectVoices) - Darkfire - 07-31-2016

Yup, music works. I can't see any mistakes that I could have made, so this is probably a bug and I have to work it around.


RE: Not all commands work in a function (EffectVoices) - Mudbill - 07-31-2016

I thought the script you posted included what wasn't working. So you added the visual effects inbetween the voice lines?

Well, not sure why they wouldn't run at all, but even if they did, they would all run at the same time at the start of that script. It wouldn't have waited until the voice started before being executed, because the voice lines do not stall the script. So if you for example had FadeSepiaColorTo > 1 in the middle and FadeSepiaColorTo > 0 at the end, it would set it to 1 and 0 at the same time, effectively nullifying itself. Could that be what happened?

Could you post the script you tried that wasn't working?


RE: Not all commands work in a function (EffectVoices) - Darkfire - 07-31-2016

This is the script.
I want the sepia to happen in the middle of the speech, so I used
PHP Code:
SetEffectVoiceOverCallback("ContinueDialogue1"); 
The function ContinueDialogue1 is called, because the next part of the speech
PHP Code:
ContinueDialogue(); 
works.
However,
PHP Code:
FadeRadialBlurTo(0.05f0.1f);
 
FadeSepiaColorTo(1.0f0.5f); 
Don't work for some reason, even though they're in the same func as
PHP Code:
ContinueDialogue(); 
, which works.

To specify, the script doesn't cause a bug, just the visual effects don't kick in.


RE: Not all commands work in a function (EffectVoices) - Mudbill - 07-31-2016

Could you post the entire script though? It's kinda hard to follow when split up like that. I also don't see the ContinueDialog() anywhere else, only the constructor for ContinueDialog1(). If you need to comment on something in between the script, I prefer using //comments instead, as an example.


RE: Not all commands work in a function (EffectVoices) - Darkfire - 07-31-2016

But... ContinueDialogue() is right down there...

Dialogue2 is called with a SetEntityPlayerInteractCallback, saying just in case.

Here's the whole script, but it's 400 lines long and everything else inside is irrelevant, so what for ? Sorry for being an ass

Spoiler below!
PHP Code:
void OnStart()
{
    
TeleportPlayer("PlayerStartArea_1");
    
CompleteQuest("Academy""FindAcademy");
    
    
AddCombineCallback("ladder""ladder1""ladder2""CombineLadder"false);
    
AddCombineCallback("ladder""ladder1""ladder3""CombineLadder"false);
    
AddCombineCallback("ladder""ladder3""ladder2""CombineLadder"false);
    
    
SetGlobalVarInt("LadVar"0);
    
    
//GiveItem("Key2", "chemical_container_full.ent", "pick", "chemical_container_full.tga", 1);
    
    
SetEntityPlayerInteractCallback("KainamKey""Dialogue"true);
    
SetEntityPlayerInteractCallback("PurpleOrb""Dialogue2"true);
    
    
////////////////////////////Item interactions
    
AddUseItemCallback("kiki""crowbar2""padlock""UnbreakableMessage"false);
    
AddUseItemCallback("koko""crowbar2""padlock_acid""BreakPadlock"false);
    
AddUseItemCallback("acidididi""Jar""FillAcidJar""FillJar"false);
    
AddUseItemCallback("kaka""acid""padlock""Melt"false);
    
AddUseItemCallback("hgh""ladder_complete""Penis""InsertLadder"false);
    
    
//doors
    
AddUseItemCallback("""StorageKey""Storage""OpenDoor"false);
    
AddUseItemCallback("""LabKey""LabDoor""OpenDoor"false);
    
AddUseItemCallback("""StudyKey""mansion_12""OpenDoor"false);
    
AddUseItemCallback("""item""door""OpenDoor"false);
    
    
AddUseItemCallback("""Key2""mansion_1""PickLock"false);
    
AddUseItemCallback("""Key2""mansion_2""PickLock"false);
    
AddUseItemCallback("""Key2""mansion_3""PickLock"false);
    
AddUseItemCallback("""Key2""FancyDoor_12""PickLock"false);
    
    
AddUseItemCallback("""Key2""padlock""LockPickMessage"false);
    
AddUseItemCallback("""Key2""padlock_acid""LockPickMessage"false);
    
AddUseItemCallback("""Key2""Storage""LockPickMessage"false);
    
AddUseItemCallback("""Key2""LabDoor""LockPickMessage"false);
    
AddUseItemCallback("""Key2""mansion_12""LockPickMessage"false);
    
AddUseItemCallback("""Key2""FancyDoor_4""LockPickMessage"false);
    
AddUseItemCallback("""Key2""FancyDoor_11""LockPickMessage"false);
    
AddUseItemCallback("""Key2""mansion_5""LockPickMessage"false);
    
AddUseItemCallback("""Key2""mansion_6""LockPickMessage"false);
    
AddUseItemCallback("""Key2""castle_1""LockPickMessage"false);
    
AddUseItemCallback("""Key2""castle_2""LockPickMessage"false);
    
    
//end doors
    /////////////////////////////
    
    
if(HasItem("crowbar2") == false)
    {
        
SetEntityActive("crowbar2"true);
    }
    
AddTimer("wegorz"0.1f"ShowEasterEggCount");
}

void LockPickMessage(string &in asItemstring &in asEntity)
{
    
SetMessage("Messages""Locked4"3);
}

void OnLeave()
{
    
StopMusic(1.0f1);
    
StopMusic(1.0f2);
    
SetupLoadScreen("LoadingScreens""LoadScreen12"0"");
}

void ShowEasterEggCount(string &in asTimer)
{
    if(
ScriptDebugOn())
    {
        
AddDebugMessage("Number of Poems:" +GetGlobalVarInt("LyricsVar"), true);
    }
    
    
AddTimer("wegorz2"0.1f"ShowEasterEggCount");
    
}

void OnEnter()
{

    
PlayMusic("22_amb"true1.0f0.0f1false);
    
AutoSave();
    
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_31"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_7"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_2"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_3"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_4"3.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_6"7.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_7"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_31"50.0f"");
    
    
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_1"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_2"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_3"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_4"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_5"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_51"2.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_53"7.01f"");
    
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_52"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_17"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_24"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_26"0.01f"");
    
    
}

void DisplayEE(string &in asEntity)
{
    
SetMessage("Messages""EasterL"6);
    if(
GetGlobalVarInt ("LyricsVar") == 0)
    {
        
SetMessage("Messages""EasterL"6);
    }
    else
    {
        
SetMessage("Messages""EasterL2"3);
    }
    
AddGlobalVarInt("LyricsVar"1);
}

void OpenDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door.snt""Player"0false);
    
RemoveItem(asItem);
    
AddPlayerSanity( -1);
    
AddPlayerSanity16);
    
    
AutoSave();
}

void PickLock(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door.snt""Player"0false);
}

void PickMessage(string &in asEntity)
{
    
SetMessage("Messages""Lousy"0);
}

//////////////OPEN THE ATTIC GATE//////////////////

void UnbreakableMessage(string &in asItemstring &in asEntity)
{
    
SetMessage("Messages""Popup33"3);
}
void BreakPadlock(string &in asItemstring &in asEntity)
{
    
PlaySoundAtEntity("""16_ladder_imp3""padlock_acid"0.01ffalse);
    
SetEntityActive("padlock_acid"false);
    
SetEntityActive("padlock_broken"true);
    
SetPropStaticPhysics("gate"false);
    
AddPlayerSanity(-1.0f);
    
GiveSanityBoost();
    
    
AutoSave();
    
}
void Melt(string &in asItemstring &in asEntity)
{
    
SetPropActiveAndFade("padlock"false2.0f);
    
SetPropActiveAndFade("padlock_acid"true1.0f);
    
PlaySoundAtEntity("""puzzle_acid""padlock_acid"0.01ffalse);
    
FadeLightTo("AcidLight"0.0f1.0f0.3f1.0f, -11);
    
AddTimer(""1.1f"TurnOffLight");
    
RemoveItem(asItem);
    
    
AutoSave();
}

void FillJar(string &in asItemstring &in asEntity)
{
    
RemoveItem(asItem);
    
PlayGuiSound("puzzle_acid_success.snt"1.0f);
    
GiveItem("acid""chemical_container_full.ent""jar3""chemical_container_full.tga"1);
    
    
AutoSave();
}

void TurnOffLight(string &in asTimer)
{
    
FadeLightTo("AcidLight"0.0f0.0f0.0f0.0f, -11);
}


////////////////END OPENING THE GATE///////////////



void End(string &in asEntity)
{
    
//StartCredits("Kai_Engel_-_02_-_Melancholy_Aftersounds.ogg", false, "Endings", "Ending1", 3);
    //StartCredits("", false, "Endings", "Ending1", 3);
}

void AddLadVar(string &in asEntity)
{
    
AddGlobalVarInt("LadVar"1);

}



///////////DIALOGUE///////////

void Dialogue(string &in asEntity)
{
    
AddEffectVoice("Academy_warning_1""""Dialogues""Academy_Warning_1"false"Player"0.0f25.0f);
    if(
HasItem("PurpleOrb") == false)
    {
        
AddEffectVoice("Academy_warning_2""""Dialogues""Academy_Warning_2"false"Player"0.0f25.0f);
    }
    else
    {
        
SetLevelDoorLocked("level_wood_2"false);
        
SetLevelDoorLocked("level_wood_1"false);
    }
    
AddEffectVoice("Academy_warning_3""""Dialogues""Academy_Warning_3"false"Player"0.0f25.0f);
    
SetEffectVoiceOverCallback("EventMusic");
}
void EventMusic()
{
    
PlayMusic("19_event_brute.ogg"false1.0f0.4f2false);
    
AddEffectVoice("Academy_warning_4""""Dialogues""Academy_Warning_4"false"Player"0.0f25.0f);
    
    
CompleteQuest("laboratory""LaboratoryKey");
    
    
CheckPoint("""KeyTeleport""Respawn""DeathHint""Entry2");
    
    
AddTimer("sdgd"3.0f"Spawn");
    
    
AutoSave();
    
    
}

void Spawn(string &in asTimer)
{
    
SetEntityActive("servant_brute_1"true);
    
SetEntityActive("servant_brute_2"true);
    
    
SetEntityActive("pot_plant_small01_5"true);
    
SetEntityActive("chair_nice02_12"true);
    
    
AddEntityCollideCallback("ScriptArea_1""servant_brute_2""StopGrunt"true1);
}

void Respawn(string &in asNameint alCount
{
    if(
alCount 4)
    {
        
PlayMusic("19_event_brute.ogg"false1.0f0.4f2false);
        
AddTimer("sdgd"3.0f"Spawn");
    }
    
    if(
GetEntitiesCollide("mansion_12""ScriptArea_3") == false)
    {
        
CreateEntityAtArea("mansion_12""mansion.ent""ScriptArea_3"false);
    }
    if(
GetEntitiesCollide("ScriptArea_2""pot_plant_small01_5") == false)
    {
        
CreateEntityAtArea("pot_plant_small01_5""pot_plant_small01.ent""ScriptArea_2"false);
    }
    
SetEntityActive("pot_plant_small01_5"true);
    
SetEntityActive("chair_nice02_12"true);
    
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_31"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_7"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_2"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_3"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_4"3.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_6"7.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_7"0.01f"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_31"50.0f"");
    
    
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_1"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_2"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_3"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_4"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_5"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_51"2.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_53"7.01f"");
    
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_52"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_17"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_24"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_26"0.01f"");
}

void StopGrunt(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive(asParenttrue);
    
AddEntityCollideCallback("ScriptArea_4""Player""AddNodes"false1);
    
AddEntityCollideCallback("ScriptArea_5""Player""Attack"false1);
}

void AddNodes(string &in asParentstring &in asChildint alState)
{
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_52"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_17"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_24"0.01f"");
    
AddEnemyPatrolNode("servant_brute_2""PathNodeArea_26"0.01f"");

}

void Attack(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("servant_brute_2");
    
ShowEnemyPlayerPosition("servant_brute_2");
}


void Dialogue2(string &in asEntity)
{
    
FadeLightTo("PointLight_58"0.0f0.0f0.0f0.0f0.0f1.0f);
    
FadeLightTo("PointLight_6"0.0f0.0f0.0f0.0f0.0f1.0f);
    
    
AutoSave();
    
    
AddEffectVoice("Academy_Speech_1""""Dialogues""Academy_Speech_1"false"Player"0.0f25.0f);
    
PlayMusic("02_thegreatunderground.ogg"false1.0f0.4f2false);
    
AddEffectVoice("Academy_Speech_2""""Dialogues""Academy_Speech_2"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_3""""Dialogues""Academy_Speech_3"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_4""""Dialogues""Academy_Speech_4"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_5""""Dialogues""Academy_Speech_5"false"Player"0.0f25.0f);
    
SetEffectVoiceOverCallback("ContinueDialogue1");
}
void ContinueDialogue1()
{
    
FadeRadialBlurTo(0.05f0.1f);
    
FadeSepiaColorTo(1.0f0.5f);
    
ContinueDialogue();
}
void ContinueDialogue()
{
    
    
AddEffectVoice("Academy_Speech_6""""Dialogues""Academy_Speech_6"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_7""""Dialogues""Academy_Speech_7"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_8""""Dialogues""Academy_Speech_8"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_9""""Dialogues""Academy_Speech_9"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_10""""Dialogues""Academy_Speech_10"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_11""""Dialogues""Academy_Speech_11"false"Player"0.0f25.0f);
    if(
HasItem("KainamKey") == false)
    {
        
AddEffectVoice("Academy_Speech_12""""Dialogues""Academy_Speech_12"false"Player"0.0f25.0f);
        
//add memento
    
}
    else
    {
        
SetLevelDoorLocked("level_wood_2"false);
        
SetLevelDoorLocked("level_wood_1"false);
    }
    
AddEffectVoice("Academy_Speech_13""""Dialogues""Academy_Speech_13"false"Player"0.0f25.0f);
    
AddEffectVoice("Academy_Speech_14""""Dialogues""Academy_Speech_14"false"Player"0.0f25.0f);
    
    
FadeRadialBlurTo(0.0f0.0f);
    
FadeSepiaColorTo(0.0f0.0f);
    
SetEffectVoiceOverCallback("ContinueDialogue2");
}
void ContinueDialogue2()
{
    
SetEntityActive("GoOut"true);
    
SetEntityPlayerInteractCallback("GoOut""TeleportBack"false);
}

void TeleportBack(string &in asEntity)
{
    
AddTimer("fadetimer"1.2f"TeleportProper");
    
AddTimer("tptimer"1.1f"TeleportProper");
    
FadeOut(1.0f);
    
PlayGuiSound("player_climb.snt"1.0f);
    
StopMusic(0.5f2);
}

void TeleportProper(string &in asTimer)
{
    if(
asTimer == "tptimer")
    {
        
TeleportPlayer("PlayerStartArea_2");
    }
    if(
asTimer == "fadetimer")
    {
        
FadeIn(1.0f);
    }
}



///////////END DIALOGUE



void InsertLadder(string &in asItemstring &in asEntity)
{
    
RemoveItem(asItem);
    
PlayGuiSound("puzzle_place_jar.snt"1.0f);
    
SetEntityActive("ladder_static_1"true);
    
SetEntityActive("LadderArea_1"true);
    
SetEntityActive("Penis"false);
    
    
AutoSave();