Jump to content

Moving NPC objects (GetPos, SetPos)


Recommended Posts

I want to set different damages for how far away the NPC is to where a spell was cast, e.g, if Phintias was 50 meters away from the fireball, he would receive 50 points of damage, or if 100 meters away, he would receive a less amount of damage.

 

How do I do this?

 

Title for this thread should be different. I know. Minor error.

Edited by VirtualSpace
Link to comment
Share on other sites

I think the function you want to use is GetDistance. It returns the number of units between 2 references.

 

I'm not much of a modder, so I don't really know how you'll use it to do what you want. When you cast a spell, the target of the spell is the one that runs the spell script. So if you have GetSelf in the script, it'll return the reference ID of whatever is hit by the spell. But I don't know how you'll get the reference ID of the one who cast the spell (not a problem if you only intend the spell to be used by the player). You could try using GetCombatTarget, but this is unreliable if the one who gets hit by the spell is fighting off multiple opponents.

 

Anyway, if this spell is only going to be cast by the player, I would use this:

 

 

scriptname DistanceVariableDamageSpellScript


ref refnpc

float distance
float mod_damage

short base_damage


Begin ScriptEffectStart

set refnpc to GetSelf
set distance to refnpc.GetDistance Player
set base_damage to 100						;put whatever you feel like for base damage
set mod_damage to (base_damage * (500 / distance))		;this would make the spell overpowered at really close distances, so you'll have to work out a balanced formula
refnpc.SetAV Health (refnpc.GetAV Health - mod_damage)

End

 

 

If you meant you wanted to make all spells have variable damage depending on distance, I'm not sure how you would go about doing that. I don't see any script attached to vanilla spells, so I think their effects are hard coded. Maybe you can try out some of the magic/spell mods.

Edited by fg109
Link to comment
Share on other sites

  • Recently Browsing   0 members

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