Hi,
I have worked through the wiki example with a quest giver with a quest to clear a hut of a handfull of monsters and am currently just trying to tidy it up a little.
One of the features I'm trying to implement is a locked door. I have set the initial state of the door to locked easily enough and I have written as script which I think will work but I do not know which event is fired when a PC tries to open a locked door, does anyone here know?
Regards
Paul
Unlocking a locked door
Débuté par
Halchek
, déc. 12 2009 12:06
#1
Posté 12 décembre 2009 - 12:06
#2
Posté 12 décembre 2009 - 02:30
SInce doors are a special type of placeable, I believe you want EVENT_TYPE_UNLOCKED, or EVENT_TYPE_FAILTOOPEN, or EVENT_TYPE_USE. Maybe EVENT_TYPE_PLACEABLE_ONCLICK too.
Modifié par Axe_Murderer, 12 décembre 2009 - 02:35 .
#3
Posté 12 décembre 2009 - 02:51
I've tried those events with no luck, I beginning to think the problem is more fundamental as it appears as if the event isn't actually firing.
Could someone please give me a quick 101 on how to link a door being clicked to it calling the relavent script file as I'm completely lost.
Regards
Paul
Could someone please give me a quick 101 on how to link a door being clicked to it calling the relavent script file as I'm completely lost.
Regards
Paul
#4
Posté 12 décembre 2009 - 07:59
It would help if I knew exactly what you were trying to do.
If what you want is a door unlocked with the lockpicking skill or a door unlocked with a key, then you don't need a custom script. You can set the lockpicking difficulty and the key tag in the door's properties. Keys can be any type of item, so long as the tag matches. The default script will handle the rest.
If you want the door to be unlocked by something else, like a lever or whatever, then you'll want something like this, run from within the same area:
object oDoor = GetObjectByTag("my_door");
SetPlaceableState(oDoor, PLC_STATE_DOOR_UNLOCKED*);
*not certain on the exact naming of this constant, going from memory.
If what you want is a door unlocked with the lockpicking skill or a door unlocked with a key, then you don't need a custom script. You can set the lockpicking difficulty and the key tag in the door's properties. Keys can be any type of item, so long as the tag matches. The default script will handle the rest.
If you want the door to be unlocked by something else, like a lever or whatever, then you'll want something like this, run from within the same area:
object oDoor = GetObjectByTag("my_door");
SetPlaceableState(oDoor, PLC_STATE_DOOR_UNLOCKED*);
*not certain on the exact naming of this constant, going from memory.
Modifié par DavidSims, 12 décembre 2009 - 07:59 .
#5
Posté 13 décembre 2009 - 08:32
Hi DavidSims,
I found the problem. My door is in fact an Area Transition that look like a door, genip_at_normal, and it doesn't have a key tag hence my confusion. I'll have a play around with the normal doors and invisible area transitions and see what I get.
Originally I was convinced that trying to open a locked door would fire an event which I could catch and test for a key or quest status in. This, I think, would match your second solution of opening a door with a lever or some such but my knowledge of scripting is as such that I've had no luck creating a script that fires when a door is clicked, could anyone point me to a resource on this as I'm sure it's likely to come up again.
Regards
Paul
I found the problem. My door is in fact an Area Transition that look like a door, genip_at_normal, and it doesn't have a key tag hence my confusion. I'll have a play around with the normal doors and invisible area transitions and see what I get.
Originally I was convinced that trying to open a locked door would fire an event which I could catch and test for a key or quest status in. This, I think, would match your second solution of opening a door with a lever or some such but my knowledge of scripting is as such that I've had no luck creating a script that fires when a door is clicked, could anyone point me to a resource on this as I'm sure it's likely to come up again.
Regards
Paul
#6
Posté 13 décembre 2009 - 08:55
Even with an area transition you shouldn't need a custom script - just create a key and enter its tag as the key tag of the area transition.
As for making a script - you should be able to get an idea of where to start from the placeable template script.
As for making a script - you should be able to get an idea of where to start from the placeable template script.
- Create and open a new script
- In the upper right, select the Templates button
- Double click Custom placeableevent.txt
- Look under EVENT_TYPE_USE
#7
Posté 13 décembre 2009 - 09:53
Craig
I'm being particularily dense this week and see what you mean now. For some reason I was just using genip_at_normal rather than deriving a sub type of it hense the key tag property was never visible.
Everythings working as expected now, thanks matey.
Thanks for the heads-up on the templates, I've had a quick look at them and I can see they'll be a valuable resource in future.
Regards
Paul
I'm being particularily dense this week and see what you mean now. For some reason I was just using genip_at_normal rather than deriving a sub type of it hense the key tag property was never visible.
Everythings working as expected now, thanks matey.
Thanks for the heads-up on the templates, I've had a quick look at them and I can see they'll be a valuable resource in future.
Regards
Paul
#8
Posté 02 février 2010 - 08:50
Can anyone tell me how to make an npc give you a key after a conversation? It's already in his inventory and compatible with the door. Thanks in advance.
#9
Posté 03 février 2010 - 01:41
Halchek, can you give me the link to the wiki example you mentioned? I saw it before, but can't seem to find it anymore.
#10
Posté 03 février 2010 - 04:29
Mysticyx wrote...
Can anyone tell me how to make an npc give you a key after a conversation? It's already in his inventory and compatible with the door. Thanks in advance.
Create a plot flag in a plot with a custom script. Set the plot flag on the last line of the conversation. In the action handler for that plot flag, put something like this:
object oItemOwner = GetObjectByTag("creature_tag");
object oItem = GetItemPossessedBy(oItemOwner, "item_tag");
MoveItem(oItemOwner, GetHero(), oItem);
If the key has been pickpocketed, the above won't transfer anything, becuase the creature doesn't have it any more. If that's not desirable for whatever reason, you could use UT_AddItemToInventory to create one in the player's inventory no matter what. If you can't kill the creature and loot the key, or pickpocket the key, there's really no reason to put it on the creature to begin with so you don't have to move or get rid of it. Otherwise, use UT_RemoveItemFromInventory to get rid of the creature's version of the key.
#11
Posté 03 février 2010 - 04:51
Thank you very much.





Retour en haut






