Jump to content

Lost already, Duality magicka


Xenavire

Recommended Posts

I am having a load of issues already, so I need some advice, help, and maybe someone to slap me if I get too hysterical.

 

I am trying to make a second Magicka resource, that works by refilling/draining dependant on magicka use. The issue I am having first of all is I have no idea how to create a second magicka, or have any idea how to make the CS recognise it, or how to make spells that point to it....

 

My problems are numerous. And the reason is I am completely new to scripting, but I honestly don't care, I am going to damn welll figure this out, because I am too stupid and stubborn to know when to quit.

 

So my very first question it this. Could I take the script from magicka, copy the contents and make a new FormID and name, and tweak around other values, and save the new script and have it actually work? And if so, where do I find the script effect for magicka? (I have been looking for it in the CS with absolutely no luck, cant find health/fatigue either.)

 

If that wont work, can I script a new resource that will be recognised in spell making? (It would be entirely dependant on magicka this way, with no chance of it being seperate.) And if so, what script calls/functions would I need to use to tell the game to check magicka use/damage and grant to the new resource that exact same amount?

 

More questions will undoubtedly follow these, but I can't even start without at least one of these answered.

Link to comment
Share on other sites

OK, on advice from someone I am looking into using a global variable, but before I do that I need to figure out if I can use a negative value to magicka for spells. This would probably have to be individually scripted for each and every spell, and would need additional scripts if I want its "magicka cost" to change with skill level.

 

Are these correct assumptions, and how would it need to be structured?

 

Another thought has occured to me, which MIGHT make the whole much more simple: Could I create a script that I can attatch to each spell that works on spell cast, and it checks how much magicka you have left (since the other resource is simply the lack of magicka) and if you would not go over that amount, it adds the mana cost, instead of removing it? (Say the base magicka cost would be 50, which usually uses up 50 magiacka. But with this script attached, when the spell is cast it checks and finds the max magicka of the player minus the current magicka of the player, and if it is greater than the cost of the spell it adds that amount of magicka to the player?)

 

So say at 100 max magicka you use one spell costing 30 magicka, bringing your current magicka down to 70. You don't have enough to cast your 50 negative magicka spell yet, so you cast that same 30 cost normal magicka spell, brining your total down to 40 magicka. You now have enough for your negative magicka spell (100-40=60) and you cast it, bringing your total magicka back up to 90.

 

 

Any help here would be greatly appreciated.

Link to comment
Share on other sites

Hi :)

 

We've already spoke a lot about this, but I'll answer the questions here as well, so that all the information is in one place.

 

The issue I am having first of all is I have no idea how to create a second magicka, or have any idea how to make the CS recognise it, or how to make spells that point to it....

So my very first question it this. Could I take the script from magicka, copy the contents and make a new FormID and name, and tweak around other values, and save the new script and have it actually work? And if so, where do I find the script effect for magicka? (I have been looking for it in the CS with absolutely no luck, cant find health/fatigue either.)

 

The mechanics of magicka are hardcoded into the system, in a way that we cannot directly mod. All you need to do is create a system that gets the engine working with you instead of against you.

 

My problems are numerous. And the reason is I am completely new to scripting, but I honestly don't care, I am going to damn welll figure this out, because I am too stupid and stubborn to know when to quit.

 

That's the way to go man. Keep fixing and tweaking things for long enough and eventually there won't be anything left to fix or tweak.

 

can I script a new resource that will be recognised in spell making? (It would be entirely dependant on magicka this way, with no chance of it being seperate.) And if so, what script calls/functions would I need to use to tell the game to check magicka use/damage and grant to the new resource that exact same amount?

 

No, for the same reasons that you can't create a new resource in the first place. You can find most functions and commands at the CS Wiki

 

OK, on advice from someone I am looking into using a global variable, but before I do that I need to figure out if I can use a negative value to magicka for spells. This would probably have to be individually scripted for each and every spell, and would need additional scripts if I want its "magicka cost" to change with skill level.

 

I don't think you can use negative magicka for spells. Also, you cannot attach scripts directly to spells, like you would attach a script to an object. You can refer to spells through script though. And I think you misunderstood how I said to use a global variable, but I'll explain that in a second.

 

 

Could I create a script that I can attatch to each spell that works on spell cast, and it checks how much magicka you have left (since the other resource is simply the lack of magicka) and if you would not go over that amount, it adds the mana cost, instead of removing it?

 

Not directly. OBSE has an OnCast event handler that runs whenever you cast a spell, and you could use GetPlayerSpell to see which spell is "equipped" at the time. This would be easier on the CPU, but as you pointed out to me an Extended Hotkey cycler would be too quick, so using IsCasting every frame may work. This also requires OBSE.

 

 

 

Before I offer my own suggestion, I'm going to make sure I understand this correctly...

You want to stop all magicka regeneration, and when the player casts a spell, the cost of that spell decreases the players magicka and increases a separate value, Anti magicka. Anti magicka is used for a different set of spells, and when those spells are cast, anti magicka is decreases and normal magicka increases. They always add up to the player's maximum magicka.

 

Which spells will use anti magicka? For my suggestion, I am assuming it is entire schools.

 

 

 

Personally, I would suggest you keep using the global variable the way that I mentioned before. I will go into more detail.

 

 

Create 2 global variables, which we will call "Magic" and "AntiMagic". "Magicka" will refer to the amount of spell points available, just like vanilla.

 

Lets assume that destruction uses magic and restoration uses anti magic. The player has 100 magicka.

A script will compare this value to your maximum magicka. If we assume that your maximum magicka is 100, then the script will set Magic to 100 and set AntiMagic to 0.

 

The destruction spell is cast, removing 40 points of magicka. Magic is now set to 60 and AntiMagic is now set to 40.

 

The player switches to the restoration spell. The script notices this, and then sets your magicka to 40. A boolean value is switched, to let the script know that you are using "Anti Magicka", although the only difference is what you call it. If you still want that HUD bar, you activate it now, preferably over the top of the original magicka bar.

 

The restoration spell is cast, which costs 20 magicka. This is deducted from your current magicka, just as the game normally does, and the script sets AntiMagic to 20 and Magic to 80.

 

The player switches back to the destruction spell. Again, the script notices this, and sets your magicka to 80, switching the boolean value again and optionally removing the HUD bar.

 

In response to the cycler issue, if (IsCasting == 1) - as in the player is currently casting a spell - then the boolean value locks in place until the spell has been cast.

 

This way, you do not have to create brand new dynamics - the engine treats it no differently than it treats normal magicka, because from a technical point of view, it is normal magicka. You just call it something different. This allows you to use any spell, vanilla or mod-added, as you do not have to explicitly refer to each spell. This is what I call "Dynamic scripting", as it can be used with anything.

 

 

 

Like I have always said, you don't need to make Oblivion jump through hoops, just make everyone think you did. This is because you will always script on Oblivion's terms, but you can tell people whatever you want.

In other words, you don't need to do some fancy modding to somehow alter the game's dynamics. You just need something that looks like what you want. Then you can call it anything you like.

Edited by WarRatsG
Link to comment
Share on other sites

OK, that alternate version you mentioned, IsCasting, would fix the issue I forsee with Enhanced hotbars autocast feature? If so, then I can't think of a single thing wrong with anything you have said, and all that leaves is learning how to put that information into script.

 

So far I have almost nothing, I got as far as "Begin" and got confused about what variables and functions I needed, or what order to place them.

 

I have been browsing the tutorials on the CS Wiki all day, but nothing is enlightening me to which functions I need sadly.

Once I have those, figuring it out from there shouldn't be too hard, as I am not completely stupid, and I did a little basic C++ a few years back. Most of it is figuring out the cause and effect, and the order you need to place things.

 

I also was browsing through the scripts from the oblivion ESM, can't find anything similar to this (a tip from CS Wiki), so figuring out how to structure this is giving me headaches.

 

First off, do I need a playerref to start this script, since it makes calls off the player? Or do I need getactorvalue? or both?

 

Figuring out the skeleton of this mod will make the whole thing easier.

 

Also, as a note for later, how would a script I need to add to the spells be like? Would it be a simple reference? Or does it require its own script to define it as seperate from normal spells? (For the main script to intereact with?)

 

Edit: I do have some temporary script for notifications, obviously WIP, still need to work on the actual framework.

scriptname Dualityalpha

Begin GameMode
GetSpellRef TemporaryPlaceholder
If TemporaryPlaceholder == 1
	Message "Anti-Magicka is flowing." ;Tells player s/he is using a Antimagic enabled spell.
Elseif TemporaryPlaceholder == 0
	Message "Magicka is flowing."
Endif
End

 

Feel free to critique, I am new to this so anything is helpful.

Edited by Xenavire
Link to comment
Share on other sites

OK, that alternate version you mentioned, IsCasting, would fix the issue I forsee with Enhanced hotbars autocast feature? If so, then I can't think of a single thing wrong with anything you have said, and all that leaves is learning how to put that information into script.

 

If you imagine a Boolean value (which just means 0 = False, 1 = True, or more simply 0 = No, 1 = Yes) called "IsUsingAntiMagic", then when you switch to a spell using Anti Magic, that boolean value is set to 1. Expanded Hotkeys will equip a spell for just a split second until you start casting it, but if we check the equipped spell every frame, then we can catch it and set IsUsingAntiMagic to the correct value. Of course, Expanded Hotkeys switches back almost immediately, before the spell is actually cast. If we use "IsCasting", it will detect when the player has started casting the spell, even before it is actually cast. When it returns 1, then we can lock IsUsingAntiMagic, so that it will reduce the correct resource. once IsCasting starts returning 0, we let the IsUsingAntiMagic flag set itself naturally.

 

 

 

 

First off, do I need a playerref to start this script, since it makes calls off the player? Or do I need getactorvalue? or both?

 

Nope. Just use "Player" as the reference, as in

Player.GetAv magicka

 

Also, as a note for later, how would a script I need to add to the spells be like? Would it be a simple reference? Or does it require its own script to define it as seperate from normal spells? (For the main script to intereact with?)

Not sure what you mean. I think we will only need 1 script to do this, maybe break it into 2 or 3 which could move at different speeds if necessary.

 

scriptname Dualityalpha

Begin GameMode
GetSpellRef TemporaryPlaceholder
If TemporaryPlaceholder == 1
	Message "Anti-Magicka is flowing." ;Tells player s/he is using a Antimagic enabled spell.
Elseif TemporaryPlaceholder == 0
	Message "Magicka is flowing."
Endif
End

 

 

Don't forget your Do Once loops :teehee:

 

 

 

Best way to start... before a big script, I sometimes just write down stuff in a notepad. Write an objective, break it down into little goals, break them down, break them down, break them down. Just think "What do I need to do that" and you can write them down. It's my proverbial drawing board :)

 

I'll do an example for you...

 

++++++++++++++++++++++++
Goal == get IsUsingAntiMagic flag to switch at the right time.
++++++++++++++++++++++++
Must constantly check equipped spell.
Command needed = GetPlayerSpell
Syntax = GetPlayerSpell
Extra Info = Result is Ref

Must constantly check school of equipped spell
Command needed = GetSpellSchool
Syntax = GetSpellSchool ref
Extra info = Result is Int (0 = Alt) (1 = Con) (2 = Des) (3 = Ill) (4=Mys) (5=Res)
Extra Info = result is most costly effect in spell, not Editor School. 
Extra Info = Scripted Spell effects return 0, alteration.


If school = x y z then flag = 1
else
flag = 0

------------------------
Sub goal - Lock flag when player begins casting a spell
------------------------

animation begins before spell is cast. Spell can be changed during this time.

Something is needed to detect this animation
Possible command - IsAnimPlaying
Possible command - IsCasting

Command Needed == IsCasting
Syntax = ref.IsCasting
Result = Boolean

Only run checks when (IsCasting == 0)

 

I now have all the info I need to do that part. I can just start any way that I want, then tweak bits as I need to. It doesn't have to be done in 1 draft.

 

This will help narrow down your search for different functions.

Edited by WarRatsG
Link to comment
Share on other sites

Oh, I see where the confusion is! I don't want to just make it black and white for spell schools. I want to have seperate spells in each school using each resource, thats why I was asking about a tag or script I would need to add to the new spells I would be creating.

 

So you are suggesting Destruction/Restoration in Magicka, and say, Conjuration and Alteration in Antimagicka, meaning the player would HAVE to split thier effects per majicka type. I was intending on a more flexible manner, allowing the player to focus on any one school, and having choices of spells for each magicka type per school (For example I might make more ice spells on the anti-magicka side, and more fire on the magicka side, etc.)

 

All your notes are helping, but I am still having trouble. The CS Wiki is incredibly confusing, and I can't find anything specific most of the time.

 

I have to say those notes have helped me ten times more than the whole CS wiki, giving me the right functions, now I need to learn how to compile those into a script. Also, about the DoOnce loop, I saw it on the CS but it was NOT very clear on why it was needed or where to place it, which might be my fault for not knowing the right places to look.

 

Oh, another question, at the beginning of the script I need to set it to check if it is casting? Is the script meant to terminate if the player is not casting? If so, it should look similar to this right?

Begin GameMode
If player.ref IsCasting != 0
	;Terminate script somehow here?
Elseif ;Rest of code here?
End

Edited by Xenavire
Link to comment
Share on other sites

Oh, I see where the confusion is! I don't want to just make it black and white for spell schools. I want to have seperate spells in each school using each resource, thats why I was asking about a tag or script I would need to add to the new spells I would be creating.

 

So you are suggesting Destruction/Restoration in Magicka, and say, Conjuration and Alteration in Antimagicka, meaning the player would HAVE to split thier effects per majicka type. I was intending on a more flexible manner, allowing the player to focus on any one school, and having choices of spells for each magicka type per school (For example I might make more ice spells on the anti-magicka side, and more fire on the magicka side, etc.)

 

The whole point of a dynamic script is that you feed in a value (in this case a spell) and the script will make decisions based on the variables of that value (in this case, whether it's magic or anti magic)

So long as you can find good, solid criteria for magicka and anti magicka, then it does not matter what that criteria is. You could use the link I gave to look through the magic section, and see what there is. If you want effects to be the deciding factor, then you will have to decide what ones take precedence - after all, some spells have multiple effects, from multiple schools.

Maybe you could get the school of the most costly effect (using GetSpellSchool as I described before), then use something from the Magic Functions list to determine what effect it actually is. Then, depending on the effect, you can decide what type of magic to assign to it.

 

 

All your notes are helping, but I am still having trouble. The CS Wiki is incredibly confusing, and I can't find anything specific most of the time.

 

The link in my last post should help - it separates the functions into categories. That said, it still requires some background knowledge of certain parts of the game.

 

I have to say those notes have helped me ten times more than the whole CS wiki, giving me the right functions, now I need to learn how to compile those into a script. Also, about the DoOnce loop, I saw it on the CS but it was NOT very clear on why it was needed or where to place it, which might be my fault for not knowing the right places to look.

 

The CS has to be as broad as possible, seen as mods are only limited by imagination. It gives a rough idea, but mostly it's just a kind of dictionary.

 

Oh, another question, at the beginning of the script I need to set it to check if it is casting? Is the script meant to terminate if the player is not casting? If so, it should look similar to this right?

Begin GameMode
If player.ref IsCasting != 0
	;Terminate script somehow here?
Elseif ;Rest of code here?
End

 

You are absolutely right, and the command you are looking for is "Return". It kills the script instantly, and is used in situations just like that, where you negate further process if the key variable is false.

You did get a little mixed up though with your syntax. "." is short for "use reference", in this case "Player" is the reference. If you want, you could use "PlayerRef", but most people stick to "player". It should look like:

If Player.IsCasting != 0

or

If PlayerRef.Iscasting != 0

 

Another good place to put this would be...

 

If GetPlayerSpell == CurrentSpell              ;If the player hasn't changed spell, there's no need to run checks on it...
    Return
Else
    Set CurrentSpell to GetPlayerSpell
    ;;;Continue

 

It's good that you thought of that - it shows a spark of intelligence ;)

 

 

Trust me mate, starting a mod is one of the hardest bits. Honestly, just write stuff down and if your as smart as you sound, it will just come naturally to you.

Link to comment
Share on other sites

Oh, stop it you! (No really, you are gonna inflate my ego haha).

 

So I need to use Return any time I need to kill the script, that is a major thing I needed to know.

 

So I have to choose a predetermined criteria for Magicka/Anti-Magicka? I was really hoping to add a blank script so I could just check the equipped/IsCasting spell for the blank script.

Say I have the basic fire spell, and I copy it, give it a new FormID and Name, and attack the blank script to it. I then make the main script check the equipped spell (or IsCasting spell) for that blank script, and if it finds it it treats it as antimagic. This would leave every vanilla and mod added spell using the vanilla values, and any spell added by me, or anyone else developing for this mod (if people decide to use my system and expand on it) will use that script and therefore antimagicka.

 

TL;DR version - Main script checks for dummy script, if it finds it it uses antimagicka, if it doesn't it uses normal magicka.

 

Once I know if this is possible or not I will really work my ass off to compile this script into something close to what I am planning. I don't want to start on one and then find out I need to do the other, especially since it is 1am and I probably wont sleep for another few hours anyway haha.

 

Edit: I might have found something but need some confirmation, would this work? HasMagicEffect EffectID (where ID is the script I created?) I don't know if scripted effects are seen as genuine magic effects by the CS, even though they act more or less like them ingame.

Edited by Xenavire
Link to comment
Share on other sites

OK, as a test for the above edit, I put this together, but it doesn't seem to be valid. I think I am missing something stupid, I made an empty script as a MagicEffect. named "AntimagickaFlag", but it doesn't seem to be valid. Do I need to add something to my dummy script? (It saved fine on it's own, but this one below does not want to save.)

 

Scriptname DualityMagicka

Begin GameMode
If Player.IsCasting != 0
	Return
Elseif Player.IsCasting == 0
	If GetPlayerSpell HasMagicEffect AntimagickaFlag
	Endif
Endif
End		

Link to comment
Share on other sites

You cannot "attach" scripts to spells, as you would attach a script to an object. If you mean adding a script effect to the spells then that wont work either, as there is no way to check which script it uses.

 

 

You can refer to spells by name though. By using the return function in the place I mentioned before, you can avoid hurting the CPU the majority of the time, while running as many checks as you want under when the player does change spell.

Just set a ref variable to GetCurrentSpell and call If <ref> == <editor id of antimagic spell>

 

 

As for the script you created, the effect ID of spell effects are either four letter codes ( fire damage = FIDG) or long integers, depending on the exact function used. Script Effect is the effect, not the script itself.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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