Frictional Games Forum (read-only)
Need some help with this script.... - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Need some help with this script.... (/thread-8676.html)

Pages: 1 2


RE: Need some help with this script.... - Tanshaydar - 06-18-2011

AddDebugMessage(string& asString, bool abCheckForDuplicates);
For this and more: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

Simply, add a:
Code:
AddDebugMessage("Debug Message: Area Collided! Now ScaryDude must be activated!", false);
or something like this in your CollidePlayerWithMonsterDoor function, and when starting the map, check the "Show Debug Messages" in debug menu.


RE: Need some help with this script.... - Doctorcheese - 06-18-2011

(06-18-2011, 09:37 PM)Tanshaydar Wrote: AddDebugMessage(string& asString, bool abCheckForDuplicates);
For this and more: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

Simply, add a:
Code:
AddDebugMessage("Debug Message: Area Collided! Now ScaryDude must be activated!", false);
or something like this in your CollidePlayerWithMonsterDoor function, and when starting the map, check the "Show Debug Messages" in debug menu.

Like this?

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}
void CollidePlayerWithMonsterDoor (string &in asParent, string &in asChild, int alState)
AddDebugMessage("Debug Message: Area Collided! Now ScaryDude must be activated!", false);
{
SetEntityActive("Scarydude", true);
ShowEnemyPlayerPosition("Scarydude");    
FadeRadialBlurTo(1.0f, 1.0f);
PlaySoundAtEntity("MonsterDoor", "react_scare.snt", "Player", 0.0f, true);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

It's not working if I do that, maybe the area doesn't collide after all... If that is the case, how could I make it collide with the player?

(Damn this is turning into a big thread for one simple script Big Grin)



RE: Need some help with this script.... - Doctorcheese - 06-19-2011

Ok so I made a new script, I'm trying to replicate the scene where you encounter a grunt at the
Spoiler below!
stair in the prison from Amnesia

I had a look at their script file and here's how I changed it a bit:
(The area is now called ScriptArea_1 and the grunt(placeholder) is called servant_grunt_1.)

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
//GRUNT WHEN PASSING THE SCRIPT AREA
void CollideAreaScriptArea_1(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("servant_grunt_1", true);
    
    AddTimer("scare", 1.0f, "TimerPlayerReact");
    AddTimer("breath", 3.0f, "TimerPlayerReact");
    AddTimer("breathl", 5.0f, "TimerPlayerReact");
    
    ShowEnemyPlayerPosition("servant_grunt_1");
}

Any errors here? If there are no errors it must be the Area that is not colliding, in that case how do I make it collide with the player?


RE: Need some help with this script.... - rojkish - 06-19-2011

void OnStart()
{
AddEntityCollideCallback("Player","MonsterDoor","CollidePlayerWithMonsterDoor");
}

At this ^ you missed both bool abDeleteOnCollide & int alStates, making it correctly would be;

"AddEntityCollideCallback("Player","MonsterDoor","CollidePlayerWithMonsterDoor", true, 1);"

You've also missed float afFadeTime on the playsoundatentity, making it correctly would be;

"PlaySoundAtEntity("MonsterDoor", "react_scare", "Player", 0.0, false);"

Other than that there is nothing wrong with the script overall and it should work. In case it doesn't I'll just redo it all for you.

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}



void CollidePlayerWithMonsterDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Scarydude", true);
FadeRadialBlurto(1.0f, 1.0f);
PlaySoundAtEntity("MonsterDoor", "react_scare", "Player", 0.0, false);
ShowEnemyPlayerPosition("Scarydude");
}





RE: Need some help with this script.... - Tanshaydar - 06-19-2011

Debug Message doesn't work because you put it in wrong place. Try to put it after '{'


RE: Need some help with this script.... - Doctorcheese - 06-19-2011

Ok so now it's like this:
Code:
void OnStart()
{
AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}
void CollidePlayerWithMonsterDoor(string &in asParent, string &in asChild, int alState)
{
AddDebugMessage("Debug Message: Area Collided! Now ScaryDude must be activated!", false);
}
SetEntityActive("Scarydude", true);
FadeRadialBlurto(1.0f, 1.0f);
PlaySoundAtEntity("MonsterDoor", "react_scare", "Player", 0.0, false);
ShowEnemyPlayerPosition("Scarydude");
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

Anything wrong? What I think might be wrong is the debug messages place in the script, I think I put it in the wrong place since it's not working at all.


RE: Need some help with this script.... - Tanshaydar - 06-19-2011

Code:
void OnStart()
{
      AddEntityCollideCallback("Player", "MonsterDoor", "CollidePlayerWithMonsterDoor", true, 1);
}
void CollidePlayerWithMonsterDoor(string &in asParent, string &in asChild, int alState)
{
     AddDebugMessage("Debug Message: Area Collided! Now ScaryDude must be activated!", false);
     SetEntityActive("Scarydude", true);
     FadeRadialBlurto(1.0f, 1.0f);
     PlaySoundAtEntity("MonsterDoor", "react_scare", "Player", 0.0, false);
     ShowEnemyPlayerPosition("Scarydude");
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}



RE: Need some help with this script.... - Doctorcheese - 06-19-2011

Well it didn't show me any debug messages this time, (used Tanshaydars script) I guess it doesn't collide with the player (the area)
How can I make it collide?


RE: Need some help with this script.... - Tanshaydar - 06-19-2011

Are you sure "show debug messages" is checked in debug menu? (F1)


RE: Need some help with this script.... - Doctorcheese - 06-19-2011

(06-19-2011, 06:16 PM)Tanshaydar Wrote: Are you sure "show debug messages" is checked in debug menu? (F1)

Mmhm, it's checked all right.

But you can close the thread though, I remade the scene so I'll script it some other time Tongue There might be something wrong in my settings that prevent the scripts from working or something like that...