Frictional Games Forum (read-only)
[SCRIPT] Make an script work when Pick up key? - 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] Make an script work when Pick up key? (/thread-16108.html)



Make an script work when Pick up key? - SilentHideButFine - 06-13-2012

Hey!! Smile

I wanna know how i make like this

You are in the first room(there are 2) the script is on the door BUT the door script is gonna work when pickup key and enter area?

any tip clue?


RE: Make an script work when Pick up key? - No Author - 06-13-2012

Use

SetEntityPlayerInteractCallback(string&
asName, string& asCallback, bool abRemoveOnInteraction);

I think.

Sorry for the text size [Image: smile.gif]. It was small when i typed.


RE: Make an script work when Pick up key? - SilentStriker - 06-13-2012

nope it's AddUseItemCallback, RemoveItem, SetSwingDoorLocked and PlaySoundAtEntity. I'm writing this on my phone so the codes might be a little wrong

If you are supposed to unlock the door with the key, if its just going to open without the key then its SetEntityPlayerInteractCallback


RE: Make an script work when Pick up key? - Mackiiboy - 06-13-2012

If you want something to happen when you pick up the key, you will need to use this:

void OnStart()
{
SetEntityCallbackFunc("name_of_your_key", "PickUpKeyFunc");
}

void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
// Put everything you want to happen here after you have picked up your key.
}
}

So, if you have a script area that is inactive in the level editor and want to be active, you could put a SetEntityActive("Your_Script_Area", true); inside the PickUpKeyFunc.


RE: Make an script work when Pick up key? - SilentHideButFine - 06-13-2012

(06-13-2012, 08:32 AM)Mackiiboy Wrote: If you want something to happen when you pick up the key, you will need to use this:

void OnStart()
{
SetEntityCallbackFunc("name_of_your_key", "PickUpKeyFunc");
}

void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
// Put everything you want to happen here after you have picked up your key.
}
}

So, if you have a script area that is inactive in the level editor and want to be active, you could put a SetEntityActive("Your_Script_Area", true); inside the PickUpKeyFunc.
When pick up key you are supposed to go out but when you come like 2 m away from the door the doors opens by it self Smile



void PickUpKeyFunc(string &in entity, string &in type)
{
if(type == "OnPickup")
{
AddBodyForce("mansion_2", -3.388, 0, 0, "world");
StartPlayerLookAt("mansion_2", 5, 5, "");
PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true);
AddTimer("StopLookAt", 3, "StopLookAtEvent");
}
}
void StopLookAtEvent(string &in asTimer)
{
StopPlayerLookAt();
}

There is the script with funcs
Sound and bodyforce dosnt work only the look at :S


RE: Make an script work when Pick up key? - SilentHideButFine - 06-13-2012

Anyone?


RE: Make an script work when Pick up key? - Mackiiboy - 06-14-2012

(06-13-2012, 10:15 PM)SilentHideButFine Wrote: Anyone?
.
Try an impulse instead of a force on the door:

AddPropImpulse("mansion_2", 50, 0, -50, "world");

You will not hear the sound if it should fade out in 3 seconds, try to put the value 0 instead and it will work just fine.

PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true);


RE: Make an script work when Pick up key? - SilentHideButFine - 06-14-2012

(06-14-2012, 09:41 AM)Mackiiboy Wrote:
(06-13-2012, 10:15 PM)SilentHideButFine Wrote: Anyone?
.
Try an impulse instead of a force on the door:

AddPropImpulse("mansion_2", 50, 0, -50, "world");

You will not hear the sound if it should fade out in 3 seconds, try to put the value 0 instead and it will work just fine.

PlaySoundAtEntity("", "react_scare.snt", "mansion_2", 3, true);
AddPropImpulse("mansion_2", 50, 0, -50, "world"); dosnt work :S want screenshot of the door ?


RE: Make an script work when Pick up key? - Mackiiboy - 06-14-2012

(06-14-2012, 04:17 PM)SilentHideButFine Wrote: AddPropImpulse("mansion_2", 50, 0, -50, "world"); dosnt work :S want screenshot of the door ?
.
Experiment and try different impulse-values (afX & afZ) till' it works. I think the result depends on how you have rotated your door in the level editor, in some cases you will just need to use X-values, some times Z-values, and some times both. You might need to use SetSwingDoorDisableAutoClose("mansion_2", true); as well to deactivate the auto-close-thing when a door is nearly closed.
-------
You could use propforces as well as propimpulses, but you will need higher values when you use forces.