Aller au contenu

Photo

How to make a card reader to open a door...


  • Veuillez vous connecter pour répondre
23 réponses à ce sujet

#1
DukeVega

DukeVega
  • Members
  • 205 messages

Hail fellow NWN nerds i need your help once again

 

So i need to make like a machine that opens and closes a door

 

 

idea is from Xenoarms II to be fair they had an okay system...

 

 

 

In front of door is a small machine

> player has a i.d card in their inventory

 

 

Player could either drop the item into the machine and door opens for 10 seconds / then closes

 

or it could be a conversation thing i guess.

 

 

 

Anyway whats your thoughts?

 

 

 

Regards,

 

 

Duke

www.projectgaming,net



#2
Tchos

Tchos
  • Members
  • 5 042 messages

You can make any placeable usable with the "Usable" box in its properties, and also the "Static" box must not be selected.  Then you just place your script into the On Used slot of the placeable's properties, and you can have anything happen, like waiting a few seconds, opening a door, and/or removing the card.  I prefer that way over the conversation method.



#3
DukeVega

DukeVega
  • Members
  • 205 messages

any chance you could make me a script plz? i can work out to edit the variables after i am sure ;)



#4
Jezla

Jezla
  • Members
  • 173 messages

Duke, you could use Lilac soul's script generator for this.  Just enter the options to check for a specific item (the key card), and then do an action (open the door).  If this is all you need, it's not that complicated, and you'll be better served by learning how to do it, rather than asking people to write scripts for you.



#5
DukeVega

DukeVega
  • Members
  • 205 messages

godam it jim im a mapper not a scripter!!!! .. .err and my conversations aint too bad.

 

 

 

 

kk ill try using lilacs

 

 

 

Should the doors be locked? then the card unlock, opens, wait 20 seconds .. close ... lock  - return card ?



#6
Tchos

Tchos
  • Members
  • 5 042 messages

Yeah, Jezla's right.  All of that can be done with Lilac's.  Creates made-to-order scripts with a few clicks.  Just tell it each of those things that you want it to do.  You can either take away the card and then give it back, or just leave the card in the player's inventory.



#7
DukeVega

DukeVega
  • Members
  • 205 messages

Bit of help please.,

 

 

okay so i made this script using lilac's which kinda works, but its ignoring the "key" and works without it ...

any ideas why please?

 

 
void main()
{
    object oTarget;
 
    // Get the creature who triggered this event.
    object oPC = GetLastUsedBy();
 
    // Unlock and open "labdoor1".
    oTarget = GetObjectByTag("labdoor1");
    SetLocked(oTarget, TRUE);
    AssignCommand(oTarget, ActionOpenDoor(oTarget));
 
    // Setting the requirement for a specific key to unlock "labdoor1".
    SetLockKeyRequired(oTarget);
    SetLockKeyTag(oTarget, "tcm_scientist_id_card1");
 
    // Close and lock "labdoor1".
    DelayCommand(8.0, SetLocked(oTarget, TRUE));
    DelayCommand(8.0, AssignCommand(oTarget, ActionCloseDoor(oTarget)));
 
    // Setting the requirement for a specific key to unlock "labdoor1".
    SetLockKeyRequired(oTarget);
    SetLockKeyTag(oTarget, "tcm_scientist_id_card1");
}


#8
Jezla

Jezla
  • Members
  • 173 messages

You don't need to worry about setting the key requirements via script.  These are the options you should select when creating the script with the wizard (roughly):

 

Normal script--> called when PC uses something --> other restrictions ---> item restrictions --->door functions (unlock, open, close, lock).  It's not every single step, but you should be able to find your way.  Try it and see how the script looks.

 

As far as the door placeable goes, make sure the blueprint is set to locked, key required (but no tag specified), and plot.  Oh, and don't forget to give it an interesting description that explains how to open it!

 

Edit - clarified the door placeable settings.


  • DukeVega aime ceci

#9
DukeVega

DukeVega
  • Members
  • 205 messages

mmm i have done all of this but it still opens without me needing to have the key in my inventory...



#10
DukeVega

DukeVega
  • Members
  • 205 messages

actually its the restriction bit im failing on,, let me re-try



#11
Jezla

Jezla
  • Members
  • 173 messages

Right after you select where the script is called from it will ask you if you want it to fire under certain conditions.  Select yes, then select other restrictions. 


  • DukeVega aime ceci

#12
kevL

kevL
  • Members
  • 4 056 messages

i think its simpler than yer thinking ...

would this work :
 

// 'dv_cardlock.nss'
//
// Place in *locked* door's OnUsed event slot.
// - door must have hitpoints, be non-static and Usable.
// - flag "key required" without a key-tag to make the door unpickable (tks to Jezla)
// - flag Plot to make the door indestructible.


// sCard = tag of the card that unlocks this door.

void main()
{
    object oPC = GetLastUsedBy();
    object oCard = GetItemPossessedBy(oPC, "tag_of_card");

    if (!GetIsObjectValid(oCard))
    {
        SendMessageToPC(oPC, "This door is locked and appears to require a special card to open.");
        return;
    }

    // automatic open:
    SetLocked(OBJECT_SELF, FALSE);
    ActionOpenDoor(OBJECT_SELF);

    // automatic close:
    DelayCommand(8.f, ActionCloseDoor(OBJECT_SELF));
    DelayCommand(8.f, SetLocked(OBJECT_SELF, TRUE));
}

Modifié par kevL, 17 juin 2014 - 10:39 .


#13
Tchos

Tchos
  • Members
  • 5 042 messages

Not sure if that script will work if placed on a door as it says to do.  Normally door scripts are placed in On Fail To Open, or On Click.  I actually prefer having the card reader be separate from the door anyway, though.



#14
kevL

kevL
  • Members
  • 4 056 messages

onClick be better yeah. I didn't test it, just tossing it out here.

 

( will edit the notes w/ feedback ... )



#15
DukeVega

DukeVega
  • Members
  • 205 messages

FML yeh i cant get these to work, using lilacs i got it to kinda work as mentioned earlier, but the restriction line seems to **** things up

 

 

   // Abort if the PC does not have the item "tcm_scientist_id_card1".
    if ( GetItemPossessedBy(oPC, "tcm_scientist_id_card1") == OBJECT_INVALID )
        return;
 
 
 
 
 
tcm_scientist_id_card1 - is the item TAG, this is correct ?


#16
Tchos

Tchos
  • Members
  • 5 042 messages

You need to set the door as locked on the object itself, not on the script.  Your script says:

SetLocked(oTarget, TRUE);

That's telling it to lock the door when you use it with the key card.  You don't want that.  It should be SetLocked(oTarget, FALSE);

 

And remove these lines, as Jezla said.  Both times they appear:

    // Setting the requirement for a specific key to unlock "labdoor1".
    SetLockKeyRequired(oTarget);
    SetLockKeyTag(oTarget, "tcm_scientist_id_card1");
 
tcm_scientist_id_card1 - is the item TAG, this is correct ?

 

If that's what you set the card's tag to be, then yes.  (It's not an acronym, so don't write "tag" in all-caps).

 

 

You need to make sure there's only one object in the world with the tag "tcm_scientist_id_card1", and only one door in the world with the tag "labdoor1".



#17
DukeVega

DukeVega
  • Members
  • 205 messages
/* 
 *  Script generated by LS Script Generator, v.TK.0
 *
 *  For download info, please visit:
 */
// Put this script OnUsed.
 
 
void main()
{
    object oTarget;
 
    // Get the creature who triggered this event.
    object oPC = GetLastUsedBy();
 
    // Abort if the PC does not have the item "tcm_scientist_id_card1".
    if ( GetItemPossessedBy(oPC, "tcm_scientist_id_card1") == OBJECT_INVALID )
    {
        SendMessageToPC(oPC, "*You need a Security Pass to Open this Door*");
        return;
    }
 
    // Unlock and open "labdoor1".
    oTarget = GetObjectByTag("labdoor1");
    SetLocked(oTarget, FALSE);
    AssignCommand(oTarget, ActionOpenDoor(oTarget));
 
    // Close and lock "labdoor1".
    DelayCommand(8.0, SetLocked(oTarget, TRUE));
    DelayCommand(8.0, AssignCommand(oTarget, ActionCloseDoor(oTarget)));
}
 
 
 
 
 
 
 
 
THIS WORKS ON THE DOOR, not sure what you think of the code used ?


#18
DukeVega

DukeVega
  • Members
  • 205 messages

oh weird this ~ONLY works on the "I fail to open"  script option



#19
Corvittin

Corvittin
  • Members
  • 23 messages

as you can see its basic
door tag = door which is locked one

spoon tag = key card that opens the door

***importante*** placeable must have some hitpoints for beeing usable... in case of using CC

place a placeable near door as a card reader and make an item tagged "spoon" which is presenting card.

this script must be on card readers onuse. and everyting will fine.... just give me some more beer thats all....

 

 

 

void main()
{
    object oTarget=GetObjectByTag("door");
    object oPC = GetLastUsedBy();
    object oCard = GetItemPossessedBy(oPC, "spoon");
 
 if (!GetIsObjectValid(oCard))
    {
        ActionSpeakString("This door is locked and appears to require a special card to open.");
        return;
    }

    SetLocked(oTarget, FALSE);
    AssignCommand(oTarget, ActionOpenDoor(oTarget));
    DelayCommand(8.f, ActionCloseDoor(oTarget));
    DelayCommand(8.f, SetLocked(oTarget, TRUE));    
}



#20
Corvittin

Corvittin
  • Members
  • 23 messages

and yes tchos is right door must be locked and plot and unlockable...



#21
DukeVega

DukeVega
  • Members
  • 205 messages

wahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh its not working, could be the placeable im trying to use not sure.

im going bed well continue this 2morow lol



#22
Corvittin

Corvittin
  • Members
  • 23 messages

anyways i uploaded doortest.mod to DB folder


  • DukeVega aime ceci

#23
DukeVega

DukeVega
  • Members
  • 205 messages

ywyy works finally, was an issue with the object i was trying to use .. changed the object and then changed model ,works ;)



#24
Chass

Chass
  • Members
  • 50 messages

If your interested. still. 

 

 

We decided to give out our precious scriptsets for a more modern/futuristic PW. Bear in mind these are in NWN1 format. I'm sure you know how to edit placeables and items in NWn2 and change them to reflect NWN2 standards.

in this package it includes:

  • Xenograph Arms Door Card Reader
  • Xenograph Arms Elevators
  • Xenograph Arms Explode-ables - C4
  • Xenograph Arms Job Work Terminal
  • Xenograph Arms Social Security - ATM Machines

 

 http://worldofisandor.wildcardstudios.org/download/D20.rar

 

These packs originate from the NWN1 version. you just need to change the models to suit (I.e the Explodeables and terminals)