Frictional Games Forum (read-only)
Shake Function - 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: Shake Function (/thread-26280.html)



Shake Function - Carlos2295 - 09-23-2014

Hi there, I was working on a custom story and I was wondering how I would make the screen shake, sort of like when the shadow roars. I used the wiki and made this code, however, it doesn't work when run. Any suggestions would be really appreciated. Here's what I've got so far:

PHP Code:
void OnStart()
{
    
AddUseItemCallback("OpenDoor""librarykey""level_wood_3""UnlockLevelDoor"true);
    
AddEntityCollideCallback("Player""PlayerCollide""ShakeFunction"true1); 
}
void OnEnter()
{
    
PlayMusic("02_amb_safe.ogg"true0.91.01true);
}
void OnLeave()
{
    
StopMusic(1);
}
void UnlockLevelDoor(string &in itemstring &in entity)
{
    
SetLevelDoorLocked(entityfalse);
    
AddPlayerSanity(100);
    
RemoveItem("librarykey");
    
CompleteQuest("""LibraryDoorQuest");
}
void memento(string &in asEntity)
{
    
AddQuest("""LibraryDoorQuest");
}
void ShakeFunction()
{
    
StartScreenShake(1,2,1,4);




RE: Shake Function - FlawlessHappiness - 09-23-2014

The reason it's not working is because you're not calling the function "ShakeFunction" anywhere.

IGNORE THIS! READ MUDBILL'S ANSWER INSTEAD

Spoiler below!

If that's not calling, nothing inside it will call either.
Question is: When do you want the shake to start?


We can quickly make it start by making ShakeFunction into a timer.
PHP Code:
void OnStart()
{
AddTimer(""4"ShakeFunction");
}

void ShakeFunction(string &in asTimer)
{
StartScreenShake(1,2,1,4);


I hope you understand.




RE: Shake Function - Mudbill - 09-23-2014

Because your ShakeFunction is a collision callback, you need the proper parameters to match, or else it's not recognized. This is written in the syntax below the collide function on the script page.

PHP Code:
void ShakeFunction(string &in asParentstring &in asChildint alState



RE: Shake Function - FlawlessHappiness - 09-23-2014

(09-23-2014, 07:07 AM)Mudbill Wrote: Because your ShakeFunction is a collision callback, you need the proper parameters to match, or else it's not recognized. This is written in the syntax below the collide function on the script page.

PHP Code:
void ShakeFunction(string &in asParentstring &in asChildint alState

Oh right! haha I didn't see that it was a collision callback! Good catch Wink


RE: Shake Function - Mudbill - 09-23-2014

^
Hehe, I almost feel like I'm competing with you here these days xD