Frictional Games Forum (read-only)
HasItem scripting 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: HasItem scripting help (/thread-24480.html)

Pages: 1 2


HasItem scripting help - MsHannerBananer - 01-29-2014

Looking over the HasItem script.

Objective is to prevent the player from leaving unless they have a key.

I'm kinda dumb at scripting complicated stuff, and the script for this kind of event isn't working for me.


Code is in the following spoilers.

Spoiler below!

script INSIDE void OnStart:

AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);


Spoiler below!

script OUTSIDE void OnStart

void notyet(string &in asParent, string &in asChild, int alState)
{

if (HasItem("SecretKey") == false)
{
SetMessage("Dialogue", "KateThought_VoiceCheck", 5);
}

if (HasItem("SecretKey") == true)
{
SetEntityActive("block", false);
}

}


The door they leave out of once they've completed the map is blocked by a block box called "block". Once they have the key, the block box is supposed to be set inactive, as shown in the script.

I tried to do this right, and even looked up how other users did it in their custom stories, however I can't seem to get it right. Woe is me, haha.

"SecretlKey" is named as such in the Name field and the CustomSubItemTypeName.


RE: HasItem scripting help - PutraenusAlivius - 01-29-2014

Can you show us the whole script and please re-check the names. See if they don't match. If they don't, match them and check again.

EDIT:
In order to have the script to check the name of the item, it needs to be specified so in the .lang file IIRC.


RE: HasItem scripting help - Daemian - 01-29-2014

PHP Code:
AddEntityCollideCallback("Player""voiceCheck_Area""notyet"true1); 

I think you're just missing the zero instead of 1.


RE: HasItem scripting help - i3670 - 01-29-2014

What is is that isn't working? Is the dialogue not working or is there a problem with the block_box?


RE: HasItem scripting help - MsHannerBananer - 01-29-2014

(01-29-2014, 05:03 PM)Amn Wrote:
PHP Code:
AddEntityCollideCallback("Player""voiceCheck_Area""notyet"true1); 

I think you're just missing the zero instead of 1.

Didn't work. >.<

(01-29-2014, 06:24 PM)i3670 Wrote: What is is that isn't working? Is the dialogue not working or is there a problem with the block_box?

The dialogue works fine, luckily. However once I have the key in my inventory, the check script box doesn't check for it and remove the block box.


RE: HasItem scripting help - FlawlessHappiness - 01-29-2014

AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);

You put the callback true. This means that it only calls once. Then it's deleted. That's why it's not working more than once.


RE: HasItem scripting help - MsHannerBananer - 01-29-2014

I've changed the script and removed the block box, and just make it so the door unlocks once the check box detects if the player has the key and just unlocks the door if they do, however remains locked if they don't.

The script is now this in the .hps (AddEntityCollide etc didn't change.

Spoiler below!

void notyet(string &in asParent, string &in asChild, int alState)
{

if(HasItem("SpecialKey") == false)
{
SetMessage("Dialogue", "KateThought_VoiceCheck", 5);
}

if(HasItem("SpecialKey") == true)
{
SetLevelDoorLocked("hospitalHome", false);
}




I checked, double checked, and triple checked the names between the .lang file and the .hps file. Everything matches up on my end.

(01-29-2014, 10:06 PM)FlawlessHair Wrote: AddEntityCollideCallback("Player", "voiceCheck_Area", "notyet", true, 1);

You put the callback true. This means that it only calls once. Then it's deleted. That's why it's not working more than once.

I figured that out last night. Big Grin Changed it. Still doesn't work. xD


RE: HasItem scripting help - FlawlessHappiness - 01-29-2014

Things to check off now:

- Is the name "SpecialKey" correctly spelled everywhere? Both with capitalizing and grammar? ALSO in the editor!
- Did you remember the last } in the "notyet" function?
- Instead of unlocking the door, just try playing a sound, to see if anything is actually calling, or even better, call an AddDebugMessage("Message", false);


RE: HasItem scripting help - MsHannerBananer - 01-29-2014

(01-29-2014, 10:18 PM)FlawlessHair Wrote: Things to check off now:

- Is the name "SpecialKey" correctly spelled everywhere? Both with capitalizing and grammar? ALSO in the editor!
- Did you remember the last } in the "notyet" function?
- Instead of unlocking the door, just try playing a sound, to see if anything is actually calling, or even better, call an AddDebugMessage("Message", false);

Spelled correctly everywhere via copy and paste.

The last } is present.

I tried changing it to a sound, didn't work, then used the AddDebugMessage("Message", false); . Neither of them worked. I don't think the function is actually calling. Which now begs the question... now what? LOL


RE: HasItem scripting help - FlawlessHappiness - 01-30-2014

Ok. So this is how it works right now.

You pass the script box without any key.
- The dialogue appears.
You pass the script box with a key
- Does the dialogue still appear?

If it does then something is wrong with your key, because it's not getting that you have "SpecialKey".