Jump to content

Putting my script in game


erratichippo

Recommended Posts

Hello, I am having some trouble getting my script into the game. It compiles just fine I just dont know how to activate it. The function of this script is to assign a hotkey to cast spells with a two handed weapon. I was getting really annoyed with having to enter a menu screen during my combat sequences to switch to spells. Normally I attach my scripts to an object like a spell or weapon. But I want this script to just run all the time while I am in game. Any idea how I can do that? I suppose I could tie this into an active magic effect that is always on the character, but I am wondering if there is a better way to do this.

 

Thank you

 

Scriptname z_two_handed_weapon_cast extends Actor

Bool Function IsKeyPressed(Int dxKeycode) Global Native
Bool bIsHotkeyPressed 
Int Property iHotkey = 260 Auto 
Int Property WeaponType Auto
Int Property WeaponTypeStorage Auto
Int Property aihand = 0 Auto
Spell Property WardSteadfastLeftHand Auto

Event onInit()
RegisterForSingleUpdate(0.5)
EndEvent 
Event OnUpdate()
If bIsHotkeyPressed != IsKeyPressed(iHotkey) ; Only run code when the status changes
	bIsHotkeyPressed = !bIsHotkeyPressed ; Set bool to whatever it isn't 
	If bIsHotkeyPressed ; ==True
		Debug.Trace("Hotkey Pressed")
		WeaponTypeStorage = Game.GetPlayer().GetEquippedItemType(1)  
		If(WeaponTypeStorage == 5 || WeaponTypeStorage == 6)
			Debug.Trace("Weapon was two handed")	
			Game.GetPlayer().GetEquippedWeapon().SetWeaponType(1)
			Game.GetPlayer().EquipSpell(WardSteadfastLeftHand, 0)
		Endif			
	Else  
		Debug.Trace("Hotkey Released")
		If bIsHotkeyPressed == False
			Game.GetPlayer().GetEquippedWeapon().SetWeaponType(WeaponTypeStorage)
		Endif		
	Endif		
Endif
RegisterForSingleUpdate(0.5)
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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