Jump to content

Need some help tweaking an existing plugin


LukeGevaerts

Recommended Posts

DISCLAIMER: The plugin in question is WMVM - Weapon Mod Vending Machine. I'm obviously not going to steal anything and pass it off as my own work; the intent is to contact the author once I've got something that works and ask for permission to upload it - or better yet, have it incorporated. Figured I'd get that out of the way first - you never know. :)

 

Hello folks,

 

I've been using the WMVM - Weapon Mod Vending Machine for a while now, and while it's functional its presentation leaves a lot to be desired; dumping a message in the console isn't precisely aesthetic. I googled around, learning as I went, and after a fashion managed to update the script to incorporate NVSE's MessageBoxEx. When activated, the vending machine now displays a message box with three buttons labeled "Purchase [insert weapon mod name here] for [insert weapon mod cost here] Caps"; it's an improvement, but I'm still not pleased with it.

 

First, the script as it looks right now:

 

scn GHWeaponModVendingScript

; Original script by Ghostifish

; Last modified on July 12, 2012 @ 2:14 AM

int ButtonPressed
int CostMultiplier
ref EquippedWeapon
int PlayerCaps
ref WeaponMod1
ref WeaponMod2
ref WeaponMod3
int WeaponMod1Value
int WeaponMod2Value
int WeaponMod3Value

Begin OnActivate

set CostMultiplier to 1
set PlayerCaps to player.getitemcount Caps001

set EquippedWeapon to player.getequippedobject 5

set WeaponMod1 to getweaponitemmod 1 EquippedWeapon
set WeaponMod2 to getweaponitemmod 2 EquippedWeapon
set WeaponMod3 to getweaponitemmod 3 EquippedWeapon

set WeaponMod1Value to getvalue WeaponMod1
set WeaponMod2Value to getvalue WeaponMod2
set WeaponMod3Value to getvalue WeaponMod3

set WeaponMod1Value to WeaponMod1Value * CostMultiplier
set WeaponMod2Value to WeaponMod2Value * CostMultiplier
set WeaponMod3Value to WeaponMod3Value * CostMultiplier

if WeaponMod1 == 0 
; It doesn't hurt to check if the weapon can be modified at all; trying to mod an unmoddable weapon makes the message box look like Sanskrit. Not even kidding.
messageboxex "%n cannot be modified." EquippedWeapon
else
messageboxex "You currently have %g Caps.|Buy %q%n%q for %g Caps.|Buy %q%n%q for %g Caps.|Buy %q%n%q for %g Caps.|Don't buy anything." PlayerCaps, WeaponMod1, WeaponMod1Value, WeaponMod2, WeaponMod2Value, WeaponMod3, WeaponMod3Value
endif

End

Begin Gamemode

set ButtonPressed to GetButtonPressed

if ButtonPressed == -1
	Return
elseif ButtonPressed == 0
	; Weapon Mod #1
	if PlayerCaps >= WeaponMod1Value
	player.removeitem caps001 WeaponMod1Value
	player.additem WeaponMod1 1
	else
		MessageEx "You do not have enough Caps."
		return
	endif
elseif ButtonPressed == 1
	; Weapon Mod #2
	if PlayerCaps >= WeaponMod2Value
	player.removeitem caps001 WeaponMod2Value
	player.additem WeaponMod2 1
	else
		MessageEx "You do not have enough Caps."
		return
	endif
elseif ButtonPressed == 2
	; Weapon Mod #3
	if PlayerCaps >= WeaponMod3Value
	player.removeitem caps001 WeaponMod3Value
	player.additem WeaponMod3 1
	else
		MessageEx "You do not have enough Caps."
		return
	endif
elseif ButtonPressed == 3
	; Cancel
endif

End

 

My questions are these:

 

1. Is it possible to pass a title variable to MessageBoxEx? It's not precisely critical, but I like to be consistent. A message box labeled "Weapon Mod Vending Machine" beats a message box without a label. I poked around in the NVSE source code but couldn't find anything (then again, reading C isn't my strong suit - to put it mildly). Did I miss something?

 

2. Is it possible to get the message box to display the weapon mod's description (e.g. "Increases damage by 3")? I managed to retrieve the numerical values by using GetWeaponItemModEffect, GetWeaponItemModValue1 and GetWeaponItemModValue2, but those aren't exactly useful to the player - and GetWeaponItemMod only provides the name of the weapon mod. A description would help the player to decide whether a weapon mod is worth purchasing. From the looks of it string manipulation is pretty much non-existent in FNV scripting, even with the added features of NVSE. I figured I could just retrieve the description associated with the weapon mod, but that didn't work out too well.

 

3. It would be nice if the player could alter the Cost Modifier on the fly - or at least through an .ini file. This one doesn't require an answer just yet; I haven't touched upon this, but I'm running a number of mods that provide this kind of functionality. I'm hoping I can figure it out by studying their code, but if that doesn't work I'll be back.

 

Thanks for your time,

 

- Luke

Edited by LukeGevaerts
Link to comment
Share on other sites

I'm pretty sure you'll have to use a regular message form and ShowMessage in order to display a title on a message box.

 

Unfortunately, you are correct about the complete lack of string functions in GECK scripting. I don't think you'll be able to directly pass a description to MessageBoxEx unless you use SetName on an object and pass it using %n or something.

Link to comment
Share on other sites

I'm pretty sure you'll have to use a regular message form and ShowMessage in order to display a title on a message box.

 

Unfortunately, you are correct about the complete lack of string functions in GECK scripting. I don't think you'll be able to directly pass a description to MessageBoxEx unless you use SetName on an object and pass it using %n or something.

 

Thanks, luthienanarion. Looks like I'm SOL, then - I'll see if I can get that workaround you suggested to behave.

Link to comment
Share on other sites

Well, that went better than expected. I'm still not completely happy with it, but it's starting to shape up.

 

The updated code:

 

scn GHWeaponModVendingScript

; Original script by Ghostifish

; Rewritten by Luke Gevaerts to utilize the NVSE [messageboxex] function
; Last modified on July 13, 2012 @ 1:06 AM

; WISHLIST

; [1] Assign a title to a message box created by [messageboxex]. Maybe I'm just missing the obvious,
; but I don't think so: I checked the NVSE source code and couldn't find anything that looked like
; being able to pass a title variable to the function. It's not a big deal, but I like being consistent.

; [2] Allow players to alter the cost multiplier in-game or through an .ini, maybe? I'm learning this
; stuff as I go, so I have no idea on how to do that. There's plenty of plugins that have this functionality,
; though, so it shouldn't be too hard to figure out. I've set it to 1 right now, effectively disabling it.

; Had to shorten variable names to avoid the 512 character limit. A character limit? Seriously?

int ButtonPressed
int CostMultiplier
ref EquippedWeapon
int PlayerCaps
ref WM1
ref WM2
ref WM3
ref WM1Desc
ref WM2Desc
ref WM3Desc
int WM1Type
int WM2Type
int WM3Type
int WM1Cost
int WM2Cost
int WM3Cost

Begin OnActivate

set CostMultiplier to 1
set PlayerCaps to player.getitemcount caps001

set EquippedWeapon to player.getequippedobject 5

set WM1 to getweaponitemmod 1 EquippedWeapon
set WM2 to getweaponitemmod 2 EquippedWeapon
set WM3 to getweaponitemmod 3 EquippedWeapon

; Need three unique objects to rename for the whole description thing to work.
; Decided upon three hidden vendor containers. They're renamed back to their
; original name upon exiting the message box. Not even sure if that's nescessary
; since the player can't interact with these containers anyway, but I like my work
; clean and wholesome. For as far as a dirty hack like this can be clean, anyway.

; TODO: Figure out how to shoehorn the numerical values into the message box.
; Some weapon mods have multiple functions and it's hard to figure out which
; is which, so I haven't touched upon this yet.

set WM1Desc to VendorContainer188Gunrunner
set WM2Desc to VendorContainer188Junk
set WM3Desc to VendorContainer188Michelle

set WM1Type to getweaponitemmodeffect 1 EquippedWeapon
set WM2Type to getweaponitemmodeffect 2 EquippedWeapon
set WM3Type to getweaponitemmodeffect 3 EquippedWeapon

set WM1Cost to getvalue WM1
set WM2Cost to getvalue WM2
set WM3Cost to getvalue WM3

set WM1Cost to WM1Cost * CostMultiplier
set WM2Cost to WM2Cost * CostMultiplier
set WM3Cost to WM3Cost * CostMultiplier

if WM1Type == 1
setname "Increases damage" WM1Desc
elseif WM1Type == 2
setname "Increases ammunition capacity" WM1Desc
elseif WM1Type == 3
 setname "Decreases spread" WM1Desc
elseif WM1Type == 4
setname "Decreases weight" WM1Desc
elseif WM1Type == 6
setname "Replenishes ammo" WM1Desc
elseif WM1Type == 7
setname "Decreases equip time" WM1Desc
elseif WM1Type == 8
setname "Increases rate of fire" WM1Desc
elseif WM1Type == 9
setname "Increases projectile velocity" WM1Desc
elseif WM1Type == 10
setname "Increases condiction" WM1Desc
elseif WM1Type == 11
setname "Reduces weapon noise or silences weapon" WM1Desc
elseif WM1Type == 12
setname "Creates two beams that together do increased damage" WM1Desc
elseif WM1Type == 13
setname "Provides a bonus in V.A.T.S." WM1Desc
elseif WM1Type == 14
setname "Adds scope and/or increases zoom level" WM1Desc
endif

if WM2Type == 1
setname "Increases damage" WM2Desc
elseif WM2Type == 2
setname "Increases ammunition capacity" WM2Desc
elseif WM2Type == 3
 setname "Decreases spread" WM2Desc
elseif WM2Type == 4
setname "Decreases weight" WM2Desc
elseif WM2Type == 6
setname "Replenishes ammo" WM2Desc
elseif WM2Type == 7
setname "Decreases equip time" WM2Desc
elseif WM2Type == 8
setname "Increases rate of fire" WM2Desc
elseif WM2Type == 9
setname "Increases projectile velocity" WM2Desc
elseif WM2Type == 10
setname "Increases condiction" WM2Desc
elseif WM2Type == 11
setname "Reduces weapon noise or silences weapon" WM2Desc
elseif WM2Type == 12
setname "Creates two beams that together do increased damage" WM2Desc
elseif WM2Type == 13
setname "Provides a bonus in V.A.T.S." WM2Desc
elseif WM2Type == 14
setname "Adds scope and/or increases zoom level" WM2Desc
endif

if WM3Type == 1
setname "Increases damage" WM3Desc
elseif WM3Type == 2
setname "Increases ammunition capacity" WM3Desc
elseif WM3Type == 3
 setname "Decreases spread" WM3Desc
elseif WM3Type == 4
setname "Decreases weight" WM3Desc
elseif WM3Type == 6
setname "Replenishes ammo" WM3Desc
elseif WM3Type == 7
setname "Decreases equip time" WM3Desc
elseif WM3Type == 8
setname "Increases rate of fire" WM3Desc
elseif WM3Type == 9
setname "Increases projectile velocity" WM3Desc
elseif WM3Type == 10
setname "Increases condiction" WM3Desc
elseif WM3Type == 11
setname "Reduces weapon noise or silences weapon" WM3Desc
elseif WM3Type == 12
setname "Creates two beams that together do increased damage" WM3Desc
elseif WM3Type == 13
setname "Provides a bonus in V.A.T.S." WM3Desc
elseif WM3Type == 14
setname "Adds scope and/or increases zoom level" WM3Desc
endif

if WM1 == 0 
; It doesn't hurt to check if the weapon can be modified at all. Trying to mod an unmoddable
; weapon makes the message box look like Sanskrit. Not even kidding.
messageboxex "%n cannot be modified." EquippedWeapon
else
; Holy long line of text Batman!
messageboxex "Thank you for using the Weapon Mod Vending Machine!%r%rYou currently have %g Caps. The following weapon mods are available for your %n:%r%rNAME: %q%n%q%rEFFECT: %n.%rCOST: %g Caps%r%rNAME: %q%n%q%rEFFECT: %n.%rCOST: %g Caps%r%rNAME: %q%n%q%rEFFECT: %n.%rCOST: %g Caps|Buy the %q%n%q|Buy the %q%n%q|Buy the %q%n%q|Nothing right now, thanks" PlayerCaps, EquippedWeapon, WM1, WM1Desc, WM1Cost, WM2, WM2Desc, WM2Cost, WM3, WM3Desc, WM3Cost, WM1, WM2, WM3
endif

End

Begin Gamemode

set ButtonPressed to GetButtonPressed

if ButtonPressed == -1
	Return
elseif ButtonPressed == 0
	; Weapon Mod #1
	if PlayerCaps >= WM1Cost
		player.removeitem caps001 WM1Cost
		player.additem WM1 1
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
	else
		MessageEx "You do not have enough Caps."
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
		return
	endif
elseif ButtonPressed == 1
	; Weapon Mod #2
	if PlayerCaps >= WM2Cost
		player.removeitem caps001 WM2Cost
		player.additem WM2 1
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
	else
		MessageEx "You do not have enough Caps."
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
		return
	endif
elseif ButtonPressed == 2
	; Weapon Mod #3
	if PlayerCaps >= WM3Cost
		player.removeitem caps001 WM3Cost
		player.additem WM3 1
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
	else
		MessageEx "You do not have enough Caps."
		setname "Michelle and Samuel's Trunk" WM1Desc
		setname "Michelle and Samuel's Trunk" WM2Desc
		setname "Michelle and Samuel's Trunk" WM3Desc
		return
	endif
elseif ButtonPressed == 3
	; Cancel
	setname "Michelle and Samuel's Trunk" WM1Desc
	setname "Michelle and Samuel's Trunk" WM2Desc
	setname "Michelle and Samuel's Trunk" WM3Desc
endif

End

 

Here's a screenshot of the message box in action:

 

http://www.femlob.com/temp/wmvm-modded-1.jpg

Link to comment
Share on other sites

Wow, I didn't even know about GetWeaponItemModEffect. Here I was thinking you would have to hard-code the description of each weapon mod...

 

 

I'm glad the roundabout way of passing a string to MessageBoxEx worked. I wasn't sure it was feasible, but it's what I would have tried. It gives me an idea about how to deal with %c not working with MessageEx/MessageBoxEx in NVSE for switched text.

Link to comment
Share on other sites

Just added a check to see if a weapon mod is equipped using GetEquippedWeaponModFlags. I won't bother with the code this time (it's just more of the same hackish stuff I've already posted), but I will say that I had a fine ol' time figuring out just what the hell to do with the cryptic output of that command. For future reference:

 

GetEquippedWeaponModFlags:

1 = Only First Mod Equipped
2 = Only Second Mod Equipped
3 = First and Second Mod Equipped
4 = Only Third Mod Equipped
5 = First and Third Mod Equipped
6 = Second and Third Mod Equipped
7 = All Three Mods Equipped

 

Oh documentation, how I lament thine absence. I would also like to add that I really, really hate that 512 character limit.

 

New screenshot: http://www.femlob.com/temp/wmvm-modded-2.jpg

 

Out of curiosity, what was that %c supposed to do?

Edited by LukeGevaerts
Link to comment
Share on other sites

In OBSE you were able to use a spell or a faction to enumerate different text strings (by spell effect names or faction ranks) so that you could pass an integer and have it display text (like "Enabled" or "Disabled" for example) by using %c and passing the spell/faction followed by the rank to the MessageEx/MessageBoxEx function.

 

NVSE just displays "unknown" using either a spell or faction.

 

 

MessageBoxEx

Edited by luthienanarion
Link to comment
Share on other sites

Funny story: trying to modify a weapon with less than three available mods turned the whole message box into Sanskrit again. So, I rewrote the whole thing: it now uses one message box (that checks for the number of available mods) to present the weapon mods and another menu for specifications and the option to purchase. This also allowed me to evade the 512 character limit JOY OH GOD JOY.

 

The code:

 

scn GHWeaponModVendingScript

; Original script by Ghostifish

; Rewritten by Luke Gevaerts
; Last modified on July 14, 2012 @ 4:32 PM

; WISHLIST

; [1] Assign a title to a message box created by [messageboxex]. Maybe I'm just missing the obvious, but I don't think so: I checked the NVSE source code and couldn't find anything that looked
; like being able to pass a title variable to the function. It's not a big deal, but I like being consistent. Reportedly impossible. Contact the NVSE team, maybe?

; [2] Allow players to alter the Price multiplier in-game or through an .ini, maybe? I'm learning this stuff as I go, so I have no idea on how to do that. There's plenty of plugins that have
; this functionality, though, so it shouldn't be too hard to figure out. I've set it to 1 right now, effectively disabling it (a multiplier of 5 is outrageous).

; [3] It would be great if I could use an actual terminal for this stuff, but the odds of that happening are pretty much zero.

Int Does_Not_Exist
Ref Equipped_Weapon
Int False
Int Menu_Exit
Int Menu_State
Int Menu_Purchase
Int Menu_Purchase_Button_Cancel
Int Menu_Purchase_Button_Pressed
Int Menu_Purchase_Button_Purchase
Int Menu_Repeat
Int Menu_Specs
Int Menu_Specs_Button_Cancel
Int Menu_Specs_Button_Pressed
Int Menu_Specs_Button_Weapon_Mod_1
Int Menu_Specs_Button_Weapon_Mod_2_or_Cancel
Int Menu_Specs_Button_Weapon_Mod_3_or_Cancel
Int None
Int One_Copy
Int Player_Caps
Int Price_Multiplier
Int Selected_Weapon_Mod
Int True
Int Weapon_Mod_1
Ref Weapon_Mod_1_Description
Int Weapon_Mod_1_Exists
Ref Weapon_Mod_1_Name
Int Weapon_Mod_1_Price
Ref Weapon_Mod_1_Status
Int Weapon_Mod_1_Type
Int Weapon_Mod_2
Ref Weapon_Mod_2_Description
Int Weapon_Mod_2_Exists
Ref Weapon_Mod_2_Name
Int Weapon_Mod_2_Price
Ref Weapon_Mod_2_Status
Int Weapon_Mod_2_Type
Int Weapon_Mod_3
Ref Weapon_Mod_3_Description
Int Weapon_Mod_3_Exists
Ref Weapon_Mod_3_Name
Int Weapon_Mod_3_Price
Ref Weapon_Mod_3_Status
Int Weapon_Mod_3_Type
Int Weapon_Mods_Status
Int Weapon_Mods_Total

Begin OnActivate
; Set variables.
Set Equipped_Weapon To Player.GetEquippedObject 5
Set Player_Caps To Player.GetItemCount Caps001
Set Weapon_Mod_1_Description To VendorContainer188Gunrunner
Set Weapon_Mod_1_Name To GetWeaponItemMod 1 Equipped_Weapon
Set Weapon_Mod_1_Price To GetValue Weapon_Mod_1_Name
Set Weapon_Mod_1_Status To VendorContainer188NCR
Set Weapon_Mod_1_Type To GetWeaponItemModEffect 1 Equipped_Weapon
Set Weapon_Mod_2_Description To VendorContainer188Junk
Set Weapon_Mod_2_Name To GetWeaponItemMod 2 Equipped_Weapon
Set Weapon_Mod_2_Price To GetValue Weapon_Mod_2_Name
Set Weapon_Mod_2_Status To VendorContainerBlake
Set Weapon_Mod_2_Type To GetWeaponItemModEffect 2 Equipped_Weapon
Set Weapon_Mod_3_Description To VendorContainer188Michelle
Set Weapon_Mod_3_Name To GetWeaponItemMod 3 Equipped_Weapon
Set Weapon_Mod_3_Price to GetValue Weapon_Mod_3_Name
Set Weapon_Mod_3_Status To VendorContainerChet
Set Weapon_Mod_3_Type To GetWeaponItemModEffect 3 Equipped_Weapon
Set Weapon_Mods_Status To Player.GetEquippedWeaponModFlags
; Set aliases.
Set Does_Not_Exist To 0
Set False To 0
Set Menu_Exit To 3
Set Menu_Purchase To 1
Set Menu_Purchase_Button_Cancel To 1
Set Menu_Purchase_Button_Purchase To 0
Set Menu_Repeat To 2
Set Menu_Specs To 0
Set Menu_Specs_Button_Cancel To 3
Set Menu_Specs_Button_Weapon_Mod_1 To 0
Set Menu_Specs_Button_Weapon_Mod_2_or_Cancel To 1
Set Menu_Specs_Button_Weapon_Mod_3_or_Cancel To 2
Set Menu_State To 0
Set None To -1
Set One_Copy To 1
Set Price_Multiplier To 1
Set True To 1
Set Weapon_Mod_1 To 1
Set Weapon_Mod_2 To 2
Set Weapon_Mod_3 To 3
Set Weapon_Mods_Total To 2 ; Implies a minimum of one weapon mod plus a cancel button.
; Alter weapon mod price based on provided multiplier.
Set Weapon_Mod_1_Price To Weapon_Mod_1_Price * Price_Multiplier
Set Weapon_Mod_2_Price To Weapon_Mod_2_Price * Price_Multiplier
Set Weapon_Mod_3_Price To Weapon_Mod_3_Price * Price_Multiplier
; Determine the status of the weapon mods.
If Weapon_Mods_Status == 0
	SetName "NOT APPLIED" Weapon_Mod_1_Status
	SetName "NOT APPLIED" Weapon_Mod_2_Status
	SetName "NOT APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 1
	SetName "APPLIED" Weapon_Mod_1_Status
	SetName "NOT APPLIED" Weapon_Mod_2_Status
	SetName "NOT APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 2
	SetName "NOT APPLIED" Weapon_Mod_1_Status
	SetName "APPLIED" Weapon_Mod_2_Status
	SetName "NOT APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 3
	SetName "APPLIED" Weapon_Mod_1_Status
	SetName "APPLIED" Weapon_Mod_1_Status
	SetName "NOT APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 4
	SetName "NOT APPLIED" Weapon_Mod_1_Status
	SetName "NOT APPLIED" Weapon_Mod_2_Status
	SetName "APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 5
	SetName "APPLIED" Weapon_Mod_1_Status
	SetName "NOT APPLIED" Weapon_Mod_2_Status
	SetName "APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 6
	SetName "NOT APPLIED" Weapon_Mod_1_Status
	SetName "APPLIED" Weapon_Mod_2_Status
	SetName "APPLIED" Weapon_Mod_3_Status
ElseIf Weapon_Mods_Status == 7
	SetName "APPLIED" Weapon_Mod_1_Status
	SetName "APPLIED" Weapon_Mod_2_Status
	SetName "APPLIED" Weapon_Mod_3_Status
EndIf
; Set the description of the first weapon mod.
If Weapon_Mod_1_Type == 1
	SetName "INCREASE WEAPON DAMAGE" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 2
	SetName "INCREASE AMMUNITION CAPACITY" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 3
	SetName "DECREASE WEAPON SPREAD" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 4
	SetName "DECREASE WEAPON WEIGHT" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 6
	SetName "REPLENISH WEAPON AMMUNITION" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 7
	SetName "DECREASE WEAPON EQUIP TIME" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 8
	SetName "INCREASE WEAPON RATE OF FIRE" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 9
	SetName "INCREASE PROJECTILE VELOCITY" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 10
	SetName "INCREASE WEAPON CONDITION" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 11
	SetName "REDUCE WEAPON MUZZLE REPORT AND FLASH" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 12
	SetName "SPLIT WEAPON BEAM" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 13
	SetName "VAULT-TEC ASSISTED TARGETING SYSTEM BONUS" Weapon_Mod_1_Description
ElseIf Weapon_Mod_1_Type == 14
	SetName "ADD WEAPON SCOPE AND/OR INCREASE ZOOM LEVEL" Weapon_Mod_1_Description
Else ; Failsafe for weapon mods that use type 0 or 5 to provide customized effects.
	SetName "NO DATA AVAILABLE" Weapon_Mod_1_Description
EndIf
; Set the description of the second weapon mod.
If Weapon_Mod_2_Type == 1
	SetName "INCREASE WEAPON DAMAGE" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 2
	SetName "INCREASE AMMUNITION CAPACITY" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 3
	SetName "DECREASE WEAPON SPREAD" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 4
	SetName "DECREASE WEAPON WEIGHT" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 6
	SetName "REPLENISH WEAPON AMMUNITION" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 7
	SetName "DECREASE WEAPON EQUIP TIME" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 8
	SetName "INCREASE WEAPON RATE OF FIRE" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 9
	SetName "INCREASE PROJECTILE VELOCITY" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 10
	SetName "INCREASE WEAPON CONDITION" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 11
	SetName "REDUCE WEAPON MUZZLE REPORT AND FLASH" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 12
	SetName "SPLIT WEAPON BEAM" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 13
	SetName "VAULT-TEC ASSISTED TARGETING SYSTEM BONUS" Weapon_Mod_2_Description
ElseIf Weapon_Mod_2_Type == 14
	SetName "ADD WEAPON SCOPE AND/OR INCREASE ZOOM LEVEL" Weapon_Mod_2_Description
Else ; Failsafe for weapon mods that use type 0 or 5 to provide customized effects.
	SetName "NO DATA AVAILABLE" Weapon_Mod_2_Description
EndIf
; Set the description of the third weapon mod.
If Weapon_Mod_3_Type == 1
	SetName "INCREASE WEAPON DAMAGE" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 2
	SetName "INCREASE AMMUNITION CAPACITY" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 3
	SetName "DECREASE WEAPON SPREAD" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 4
	SetName "DECREASE WEAPON WEIGHT" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 6
	SetName "REPLENISH WEAPON AMMUNITION" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 7
	SetName "DECREASE WEAPON EQUIP TIME" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 8
	SetName "INCREASE WEAPON RATE OF FIRE" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 9
	SetName "INCREASE PROJECTILE VELOCITY" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 10
	SetName "INCREASE WEAPON CONDITION" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 11
	SetName "REDUCE WEAPON MUZZLE REPORT AND FLASH" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 12
	SetName "SPLIT WEAPON BEAM" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 13
	SetName "VAULT-TEC ASSISTED TARGETING SYSTEM BONUS" Weapon_Mod_3_Description
ElseIf Weapon_Mod_3_Type == 14
	SetName "ADD WEAPON SCOPE AND/OR INCREASE ZOOM LEVEL" Weapon_Mod_3_Description
Else ; Failsafe for weapon mods that use type 0 or 5 to provide customized effects.
	SetName "NO DATA AVAILABLE" Weapon_Mod_3_Description
EndIf
; Check if the provided weapon can be modified. If the first weapon mod doesn't exist, it means it can't be.
If Weapon_Mod_1_Name == Does_Not_Exist
	MessageBoxEx "The terminal on the machine lights up as you insert your %n into the receptacle:%r%r        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%rERROR: INSERTED WEAPON <%n> CANNOT BE MODIFIED%r%rand provides you with a single option:|REMOVE <%n> FROM MACHINE" Equipped_Weapon, Equipped_Weapon, Equipped_Weapon
	Set Menu_State To Menu_Exit
Else
	Set Weapon_Mod_1_Exists To True
	; Check the number of mods available for the provided weapon. The first weapon mod has to exist by this point, so check for weapon mods number two and three and increment the counter.
	If Weapon_Mod_2_Name == Does_Not_Exist
		Set Weapon_Mod_2_Exists To False
	Else
		Set Weapon_Mod_2_Exists To True
		Set Weapon_Mods_Total To Weapon_Mods_Total + 1
	EndIf
	If Weapon_Mod_3_Name == Does_Not_Exist
		Set Weapon_Mod_3_Exists To False
	Else
		Set Weapon_Mod_3_Exists To True
		Set Weapon_Mods_Total To Weapon_Mods_Total + 1
	EndIf
	; Throw the message box.
	MessageBoxEx "The terminal on the machine lights up as you insert your %n into the receptacle:%r%r        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%rand provides you with %g options to choose from:|SPECS FOR <%n>%{|SPECS FOR <%n>%}%{|SPECS FOR <%n>%}|REMOVE <%n> FROM MACHINE" Equipped_Weapon, Weapon_Mods_Total, Weapon_Mod_1_Name, Weapon_Mod_2_Exists, Weapon_Mod_2_Name, Weapon_Mod_3_Exists, Weapon_Mod_3_Name, Equipped_Weapon
EndIf
End

Begin GameMode
; Specifications menu.
If Menu_State == 0 ; Can't use an alias here, for whatever reason.
	Set Menu_Specs_Button_Pressed To GetButtonPressed
	If Menu_Specs_Button_Pressed == None
		Return
	ElseIf Menu_Specs_Button_Pressed == Menu_Specs_Button_Weapon_Mod_1
		MessageBoxEx "The terminal reports the following:%r%r        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%r  NAME: <%n>%r  EFFECT: %n%r  STATUS: %n TO WEAPON <%n>%r  Price: %g CAPS%r%rand provides you with 2 options to choose from:|PURCHASE <%n>|PREVIOUS MENU" Weapon_Mod_1_Name, Weapon_Mod_1_Description, Weapon_Mod_1_Status, Equipped_Weapon, Weapon_Mod_1_Price, Weapon_Mod_1_Name
		Set Selected_Weapon_Mod To Weapon_Mod_1
		Set Menu_State To Menu_Purchase
	ElseIf Menu_Specs_Button_Pressed == Menu_Specs_Button_Weapon_Mod_2_or_Cancel
		If Weapon_Mod_2_Exists == True
			MessageBoxEx "The terminal reports the following:%r%r        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%r  NAME: <%n>%r  EFFECT: %n%r  STATUS: %n TO WEAPON <%n>%r  Price: %g CAPS%r%rand provides you with 2 options to choose from:|PURCHASE <%n>|PREVIOUS MENU" Weapon_Mod_2_Name, Weapon_Mod_2_Description, Weapon_Mod_2_Status, Equipped_Weapon, Weapon_Mod_2_Price, Weapon_Mod_2_Name
			Set Selected_Weapon_Mod To Weapon_Mod_2
			Set Menu_State To Menu_Purchase
		Else
			; No second weapon mod exists, which means the user opted to cancel out of the menu.
			Set Menu_State To Menu_Exit
		EndIf
	ElseIf Menu_Specs_Button_Pressed == Menu_Specs_Button_Weapon_Mod_3_or_Cancel
		If Weapon_Mod_3_Exists == True
			MessageBoxEx "The terminal reports the following:%r%r        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%r  NAME: <%n>%r  EFFECT: %n%r  STATUS: %n TO WEAPON <%n>%r  Price: %g CAPS%r%rand provides you with 2 options to choose from:|PURCHASE <%n>|PREVIOUS MENU" Weapon_Mod_3_Name, Weapon_Mod_3_Description, Weapon_Mod_3_Status, Equipped_Weapon, Weapon_Mod_3_Price, Weapon_Mod_3_Name
			Set Selected_Weapon_Mod To Weapon_Mod_3
			Set Menu_State To Menu_Purchase
		Else
			; No third weapon mod exists, which means the user opted to cancel out of the menu.
			Set Menu_State To Menu_Exit
		EndIf
	ElseIf Menu_Specs_Button_Pressed == Menu_Specs_Button_Cancel
		Set Menu_State To Menu_Exit
	EndIf
EndIf
; Purchase menu.
If Menu_State == 1 ; Can't use an alias here, for whatever reason.
	Set Menu_Purchase_Button_Pressed To GetButtonPressed
	If Menu_Purchase_Button_Pressed == None
		Return
	ElseIf Menu_Purchase_Button_Pressed == Menu_Purchase_Button_Purchase
		If Selected_Weapon_Mod == Weapon_Mod_1
			If Player_Caps >= Weapon_Mod_1_Price
				Player.RemoveItem Caps001 Weapon_Mod_1_Price
				Player.AddItem Weapon_Mod_1_Name One_Copy
			Else
				MessageEx "You do not have enough Caps to purchase this weapon mod."
			EndIf
		ElseIf Selected_Weapon_Mod == Weapon_Mod_2
			If Player_Caps >= Weapon_Mod_2_Price
				Player.RemoveItem Caps001 Weapon_Mod_2_Price
				Player.AddItem Weapon_Mod_2_Name One_Copy
			Else
				MessageEx "You do not have enough Caps to purchase this weapon mod."
			EndIf
		ElseIf Selected_Weapon_Mod == Weapon_Mod_3
			If Player_Caps >= Weapon_Mod_3_Price
				Player.RemoveItem Caps001 Weapon_Mod_3_Price
				Player.AddItem Weapon_Mod_3_Name One_Copy
			Else
				MessageEx "You do not have enough Caps to purchase this weapon mod."
			EndIf
		EndIf
		; Reset the names of the inaccessible vendor chests used to provide the description and status of all weapon mods.
		SetName "Michelle and Samuel's Trunk" Weapon_Mod_1_Description
		SetName "Michelle and Samuel's Trunk" Weapon_Mod_2_Description
		SetName "Michelle and Samuel's Trunk" Weapon_Mod_3_Description
		SetName "Michelle and Samuel's Trunk" Weapon_Mod_1_Status
		SetName "Blake's Shop" Weapon_Mod_2_Status
		SetName "Chet Inventory" Weapon_Mod_3_Status
		Set Menu_State To Menu_Exit
	ElseIf Menu_Purchase_Button_Pressed == Menu_Purchase_Button_Cancel
		Set Menu_State To Menu_Repeat
	EndIf
EndIf
; Repeat menu.
If Menu_State == 2 ; Can't use an alias here, for whatever reason.
	MessageBoxEx "        ROBCO INDUSTRIES WEAPON MOD VENDING MACHINE%r              COPYRIGHT 2075-2077 ROBCO INDUSTRIES%r%rThere are %g options to choose from:|SPECS FOR <%n>%{|SPECS FOR <%n>%}%{|SPECS FOR <%n>%}|REMOVE <%n> FROM MACHINE" Weapon_Mods_Total, Weapon_Mod_1_Name, Weapon_Mod_2_Exists, Weapon_Mod_2_Name, Weapon_Mod_3_Exists, Weapon_Mod_3_Name, Equipped_Weapon
	Set Menu_State To Menu_Specs
EndIf
End

 

All that's left is to add the numerical changes and figure out the whole .ini business and I might just have myself a script that would be worthy of being added to the existing release.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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