Jump to content

Race Exclusive Script Efffects


InuyashaFE

Recommended Posts

I've been practicing my scripting lately, and what I've been trying to do is create some weapons that would be effective against vampires.

 

So, I made a script effect that would add a permanent fire damage ability, similiar to the way poisoned apples work.

 

I was wondering if someone could tell me how to make sure this script effect only works on vampires, and leaves normal beings alone.

 

ScriptName aaaSunDamageScript

begin ScriptEffectStart
ref userref
userref.addspell aaaSunDamage
end

 

See, melee weapons have en enchantment with this script effect to occur on touch/strike, which is why I used the userref coding, because it would theoretically reference the one with the script effect, right?

 

So to sum up, what I'm asking for is some help on making sure this script is kosher, and how to code it so it only works on vampires.

Link to comment
Share on other sites

If I'm understanding you right, you want a weapon to add aaaSunDamage on strike, but only if the target is a vampire? If so, you might want to try this script:

 

ScriptName aaaSunDamageScript

ref Target

Begin ScriptEffectStart

Set Target to GetSelf

if Target.GetVampire > 0 && Target.IsSpellTarget aaaSunDamage == 0
  Target.AddSpell aaaSunDamage
Endif

End

 

That should add the sun damage spell if the target is a vampire and isn't already being affected by aaaSundamage.

 

Note: If (as I suspect) aaaSundamage is an ability type spell, you need to add a script to it so that it removes itself after a time. Otherwise it will continue to affect the target until it dies, meaning that one strike will (eventually) prove fatal to vampires.

 

A script that would romove aaaSunDamage after five seconds would look like:

 

scn aaaSunDamageRemovalScript
float timer
ref me

begin GameMode
set me to GetSelf
set timer to timer + GetSecondsPassed
if timer >= 5
me.RemoveSpell aaaSunDamage
endif
end

 

You'll need to attach this script to the spell itself (by that, I mean aaaSunDamage) in order for it to work.

Link to comment
Share on other sites

ScriptName aaaSunDamageScript

Begin ScriptEffectStart

if (GetInFaction VampireFaction)
	AddSpell aaaSunDamage
endif

End

 

Thanks, that's certainly a good start, though some of the vampires, especially some of the quest-vamps aren't even in the vampirefaction.

 

If I'm understanding you right, you want a weapon to add aaaSunDamage on strike, but only if the target is a vampire? If so, you might want to try this script:

 

ScriptName aaaSunDamageScript

ref Target

Begin ScriptEffectStart

Set Target to GetSelf

if Target.GetVampire > 0 && Target.IsSpellTarget aaaSunDamage == 0
  Target.AddSpell aaaSunDamage
Endif

End

 

That should add the sun damage spell if the target is a vampire and isn't already being affected by aaaSundamage.

 

Note: If (as I suspect) aaaSundamage is an ability type spell, you need to add a script to it so that it removes itself after a time. Otherwise it will continue to affect the target until it dies, meaning that one strike will (eventually) prove fatal to vampires.

 

A script that would romove aaaSunDamage after five seconds would look like:

 

scn aaaSunDamageRemovalScript
float timer
ref me

begin GameMode
set me to GetSelf
set timer to timer + GetSecondsPassed
if timer >= 5
me.RemoveSpell aaaSunDamage
endif
end

 

You'll need to attach this script to the spell itself (by that, I mean aaaSunDamage) in order for it to work.

 

Thanks, that should be just right! :)

 

So the first script uses a targetref instead of a userref. Since I'm a novice scripter, what sets a targetref apart from the userref as far as this particular script effect goes?

Edited by InuyashaFE
Link to comment
Share on other sites

The variable names "Target" and "userref" are completely arbitrary. If you wanted to, you could even name it "afjkahasdjkf" or "TheActorUponWhichThisScriptWillBeRun".

 

The_Vyper's script is good, although I'm not sure if the second script will work right with a gamemode block. If it doesn't work, I suggest changing aaaSunDamage into a spell with a 5 second duration instead of an ability.

Link to comment
Share on other sites

To sum things up, spell scripts use the reference they're running on as implicit default. So function calls like "ref.doSomething" can just be used as "doSomething" and will use the reference the script is running on by default. If you need the reference as an actual parameter though, like with a function "doSomethingTo ref", you can use "getSelf" to obtain the reference the script is running on, as was done with "set Target to getSelf" here. However, in the underlying spell script this won't even be necessary, as no such function requiring an explicit reference parameter was used. Instead of "Target.GetVampire", "Target.IsSpellTarget" and "Target.AddSpell" you can just use "GetVampire", "IsSpellTarget" and "AddSpell" directly and it will implicitly affect the target of the spell by default.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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