Troubles with Dynamically Attaching a Script. (Also, how to

Post » Thu Jun 21, 2012 1:31 am

The first thing I have is a spell directly attached to the Player actor (as opposed to an alias filled by the character). Maybe this is the problem.

This spell is a cloak with 192 foot radius constant effect ability with the associated value as another spell. This second spell is a concentration aimed spell that just adds yet a third spell to akTarget. This third spell is the following script, which basically handles all of combat under the d20 system:

Scriptname d20damaged extends ActorKeyword Property d2damager autoKeyword Property d4damager autoKeyword Property d6damager autoKeyword Property d8damager autoKeyword Property d10damager autoKeyword Property d12damager autoKeyword Property CrescentAxeKey autoFaction Property DnDLinearDamageAdjuster autoFaction Property DnDTHAC0 autoFaction Property DnDArmorClass autoFaction Property DnDBonusWithSlash autoFaction Property DnDBonusWithBash autoFaction Property DnDBonusWithPierce autoFaction Property DnDBonusAgainstSlash autoFaction Property DnDBonusAgainstBash autoFaction Property DnDBonusAgainstPierce autoFaction Property DnDSlashResist autoFaction Property DnDPierceResist autoFaction Property DnDBashResist autoKeyword Property DnDSlashingWeap autoKeyword Property DnDPiercingWeap autoKeyword Property DnDBashingWeap autoKeyword Property DnDWeapon autoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \  bool abBashAttack, bool abHitBlocked)  int damagetype = 0  float damagetotal = 0  if akSource.HasKeyword(DnDSlashingWeap)==1	 damagetype = 1  endIf  if akSource.HasKeyword(DnDPiercingWeap)==1	 damagetype = 2  endIf  if akSource.HasKeyword(DnDBashingWeap)==1	 damagetype = 3  endIf   int d20roll = Utility.randomint(1,20)   Actor attacker = akAggressor as actorif akSource.HasKeyword(DnDWeapon)==1  if akSource.HasKeyword(d2damager) ==1  int d2random = Utility.randomint(1,2)			 int ModdedD2 = d2random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd2  endif  if akSource.HasKeyword(d4damager) ==1  int d4random = Utility.randomint(1,4)			 int ModdedD4 = d4random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd4  endif  if akSource.HasKeyword(d6damager) ==1  int d6random = Utility.randomint(1,6) 			 int ModdedD6 = d6random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd6  endif  if akSource.HasKeyword(d8damager) ==1  int d8random = Utility.randomint(1,8) 			 int ModdedD8 = d8random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd8  endif  if akSource.HasKeyword(d10damager) ==1  int d10random = Utility.randomint(1,10) 			 int ModdedD10 = d10random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd10  endif  if akSource.HasKeyword(d12damager) ==1  int d12random = Utility.randomint(1,12) 			 int ModdedD12 = d12random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd12  endif  if akSource.HasKeyword(CrescentAxeKey) ==1  int Crescentrandom = Utility.randomint(2,7) 			 int Moddedcrescent = crescentrandom + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + ModdedCrescent  endifelse   ;debug.notification("Attack Missed")   if d20roll==1	  debug.notification("Critical Miss!")	  attacker.DamageAV("Health", 4)   endIfendIFint hitchance = 0hitchance = hitchance +d20roll + attacker.GetFactionRank(DnDTHAC0) as int +- (self as actor).GetFactionRank(DnDArmorClass) as intif damagetype==1   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithSlash) as int +- (self as actor).GetFactionRank(DnDBonusAgainstSlash) as int   damagetotal = damagetotal * (100-(5*(self as actor).GetFactionRank(DnDSlashResist)))/100endIfif damagetype==2   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithPierce) as int +- (self as actor).GetFactionRank(DnDBonusAgainstPierce) as int   damagetotal = damagetotal * (100-(5*(self as actor).GetFactionRank(DnDPierceResist)))/100endIfif damagetype==3   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithBash) as int +- (self as actor).GetFactionRank(DnDBonusAgainstBash) as int   damagetotal = damagetotal * (100-(5*(self as actor).GetFactionRank(DnDBashResist)))/100endIfif hitchance >= 0(self as actor).DamageAV("health", damageTotal)endIfEndEvent

Anyhow, this doesn't seem to be working properly. I can walk up to actors to whom I've manually added this script, and combat works appropriately. However, dynamically attaching it doesn't seem to want to work. Any hints?
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm

Post » Thu Jun 21, 2012 12:46 pm

The best way, I think, would be to use SkyProc to add the script to all NPCs.
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Thu Jun 21, 2012 8:52 am

SkyProc? This sounds like sorcery to me.
User avatar
Helen Quill
 
Posts: 3334
Joined: Fri Oct 13, 2006 1:12 pm

Post » Thu Jun 21, 2012 1:23 pm

Actually, I think I cracked it. The script needed adjusting for being a magic effect. New version here:
Scriptname d20damaged extends activemagiceffectKeyword Property d2damager autoKeyword Property d4damager autoKeyword Property d6damager autoKeyword Property d8damager autoKeyword Property d10damager autoKeyword Property d12damager autoKeyword Property CrescentAxeKey autoFaction Property DnDLinearDamageAdjuster autoFaction Property DnDTHAC0 autoFaction Property DnDArmorClass autoFaction Property DnDBonusWithSlash autoFaction Property DnDBonusWithBash autoFaction Property DnDBonusWithPierce autoFaction Property DnDBonusAgainstSlash autoFaction Property DnDBonusAgainstBash autoFaction Property DnDBonusAgainstPierce autoFaction Property DnDSlashResist autoFaction Property DnDPierceResist autoFaction Property DnDBashResist autoKeyword Property DnDSlashingWeap autoKeyword Property DnDPiercingWeap autoKeyword Property DnDBashingWeap autoKeyword Property DnDWeapon autoActor MySelfEvent OnEffectStart(Actor akTarget, Actor akCaster)   Myself = akTargetendEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \  bool abBashAttack, bool abHitBlocked)  int damagetype = 0  float damagetotal = 0  if akSource.HasKeyword(DnDSlashingWeap)==1	 damagetype = 1  endIf  if akSource.HasKeyword(DnDPiercingWeap)==1	 damagetype = 2  endIf  if akSource.HasKeyword(DnDBashingWeap)==1	 damagetype = 3  endIf   int d20roll = Utility.randomint(1,20)   Actor attacker = akAggressor as actorif akSource.HasKeyword(DnDWeapon)==1  if akSource.HasKeyword(d2damager) ==1  int d2random = Utility.randomint(1,2)			 int ModdedD2 = d2random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd2  endif  if akSource.HasKeyword(d4damager) ==1  int d4random = Utility.randomint(1,4)			 int ModdedD4 = d4random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd4  endif  if akSource.HasKeyword(d6damager) ==1  int d6random = Utility.randomint(1,6) 			 int ModdedD6 = d6random +  (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd6  endif  if akSource.HasKeyword(d8damager) ==1  int d8random = Utility.randomint(1,8) 			 int ModdedD8 = d8random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd8  endif  if akSource.HasKeyword(d10damager) ==1  int d10random = Utility.randomint(1,10) 			 int ModdedD10 = d10random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + Moddedd10  endif  if akSource.HasKeyword(d12damager) ==1  int d12random = Utility.randomint(1,12) 			 int ModdedD12 = d12random + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal +Moddedd12  endif  if akSource.HasKeyword(CrescentAxeKey) ==1  int Crescentrandom = Utility.randomint(2,7) 			 int Moddedcrescent = crescentrandom + (attacker.GetFactionRank(DnDLinearDamageAdjuster) as int)		    damagetotal = damagetotal + ModdedCrescent  endifelse   ;debug.notification("Attack Missed")   if d20roll==1	  debug.notification("Critical Miss!")	  attacker.DamageAV("Health", 4)   endIfendIFint hitchance = 0hitchance = hitchance +d20roll + attacker.GetFactionRank(DnDTHAC0) as int +- Myself.GetFactionRank(DnDArmorClass) as intif damagetype==1   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithSlash) as int +- Myself.GetFactionRank(DnDBonusAgainstSlash) as int   damagetotal = damagetotal * (100-(5*Myself.GetFactionRank(DnDSlashResist)))/100endIfif damagetype==2   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithPierce) as int +- Myself.GetFactionRank(DnDBonusAgainstPierce) as int   damagetotal = damagetotal * (100-(5*Myself.GetFactionRank(DnDPierceResist)))/100endIfif damagetype==3   hitchance = hitchance + attacker.GetFactionRank(DnDBonusWithBash) as int +- Myself.GetFactionRank(DnDBonusAgainstBash) as int   damagetotal = damagetotal * (100-(5*Myself.GetFactionRank(DnDBashResist)))/100endIfif hitchance >= 0Myself.DamageAV("health", damageTotal)endIfEndEvent
User avatar
James Shaw
 
Posts: 3399
Joined: Sun Jul 08, 2007 11:23 pm

Post » Thu Jun 21, 2012 1:50 pm

Hmmm. Curiouser an curiouser. Now whenever I get in cloak range of someone, my own max health goes down. I need to look into that...
User avatar
BlackaneseB
 
Posts: 3431
Joined: Sat Sep 23, 2006 1:21 am


Return to V - Skyrim