Recent changes Random page
GAMING
Gaming
 
WoWWiki
Diablo Wiki
Fallout-The Vault
Grand Theft Wiki
Halopedia
StarCraft Wiki
FFXIclopedia
Resident Evil Wiki
See more...

Vault maker

From NWNWiki

Jump to: navigation, search


Contents

[edit] VaultMaker

[edit] What it does

Allows players in single or multiplayer to create their own vaults that no one else can unlock.


[edit] Notes

  • The player uses an item, called here a "VaultMaker" that, when activated, creates an inventory-capable placeable at said player's location that no one else can unlock.
  • The "Vault," upon creation, is given a local variable, a number between 1 and 1,000,000. The player is also given this variable. When any player tries to open a vault, the vault "checks" the player's variable to see if it matches its own. If it does, the vault unlocks. If it does not, it is inaccessible.
  • Once a player creates a vault, he may not create another until the previous vault is destroyed. To create a new vault, the player simply activates the "VaultMaker", and if the player's existing vault is empty, it is destroyed, and a new vault is created at the players location, wherever he may be on activation.

If there are items in the existing vault, the VaultMaker will warn the player that he has items in his existing vault, and advise him that if he wants to destroy it anyway, to use the "VaultMaker" one more time. I should emphasize that if a player activates his VaultMaker when inventory is in his existing vault, the next time he activates it, the existing vault and all of its items are destroyed irrevocably. The vault maker does give fair warning of this however.

  • The player uses the vault itself like this: Upon creation, the vault is unlocked. Once it is closed, it is locked and only the player who created it can open it. The vault alerts the player that it is locked or unlocked. Once it is locked, the player must click the vault twice to access its inventory; once to unlock it, and once to open it. Once it is closed, it will be locked again, but if clicked on again by the owner, it will unlock, BUT NOT OPEN. Because of this I felt it very important to alert the player that his vault is unlocked, and that is in.
  • When non-owners of a vault click on said vault, A floating string appears telling the player who clicked on it who the vault belongs to, i.e "Ateara Steel's Vault. Don't Touch!"

Implimenting these scripts is very, very simple. Simply create a custom item and name it "VaultMaker" on creation -- feel free to change the NAME of said item afterwards. Give the item Cast Spell: Unique Power Self-Only with unlimited uses, and make sure it is identified.

Then create a custom Placeable and call it "Vault". Be sure that this Placeable has "Has Inventory", and "Can Be Relocked" checked, and on the LOCK tab, be sure the "Open Lock DC" is set to 250. Also, if you don't want the chest able to be destroyed by any player or creature, check "Plot Item." Also, take out the scripts that are on it already so it doesn't generate treasure.

[edit] The Script

And finally, place the following scripts in your module

[edit] In "Vault"'s OnUsed

void main()
{
ClearAllActions();
object oPC = GetLastUsedBy();
int nCount = GetLocalInt (OBJECT_SELF, "Count");
int iUserCode = GetLocalInt (oPC, "MyCode");
int iVaultCode = GetLocalInt (OBJECT_SELF, "MyCode");
string sRPGTag = GetLocalString (OBJECT_SELF, "RPG_TAG");
if  (iUserCode ==iVaultCode)
    {
    SetLocked (OBJECT_SELF, FALSE);
    if (GetLocalInt (OBJECT_SELF, "Locked") ==1)
        {
        FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC);
        SetLocalInt (OBJECT_SELF, "Locked", 0);
        }
    }
else if (!(iUserCode ==iVaultCode))
    {
    FloatingTextStringOnCreature (""+sRPGTag+"'s Vault.", oPC);
    }
}

[edit] In "Vault"'s OnClose

void main()
{
object oPC = GetLastUsedBy ();
DelayCommand (0.2, SetLocked (OBJECT_SELF, TRUE));
DelayCommand (0.2, SetLocalInt (OBJECT_SELF, "Locked", 1));
FloatingTextStringOnCreature ("The Vault is Locked", oPC);
}

[edit] In your module's OnActivateItem

void main()
{
int iMyLock = Random (1000000);
object oVaultMaker = GetObjectByTag ("VaultMaker");
object oItem = GetItemActivated();
object oPC = GetItemActivator();
object oOldVault = GetLocalObject (oPC, "HasVault");
object oSlot1 =GetFirstItemInInventory (oOldVault);
location lVault = GetLocation (oPC);
string sRPGTag = GetName (oPC);
if  (oItem ==oVaultMaker)
    {
    if  (!(GetIsObjectValid (oOldVault)))
        {
        CreateObject (OBJECT_TYPE_PLACEABLE, "vault", lVault, FALSE);
        object oVault = GetObjectByTag("Vault");
        SetLocalInt (oVault, "MyCode", iMyLock);
        SetLocalInt (oPC, "MyCode", iMyLock);
        SetLocalString (oVault, "RPG_TAG", sRPGTag);
        SetLocalObject (oPC, "HasVault", oVault);
        FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC);
        }
    if ((GetIsObjectValid (oOldVault)) && !(GetIsObjectValid (oSlot1)) ||
    (GetLocalInt (oPC, "DestroyAnyway") ==1))
        {
        CreateObject (OBJECT_TYPE_PLACEABLE, "vault", lVault, FALSE);
        object oVault = GetObjectByTag("Vault");
        SetLocalInt (oVault, "MyCode", iMyLock);
        SetLocalInt (oPC, "MyCode", iMyLock);
        SetLocalString (oVault, "RPG_TAG", sRPGTag);
        SetLocalObject (oPC, "HasVault", oVault);
        FloatingTextStringOnCreature ("Old Vault Destroyed", oPC);
        DelayCommand (1.5, FloatingTextStringOnCreature ("VAULT UNLOCKED", oPC));
        DestroyObject (GetFirstItemInInventory (oOldVault));
        int a=0;
        while (a<300)
            {
             SetLocalInt (OBJECT_SELF, "Full", 1);
            DestroyObject (GetNextItemInInventory (oOldVault));
            a++;
            }
        DestroyObject (oOldVault);
        SetLocalInt (oPC, "DestroyAnyway", 0);
            }
       else if ((GetIsObjectValid (oSlot1)))
       {
       FloatingTextStringOnCreature ("Your old Vault has items!", oPC, FALSE);
       DelayCommand (1.0, FloatingTextStringOnCreature ("Use VaultMaker again to destroy anyway?", oPC, FALSE));
       SetLocalInt (oPC, "DestroyAnyway", 1);
       }
    }
}
Rate this article:
Share this article: