Addspell not working

Post » Thu Jun 21, 2012 11:54 am

Ok I'm working on a script to add diseases to enemies when they are hit with a spell. But
aktarget.addspell(diseasespell)
is not working. Is there something that prevents you from adding disease spells to enemies?
User avatar
Shirley BEltran
 
Posts: 3450
Joined: Wed Jul 26, 2006 4:14 pm

Post » Thu Jun 21, 2012 9:08 am

.
User avatar
Nauty
 
Posts: 3410
Joined: Wed Jan 24, 2007 6:58 pm

Post » Thu Jun 21, 2012 10:50 am

did you make a property for the spell?, its hard to help with out the whole script.
Example
Spell Property disease1 AUTOEvent Onsomeevent()if somecondition() = 0aktarget.addspell(disease1)endifendevent
User avatar
Lynette Wilson
 
Posts: 3424
Joined: Fri Jul 14, 2006 4:20 pm

Post » Thu Jun 21, 2012 3:30 am

also scripts that apply vanilla diseases use http://www.creationkit.com/DoCombatSpellApply_-_Actor
not AddSpell
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Thu Jun 21, 2012 11:18 am

Ahhhh Fantastic. Thank you! I didn't know about the DoCombatSpellApply

As it turns out I have started actually doing all the effects through scripting in the actual Affliction spell that applies a random disease. It's working out pretty well in early testing because I can have perks that increase the effectiveness of the disease as well as chance to inflict it and do it all in the script without having to make additional versions of the diseases that are more potent. Although truth be told it might be faster to create additional diseases instead.. Unless I add a lot of perk ranks in which case scripting is a lot faster.
User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Post » Thu Jun 21, 2012 11:24 am

Actually the DoCombatSpellApply doesn't seem to be working for diseases either. But there are other ways to work around it and get the same desired effects. No big deal.
User avatar
Spencey!
 
Posts: 3221
Joined: Thu Aug 17, 2006 12:18 am

Post » Wed Jun 20, 2012 11:35 pm

maybe post the script you're working with.
User avatar
Cheryl Rice
 
Posts: 3412
Joined: Sat Aug 11, 2007 7:44 am

Post » Wed Jun 20, 2012 9:01 pm

aktarget is not an actor (I know, I know ....it is not very intuitive...that is Skyrim in a nutshell...).

You need to do this:

Actor Target = (aktarget)
Target.addspell(YourSpell)

Or this may work:

((aktarget)as actor).addspell(YourSpell)
User avatar
Jesus Duran
 
Posts: 3444
Joined: Wed Aug 15, 2007 12:16 am

Post » Thu Jun 21, 2012 10:53 am

Hmmm Ok I'm about to try that. Turns out I needed to actually apply some sort of spell or equip an item to represent the spell in order to keep the script from applying the same spell over and over if it draws that random number again. That or setting some sort of Global property and setting it back to 0 when the enemy dies but that would just be all kinds of screwed up and lead to a thousand other problems I'm sure.
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Thu Jun 21, 2012 3:31 am

Here is the script as it is now.. Obviously I'm still working on it and I'll try using AkTarget as Actor but as it stands now the script is..

Scriptname PsiDiseaseScript1 extends activemagiceffect  PsiNecromancyQuestScript Property PsiNecroQuest AutoSpell Property DisBloodLung autoSpell Property DisBoneBreakFever autoSpell Property DisBrainRot autoSpell Property DisMonkeyFinger autoSpell Property DisRockJoint autoSpell Property DisWitBane autoSpell Property Rattles autoPerk Property CurseMastery autoInt Property MonkeyFinger autoInt property DiseaseChanceBonus autoInt Property     DiseaseBonus autoInt Property HasBoneBreakFever autoInt Property HasBrainRot autoInt Property HasMonkeyFinger autoInt Property HasRattles autoInt Property HasRockJoint autoInt Property HasWitbane autoInt Property HasBloodLung autoInt Property DiseasedStamina autoInt Property DiseasedMagicka autoInt Property DiseasedEnemyCarryWeight autoInt Property DiseasedOneHandSkills autoInt Property DiseasedTwoHandSkills autoInt Property DiseasedDisResist autoInt Property DiseasedOneHandedSkills autoInt Property DiseasedTwoHandedSkills autofloat Diseasebonusfloatfloat DiseasedMagickaRegenFloat ApplyOnceEvent OnInit()ApplyOnce = 0EndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Events Starting Magick Effect;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnEffectStart(Actor AkTarget, Actor Caster)actor myTargetmyTarget = akTarget as Actor;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Get Player Perk Bonuses;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if (Game.GetPlayer().HasPerk(CurseMastery))    DiseaseChanceBonus = 100    DiseaseBonus = 10Endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Get Random Ints for resist and such;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    int EnemyResist = Utility.RandomInt(1, EnemyHealth) as int    int DiseaseChance = Utility.RandomInt(1, 100 + (DiseaseChanceBonus)) as int    DiseaseChance = (DiseaseChance + MonkeyFinger)    int DiseaseScale = Utility.RandomInt(1, 100) as int    Actor TargetActor = GetTargetActor();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Define Enemy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    int EnemyHealth = TargetActor.GetAV("Health") as int    int EnemyMagicka = TargetActor.GetAV("Magicka") as int    int EnemyHealthRegen = TargetActor.GetAV("HealRate") as int    int EnemyMagickaRegen = TargetActor.GetAV("MagickaRate") as int    int EnemyStamina = TargetActor.GetAV("Stamina") as int    int EnemyStaminaRate = TargetActor.GetAV("StaminaRate") as int    int EnemyCarryWeight = TargetActor.GetAV("CarryWeight") as int    int EnemyOnehand = TargetActor.GetAV("OneHanded") as int    int EnemyTwohand = TargetActor.GetAV("TwoHanded") as int    int EnemyDiseaseResist = TargetActor.GetAV("DiseaseResist") as int;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; What happens if enemy gets diseased;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if DiseaseChance > EnemyResist                int WhichDisease = Utility.RandomInt(1, 100 + (DiseaseBonus)) as int    ;Debug.Messagebox("The enemy failed Resist check");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    if WhichDisease < 20        DiseasedStamina = 0        if AkTarget.HasSpell(DisBloodLung)            HasBloodLung = 1            WhichDisease = (WhichDisease + 10)        endif        if HasBloodLung == 0            Int BloodLung = Utility.RandomInt(1, 10) as int            BloodLung = (BloodLung + DiseaseBonus)            DiseasedStamina = (EnemyStamina - BloodLung) as Int            AkTarget.SetAV("Stamina", DiseasedStamina)            HasBloodLung = 1            Debug.Messagebox("Your target has been afflicted with Blood Lung! Stamina reduced by" + BloodLung)        Endif    endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    If WhichDisease < 19        If WhichDisease < 40            If HasBoneBreakFever == 1                WhichDisease = (WhichDisease + 10)            endif            If HasBoneBreakFever == 0                Int BoneBreakFever = Utility.RandomInt(10, 50 ) as int                if DiseaseBonus == 10                    DiseaseBonus = (DiseaseBonus + 30)                endif                BoneBreakFever = (BoneBreakFever + DiseaseBonus)                DiseasedEnemyCarryWeight = (EnemyCarryWeight - BoneBreakFever) as int                AkTarget.SetAV("CarryWeight", DiseasedEnemyCarryWeight)                HasBoneBreakFever = 1                Debug.Messagebox("Your target has been afflicted with BoneBreakFever! Carry Weight reduced by" + BoneBreakFever)            endif        endif    endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    If WhichDisease > 39        If WhichDisease < 60            If HasBrainRot == 1                WhichDisease = (WhichDisease + 10)            endif            If HasBrainRot == 0                If ApplyOnce == 0                    int BrainRot = Utility.RandomInt(10, 50) as Int                    BrainRot = (BrainRot + DiseaseBonus)                    DiseasedMagicka = (EnemyMagicka - BrainRot) as int                    AkTarget.SetAV("Magicka", DiseasedMagicka)                    HasBrainRot = 1                    Debug.Messagebox("Your target has been afflicted with Brain Rot! Magicka Reduced by" + BrainRot)                    ApplyOnce = 1                endif            endif        endif    endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    If WhichDisease > 59        If WhichDisease < 80            If HasWitbane == 1                WhichDisease = (WhichDisease + 10)            endif            If HasWitbane == 0                if ApplyOnce == 0                    if DiseaseBonus == 10                        DiseaseBonusfloat = 0.1                    endif                    DiseasedMagickaRegen = ( 0.5 - DiseaseBonusfloat)                    AkTarget.SetAV("MagickaRegen", DiseasedMagickaRegen)                    HasWitbane = 1                    Debug.Messagebox("Your target has been afflicted with Witbane! Magicka Regen is at" + DiseasedMagickaRegen)                    ApplyOnce = 1                endif            endif        endif    endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    If WhichDisease > 79        if WhichDisease < 96            if HasRockJoint == 1                WhichDisease = (WhichDisease + 10)            endif            if HasRockJoint == 0                if ApplyOnce == 0                    int RockJoint = Utility.RandomInt(5, 25) as int                    RockJoint = (RockJoint + DiseaseBonus)                    DiseasedOneHandSkills = (EnemyOneHand - RockJoint) as int                    DiseasedTwoHandSkills = (EnemyTwoHand - RockJoint) as int                    AkTarget.SetAV("OneHanded", DiseasedOneHandedSkills)                    AkTarget.SetAV("TwoHanded", DiseasedTwoHandedSkills)                    Debug.Messagebox("Your target has been afflicted with Rock Joint! Weapon Skills Reduced by" + RockJoint)                    HasRockJoint = 1                    ApplyOnce = 1                endif            endif        endif    endif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    If WhichDisease > 95        if HasMonkeyFinger == 0            if ApplyOnce == 0                MonkeyFinger = (25 + DiseaseBonus)                DiseasedDisResist = (EnemyDiseaseResist - MonkeyFinger)                AkTarget.SetAV("DiseaseResistance", DiseasedDisResist)                HasMonkeyFinger = 1                Debug.Messagebox("Your target has been afflicted with Monkey Finger! Disease Resistance has been reduced by" + MonkeyFinger)                ApplyOnce = 1            Endif        Endif    endifendif;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Check to see if has all diseases;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;if HasMonkeyFinger == 1    if HasRockJoint ==1        if HasWitbane == 1            if HasBrainRot == 1                if HasBoneBreakFever == 1                    if HasBloodLung == 1                        Debug.Messagebox("Your target has been afflicted with All diseases known to you!")                    endif                endif            endif        endif    endifendifEndEventEvent OnEffectFinish(Actor Target, Actor Caster)EndEvent

I do like doing it through scripting because I can give the player message's telling them what disease they gave the enemy as well as what the effects were, not to mention I can increase the effect in the script through the use of perks.
User avatar
pinar
 
Posts: 3453
Joined: Thu Apr 19, 2007 1:35 pm

Post » Thu Jun 21, 2012 5:07 am

Actually I forgot I had defined MyTarget as AkTarget as an Actor. I had tried that earlier when working to AddSpell but it wasn't working.. Perhaps because I was not using DoCombatSpellApply or whatever.. You will see a number of other things that are irrelivant to the script that I had tried at one point in time to get the addspell to work like Actor TargetActor = GetTargetActor() None of which was working.

I just have not cleaned that stuff out yet..
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Wed Jun 20, 2012 8:10 pm

Actually I have completely resolved this issue now and everything is working perfectly. I may just try to find a way for the effects of disease to be cured but its not a big deal either way since I have heard that SetAB is only temporary until the next save or load anyways although I need to verify that myself.
User avatar
Emma louise Wendelk
 
Posts: 3385
Joined: Sat Dec 09, 2006 9:31 pm


Return to V - Skyrim