Frictional Games Forum (read-only)
[SCRIPT] Script Help - 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] Script Help (/thread-20888.html)

Pages: 1 2 3 4


RE: check if active/ string to int - Adrianis - 03-25-2013

(03-25-2013, 10:00 AM)Knusper. Wrote: ok, i found the problem, i didnt wrote void MyFunc(string &in asTimer)

I can't see anywhere in your script that you are using a timer, are you sure that that is the problem?

(03-25-2013, 10:00 AM)Knusper. Wrote: Now only At
Code:
void FadeOut1(string &in asParent, string &in asChild, int alState)
{
    IsInArea = false;
    string areanumber2 = StringSub(asChild, 11, 2);
    int i1, i2;
    
    i2 = areanumber2[0] *10 + areanumber2[1];       
    i1 = LastArea[0] *10 + LastArea[1];                
    
    if(i1 == i2 - 10)
    {
        AddDebugMessage("fade", false);
        LastArea = areanumber2;
    }
    
}

He sometimes shows the message and sometimes he does not.

Is there any particular reason you need to store the locations like areanumber and LastArea as strings, and not int's?

Did you write all of this script yourself, or has it been copied & pasted from other places?


RE: check if active/ string to int - Knusper. - 03-25-2013

Yes, it all has to be.
And the timer works now, before i changed it it didnt work.
And I write all scripts myself, just with help of the engine scripts.
Here is the complete script:
Code:
void OnEnter()
{
    PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);  
    
}

void OnStart()
{
    
    for (int i = 0; i < 10; i++)
        {
            AddEntityCollideCallback("Player" , "ScriptArea_" + 0 + i , "InArea" , true , 1);
        }
        
        
    for (int i = 11; i < 20; i++)
    
        {
            for (int j = 1; j < 5; j++)
                AddEntityCollideCallback("Player" , "ScriptArea_" + i + "." + j, "FadeOut1" , true , 1);
        }
        
    SetSanityDrainDisabled(true);
    AddEntityCollideCallback("Player" , "Music2" , "secondmusic" , true , 1);    
    AddEntityCollideCallback("Player" , "activeslendy_1" , "Slender1" , true , 1);    
    AddEntityCollideCallback("Player" , "activeslendy_2" , "Slender2" , true , 1);    
}

bool IsInArea = false;
bool Slender_1active = false;
bool Slender_2active = false;
string LastArea = "00";


void secondmusic (string &in asParent, string &in asChild, int alState)
{
    StopMusic(0.0f, 1);
    PlayMusic("Slender 2.ogg", true, 1.0f, 0.0f, 2, true);
}


void Slender1 (string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("Slender_1", true);
    Slender_1active = true;
    AddDebugMessage("active", false);
}

void Slender2 (string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("Slender_2", true);
    Slender_2active = true;
    AddDebugMessage("active2", false);
}

void InArea(string &in asParent, string &in asChild, int alState)
{
    string areanumber1 = StringSub(asChild, 11, 2);
    if ("Slender_" + areanumber1[1] + active)
    {
        AddDebugMessage("InArea > if statement executing", false);
        IsInArea = true;
        LastArea = areanumber1;
        
        AddTimer("Dead", 3, "Dead");
    }
    
}


void Dead(string &in asTimer)
{
    if(IsInArea == true)
    {
        FadeOut(0.5);
        SetPlayerHealth(0);
    }
}


void FadeOut1(string &in asParent, string &in asChild, int alState)
{
    IsInArea = false;
    string areanumber2 = StringSub(asChild, 11, 2);
    int i1, i2;
    
    i2 = areanumber2[0] *10 + areanumber2[1];       //LastArea 2 als int
    i1 = LastArea[0] *10 + LastArea[1];                //LastArea 1 als int
    
    if(i1 == i2 - 10)
    {
        //FadeOut
        AddDebugMessage("fade", false);
        LastArea = areanumber2;
    }
    
}


void OnLeave ()
{
    SetupLoadScreen("", "", 5, "");
}



RE: check if active/ string to int - Knusper. - 03-25-2013

Now i think i got it.
It seems to work correctly.
Here it is: (after 3 hours of working Dodgy)
Code:
void OnEnter()
{
    PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);  
    
}

void OnStart()
{
    
    for (int i = 0; i < 10; i++)
        {
            AddEntityCollideCallback("Player" , "ScriptArea_" + 0 + i , "InArea" , false , 1);
        }
        
        
    for (int i = 11; i < 20; i++)
    
        {
            for (int j = 1; j < 5; j++)
                AddEntityCollideCallback("Player" , "ScriptArea_" + i + "." + j, "FadeOut1" , false , 1);
        }
        
    SetSanityDrainDisabled(true);
    AddEntityCollideCallback("Player" , "Music2" , "secondmusic" , true , 1);    
    AddEntityCollideCallback("Player" , "activeslendy_1" , "Slender1" , true , 1);    
    AddEntityCollideCallback("Player" , "activeslendy_2" , "Slender2" , true , 1);    
}


bool IsInArea = false;
bool Slender_1active = false;
bool Slender_2active = false;
string Slender_active = "000000000";
string LastArea = "00";


void secondmusic (string &in asParent, string &in asChild, int alState)
{
    StopMusic(0.0f, 1);
    PlayMusic("Slender 2.ogg", true, 1.0f, 0.0f, 2, true);
}



void Slender1 (string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("Slender_1", true);
    Slender_active = "1" + StringSub(Slender_active, 1, 8);
    AddDebugMessage("active", false);
    AddDebugMessage(Slender_active, false);
}



void Slender2 (string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("Slender_2", true);
    Slender_active = StringSub(Slender_active, 0, 1) + "1" + StringSub(Slender_active, 2, 7);
    AddDebugMessage("active2", false);
    AddDebugMessage(Slender_active, false);
}



void InArea(string &in asParent, string &in asChild, int alState)
{
    string areanumber1 = StringSub(asChild, 11, 2);
    int i;
    i = (areanumber1[0] -48) *10 + areanumber1[1] -48;       
    AddDebugMessage(Slender_active, false);
    if (Slender_active[i-1] == 1 + 48)
    {
        AddDebugMessage("InArea > if statement executing", false);
        IsInArea = true;
        LastArea = areanumber1;
        AddTimer("Dead", 2, "Dead");
    }
    
}



void Dead(string &in asTimer)
{
    if(IsInArea == true)
    {
        FadeOut(0.3);
        SetPlayerHealth(0);
        
    }
}



void FadeOut1(string &in asParent, string &in asChild, int alState)
{
    IsInArea = false;
    string areanumber2 = StringSub(asChild, 11, 2);
    int i1, i2;
    
    i2 = (areanumber2[0] - 48) *10 + areanumber2[1] -48;       
    i1 = (LastArea[0] - 48) *10 + LastArea[1] -48;                
    AddDebugMessage("i1 =" + i1, false);
    AddDebugMessage("i2 =" + i2, false);
    if(i1 == i2 - 10)
    {
        //FadeOut
        AddDebugMessage("fade", false);
        LastArea = areanumber2;
        
    }
    
}

Now I know how to use the ASCII code at:
i2 = (areanumber2[0] - 48) *10 + areanumber2[1] -48;
i1 = (LastArea[0] - 48) *10 + LastArea[1] -48;

Thx all who helped!!!
I think its done.


RE: check if active/ string to int - Adrianis - 03-25-2013

Np, glad to hear it's working!

Post again if it stops working Smile


RE: check if active/ string to int - Knusper. - 03-26-2013

ok, now i have another problem Dodgy
I dont hear the sounds i added.
Example:
PlaySoundAtEntity("", "Slender pip.snt", "player", 0, false);

Maybe it has to do something with the priority???
Before all sounds there is:
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);

But, i dont know how to fix that.
What can it be?


RE: check if active/ string to int - Adrianis - 03-26-2013

(03-26-2013, 10:44 AM)Knusper. Wrote: ok, now i have another problem Dodgy
I dont hear the sounds i added.
Example:
PlaySoundAtEntity("", "Slender pip.snt", "player", 0, false);

Maybe it has to do something with the priority???
Before all sounds there is:
PlayMusic("Slender 1.ogg", true, 1.0f, 0.0f, 1, true);

But, i dont know how to fix that.
What can it be?

The priority of the music shouldn't be a problem - both should be able to play.

Can you post up the text in 'Slender pip.snt'?


RE: check if active/ string to int - Knusper. - 03-26-2013

Code:
<SOUNDENTITY>
  <SOUNDS>
      <Main>
          <Sound File="Slender pip.ogg" />
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="2" MinDistance="0" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="false" Loop="false" Use3D="false" Blockable="false" BlockVolumeMul="0.5" Priority="2" />
</SOUNDENTITY>



RE: check if active/ string to int - Adrianis - 03-26-2013

(03-26-2013, 12:10 PM)Knusper. Wrote:
Code:
<SOUNDENTITY>
  <SOUNDS>
      <Main>
          <Sound File="Slender pip.ogg" />
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="2" MinDistance="0" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="false" Loop="false" Use3D="false" Blockable="false" BlockVolumeMul="0.5" Priority="2" />
</SOUNDENTITY>

I'm not sure if any of these suggestions will fix it but it's all I can suggest for now Smile

- rename both the .ogg and .snt to use a '_' rather than just a space
- remove the .ogg file extension so it reads <Sound File="Slender_pip" />
- if you only have 1 sound, then Random should be "0"
- set the minimum distance to at least 1 (not sure that's necessary, but worth trying!)

Give those a go, let me know if it works or not...


RE: check if active/ string to int - Knusper. - 03-26-2013

tried all but it still doesnt work. Huh


RE: check if active/ string to int - Adrianis - 03-26-2013

Hrrrm...

Try with Volume="1", Priority="1", Use3D="True"