Jump to content

Having trouble trying to get two mods to interact.


Recommended Posts

I made a recharge spell that after its cast requires you to hold block to recharge your enchanted weapon and after trail and error got it to work and it behaves exactly as I wanted it to. I also have another mod Goldbrand of Lore which also requires you to hold block for an extended period of time to activate an ability which is a fire shield that consumes charge while active, and when both mods are activated at the same time this consumes charge faster than the recharge spell can, well, recharge. So to solve this I put a getplayerspell == 0 check before the fire shield portion so that it would not work while recharging, but this just kills the entire script or deactivates the mod. I tried shifting this check to all parts of the script still no solution. Even when I add the spell it should be looking for to the goldbrand mod itself and deactivate the Recharge mod and make clean save its like it remembers that I pissed it of and kills the mod, any assistance would be appreciated.

 

 

Goldbrand of Lore

 ScriptName GoldbrandEnchantmentScript

ref user
short normal
float btimer
float ctimer
float dctimer
float gtimer
short golden
short charged
short doonce
short spelldetected
short halfcloak
short fullcloak
short weaponswapped
short weaponsheath


Begin OnEquip
Set user To GetContainer
set normal to 1
set golden to 0
set ctimer to 0
set btimer to 0
set gtimer to 0
set charged to 0
set dctimer to 0
set spelldetected to 0
set fullcloak to 0
set weaponsheath to 1
set weaponswapped to 0
Set halfcloak to 0
End

Begin GameMode	

					if GetGameLoaded
						Set user To GetContainer 
						set normal to 1
						set golden to 0
						set btimer to 0
						set ctimer to 0
						set gtimer to 0
						set doonce to 0
						set charged to 0
						set dctimer to 0
						set spelldetected to 0
						set fullcloak to 0
						set weaponsheath to 1
						set weaponswapped to 0
						Set halfcloak to 0
						if user.GetEquipped Goldshield2  == 1
							set fullcloak to 1
						endif	
						if user.GetEquipped Goldshield1 == 1
							set halfcloak to 1
						endif
					endif	
					if GetCurrentCharge > 0
							set charged to 1
						else 
							set charged to 0		
					endif
;if user.IsBlocking == 1
;	if user.GetPlayerSpell 	RechargeSpell1 == 1 || user.GetPlayerSpell  RechargeSpell2 == 1 || user.GetPlayerSpell  RechargeSpell3 == 1
;			set spelldetected to 1			
;	endiF
;endif	
;	if user.GetEquipped RRRechageToken == 1
;		set spelldetected to 1		
;	endif	
		If user 
			if user.GetEquippedObject 16 == 	DAGoldbrand	
			if IsEquipped == 1		
				if user.GetPlayerSpell 	RechargeSpell1 == 0
						if user.IsWeaponOut == 1
							if	weaponsheath == 1
							set weaponsheath to 0
	;								Message "Weapon is drawn " 1
						endif	
							if user.IsAnimGroupPlaying attackbackpower
								SetEnchantment DAGoldbranBackPowerEnchant DAGoldbrand
	;							Message "backpower is working" 1
								set normal to 0	
						elseif user.IsAnimGroupPlaying attackforwardpower
								SetEnchantment DAGoldbrandForwardPowerEnchant DAGoldbrand
	;							Message "forwardpower is working" 1
								set normal to 0
						elseif user.IsAnimGroupPlaying attackPower
								SetEnchantment DAGoldbrandPowerEnchant DAGoldbrand
	;							Message "power is working" 1
								set normal to 0
						else
							if normal == 0
								SetEnchantment DAGoldbrandEnchant DAGoldbrand
	;							Message "return to normal is working" 1
								set normal to 1
						endif	
					endif
					if charged == 1
						if user.IsBlocking == 1
							
;							if user.GetPlayerSpell 	RechargeSpell1 == 0 ;if spelldetected == 0
							set gtimer to 10
							if fullcloak == 0
								set btimer to btimer + GetSecondsPassed
								;message " blocktimer " 1
								if btimer > 3 &&  halfcloak == 1
										user.UnEquipItemSilent Goldshield1
										user.RemoveItemNS Goldshield1 1
										user.RemoveSpell GoldbrandHalfCloak
										set btimer to 0	
										user.AddSpellNS GoldbrandFullCloak
										user.AddItemNS Goldshield2 1
										user.EquipItemSilent Goldshield2
										Set fullcloak to 1
	;									Message "Goldenarmor check" 1
							elseif  halfcloak == 0
									if  btimer > 3
										user.AddItemNS Goldshield1 1
										user.EquipItemSilent Goldshield1
										user.AddSpellNS GoldbrandHalfCloak
										Set halfcloak to 1
										set btimer to 0
	;									Message "Goldenshield check" 1
									endif
								endif
							;endif	
							endif	
						endif
					
								if halfcloak == 1
									if ctimer < 1
										set ctimer to ctimer + GetSecondsPassed
									else
										user.ModEquippedCurrentCharge -5 16
										set ctimer to 0
									endif
								endif
								if fullcloak == 1
									if ctimer < 1
										set ctimer to ctimer + GetSecondsPassed
									else
										user.ModEquippedCurrentCharge -15 16
										set ctimer to 0	
									endif
								endif
					endif
						if user.IsBlocking == 0
							set btimer to 0
							if gtimer > 0
								set gtimer to gtimer - GetSecondsPassed
							else
								if fullcloak == 1
										user.UnEquipItemSilent Goldshield2
										user.RemoveItemNS Goldshield2 1
										user.UnEquipItemSilent Goldshield1
										user.RemoveItemNS Goldshield1 1
										user.RemoveSpell GoldbrandHalfCloak
										user.RemoveSpell GoldbrandFullCloak
									set fullcloak to 0
									set doonce to 0
	;									Message "Goldenarmor removed check" 1
							elseif	halfcloak == 1				
										user.UnEquipItemSilent Goldshield1
										user.RemoveItemNS Goldshield1 1
										user.RemoveSpell GoldbrandHalfCloak
										user.RemoveSpell GoldbrandFullCloak		
										Set halfcloak to 0				
	;									Message "Goldenshield removed check" 1
							endif
						endif
					endif
					else 
						if weaponsheath == 0
							user.UnEquipItemSilent Goldshield1
							user.RemoveItemNS Goldshield1 1
							user.UnEquipItemSilent Goldshield2
							user.RemoveItemNS Goldshield2 1	
							user.RemoveSpell GoldbrandHalfCloak
							user.RemoveSpell GoldbrandFullCloak	
							set golden to 0
							set doonce to 0
							set fullcloak to 0
							Set halfcloak to 0
							set weaponsheath to 1
	;						Message "Weapon is sheath " 1
						endif
					endif
				else
					if weaponswapped == 0
							user.UnEquipItemSilent Goldshield1
							user.RemoveItemNS Goldshield1 1
							user.UnEquipItemSilent Goldshield2
							user.RemoveItemNS Goldshield2 1	
							user.RemoveSpell GoldbrandHalfCloak
							user.RemoveSpell GoldbrandFullCloak					
						set weaponswapped to 1
						set doonce to 0
				endif
			endif
		endif			
	endif	
endif		
End
begin OnUnEquip
user.UnEquipItemSilent Goldshield1
user.RemoveItemNS Goldshield1 1
user.UnEquipItemSilent Goldshield2
user.RemoveItemNS Goldshield2 1	
user.RemoveSpell GoldbrandHalfCloak
user.RemoveSpell GoldbrandFullCloak
;Message "Goldenshield unequipped check" 1
End

Rechagre spell

 

I attached the esp.

ScriptName RRWeaponrechargeScript1

ref user
ref Weapon
short active
short doonce
short blocking
short charging
short counter
float drain
float curmag
float rmag ; recorded mag
float maxmag
float maxcharge
float curcharge
float rcharge ;recorded charge
float window
Float myst
float rctimer ;recharge timer
float mtimer ;message timer
short goldbrand
float exspended
float infused
float infusedo ; original value
float exspendedm ; message
float exspendeds ; added until == 1
float exremainder ; fractions
float exspendedo ; original value
float infusedm ; message

Begin ScriptEffectStart
set blocking to GetControl 6
set user to PlayerRef
set weapon to user.GetEquippedObject 16
set maxcharge to user.GetObjectCharge weapon
set window to 3
set mtimer to 0
set counter to 1
set rctimer to 0
set goldbrand to 0
set exremainder	to 0
Set charging to 0
set active to 1
set doonce to 0
set curmag to user.GetActorValue Magicka
set maxmag to user.GetBaseActorValue Magicka
set myst to	user.GetActorValue Mysticism
if myst < 75 
	user.SetPowerTimer RechargeSpell1 3600		
elseif myst >= 75 && <100
	user.SetPowerTimer RechargeSpell1 1800
elseif	myst >= 100
	user.SetPowerTimer RechargeSpell1 1200
endif		
if user.GetEquippedObject 16 == DAGoldbrand
	set goldbrand to 1
endif	
set exspended to (maxmag*2)/100 ; 2%
set infused to ((myst/25) * exspended)/4
set exspended to (exspended/4) * (-1)	
set exspendeds to exspended
set exspendedo to exspended
set infusedo to infused
user.Dispel RechargeSpell3
StopMagicShaderVisuals RReffectRecharge3
SelectPlayerSpell RechargeSpell2
Message "level 1" 1
End

Begin Gamemode
set curmag to user.GetActorValue Magicka
set curcharge to user.GetEquippedCurrentCharge 16
set window to window - GetSecondsPassed
if user.GetEquippedObject 16 == Weapon
	if user.IsBlocking == 1
			
		if maxcharge > curcharge && curmag > 0
				
			set rctimer to rctimer + GetSecondsPassed
			if rctimer > .25
				set exspended to exspended + exremainder 
					if 	exspended < -1
						set drain to exspended *5
						user.ModActorValue2 magicka  exspended
						user.ModActorValue2 Fatigue  drain
						user.ModActorValue2 Health  exspended
					user.ModEquippedCurrentCharge infused 16
					set exremainder to  exspended % 1
					set exspended to exspendedo
					set infused to infusedo
				else
					set exspendeds to exspendeds + exspended
					if exspendeds < -1
						set exspended to exspendeds
						set exspendeds to exspendedo
					endif
					set infused to infused + infusedo
				endif			
				
				if doonce == 0
					set	rmag to curmag
					set rcharge to curcharge
					weapon.PlayMagicShaderVisuals RReffectRecharge1
					PlayMagicShaderVisuals RReffectRecharge1
					set doonce to 1
				endif
				set window to 3
				set rctimer to 0
				Set charging to 1		
			endif
		else 
			Set charging to 0
			set doonce to 0
			set window to 0
			
			user.RemoveItemNS RRRechargeToken 1
	endif
			if charging == 1
			user.AddItemNS RRRechargeToken 1
			set mtimer to mtimer + GetSecondsPassed
			if mtimer > 1
				set curmag to user.GetActorValue Magicka
				set curcharge to user.GetEquippedCurrentCharge 16
				set exspendedm to exspendedo *(-4)
				set infusedm to curcharge - rcharge				
				message "Capacity  %4.0f/%2.0f  charging at %2.1f per sec  magicka use %2.1f per sec  " , maxcharge, curcharge, infusedm, exspendedm 1
				set rcharge to curcharge
				set mtimer to 0
			endif
			endif
		  if goldbrand == 1
			if mtimer > .9
				DAGoldbrand.RunScriptLine 	"set gtimer to 0"			
		   endif
		endif		
	endif	
	if window <= 0
		SelectPlayerSpell RechargeSpell1
		StopMagicShaderVisuals RReffectRecharge1
			user.Dispel RechargeSpell1
			user.RemoveItemNS RRRechargeToken 1
	;	EnableControl 6
	endif
else
	SelectPlayerSpell RechargeSpell1
	StopMagicShaderVisuals RReffectRecharge1
		user.Dispel RechargeSpell1
		user.RemoveItemNS RRRechargeToken 1
;	EnableControl 6
endif		
End

Begin ScriptEffectFinish
	StopMagicShaderVisuals RReffectRecharge1
	user.Dispel RechargeSpell1
	user.RemoveItemNS RRRechargeToken 1
End

 

 

 

 

 

 

Link to comment
Share on other sites

Unless one of your mods is dependant on another as a master, you can't just use EditorIDs from different esp. What you need are IsModLoaded and GetFormFromMod functions. I don't know the esp name or FormIDs from your mod, but should look something like this:

if IsModLoaded "YourMod.esp"
     if GetPlayerSpell == GetFormFromMod "YourMod.esp" SpellFormID
          *do what you need*
     endif
endif

 

Link to comment
Share on other sites

Thanks alot qwertyasdfgh this is exactly what I was looking for. I never used the "mod" category of functions of obse before and might be needing them for future mods, btw I saw you can access a mods variable from another mod but that requires setting it up in the first mod you're going to be taking the variable from before hand, idk if there is a way that a mod can just read a variable without any adjustment done to the first mods script? If not that's fine your solution works thanks again!.

Link to comment
Share on other sites

There are 2 potential ways to retrieve a quest variable from another mod without dependency.

 

The first is GetVariable function. It requires a reference for a quest, so the aforementioned GetFormFromMod function is also needed, like this:

ref tempQuestRef
short variable

Let tempQuestRef := GetFormFromMod "YourMod.esp" QuestFormID
Let variable := GetVariable "something" tempQuestRef

Second is RunScriptLine function. It requires a string that is processed like a console command, for example:

RunScriptLine "set MyQuest.variable1 to QuestFromAnotherMod.variable2"

 

Link to comment
Share on other sites

  • 3 months later...
  • Recently Browsing   0 members

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