Jump to content

Help create a script


Recommended Posts

Read more:


Does everyone remember the magic system in Morrowind? If you cast magic, you can not equip weapons, you had to choose one, or you use magic, or weapons, and not all at once, so I want to return this system to Skyrim, so that when you equip weapons(in the left or right hand), you can not choose magic, or play purely with weapons, or purely with magic!

Link to comment
Share on other sites

Some things cannot be done since this kind of functions are "Hard Coded" and is the Skyrim base structure of the game engine mechanic system.


Although, you could do something like this (dummy mechanic), but it'll require the creation of a script that will have all Skyrim spells in it, and listen for those spells when they are equipped and then force unequipped them each time, and vise versa for weapons.


This has the disadvantage that you can only do this with Skyrim spell since it is impossible to add every single spell that exists out there (as they exist spell mods), plus a lot of those spell mods don't use the convesional vanilla spell mechanics and they moddify a lot of things, so taking a short cut and listen for example the school they apply might not even work as a lot of them don't even use school of magic and the whole spell is just scripted.


I hope i've covered the basics...


EDIT: a bunch of typos...

Edited by maxarturo
Link to comment
Share on other sites

Maxaturo you don't need to check for all spells and weapons in the script. You can just check by casting As weapon, or As spell. To do this, I would make a new Spell Ability and put it on the player. Put this script on the magic effect:

 

 

 

Scriptname WeaponSpellRestricScript extends ActiveMagicEffect 

Actor Target

Event OnEffectStart(Actor akTarget, Actor akCaster)
    Target = akTarget
EndEvent 

Auto State NothingEquipped 
    Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) 
        If (akBaseObject as Spell) && (akBaseObject as Shout) == false ;if a spell was equipped and its not a shout
            GoToState("SpellEquipped")
        Elseif (akBaseObject as Weapon) ;if a weapon was equipped
            GoToState("WeaponEquipped")
        Endif
    EndEvent 
EndState

State SpellEquipped 

    Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) 
        If (akBaseObject as Weapon)
            Target.UnEquipItem(akBaseObject) 
        Endif
            
    EndEvent
    
    Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
        Utility.Wait(0.1) 
        If Target.GetEquippedItemType(0) != 9 && Target.GetEquippedItemType(1) != 9 ;if no spells are equipped 
            GoToState("NothingEquipped")
        Endif 
    EndEvent 
    
EndState
            
State WeaponEquipped 

    Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) 
        If (akBaseObject as Spell) && (akBaseObject as Shout) == false
            Target.UnEquipItem(akBaseObject) 
        Endif
    EndEvent
    
    Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
        Utility.Wait(0.1) 
        If Target.GetEquippedItemType(0) == 0 || Target.GetEquippedItemType(0) == 9 || Target.GetEquippedItemType(0) == 10 || Target.GetEquippedItemType(0) == 11  
            If Target.GetEquippedItemType(1) == 0 || Target.GetEquippedItemType(1) == 9 || Target.GetEquippedItemType(1) == 10 || Target.GetEquippedItemType(1) == 11 
                ;if no weapons are equipped
                GoToState("NothingEquipped")
            EndIf
        Endif 
    EndEvent 
    
EndState   

Edited by dylbill
Link to comment
Share on other sites

@ dylbill

Your scripting logic makes sense and can work as a 'Dummy Mechanic'.


Note:

I mostly check this forums for assistance before i go to work while i'm still kind of sleeping, or before i go to sleep while my brain is tired and already overflowed with data, in some rare cases during some modding or working breaks, here is most likely that i can be more precise.


Fortunately for everyone this is an open forum and other experience modders as yourself can also lay a hand.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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