Jump to content


Photo

How to check if an item exists in the game?


2 replies to this topic

#1 BCaesar

BCaesar
  • Members
  • 13 posts
  • Gender:Male

Posted 13 May 2017 - 10:07 PM

Hello all,

         I have the following issue. I'm working on scripts to create Hexxat's bag (Dragomir's Respite) if she dies before giving it to you, and then to allow you to stake her and have a dead Clara rejoin your party once you have the bag. It takes an astounding number of scripts to have this work right in every case because Hexxat is complicated (and invincible). So far I have a script that works in every possible situation I've tested, no matter how improbable, except one.

 

           If you accept Hexxat into your party and you have already picked up Dragomir's Cloak, and you then give Hexxat the cloak when she asks about it, and then talk her into joining your party, and then you remove her from your party during that minute before she gives you her bag, and then you kill her before she escapes the area then the trigger for creating the bag doesn't work (the top script in the list). It still triggers the overhead dialogue ("You defeat the vampire, but she transforms into mist and quickly disappears. All that remains where she stood is an old sack."), but it doesn't create the bag on the ground where she died.

 

          In all other cases I've tested that script works to create the bag. If you fight her before she joins you and kill her it works. If you talk her into joining and then kill her while she's a party member and then remove her it works. If she escapes to the Copper Coronet and never joins your party and you meet her there and kill her it works. But I would like something that works 100% of the time no matter how the player decides to go about it. Any ideas?

 

            My thought was if I can have a script to check if the bag exists then I could make a back-up script to create it in Player one's inventory if done the first script but the bag didn't get created. I tried using !Exists("OHHBAG")

 

Here's the script:

IF    //Script to create the bag if Hexxat dies.
    OR(2)
        Dead("hexxat")
        StateCheck("hexxat",STATE_DEAD)
    !PartyHasItem("OHHBAG")
    Global("_bHexxatBag","GLOBAL",0)
    !InPartyAllowDead("hexxat")
    !Global("OHH_dragorespite","GLOBAL",3)
THEN
    RESPONSE #100
    GiveItemCreate("OHHBAG","hexxat",0,0,0)
    ActionOverride("hexxat",DropInventory())
    SetGlobal("_bHexxatBag","GLOBAL",1)
    SetGlobal("OHH_dragorespite","GLOBAL",3)
    ActionOverride(Player1,DisplayStringNoNameHead(Player1,@1)) /*You defeat the vampire, but she transforms into mist and quickly disappears. All that remains where she stood is an old sack.*/
END


IF    //Script to put Hexxat inside the casket when she dies if she didn't yet give the bag to you. This would trigger after you pick up the bag.
    PartyHasItem("OHHBAG")
    StateCheck("hexxat",STATE_DEAD)
    OR(2)
        Global("_bHexxatBag","GLOBAL",0)
        Global("_bHexxatBag","GLOBAL",1)
    Global("_bHexxatDeadCasketTransform","GLOBAL",0)
THEN
    RESPONSE #100
    ActionOverride(Player1,TakePartyItem("OHHBAG"))
    ActionOverride(Player1,TransformItem("ohhcask","_bcask2"))
    SetGlobal("_bHexxatDeadCasketTransform","GLOBAL",1)
END


IF    //If you have the bag and hexxat is dead, but you don't have a stake.
    OR(2)
        PartyHasItem("OHHBAG")
        Exists("OHHBAG")
    !InPartyAllowDead("hexxat")
    Dead("hexxat")
    OR(2)
        Global("_bHexxatBag","GLOBAL",0)
        Global("_bHexxatBag","GLOBAL",1)
    !PartyHasItem("MISC6W")
THEN
    RESPONSE #100
    SetGlobal("_bHexxatBag","GLOBAL",2)
    ActionOverride(Player1,DisplayStringNoNameHead(Player1,@2)) /*The vampire is regenerating in her casket inside the old sack. If you had a stake you could end her life forever.*/
    ActionOverride(Player1,TakePartyItem("OHHBAG"))
    ActionOverride(Player1,TransformItem("ohhcask2","_bcask2"))  //Prevents her from coming back.
END


IF    //If you have the bag and hexxat is dead and not in the party, and you have a stake.
    PartyHasItem("OHHBAG")
    !InPartyAllowDead("hexxat")
    Dead("hexxat")
    OR(3)
        Global("_bHexxatBag","GLOBAL",0)
        Global("_bHexxatBag","GLOBAL",1)
        Global("_bHexxatBag","GLOBAL",2)
    PartyHasItem("MISC6W")
THEN
    RESPONSE #100
    SetGlobal("_bHexxatBag","GLOBAL",3)
    ActionOverride(Player1,DisplayStringNoNameHead(Player1,@3)) /*You drive a stake through the vampire's heart ending her existence. With the vampire destroyed, her victim can be raised.*/
    TakePartyItem("MISC6W")
    AddexperienceParty(12000)
    ActionOverride(Player1,TakePartyItem("OHHBAG"))
    ActionOverride(Player1,TransformItem("ohhcask2","ohhcask"))
    ActionOverride(Player1,TransformItem("_bcask2","ohhcask"))
    AddJournalEntry(@4,USER) /*Dragomir's Tomb was a trap. The one I knew as Hexxat was a thrall under the control of a vampire, one who wished to speak with me. But I do not treat with monsters. I have killed the vampire and freed this girl's soul. Hopefully she will be better at making conversation now.*/
    SetGlobal("_bClaraLives","GLOBAL",1)
END
    

IF    //Script to add Clara to your party once Hexxat is dead.
    Dead("hexxat")
    Global("_bClaraLives","GLOBAL",1)
    !InPartyAllowDead("hexxat")
THEN
    RESPONSE #100
    SetGlobal("_bClaraLives","GLOBAL",2)
    CreateCreature("_bClara",[-1.-1],N)
    ActionOverride("_bClara",JoinParty())
END


IF    //Bug fix for killing Fake Hexxat if Hexxat doesn't in their cutscene.
    Global("OHH_hexxat","OH7000",3)
    !Dead("OHHFAK")
THEN
    RESPONSE #100
    Kill("OHHFAK")
END


IF    //Script to allow you to kill Hexxat if she's not in the party (normally she's invulnerable)
    HPLT("hexxat",2)
    !InPartyAllowDead("hexxat")
THEN
    RESPONSE #100
    Kill("hexxat")
END   


Edited by BCaesar, 13 May 2017 - 10:08 PM.


#2 Avenger

Avenger
  • Modders
  • 3694 posts
  • Gender:Male
  • Location:Hungary

Posted 13 May 2017 - 10:37 PM

    GiveItemCreate("OHHBAG","hexxat",0,0,0)
    ActionOverride("hexxat",DropInventory())

 

Doesn't work on dead creatures.

 

What if you create the bag in the mist form?

 

There is no trigger to check if an item exists in the area or such.  :(



#3 Roxanne

Roxanne
  • Modders
  • 1503 posts
  • Gender:Not Telling

Posted 13 May 2017 - 10:47 PM

0x400D Exists(O:Object*)
Returns true only if the specified object exists in the current area (note that dead creatures can still be counted as existing).

 

This does not work for items lying on the ground.

(It works only for a dead body lying on the ground if that body is not an itm but a cre with DV).

 

You can only check for items that are either in the inventory of party members or are in containers.

 

You could check for a global which is set in your described case by whatever script creates the item - or (if none exists) modify the script that drops the item to set a global you can then use for your check.


Edited by Roxanne, 13 May 2017 - 10:50 PM.

The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users