Jump to content

Setting CRE gold via script


Recommended Posts

In my Transitions mod, I'm distributing gold to members of the party but want the gold setting in their CREs to be something other than what they were given.  It might be half, or a fixed number.

There is no way, that I'm aware of, to destroy gold using a global variable as the value to be destroyed.  There is a way to add gold using a global variable, however.  So I thought I'd try to use that in conjunction with DestroyGold(0).  Timing is an issue though.  If I use, GiveObjectGoldGlobal("#L_500Gold","GLOBAL","JAHEIRA") while she's still in the party, the gold gets added to the party, if I wait until she's out, like LeaveParty() SmallWait(3) GiveObject..., it still gets added to the group, EDIT: it doesn't get added to the group but neither does it get added to her CRE, though it worked with Ajantis, for some reason (maybe he was modded differently).  She doesn't leave the area either, which leads me to think that nothing after the SmallWait is being executed.  Instead, she initiates dialogue.  I need to find something that'll work whether they're modded to talk to the PC after leaving or not.  I tried SetInterrupt(FALSE) but that had zero affect.  I'm going to try to ActionOverride the wait and see if that has any affect. EDIT: the only affect that had was the gold was added to the party.  Still nothing to the NPCs, except Ajantis.

Here's the code - it's sort of in disarray as I've tried various things that just aren't working...except for Ajantis.:

Spoiler

CHAIN
    IF WEIGHT #-997 ~Global("#L_AjantisModded","GLOBAL",0) GlobalGT("#L_NPCSoD","GLOBAL",0) GlobalTimerExpired("#L_NPCSoD","GLOBAL") Global("#L_NPCSoDLeft","GLOBAL",0)~ THEN AJANTJ PRE_SOD_LEAVE
        @2284 /* ~It has been an honor.  Farewell.~ */
        == JAHEIJ IF ~IsValidForPartyDialogue("JAHEIRA") Global("#L_JaheriaModded","GLOBAL",0)~ @2328 /* ~Take care of yourself.~ */ DO ~SetGlobal("#L_JaheiraOkInBG1Areas","GLOBAL",1) ActionOverride("JAHEIRA",DestroyGold(0)) ActionOverride("JAHEIRA",LeaveParty()) SmallWait(1) GiveObjectGoldGlobal("#L_500Gold","GLOBAL","JAHEIRA") ActionOverride("JAHEIRA",EscapeArea())~
        == KHALIJ IF ~IsValidForPartyDialogue("KHALID") Global("#L_KhalidModded","GLOBAL",0)~ @2334 /* ~Goodbye.~ */ DO ~SetGlobal("#L_KhalidOkInBG1Areas","GLOBAL",1) ActionOverride("KHALID",DestroyGold(0)) ActionOverride("KHALID",LeaveParty()) SmallWait(3) GiveObjectGoldGlobal("#L_100Gold","GLOBAL","KHALID") ActionOverride("KHALID",EscapeArea())~
        == DORNJ_ IF ~IsValidForPartyDialogue("DORN") Global("#L_DornModded","GLOBAL",0)~ @2346 /* ~Until we meet again.~ */ DO ~SetGlobal("#L_DornOkInBG1Areas","GLOBAL",1) ActionOverride("DORN",DestroyGold(0)) ActionOverride("DORN",LeaveParty()) ActionOverride("DORN",EscapeArea())~
        == EDWINJ_ IF ~IsValidForPartyDialogue("EDWIN") Global("#L_EdwinModded","GLOBAL",0)~ @2353 /*~I'm outta here!~ */ DO ~SetGlobal("#L_EdwinOkInBG1Areas","GLOBAL",1) ActionOverride("EDWIN",DestroyGold(0)) ActionOverride("EDWIN",LeaveParty()) SmallWait(3) GiveObjectGoldGlobal("#L_HalfGold","GLOBAL","EDWIN") ActionOverride("EDWIN",EscapeArea())~
        == NEERAJ_ IF ~IsValidForPartyDialogue("NEERA") Global("#L_NeeraModded","GLOBAL",0)~ @2356 /* ~See ya!  Good luck and all.~ */ DO ~SetGlobal("#L_NeeraOkInBG1Areas","GLOBAL",1) ActionOverride("NEERA",DestroyGold(0)) ActionOverride("NEERA",LeaveParty()) SmallWait(3) GiveObjectGoldGlobal("#L_HalfGold","GLOBAL","NEERA") ActionOverride("NEERA",EscapeArea())~
        == BAELOTHJ IF ~IsValidForPartyDialogue("BAELOTH") Global("#L_BaelothModded","GLOBAL",0)~ @2362 /* ~Look for my name in lights, I'm bowing out of this dump!~ */ DO ~SetGlobal("#L_BaelothOkInBG1Areas","GLOBAL",1) ActionOverride("BAELOTH",DestroyGold(0)) ActionOverride("BAELOTH",LeaveParty()) SmallWait(3) GiveObjectGoldGlobal("#L_HalfGold","GLOBAL","BAELOTH") ActionOverride("BAELOTH",EscapeArea())~
        == GARRIJ IF ~IsValidForPartyDialogue("GARRICK") Global("#L_GarrickModded","GLOBAL",0)~ @2368 /* ~Farewell, <CHARNAME>.  I shall immortalize your name in song!~ */ DO ~SetGlobal("#L_GarrickOkInBG1Areas","GLOBAL",1) ActionOverride("GARRICK",DestroyGold(0)) ActionOverride("GARRICK",LeaveParty()) SmallWait(1) GiveObjectGoldGlobal("#L_HalfGold","GLOBAL","GARRICK") ActionOverride("GARRICK",EscapeArea())~
        == XANJ IF ~IsValidForPartyDialogue("XAN") Global("#L_XanModded","GLOBAL",0)~ @2374 /* ~Farewell though I certainly shall not.~ */ DO ~SetGlobal("#L_XanOkInBG1Areas","GLOBAL",1) ActionOverride("XAN",DestroyGold(0)) ActionOverride("XAN",LeaveParty()) ActionOverride("XAN",SetInterrupt(FALSE)) SmallWait(3) GiveObjectGoldGlobal("#L_100Gold","GLOBAL","XAN") ActionOverride("XAN",EscapeArea())~
        == MINSCJ_ IF ~IsValidForPartyDialogue("MINSC") Global("#L_MinscModded","GLOBAL",0)~ @2377 /* ~If you need us, look for us at the Three Old Kegs.~ */ DO ~SetGlobal("#L_MinscOkInBG1Areas","GLOBAL",1) ActionOverride("MINSC",DestroyGold(500)) ActionOverride("MINSC",LeaveParty()) ActionOverride("MINSC",EscapeArea())~
    END
    IF ~~ THEN DO ~SetGlobal("#L_NPCSoDLeft","GLOBAL",1) SetGlobal("#L_AjantisOkInBG1Areas","GLOBAL",1) ActionOverride("AJANTIS",DestroyGold(0)) ActionOverride("AJANTIS",LeaveParty()) SmallWait(3) GiveObjectGoldGlobal("#L_100Gold","GLOBAL","AJANTIS") ActionOverride("AJANTIS",EscapeArea())~ EXIT

 

 

Edited by Lauriel
Link to comment

Yes it does, but that's the action I can't get to work properly in this instance.  I just settled for a generic DestroyGold amount no matter which NPC got the gold.  I wanted to adjust it per NPC for roleplaying reasons but it just didn't work.  I'll need to do any adjustments like that in character scripts upon joining if I feel it necessary. 

Link to comment
2 hours ago, qwerty1234567 said:

You can try giving her "gold" item (a stash, like in containers)

That never even crossed my mind.  Way to think outside the box!  Thank you!  I'll try this.  Though I think NPCs hand over anything in their backpack upon leaving, which I find annoying.  But I'll still try it to see if giving it to her after she leaves the group will still return it to Player1.

EDIT:  That sort of worked.  The gold was in Jaheir's inventory after she left, it didn't interfere with her leaving the area, however it did give the message that 'the party has received an item: Gold', even though it didn't.  I'll stick with the NPC scripts upon joining mechanism.  But thank you again for this really good idea.

Edited by Lauriel
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...