Frictional Games Forum (read-only)
Script Problem.. Crowbar and open hatch. - 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 Problem.. Crowbar and open hatch. (/thread-39922.html)



Script Problem.. Crowbar and open hatch. - sabrinagsoledad - 02-22-2016

HI.

I saw a video guide about how to write the script for using crowbar with all the effects...
In my case is not a door its a hatch...(kind of...) the item im using is hatch_metal01...because cealing hatch(the one i wanted) it never got locked.

When i enter to the game... nothing hapens.. the crowbar does nothing.

Here is my script... (my level items has the same names as the ones in the script, so there isnt a wrong name issue...

At first in "AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", instead of ScriptArea_1, was the name of the door item... that was hatch_1.... but it didnt work, so the one that make the guide told me that with some entitys u cant interact, so i could try to change hatch_1 to ScriptArea_1...
In both ways it dont work. Please what i should do?... (I also check the "script areas" position and the ScriptArea_1 is huge and just below the hatch).

Just to know... "crowbar_1" is the pickup crowbar, "joint" is a crowbar that appear stuck in the door the one i will move, and "brokencrowbar" is the one in two parts that will fall.


void OnStart()
{
AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", "UseCrowbarOnDoor", true);
AddEntityCollideCallback ("joint", "ScriptArea_1", "BreakHatch", true, 1);
}

void UseCrowbarOndoor(string &in asItem, string &in asEntity)
{
RemoveItem("crowbar_1");
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");
}

void TimerPlaceCrowbar (string &in asTimer)
{
SetEntityActive("joint", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}

void BreakHatch(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("joint", false);
SetEntityActive("brokencrowbar", true);
SetSwingDoorLocked("hatch", false, false);
SetSwingDoorClosed("hatch", false, false);
SetSwingDoorDisableAutoClose("hatch", true);
AddPropImpulse("hatch", 0, -3, 0, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
PlaySoundAtEntity("", "break_wood_metal.snt", "AreaEffect", 0, false);
GiveSanityBoostSmall();
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
AddTimer ("", 0.1, "TimerPushHatch");
}

void TimerPushHatch (string &in asTimer)
{
AddPropImpulse("hatch", 0, -2, -1, "world");
AddTimer ("", 1.1, "TimerHatchCanClose");
}

void TimerHatchCanClose (string &in asTimer)
{
SetSwingDoorDisableAutoClose("hatch", false);
}



Thanks for the attention.


RE: Script Problem.. Crowbar and open hatch. - Spelos - 02-23-2016

[Image: rqRK3oA.png]

Hope this solves your problem.


RE: Script Problem.. Crowbar and open hatch. - sabrinagsoledad - 02-23-2016

Hi..
I didnt have those activated... but still isnt working TT it could be the item used? i mean the door entity?


RE: Script Problem.. Crowbar and open hatch. - Spelos - 02-23-2016

PHP Code:
AddTimer(asEntity0.2"TimerPlaceCrowbar"); 

That's not a float. You put a double there. Use:

PHP Code:
AddTimer(asEntity0.2f"TimerPlaceCrowbar");

///....

AddTimer (""0.1f"TimerPushHatch");

///...

AddTimer (""1.1f"TimerHatchCanClose"); 

That's for all of your other functions as well..
1.3 is a double
1.3f is a float
THOSE FUNCIONS REQUIRE A FLOAT

PHP Code:
PlaySoundAtEntity("""player_crouch.snt""Player"0.05ffalse); 

Although it should work regardless... =/

I've got it!

The simplest little mistake.

AddUseItemCallback("openhatch", "crowbar_1", "ScriptArea_1", "UseCrowbarOnDoor", true);

void UseCrowbarOndoor(string &in asItem, string &in asEntity)
...


Be sure to copy Function names to avoid this problem.
And let me mention that if you didn't check the ItemInteraction it still wouldn't work.

Fixed code:
PHP Code:
void OnStart()
{
    
AddUseItemCallback("openhatch""crowbar_1""ScriptArea_1""UseCrowbarOnDoor"true);
    
AddEntityCollideCallback ("joint""ScriptArea_1""BreakHatch"true1);
}

void UseCrowbarOnDoor(string &in asItemstring &in asEntity)

    
RemoveItem("crowbar_1");
    
PlaySoundAtEntity("""player_crouch.snt""Player"0.05false);
    
AddTimer(asEntity0.2"TimerPlaceCrowbar");
}

void TimerPlaceCrowbar (string &in asTimer)

    
SetEntityActive("joint"true);
    
PlaySoundAtEntity("""puzzle_place_jar.snt"asTimer0false);
}

void BreakHatch(string &in asParentstring &in asChildint alState
{
    
SetEntityActive("joint"false);
    
SetEntityActive("brokencrowbar"true);
    
SetSwingDoorLocked("hatch"falsefalse);
    
SetSwingDoorClosed("hatch"falsefalse);
    
SetSwingDoorDisableAutoClose("hatch"true);
    
AddPropImpulse("hatch"0, -30"world");
    
CreateParticleSystemAtEntity("""ps_hit_wood.ps""AreaEffect"false);
    
PlaySoundAtEntity("""break_wood_metal.snt""AreaEffect"0false);
    
GiveSanityBoostSmall();
    
PlayMusic("10_puzzle01.ogg"false0.70.110false);
    
AddTimer (""0.1"TimerPushHatch");
}

void TimerPushHatch (string &in asTimer)
{
    
AddPropImpulse("hatch"0, -2, -1"world");
    
AddTimer (""1.1"TimerHatchCanClose");
}

void TimerHatchCanClose (string &in asTimer)
{
    
SetSwingDoorDisableAutoClose("hatch"false);


And I suggest making another Script Area for the crowbar, since I presume the one you have is already in that area and would basically trigger immediately.


RE: Script Problem.. Crowbar and open hatch. - sabrinagsoledad - 02-23-2016

Hi. Thank you so much!.. when i read like 30 times the same thing those damn mistakes wont appear. But now i have another issue, my joint (the crowbar attached) its moving, it lurches from side to side, im trying to moving its position to change that with no luck..

THANKS again!


RE: Script Problem.. Crowbar and open hatch. - Mudbill - 02-23-2016

It might be too close to something else, causing weird collisions. If I understand you correctly, it's jiggering and moving on its own?
Try moving it slightly in the editor. Feel free to post a screenshot.


RE: Script Problem.. Crowbar and open hatch. - sabrinagsoledad - 02-23-2016

here is a picture of their positions., yes it's jiggering and moving on its own


RE: Script Problem.. Crowbar and open hatch. - sabrinagsoledad - 02-25-2016

(02-23-2016, 02:19 PM)sabrinagsoledad Wrote: here is a picture of their positions., yes it's jiggering and moving on its own



-----

I SOLVE IT... its was it position....

Thanks