The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working AMFP Phone Box for Amnesia (download)
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#1
Working AMFP Phone Box for Amnesia (download)

I can understand that people had issues porting this particular entity over to TDD, though it was quite fun to do I must admit. So here it is folks.

There are some things you need to know if you want to use this entity though.

  1. There are 2 entities you must place in your level, one being the phone box itself, and the other being the green light entity. The light must have the same internal name as the phone appended with _light. Remember to set the default state to "unlit".
  2. You must include the script below in each level you use the phone.

You could always script your own version of the phone, like if you need to tweak anything in the "internal" (so to speak) coding I did, feel free to do so, but for most applications, what I have should be perfectly fine.

You can download the entity here

Here's a vid btw.


Ok, on to the instructions:

First off, paste this script anywhere into your level's .hps file (for example at the very bottom). You're not required to read the script or know how it works, but it MUST be included if you wish to use the function below.

Spoiler below!
PHP Code: (Select All)
////////////////////////
// PHONE SCRIPT       //
// Written by Mudbill //
////////////////////////
void StartPhoneRinging (string &in asEntity
                        
string[] &in asAudioFiles
                        
string &in asSubCat
                        
string[] &in asSubEntries
                        
string &in asCallback) {
    
SetLocalVarInt("_PhoneFilesTotal"asAudioFiles.length());
    
SetLocalVarInt("_PhoneEntriesTotal"asSubEntries.length());
    for(
int i 0asAudioFiles.length(); i++)
        
SetLocalVarString("_PhoneAudioFile_"+iasAudioFiles[i]);
    for(
int i 0asSubEntries.length(); i++)
        
SetLocalVarString("_PhoneSubEntry_"+iasSubEntries[i]);
    
SetLocalVarString("_PhoneEnt"asEntity);
    
SetLocalVarString("_PhoneCallback"asCallback);
    
SetLocalVarString("_PhoneCat"asSubCat);
    
SetEntityPlayerInteractCallback(asEntity"_PhoneStartCall"true);
    
_PhoneRingLoop("ring");
}
void _PhoneRingLoop(string &in asTimer) {
    
PlayPropAnimation(GetLocalVarString("_PhoneEnt"), "hammer"0.0ffalse"");
    
PlaySoundAtEntity("ring""phone_ring"GetLocalVarString("_PhoneEnt"), 0.0ffalse);
    
AddTimer(asTimer5.0f"_PhoneRingLoop");
}
void _PhoneStartCall(string &in asEntity) {
    
SetLampLit(asEntity+"_light"truefalse);
    
PlaySoundAtEntity("""phone_up"asEntity0.0ffalse);
    
PlayPropAnimation(asEntity"switchon"0.0ffalse"_PhoneCall");
    
StopSound("ring"0.0f);
    
RemoveTimer("ring");
}
void _PhoneCall(string &in asProp) {    
    for(
int i 0GetLocalVarInt("_PhoneFilesTotal"); i++)
        
AddEffectVoiceGetLocalVarString("_PhoneAudioFile_"+i), 
                        
""
                        
GetLocalVarString("_PhoneCat"), 
                        
GetLocalVarString("_PhoneSubEntry_"+i), 
                        
true
                        
asProp
                        
0.0f
                        
10.0f);
    
SetEffectVoiceOverCallback("_PhoneEndCall");
}
void _PhoneEndCall() {
    
SetLampLit(GetLocalVarString("_PhoneEnt")+"_light"falsefalse);
    
PlayPropAnimation(GetLocalVarString("_PhoneEnt"), "switchoff"0.0ffalse"");
    
PlaySoundAtEntity("""phone_down"GetLocalVarString("_PhoneEnt"), 0.0ffalse);
    
AddTimer(GetLocalVarString("_PhoneEnt"), 0.0fGetLocalVarString("_PhoneCallback"));
}
//////////////////////
// END PHONE SCRIPT //
////////////////////// 


Once you have that script, you can use this function to configure your phone box:

PHP Code: (Select All)
void StartPhoneRinging(string &in asEntitystring[] &in asAudioFilesstring &in asSubCatstring[] &in asSubEntries
string &in asCallback); 

Callback syntax: void MyFunc(string &in asEntity)

asEntity - The phone box entity.
asAudioFiles - An array containing a list of all the audio files you wish to play when the phone is picked up.
asSubCat - The .lang category for your subtitles.
asSubEntries - An array containing a list of all the subtitle entries to display. I recommend it has the same length as the audio files.
asCallback - A callback that is called when the entire phone sequence has finished.



If you're unsure how to use the arrays, create them like so:

PHP Code: (Select All)
string[] example_array = {"item1""item2""item3"}; 

Then you just give the function this example_array as an argument. Do this for both the audio files and subtitle entries.



Here's an example of how you can implement it.

Spoiler below!
PHP Code: (Select All)
void OnStart()
{
    
string[] files = {"brokenrec_basile_02.ogg""brokenrec_basile_04.ogg"};
    
string[] entries = {"Entry_1""Entry_2"};
    
    
StartPhoneRinging("phone_box"files"Subtitles"entries"Finished");
}

void Finished(string &in asEntity) {
    
AddDebugMessage("FINISHED"false);



Oh, and as for installation, you place the "phone_box" folder within the downloaded archive inside your Amnesia/entities/custom/ folder (create a custom folder if you wish).
Remember to also keep a copy of the phone box within your mod's or custom story's directories when you export it.

If you use this, then credits would be nice.

(This post was last modified: 10-16-2016, 12:51 PM by Mudbill.)
10-15-2016, 03:13 PM
Find


Messages In This Thread
Working AMFP Phone Box for Amnesia (download) - by Mudbill - 10-15-2016, 03:13 PM



Users browsing this thread: 1 Guest(s)