Jump to content

a little help in (spell) Scripting...


maYuYang

Recommended Posts

Hi dear Modding Community^^,

 

At the moment I'm creating a new race(with other races as resource, don't worry, I'll credit them all once I publish this^^), but need some help on some scripts.

 

1. That race is very powerful and to balance that I want to prohibit Healing Spells in a way so if you use them, they inflict damage. I was already experimenting with scripts, but couldn't create this one. Also, if I have that script, how do I "attach" it to my new race? I will also check if I can make a lesser power for this, but from what I saw till now, I'm quite sure a script is needed.

 

 

2. There are several Spell Scripting Tutorials, but I still couldn't figure out how to make a Thunder Strike(lightning striking the target from the sky). To specify it a bit: This Lightning should cause an AoE Explosion on impact...

 

 

3. Getting more complicated now: I really like Midas' Lightning Storm, but copy/paste and individualizing doesn't work here(The script uses some special terms like "MidasAngerActor" and something like that. I think that this script is using other scripts.. So how can I create a Thunder Storm with properties from my previous request(AoE on Impact), just stronger(i.e. 2 times or even 3 times stronger)? the big difference is that I want to use a OblivionStormSky instead of the normal thunderstormsky. Also, How can I set this "Power" ability to be useable from later levels (i.e. lvl20)?

 

4. The propably hardest script: this one should activate an animation. Since I didn't create that one yet, I only need some basic Information: Can I apply an animation to a Spell Script, so once I use that spell, the animation starts? This Spell would somewhat "awake powers" so the animated Mesh stays for the remaining spell time, the player can control the now overpowered character and slay enemies within the time. In the end, the animated mesh vanishes again. Finally, at increasing levels, this spell should last longer(lvl10 = 10 seconds, lvl 15 = 15 seconds, etc.)

 

 

I know that this are a lot of questions, but these are the only obstacles I have at the moment. Also, as I mentioned before, the Spell Tutorials are not specific enough for me and I don't know the terms I have to use yet...http://thenexusforums.com/style_emoticons/default/wallbash.gif

So would you kindly help me on this?

Of course you will recieve credits for your help^^

Link to comment
Share on other sites

Firstly, have the modders you've borrowed from for the race-mod given you permission? (or at least made an attempt to?) If you don't have it, (either by asking specifically or them giving it to everyone in their readme file) it's still sort of poor form to release a mod using the resources.

 

1: The only two ways of doing this without OBSE are a: to slap a script directly on the player with an OnMagicEffectHit RSHE block, check GetIsRace to see if the player is your race and, if so, hit him with a damaging spell via activator. (see 2) The problems with that are A: It will also run if someone else casts a healing effect on the player and, more importantly, B: attaching scripts to the player is very frowned upon in modding, since it would mean unresolvable conflicts with any other mod that does. The other method is to use a ScriptEffectUpdate block on a magic effect to check if the player HasMagicEffect RSHE and, if so, damage them. (You'd probably also want a variable that switches between 1 and 0 depending on that so it would only run once per effect hit. The problem with that is that it would only work for spells with a duration other than 0, of which most Restore Health effects don't have.

Cracking open OBSE, it'd be best to give the player a scripted ability with a ScriptEffectUpdate block, use IsCasting to check if the player is casting a spell and, if so, check if GetPlayerSpell MagicItemHasEffect RSHE and, if so, cast a damaging spell on the player via activator or just use ModAV2. Like the second non-OBSE method, you'll want to use a variable to check if the player has already been damaged for that "cast". The problem with that method is that it will also run when the player uses an On Target Restore Health effect, if you don't want that to be the case. A similar method that doesn't have that problem is, whenever the player changes spells, (GetPlayerSpell is different from a variable set to GetPlayerSpell at the end of the script) cycle through all of that spell's magic effects using SaveIP, RestoreIP, GetNthEffectItemCode, GetMagicEffectCode, GetNthEffectItemRange, GetMagicItemEffectCount, and a variable to hold which effect is currently being checked, and see if any of them are Restore Health on Self. If so, set a variable to 1, and if not to 0. Then, when the player does cast a spell, damage him if it's 1, and not if it's 0.

 

2: To start, put an invisible activator (I use TrigZones for some reason) into a new "holding" cell, and in a ScriptEffectStart block for your spell, use MoveTo and Cast to move the "caster" activator high above the target and have it cast the Shock Damage effect at the target. Assuming you want an explosion instead of just AoE shock damage, the next part could be very easy if you wanted it just to explode when it hits the target, or significantly harder (and still very imperfect) if you want it to also explode when it hits the ground. If you just want it to explode when it hits an actor, (or something else that a Script Effect runs on like a door or furniture) just add another Script Effect to the Shock spell that moves the "caster" activator to the subject and has the activator cast an AoE Fire Damage spell at them. If you want it to explode whenever it hits the ground, the only method I can think of is, after a set amount of time passes, (Use a "timer" variable or a ScriptEffectFinish block on the original spell's script effect) move the "caster" activator down to where the target was, move another invisible "Marker" activator directly below that, and have the caster cast the AoE Fire Damage effect at the marker.

 

3: GetLevel is helpful for checking if the player is high-enough level to cast it. For the Storm effect, you might take a look at ForceWeather/SetWeather and GetCurrentWeatherID.

 

4: What do you mean by "Animated Mesh"? If it's an animation running on the player for the entire spell it might be troublesome to have him moving around/attacking, but either way it's quite doable. I know very little about all but the most basic animation-running, though.

 

I could give more in-depth tutorials for 1 and 2, but it might be a waste until you know which methods you'd like to use.

Link to comment
Share on other sites

Yeah, you're right, I should ask first before using a mod as resource.... Will do it in my break time today^^.

 

Great that you help my, I will specify no. 1 and 2:

 

1. Using OBSE for the Heal Damage is actually something I was already thinking of. Basically the PC should take damage when the Player is using a healing spell on self, no matter if it is instant heal or heal over time. But it should only apply when using a spell, not when using potions or bangages(or whatever).

 

2. The Thunder Strike should cause an AoE Explosion on any impact, so once it hits the ground, there should be a small explosion which inflicts dmg(less than direct impact of course) and may flung a npc(target) onto the ground or maybe 1 or 2 yards away.

 

About 3: applying a thunderstorm might help, but is it possible using another sky type like the oblivion sky instead of the cloudy storm sky? Also, the thunderstrikes should act same like in point 2, but how do I attach them to the storm?

 

About 4: Yes, the animation will play the entire spell and will end afterwards, but I will animate it in a way so the PC doesn't look weird. Not the character animation will be changed, but an additional effect or animation will be played(like an aura or maybe wings[not flying]).

 

Thank you for helping me out^^, I will definitly credit you once I publish this mod^^.

Link to comment
Share on other sites

1: To clarify, should this only be for the player casting spells the normal way, or also scrolls and/or powers?

 

2: I just realized the method I previously planned would cause trouble when casting it on non-actors and it being disrupted, so will need a bit to come up with a new method... :(

 

3: SetWeather and ForceWeather should work fine with weathers not normally found in the climate, but Midas Magic actually uses entirely new magic meshes for its lightning bolts, and the other one hugely ramps up the speed of the Shock Damage projectile, so I'm afraid you're on your own for this one. I don't think Midas Magic matches the attacks with the Lightning Bolt sounds, though.

 

4: Depending on if you wanted to use wings (or a wing-equivelant) or an aura, this would be done completely differently. You'd probably equip/unequip a solid object for the wings, and use PlayMagicShaderVisuals/StopMagicShaderVisuals for an aura. Either way, it's basically a cinch.

Link to comment
Share on other sites

Ah great, I will try to get No. 4 done then(didn't think that this one would be the 1st... Oh well, it's the 1st skill the PC is allowed to use anyway^^).

 

3.) I will give it a shot. I could imagine that writing the script so the spell also attacks NPCs might be the next chapter for this, but I will try it myself, the input you gave me already is great and I think with checking other scripts and experimenting I should get this spell to work^^.

 

2.)Ah, that's too bad. I thought the timer would be feasible.

Yesterday I had another idea and this one should be easier than the thunder strike: I'm thinking of a Beam-like attack emitting from the casters hands. However, For the time this is cast, the PC cannot move or turn. This Spell would take let's say 5 seconds and fade out too the end(or become "thinner"). I already have an idea of how to set the script, but there're 3 problems: The visual effect, this spell is not just a line but should be quite thick, mayba half of a character. My idea was to put several lightning spells together... The 2nd problem is the target area. It's an AoE Spell which should attack all targets in it's line, but it seems that AoE is only possible in circular areas. My idea was to put several circles in a line, but how.... And last but not least the movement lock on the PC, I do not know the scripting codes for this, but I know that this is possible. [One last optional thing would be a charge time of 2 seconds before the spell starts.]

 

1.) Lesser Power or Power. The Heal Damage is a permament DeBuff, so everytime the PC casts heal, it should damage. Since the Heal spells heal immediately and not over time(at least I never found such a spell), it shouldn't be such a big problem to set this. I was thinking of something like damage-if-player-casts-heal-on-self. I just don't know the scripting code again-_-. Maybe we could amplify the negative effect by adding a disease to the PC if she/he tries^^.

 

0.) There's one thing I wonder about: One of the new spells I created(still without visual effect to see if it even works) became of some sort of a mind breaker: I want to create an AoE DeBuff, but the centre should be the PC. Since the only Targets I actually can set are self, touch and target, this looks like another spell for a script... Again, How do I set a target area for a specific time by script? My first idea was to set an activator and use the term moveto and cast, but I need to attach the AoE effect and distance somehow.

 

 

P.S.: Could it be that you're also playing Disgaea?

Link to comment
Share on other sites

I stopped at world 6, I think. Just finished Soul Nomad, though. :)

 

3: Best of luck.

 

2: The timer should work to an extent, it's just that the "governor" for it would need to be the player, since on some objects a ScriptEffectStart block will run and not ScriptEffectUpdate. That also means you need a quest variable to hold the victim. So maybe when the lightning call hits the activator casts a governing spell on the player as well.

Midas Magic actually has a few Beam effects, but they're only really accomplished through the use of new meshes and victim's "triggering" it.

 

1: In that case I imagine the script would go... (Attached to an "Ability" spell given to the race by normal means)

 

scn MyRaceAntiHealScript
ref PlayerSpell
ref OldPlayerSpell
float REHECode
short CastingSpell
short TotalEffects
short NthEffect
short HealingSelf

Begin ScriptEffectUpdate
 set PlayerSpell to GetPlayerSpell
 if (PlayerSpell != OldPlayerSpell)

	  if (MagicItemHasEffect REHE PlayerSpell)
		   set TotalEffects to GetMagicItemEffectCount PlayerSpell
		   set REHECode to GetMagicEffectCode REHE
		   set NthEffect to 0
		   SaveIP

		   if (GetNthEffectItemCode PlayerSpell NthEffect != REHECode)
				set NthEffect to NthEffect + 1
				if (NthEffect <= TotalEffects)
					 RestoreIP
				else
					 set HealingSelf to 0
				endif

			elseif (GetNthEffectItemRange PlayerSpell NthEffect != 0)
				set NthEffect to NthEffect + 1
				if (NthEffect <= TotalEffects)
					 RestoreIP
				else
					 set HealingSelf to 0
				endif
		   else
				set HealingSelf to 1
			endif
	   else
			set HealingSelf to 0
	  endif
 endif

 if (IsCasting && PlayerCasting == 0)
	  set PlayerCasting to 1
	  if (HealingSelf == 1)
;Do horrible things to the player
	  endif
 elseif (IsCasting == 0 && PlayerCasting == 1)
	  set PlayerCasting to 0
 endif

 set OldPlayerSpell to PlayerSpell
end

 

0: I don't know why you can't just use MoveTo and cast, using an On Target spell with whatever area you want.

 

EDIT: Actually, I don't tihnk there is a function to entirely disable the player's turning. SetRestrained stops everything but looking up/down, though, and I suppose it would work if combined with judicious usage of SetAngle X.

Link to comment
Share on other sites

Sorry for my late answer.

 

Wow, you made the script, thank you^^.

 

Now I want to use that opportunity to learn abit more about scripting:

What exactly do these do?

ref PlayerSpell = Reference Player Spell?

ref OldPlayerSpell = Reference Old Player Spell?

float REHECode = ?

short CastingSpell

short TotalEffects

short NthEffect

short HealingSelf

 

GetNthEffectItemCode and != REHECode(untill now, I thought that this one means "Only if" or "Must be")

 

Those are the only 2 things I do not understand completely

 

Btw, that line is the best^^:

Do horrible things to the player

 

 

2. Ahh, I see. So in order to make the explosion appear always, we would need to hold the victim in place.

About the ScripteEffectStart and ScriptEffectUpdate, do you mean that those would not work always? Could we fix that by making the spell only available outside?

 

2b. Yeah, I was afraid you would say that. Looks like I have to do a crash course in Blender....

By "victim's triggering it", do you mean something like targetcast? Does that mean that by setting let's say 5 targetcast, the maximum amount of affectable targets are 5? That would be actually great, I was thinking how to nerf such a powerful spell...

SetRestrained was what I was looking for. Setting an angle would propably cause bad results(spell hits hill and not victim standing on top of it). But what I need then is the code for locking the magic effect, so the player can not alter the angle by looking up. Lol, It could be that a code is not neccessary if the player can not alter the angle while casting by default^^.

 

0. I will set up that one this evening and maybe tomorrow. I should find all neccessary codes in the CS Wiki^^.

 

One more question for 2b: could I use

reference.GetTotalAEPowerMagnitude effectCode:chars

to set up the damage multiplier for the spell?

Link to comment
Share on other sites

I probably should have included notes... Thanks for asking. :)

Floats and Shorts hold numbers, (Float variables larger ones) while Ref variables hold objects or references in the CS.

PlayerSpell is set to the player's selected spell at the beginning of the script, and OldPlayerSpell is set to it at the end of the script. That way, when PlayerSpell is different from OldPlayerSpell (!= means "Not equal to") it means the player just changed his spell, and we need to look to see if it has a Restore Health on Self effect.

 

CastingSpell is set to 1 when the player is casting, and 0 when he's not. That's to make sure the Horrible Things script only runs once per casting, and that it doesn't run if the player changes to a Restore Health on Self spell while in the midst of casting a different one.

 

REHECode: There's a GetNthEffectItemCode function, but not one for GetNthEffectItem...Effect. REHECode stores Restore Health (REHE)'s Magic Effect Code for use in checking if the Nth Effect is Restore Health. ScriptEffectStart and ScriptEffectUpdate should run just fine for actors, but it you cast it on a door or piece of furniture only ScriptEffectStart would run on it. Nothing to do with outside/inside.

 

TotalEffects is used to store the number of Magic Effects PlayerSpell has, and NthEffect stores which one is currently being checked. It starts at 0 and, rvery time the "Looking for REHE" bit runs and doesn't find the proper effect, it increases by one. If it's not now greater than TotalEffects, it uses RestoreIP to check if the next Magic Effect in line is Restore Health on Self. By the way it's rigged, it first checks if the effect is not Restore Health and, if that's not the case, (so it is Restore Health) it checks if it's not On Self. If it's not not On Self either, set HealingSelf to 1. If the whole things is cycled through without finding a Restore Health On Self effect, or it doesn't have a Restore Health effect at all as checked earlier, set HealingSelf to 0.

 

HealingSelf is used when the player casts to check if Horrible Things need to be done to him.

 

2: Only by the old method. If the Player is given the effect that governs the whole thing instead of the target, the caster can just be moved downwards, a "target" activator placed below that, and the AoE Fire Damage spell cast.

 

2b: Victims triggering it meant in the same sense as traps are triggered. The Begin blocks OnTriggerActor and OnTriggerMob can run when something goes "inside" the object. You'd probably just be moving the Beam activator to the player when he casts it and moving it away when the spell's over, so it would actually be more work to get it to follow the player's movement/angle after the casting. I thought you just wanted to hold the player still for the look of it...

 

I don't really see how you'd use GetTotalAEPowerMagnitude for that... :unsure:

Link to comment
Share on other sites

Ok, that is propably the most embarrassing question ever...

I wanted to use the script you provided me with, but couldn't save it in CS. I remembered that it is an OBSE script, but how do I... I mean where can I save that? It's the 1st time I'm creating a OBSE mod at all and wherever I look, there's no information how to set up such a script... I suppose that it must be quite easy.. Would you tell me please?

Link to comment
Share on other sites

You need to make a shortcut to obse_loader, right click on it and select Properties, and click the Shortcut tab. Under "Target", there should be a filepath pointing to the main file, as is normal. At the end of the textbox, outside the quotes, add "-editor". (Without the quotes) Then that shortcut will lead to an OBSE-enabled CS.

 

Not as simple as one would expect, is it? :P

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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