VirtualSpace Posted March 6, 2011 Share Posted March 6, 2011 (edited) 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 March 6, 2011 by VirtualSpace Link to comment Share on other sites More sharing options...
fg109 Posted March 6, 2011 Share Posted March 6, 2011 (edited) 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 March 6, 2011 by fg109 Link to comment Share on other sites More sharing options...
VirtualSpace Posted March 7, 2011 Author Share Posted March 7, 2011 Got it. Thanks mate. Link to comment Share on other sites More sharing options...
Recommended Posts