Jump to content

Displaying Global Values in Dialogue?


user826

Recommended Posts

No, it's okay, I think I'm just ultimately going to leave the mod in its current state. This was a "would be nice" feature but if it's not possible with vanilla GECK, I'm not going to tack on a dependency just for this.

 

I don't think the method of changing the player name would be a viable option because I have no way of storing the current player name value, so even if it worked, for the rest of the playthrough, the player's name would randomly change between "6000", "7500", and "10000"!

 

"[barter] Doctor 6000 detects a terminal lack of caps in this discussion." Haha

Thanks for your help, though! I knew it was a long shot even when I posted the thread, because if such a useful feature existed, I probably would've stumbled across it at least once before now.

Link to comment
Share on other sites

No, it's okay, I think I'm just ultimately going to leave the mod in its current state. This was a "would be nice" feature but if it's not possible with vanilla GECK, I'm not going to tack on a dependency just for this.

 

I don't think the method of changing the player name would be a viable option because I have no way of storing the current player name value, so even if it worked, for the rest of the playthrough, the player's name would randomly change between "6000", "7500", and "10000"!

 

 

 

Thats where you are wrong .... do you think I would lead you down that kind of rabbit hole ? Well don't answer that ... wouldn't blame you for thinking that.

But you can store the players name as a string variable ... then switch it back after this temp condition of using it to input a string with an int value ... in the dialogue.

Albeit could be a secondary file ear marked for changing the economy scale.

Which I gather you think is important , since you were thinking about this awhile ago ? And is not up to me to decide what is important ... I'm just here to help you with what is possible.

 

Add edit : sorry no do not need the ShowOff plugin for what I was saying ... If infact can change the player name. The whole premise hinges on that ... but saving the player name is easy.

 

What might work is changing the name on the Player npc in the item tree. Don't know though ... needs testing ... which I am in the middle of my own testing for that.

Actually using the player npc as a template for another unique npc. Which I am dealing with items added / equipped ... and packages with idle anims.

If the name thing pops up ... will check for ya.

Link to comment
Share on other sites

I never thought for a second that you would leave me high and dry that way, haha! But what I meant was that using only vanilla GECK, there's no way to store string variables, so that even if I found a way to replace the player's name with the Global, I wouldn't be able to change it back using only vanilla GECK.

Link to comment
Share on other sites

Yes "ToString" is from NVSE ... the very first addition to Vanilla .

 

To be clear when I said vanilla prior ... I meant your original mod without worrying how to change the economy scale.

 

So you want my backing to tell your mod down loaders to go F@! themselves with your hard coded prices and their whining ?

 

Hell Ya ... Deliver a Nuke .... but then again ... I don't upload and maintain mods ... at least until my StarCraft proxy gets done.

and we all know when that is likely to happen ;)

Link to comment
Share on other sites

Like I said earlier, this isn't a game-breaker. I figure anyone who changes the Global will likely remember a) that they did so, and b) what they changed it to, so seeing <6000 caps> show up in dialogue shouldn't send them into a spiral of confusion, haha

Link to comment
Share on other sites

One way you could accomplish this is by having a menu pop up with all the different guns and all the different prices, you can have this done via activator or begin/end script in your dialogue.

Rather than use ShowMessage, you could use MessageBoxExAlt (https://geckwiki.com/index.php?title=MessageBoxExAlt). It allows you to dynamically create MessageBoxes that you can apply your Global variables to.

It uses the JIP NVSE Plugin, but it isn't hard to get working. I understand there's a bit of a taboo with scripting with NVSE or any of the other extenders, or atleast that's how I felt until I sat down to learn them. Once you get a grasp, the world of GECK truly opens.

The way I'd do this is by using Call (https://geckwiki.com/index.php?title=Call) in your Activator Script or Begin/End Result Script. I feel like I'm a huge advocate for using Call, but ever since learning about it I can't stop.

Call allows you to run (or call) another script from whatever script you're working in. The calling script doesn't need to be attached to any item/npc/activator/etc. You just call it. Pairing that with strings and MessageBoxExAlt let's you make any dynamic script you choose to.

Here's what I'd do...

Have a quest script with variables related to the specific weapons that are being sold at the given time. For this example, we'll say that you can only purchase any of these custom weapons once.

scn myWeaponQuest ; or whatever you wanna call it


; first, we'll declare the weapon booleans.
short bWeapon1
short bWeapon2
short bWeapon3
; add as many of these as you need
; when the variable is set to 1, the weapon can no longer be purchased from Vlad.

; next, unless you are deadset on using GLOBALS for the weapon prices, you can set the weapon prices here.
int iWeapon1
int iWeapon2
int iWeapon3
; add as many of these as you need

; finally, you can do 1 of 2 things...
; Option 1, the easiest. Declare a string variable for each of these weapons.
string_var sWeapon1
string_var sWeapon2
string_var sWeapon3

; Option 2, the harder bit. Create a single string variable.
string_var sWeaponList
; For Option 2, you would want to create an array of every weapon. You can store references, or even variables into arrays.
; You would want to create the array with every weapon, either using it's reference or editorID, or by using it's boolean. Whichever works.
; You would then want to create a For Each Loop that runs through the number of items you have in your array.
; Within this, you could have the sWeaponList string add every object (it's price, it's name, whatever) to the end of the sWeaponListString.
; I RECOMMEND THIS OPTION, and I would be happy to further elaborate how to get it to work, but if you don't want to get to technical - stick with option 1.

Begin Gamemode
; So let's just do "Option 1", yeah?
; And to optimize this out of the box, we should give Vlad (the NPC Merchant) a boolean called "bUpdateList"
; You would want to set "bUpdateList" to 1 every time the player activates VladREF, and 0 every time the player says Goodbye or whatever.

set iWeapon1 to "DEFAULTPRICE" ; this can be a global if you wanted it to be.
set iWeapon2 to "DEFAULTPRICE"
set iWeapon3 to "DEFAULTPRICE"

if (VladREF.bUpdateList == 1)
	if (bWeapon1 == 0)
		let sWeapon1 := "[" + $iWeapon1 + " CAPS] " + $Weapon1EditorID
		;"let" is the greatest way to say "set" with NVSE.
		;":=" is the way you'd say "to" if using LET.
		; the string's output would be "[6000 CAPS] Vlad's Assault Rifle"
	endif

	if (bWeapon2 == 0)
		let sWeapon2 := "[" + $iWeapon2 + " CAPS] " + $Weapon2EditorID
	endif

	if (bWeapon3 == 0)
		let sWeapon3 := "[" + $iWeapon3 + " CAPS] " + $Weapon3EditorID
	endif
	
	; and so on depending on the amount of weapons you have.

END
; we would use "bUpdateList" because we don't want the quest script to update every frame. 
    
    

If you end up taking the Option 1 route, you wouldn't need to use Call, I believe.

You would still need to make a separate script to handle the messageBox/weapon menu, however.

 

So let's say you're doing Option 1, your result script would read as follows...

; in the begin/end result script in your dialogue...

MessageBoxExAlt WeaponMessageScript "^Vlad's Custom Weapons^Select an option:|" + $myWeaponQuest.sWeapon1 + "|" + $myWeaponQuest.sWeapon2 + $myWeaponQuest.sWeapon3 + "| Cancel"

"MessageBoxExAlt" calls a script with the sole purpose of creating a script. The calling script.

"WeaponMessageScript" would be a script that isn't attached to anything. The called script.

 

Now for the final bit,

You'll be working with a DynamicMenuScript(https://geckwiki.com/index.php?title=DynamicMenuScript)

scn WeaponMessageScript; the called script

int iButton

string_var sMenu

begin function { iButton } ; pass -1 by default
; "Function {}" is a blocktype added with NVSE that will run when called, and then reset it's variables when it's ran through.
; we put "iButton" within the {BRACKETS} because it's being returned.

    let iIndex := -1
    ; "iIndex" needs to be set to -1 because it is the header text, and the header text is not a button.

    let sMenu := "^Vlad's Custom Weapons^Select an option:"
    ; sMenu is what store's all the text of the Dynamic Menu you're creating.

    ; Add option
    let iIndex += 1
    ; "let iIndex += 1" is the same as saying "set iIndex to iIndex + 1". It's just short hand, and I believe it's the required syntax for this.
    let sMenu += "|" + $myWeaponQuest.sWeapon1
    if iButton == iIndex 
        player.removeItem caps001 (myWeaponQuest.iWeapon1)
        player.addItem Weapon1EditorID 1
        return
    endif

    ; Add option
    let iIndex += 1
    let sMenu += "|" + $myWeaponQuest.sWeapon2
    if iButton == iIndex
        player.removeItem caps001 (myWeaponQuest.iWeapon1)
        player.addItem Weapon2EditorID 1
        return
    endif

    ; Add option
    let iIndex += 1
    let sMenu += "|" + $myWeaponQuest.sWeapon3
    if iButton == iIndex
        player.removeItem caps001 (myWeaponQuest.iWeapon1)
        player.addItem Weapon3EditorID 1
        return
    endif

   ;Last Option, usually "Cancel" unless the player is required to choose a weapon.
   let iIndex += 1
   let sMenu += "|Cancel"
   if iButton == iIndex
       return; cancel was chosen, player doesn't want to buy.
   endif
    ; Use the same script as callback
    MessageBoxExAlt WeaponMessageScript $sMenu
    ; "MessageBoxExAlt" along with the current script name and the returned string will always be at the footer of the function.

end

Implementing Barter Skill:

if you want the player's barter skill to affect the price of the weapon, within the quest script, when "bUpdateList == 1" you can create an equation that reduces the price of the weapon (AKA a variable such as iWeapon1).

scn WeaponQuestScript

...
int iWeapon1
...

Begin Gamemode
...
if (VladREF.bUpdateList == 1)
	if (bWeapon1 == 0)
                let iWeapon1 *= (player.getAV Barter * X)
                ; this will reduce the price of Weapon1 by Barter and X.
		let sWeapon1 := "[" + $iWeapon1 + " CAPS] " + $Weapon1EditorID
                ; in the Weapon Menu, iWeapon1 will reflect the bartered price.
	endif
...
END

Merchant Extra Dialogue:

If you want the Merchant to say a specific line of dialogue after purchasing a weapon...

scn WeaponMessageScript

...

Function {iButton}

...

    let iIndex += 1
    let sMenu += "|" + $myWeaponQuest.sWeapon3
    if iButton == iIndex
        player.removeItem caps001 (myWeaponQuest.iWeapon1)
        player.addItem Weapon3EditorID 1
        VladREF.sayToPlayer VladWeapon1Bark (arg1, arg2); <--------------- ADD THIS
        return
    endif

And that's that.

It should work with some tweaking. I'm sure there's a good chance you may not want to take this route, but I can guarantee you it'll make you a stronger modder.

I'm sure I may have missed something, hell - you may not even want to read this essay I wrote up.

But if you do, feel free to ask any questions if you have any or PM me.

 

- StealthDick

Link to comment
Share on other sites

Thank you for the comprehensive write-up! I know I could do this very easily using engine extensions, but I was hoping for a way to do it dynamically within the dialogue using vanilla GECK functions, which it turns out isn't possible. I force myself to use only vanilla GECK when making my mods without NVSE, JIP, or any other third-party extensions as a self-imposed challenge, since limitations breed creativity.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...