Jump to content

Script - Changing weapon based on current magicka?


Deridor

Recommended Posts

I want to create a set of weapons that grow stronger or weaker based on your reserves of magicka (I.E. they would be stronger with fortify magicka effects, weaker when you use your magicka). MY plan for this is for the weapon to switch out whenever your magicka goes above certain levels (or is at 0, if that should happen).

 

I have some experience with TES modding, but virtually no scripting experience in oblivion (been far too long to remember much from morrowind either), but I know this is at least somewhat possible, due to dawnfang/duskfang.

 

So is it possible to make a swapping script that reads your current magicka level? or am I better off attempting just a basic scaling with the users intelligence?

Link to comment
Share on other sites

If you insist on swapping weapons around to change the damage the player does, then I advise you use a basic scaling method - magicka fluctuates a lot, so the weapon could constantly be shifting around and some people would barely get a chance to swing before they have to redraw another version of the weapon.

 

However, if you use OBSE you can directly modify the weapon's damage, without swapping it out and making the player redraw their weapon. The commands "SetAttackDamage" and "ModAttackDamage" are what you need.

Link to comment
Share on other sites

I had planned on tying in a visual change as well, using slightly altered models for each one (since that is entirely possible with the weapon swapping method). Guess I'll find another way...

 

I would prefer not to use OBSE, it (most likely in part with some mods I have floating around) causes my fps to drop to about half, and I would like to enjoy my own mod :P

Link to comment
Share on other sites

The problem with non obse format is that when you change the weapon out, you will have the animation of the player drawing the weapon. This is the issue pointed out by WarRatsG. If you use player.removeitem and player.additem, you will have to set another piece of code to make the player equip it. There is a code on Dawnfang, a sword you get from Shivering Isles which has a similar code:

 

scn DawnfangScript

;related to DuskfangScript

short ShouldEquip						;This variable is a flag if the weapon was previously equipped for use when the weapons swap


;This block resets the global variable SESwordDawnfangKills and sets the should equip flag if the previous weapon was equipped

begin OnAdd Player

Set SESwordDawnfangKills to 0
if ( SESwordDuskfangEquip == 1 )
	Set ShouldEquip to 1
	Set SESwordDuskfangEquip to 0
endif

end

;This block sets the equip flag upon equip of this weapon, the second block does the opposite

begin OnEquip Player

if ( SESwordDawnfangEquip < 1 )
	Set SESwordDawnfangEquip to 1
endif

end

begin OnUnEquip Player

if ( SESwordDawnfangEquip > 0 )
	Set SESwordDawnfangEquip to 0
endif

end

;This block auto-equips the weapon if the should equip flag was set to 1.. it equips the entire list, as we dont know which one the player has

begin gamemode

if ( ShouldEquip == 1 )
	Player.EquipItem SE03Dawnfang01
	Player.EquipItem SE03Dawnfang05
	Player.EquipItem SE03Dawnfang10
	Player.EquipItem SE03Dawnfang15
	Player.EquipItem SE03Dawnfang20
	Player.EquipItem SE03Dawnfang25
	Player.EquipItem SE03Dawnfang30
	Player.EquipItem SE03Dawnfang01A
	Player.EquipItem SE03Dawnfang05A
	Player.EquipItem SE03Dawnfang10A
	Player.EquipItem SE03Dawnfang15A
	Player.EquipItem SE03Dawnfang20A
	Player.EquipItem SE03Dawnfang25A
	Player.EquipItem SE03Dawnfang30A
	Set SESwordDawnfangEquip to 1
	Set ShouldEquip to 0
endif

end

 

It utilizes the player.equipitem block. I'm not sure if this runs the animation of player unsheathing the sword or not, but it might. The other code attatched to this sword is on a quest:

 

scn SE03TsaesciBladeScript

;DawnfangScript related
;DuskfangScript related

short Dawnblade				;This is the trigger variable to make the change (sets off the gamemode block) to Dawnfang
short Duskblade				;This is the trigger variable to make the change (sets off the gamemode block) to Duskfang
short Exchange				;This is a DoOnce variable that is set after the change then reset in the timing blocks
short Daytime					;This is a DoOnce variable for the timing block in the daytime mode
short Dusktime					;This is a DoOnce variable for the timing block in the evening mode
short Test						;This is a DoOnce variable for the original rewarding of the weapon
short Reward					;This is a trigger variable for the original rewarding of the weapon from Kiliban in SE03

float fQuestDelayTime

begin gamemode

;These blocks determine when the blades will "change form"

if ( Daytime == 0 )
	if ( Gamehour >= 6 ) && ( Gamehour < 18 )
		Set Dusktime to 0
		Set Exchange to 0
		Set Duskblade to 0
		Set Dawnblade to 1
		Set Daytime to 1
	endif
endif

if ( Dusktime == 0 )
	if ( Gamehour >= 18 ) || ( Gamehour < 6 )
		Set Daytime to 0
		Set Exchange to 0
		Set Dawnblade to 0
		Set Duskblade to 1
		Set Dusktime to 1
	endif
endif

;These blocks handle the actual exchange. Because we dont know what type of blade (level) the player will have, we test for all of them.

if ( Dawnblade == 1 )
	if ( Player.IsInCombat == 0 ) && Player.IsRidingHorse == 0 
		if ( Exchange == 0 )
			if ( Player.GetItemCount SE03Duskfang01 == 1 ) || ( Player.GetItemCount SE03DuskFang01A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang01 1
					Player.Removeitem SE03Duskfang01 1
					Player.Removeitem SE03Duskfang01A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang01A 1
					Player.Removeitem SE03Duskfang01 1
					Player.Removeitem SE03Duskfang01A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang05 == 1 ) || ( Player.GetItemCount SE03DuskFang05A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang05 1
					Player.Removeitem SE03Duskfang05 1
					Player.Removeitem SE03Duskfang05A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang05A 1
					Player.Removeitem SE03Duskfang05 1
					Player.Removeitem SE03Duskfang05A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang10 == 1 ) || ( Player.GetItemCount SE03DuskFang10A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang10 1
					Player.Removeitem SE03Duskfang10 1
					Player.Removeitem SE03Duskfang10A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang10A 1
					Player.Removeitem SE03Duskfang10 1
					Player.Removeitem SE03Duskfang10A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang15 == 1 ) || ( Player.GetItemCount SE03DuskFang15A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang15 1
					Player.Removeitem SE03Duskfang15 1
					Player.Removeitem SE03Duskfang15A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang15A 1
					Player.Removeitem SE03Duskfang15 1
					Player.Removeitem SE03Duskfang15A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang20 == 1 ) || ( Player.GetItemCount SE03DuskFang20A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang20 1
					Player.Removeitem SE03Duskfang20 1
					Player.Removeitem SE03Duskfang20A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang20A 1
					Player.Removeitem SE03Duskfang20 1
					Player.Removeitem SE03Duskfang20A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang25 == 1 ) || ( Player.GetItemCount SE03DuskFang25A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang25 1
					Player.Removeitem SE03Duskfang25 1
					Player.Removeitem SE03Duskfang25A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang25A 1
					Player.Removeitem SE03Duskfang25 1
					Player.Removeitem SE03Duskfang25A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Duskfang30 == 1 ) || ( Player.GetItemCount SE03DuskFang30A == 1 )
				if ( SESwordDuskfangKills < 12 )
					Player.Additem SE03Dawnfang30 1
					Player.Removeitem SE03Duskfang30 1
					Player.Removeitem SE03Duskfang30A 1
					Set Exchange to 1
				else
					Player.Additem SE03Dawnfang30A 1
					Player.Removeitem SE03Duskfang30 1
					Player.Removeitem SE03Duskfang30A 1
					Set Exchange to 1
				endif
			endif
		endif
	endif
endif

if ( Duskblade == 1 )
	if ( Player.IsInCombat == 0 ) && Player.IsRidingHorse == 0
		if ( Exchange == 0 )
			if ( Player.GetItemCount SE03Dawnfang01 == 1 ) || ( Player.GetItemCount SE03Dawnfang01A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang01 1
					Player.Removeitem SE03Dawnfang01 1
					Player.Removeitem SE03Dawnfang01A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang01A 1
					Player.Removeitem SE03Dawnfang01 1
					Player.Removeitem SE03Dawnfang01A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang05 == 1 ) || ( Player.GetItemCount SE03Dawnfang05A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang05 1
					Player.Removeitem SE03Dawnfang05 1
					Player.Removeitem SE03Dawnfang05A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang05A 1
					Player.Removeitem SE03Dawnfang05 1
					Player.Removeitem SE03Dawnfang05A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang10 == 1 ) || ( Player.GetItemCount SE03Dawnfang10A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang10 1
					Player.Removeitem SE03Dawnfang10 1
					Player.Removeitem SE03Dawnfang10A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang10A 1
					Player.Removeitem SE03Dawnfang10 1
					Player.Removeitem SE03Dawnfang10A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang15 == 1 ) || ( Player.GetItemCount SE03Dawnfang15A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang15 1
					Player.Removeitem SE03Dawnfang15 1
					Player.Removeitem SE03Dawnfang15A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang15A 1
					Player.Removeitem SE03Dawnfang15 1
					Player.Removeitem SE03Dawnfang15A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang20 == 1 ) || ( Player.GetItemCount SE03Dawnfang20A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang20 1
					Player.Removeitem SE03Dawnfang20 1
					Player.Removeitem SE03Dawnfang20A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang20A 1
					Player.Removeitem SE03Dawnfang20 1
					Player.Removeitem SE03Dawnfang20A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang25 == 1 ) || ( Player.GetItemCount SE03Dawnfang25A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang25 1
					Player.Removeitem SE03Dawnfang25 1
					Player.Removeitem SE03Dawnfang25A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang25A 1
					Player.Removeitem SE03Dawnfang25 1
					Player.Removeitem SE03Dawnfang25A 1
					Set Exchange to 1
				endif
			elseif ( Player.GetItemCount SE03Dawnfang30 == 1 ) || ( Player.GetItemCount SE03Dawnfang30A == 1 )
				if ( SESwordDawnfangKills < 12 )
					Player.Additem SE03Duskfang30 1
					Player.Removeitem SE03Dawnfang30 1
					Player.Removeitem SE03Dawnfang30A 1
					Set Exchange to 1
				else
					Player.Additem SE03Duskfang30A 1
					Player.Removeitem SE03Dawnfang30 1
					Player.Removeitem SE03Dawnfang30A 1
					Set Exchange to 1
				endif
			endif
		endif
	endif
endif

end

 

While I will not modify/write these for you, If you would like I could write the scripts and release them as source here on the nexus. Or I could pm them to you for credit on the work.

Edited by theuseless
Link to comment
Share on other sites

You could try to add the blade to your player (player.additem SE03Duskfang30A 1). If the animation plays, then I would skip this code. If not, then this code has it somewhere inside to make it right. It says in the beginning that it wont change out if the player is in combat or riding a horse (if Player.IsInCombat == 0 && Player.IsRidingHorse == 0), which makes me think that it will play the anim.

 

The hard way would be to make it check every time you hit something with it, then add a spell which causes the damage to whatever it hit. This is difficult at best without obse.

Edited by theuseless
Link to comment
Share on other sites

Ok, replying to another post later led me to this idea. Check the post herefor more details. Ok. So we can supermodify this code to suit your purpose. You can get more shaders and effects visuals on the nexus and other sites. Experiment around with them or at least the vanilla ones. List of vanilla shaders is here. Vanilla effects visuals are here. So if you use the functions in the post aforementioned, you should be able to make a relevant check to player.GetAV magic and then determine a set of if conditions to modify how much damage is used. I'm going to go work on my mod now, but you should post a new topic in the mod requests if this kick in the bum didn't get ya thinkin :turned: . Just link them back here and it should all fall into place simply.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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