Metalfiend's scripting questions

Post » Tue May 17, 2011 6:29 am

I'm wanting to make a script that will lower the condition of the player's weapon to 0 (if it is something other than a staff) and then cause the player to drop the weapon. My first problem is i dont know how to make this script run in game, I cant attach it to every weapon.

Anyway this is what i came up with, which is total crap. If somebody could give me a push in the right direction that would be great.

scn MFweaponcurseV2;this will be attached to a birth sign ability (curse)Begin GameMode       If Player.GetWeaponType == 4			;weapon type 4 is staff                return       ElseIf Player.GetWeaponType != 4			                cast disentegrateWeapon player		;ill create the spell later                messagebox "You shall not spill blood"	;message from a god, ill try and make this less corny later       EndifEnd

User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Tue May 17, 2011 11:04 am

I'd assume you don't want this to happen to every weapon, all the time, or there would be no point in having weapons in the game. Under what circumstances do you want this to happen?

It could be the effect of someone casting a spell, or the player entering a specific location, or various other things, and each one would be handled a little differently.
User avatar
Scott Clemmons
 
Posts: 3333
Joined: Sun Sep 16, 2007 5:35 pm

Post » Tue May 17, 2011 4:31 pm

I found a mod that gives the player an enchanting spell and I found another mod that allows you to enchant staves properly. I wanted to make a class that has to rely on enchanting to most of his/her damage. I'm going to make a new birth sign that caused stunted magica, the no weapons curse, and increase the power of the players enchanting ability.
User avatar
Dominic Vaughan
 
Posts: 3531
Joined: Mon May 14, 2007 1:47 pm

Post » Tue May 17, 2011 11:55 am

But do you want the player to equip any other weapon and then have it disintegrate and drop, or just prevent him equipping it in the first place?

In either case, you'd need to catch the attempt in menu mode when the item is selected from the inventory. At that point, either deny the attempt, or have the player cast a "Disintegrate Weapon on self" spell at a high enough value to break any weapon - e.g. 10000. The broken weapon then gets unequipped (but not dropped) by the game. The spell would be a Lesser Power so that the player could always cast it at zero magicka cost. The easiest way may be to just turn on a quest variable (flag) when the inventory menu is opened, and then test it in a quest script as soon as the inventory closes. If set, turn it back off and look in the weapon slot to see if anything needs disintegrating.

You'd probably have to do some extra work to make sure the player can't put a weapon onto a hotkey to bypass the equipping from inventory, possibly by checking the hotkey assignments for weapons at the same time as the weapon slot.
User avatar
Gisela Amaya
 
Posts: 3424
Joined: Tue Oct 23, 2007 4:29 pm

Post » Tue May 17, 2011 11:20 am

Thanks for the info. This is exactly what I wanted, some direction.

I have two questions.

1.Menu mode block: does this script have to be attached to something or will it run when ever the player opens the menu just as long as the script is in the esp?

2.If I'm understanding you right, this will be two scripts one will be the menumode script and the other a quest script? The menu mode script will "enable" the quest script which will cast disintegrate along with a message?

Edit: Or is it just one script that is a quest script (which is kind of like a global script right?)
User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am

Post » Tue May 17, 2011 3:48 am

1.Menu mode block: does this script have to be attached to something or will it run when ever the player opens the menu just as long as the script is in the esp?
Not attached to anything, but the script must be a Quest script, and a Quest must be Start Game Enabled, and have this script as its Quest Script.

2.If I'm understanding you right, this will be two scripts one will be the menumode script and the other a quest script? The menu mode script will "enable" the quest script which will cast disintegrate along with a message?

Edit: Or is it just one script that is a quest script (which is kind of like a global script right?)
Right. And this can have one GameMode block and one MenuMode block (or even several MenuMode blocks for different menutypes) if needed.
User avatar
Laura-Jayne Lee
 
Posts: 3474
Joined: Sun Jul 02, 2006 4:35 pm

Post » Tue May 17, 2011 3:24 am

I made a start game enabled quest and attached this quest script to it.

Spoiler
scn MFQWeaponCurse1Ref EquipedWeaponBegin MenuModeSet EquipedWeapon to Player.GetEquippedObject 16	IF Player.GetWeaponType EquipedWeapon != 4		MessageBox "testing 1 2 3"	EndIfEnd


The result was i would get the "testing 1 2 3" message every few seconds (even on the select saved game screen) regardless if I had a weapon equipped or not.
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Tue May 17, 2011 3:51 pm

Ok, I changed menumode to a specific menu. Now I only get the message in the inventory screen, but It still pops up every few seconds weather i have a weapon equipped or not.

new script
Spoiler
scn MFQWeaponCurse1Ref EquipedWeaponBegin MenuMode 1002Set EquipedWeapon to Player.GetEquippedObject 16	IF Player.GetWeaponType EquipedWeapon != 4		MessageBox "testing 1 2 3"	EndIfEnd


EDIT: For some reason "!=" doesn't work. I changed "!=" to "==", opened my inventory menu and nothing happened (I got gitty like a school girl) then I equipped a staff and boom I get the message like I'm supposed to. This isn't exactly what i wanted, but it's a start.


EDIT 2: Here is my newest attempt.

Spoiler
scn MFQWeaponCurse1Ref EquipedWeaponBegin MenuMode 1002Set EquipedWeapon to Player.GetEquippedObject 16	IF Player.GetWeaponType EquipedWeapon == 0		MessageBox "Sword"	ElseIf Player.GetWeaponType EquipedWeapon == 1		MessageBox "Big sword"	ElseIf Player.GetWeaponType EquipedWeapon == 2		MessageBox "Blunt"	ElseIf Player.GetWeaponType EquipedWeapon == 3		MessageBox "Big,,,,, Blunt?"	ElseIf Player.GetWeaponType EquipedWeapon == 5		MessageBox "Bow"	EndIfEnd


I'm getting a similar result to one the earlier script attempts. I get the "Sword" message whenever i'm in the inventory screen regardless if I have a sword equipped or not.


EDIT 3: Ok for some reason "IF Player.GetWeaponType EquipedWeapon == 0" messes everything up. It's something to do with "0", But "0" is 1hSword so I don't understand what what the problem is. "4" works fine, when ever i equip a staff I get the message.


EDIT4: solved.

Spoiler
scn MFQWeaponCurse1Ref WeaponShort WeaponTypeBegin MenuMode 1002Set Weapon to Player.GetEquippedObject 16Set weapontype to GetWeaponType Weapon	IF WeaponType < 0								;probably unnecessary		return	ElseIF WeaponType == 0		If Player.GetEquippedObject 16 == 0			return		ElseIf Player.GetEquippedObject 16  != 0			MessageBox "Sword"		EndIf	ElseIF WeaponType == 4		MessageBox "Staff"	Else													;probably unnecessary		Return	EndIfEnd

User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Tue May 17, 2011 5:14 am

Ok, new question. Can I force the menu to close from a menumode block. I know there is a toggleMenus function in morrowind, but I cant save my script in tes4cs, it says, "console only command". Is there a workaround for this or maybe a obse command?

Edit: sorry i found it
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Tue May 17, 2011 10:36 am

I'm trying to figure out the obse function "SetScript". I can't get it to work. The test script I've set up is a spell effect that sets a script to the currently equipped weapon.

The spell script that sets the script
Spoiler
scn MfSpellSetScriptRef WeaponRef MfSetScriptTarBegin GameModeSet Weapon to Player.GetEquippedObject 16Weapon.SetScript MfSetScriptTar Player.UnequipItem weaponPlayer.EquipItem WeaponEnd


The simple test script
Spoiler
scn MfSetScriptTarShort ControlVarBegin OnEquip	If ControlVar == 0		MessageBox "Test 1 2 3"		Set ControlVar to 1	EndIfEnd


The spell script un/re-equips the weapon which I thought would start the OnEquip script on the weapon. But it doesn't.
User avatar
Alisha Clarke
 
Posts: 3461
Joined: Tue Jan 16, 2007 2:53 am


Return to IV - Oblivion