OneOnOne1162 Posted May 11, 2020 Share Posted May 11, 2020 (edited) Hello everyone, I'm sure you're all getting tired of seeing me by now but I cannot for the life of me (despite trying this for about 2 hours) seem to figure out why my "GetRace()" function isn't working properly. It's a spell effect and I want it to have different effects on different races. I started off by trying to use "if akTarget.GetRace() == NordRace" but that didn't work. I then tried "if akTarget.GetActorBase().GetRace() == Nord Race" but that also didn't work. Then I tried to use a comparison so I first used and Actor and then an ActorBase to compare it to. So "if akTarget.GetRace() == NordReference.GetRace()" and "if akTarget.GetActorBase.GetRace() == NordReference.GetActorBase.GetRace()." None of these worked either. Then finally I created a debug notification to try to see what was going on "Debug.Notification("" + akTarget.GetActorBase().GetRace())" but when I use the effect in game it just returns "[Race" and I have no idea what to make of that. The only thing that seems to work is "if akTarget.GetRace() == akTarget.GetRace()." Can I not get the race from akTarget directly? Is there some indirect way around this? Edit: Just to clarify in the code I wrote above "NordRace" is defined by "Race Property NordRace Auto" and "NordReference" was at one point defined by "Actor Property NordReference Auto" and at another point "ActorBase Property NordReference Auto." "NordRace" is the value I used for the "NordRace" property and for the "NordReference" property I used Ulfric. Edited May 11, 2020 by OneOnOne1162 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 11, 2020 Share Posted May 11, 2020 You need a property that points to the target race and compare that against the race of the target actor. Race Property NordRace Auto ;inside your event ;akTarget is normally defined as an actor -- the following should work If akTarget.GetRace() == NordRace Debug.Notification("Target is a Nord") Else Debug.Notification("Target is not a Nord") EndIf Link to comment Share on other sites More sharing options...
OneOnOne1162 Posted May 11, 2020 Author Share Posted May 11, 2020 You need a property that points to the target race and compare that against the race of the target actor. Race Property NordRace Auto ;inside your event ;akTarget is normally defined as an actor -- the following should work If akTarget.GetRace() == NordRace Debug.Notification("Target is a Nord") Else Debug.Notification("Target is not a Nord") EndIf I've tried that and somehow it doesn't seem to work and I have no idea why. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 11, 2020 Share Posted May 11, 2020 Did you assign the data to the property via the properties window? Writing it in the script is not enough, the actual data has to be assigned or it will fail to function. Link to comment Share on other sites More sharing options...
OneOnOne1162 Posted May 11, 2020 Author Share Posted May 11, 2020 (edited) Did you assign the data to the property via the properties window? Writing it in the script is not enough, the actual data has to be assigned or it will fail to function. Jup, I did. I have made several mods before and, as far as I know, I did all the basics. Edited May 11, 2020 by OneOnOne1162 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted May 11, 2020 Share Posted May 11, 2020 GetRace() should work on both, the actor base and the reference. If it's a leveled actor try: akTarget.GetLeveledActorBase().GetRace() Link to comment Share on other sites More sharing options...
OneOnOne1162 Posted May 11, 2020 Author Share Posted May 11, 2020 GetRace() should work on both, the actor base and the reference. If it's a leveled actor try: akTarget.GetLeveledActorBase().GetRace() After you suggested it I tried it but it still doesn't work. The effect still doesn't happen properly and it still returns "]Race." Link to comment Share on other sites More sharing options...
Ghaunadaur Posted May 11, 2020 Share Posted May 11, 2020 (edited) No idea then. I've used that function before, in a magic effect script as well, and it worked properly. Could you post the script? Edited May 11, 2020 by Ghaunadaur Link to comment Share on other sites More sharing options...
OneOnOne1162 Posted May 11, 2020 Author Share Posted May 11, 2020 (edited) No idea then. I've used that function before, in a magic effect script as well, and it worked properly. Could you post the script? Currently I've reduced it to this, but I've tried many other variations: Scriptname BlooddrinkerEffectScript extends activemagiceffect Event OnEffectStart(Actor akCaster, Actor akTarget)Debug.Notification("" + akTarget.GetLeveledActorBase().GetRace())if akTarget.GetLeveledActorBase().GetRace() == NordRace if NordEffect.GetValue() == 0 Debug.Notification("You hit a Nord.") ; Nothing happens elseif NordEffect.GetValue() == 1 NordDamage1.Cast(akTarget, akCaster) endifelseDebug.Notification("Target is not a Nord.")endifEndEvent Race Property NordRace Auto GlobalVariable Property NordEffect Auto SPELL Property NordDamage1 Auto Actor Property NordReference Auto Edited May 11, 2020 by OneOnOne1162 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted May 11, 2020 Share Posted May 11, 2020 (edited) your code is Event OnEffectStart(Actor akCaster, Actor akTarget)should be (look at vanilla script "ActiveMagicEffect.psc") Event OnEffectStart(Actor akTarget, Actor akCaster)No idea what are your spell conditions and the condition for your globalVar is also mysterious for me. Maybe next sample brings light to you. BlooddrinkerEffectScript Scriptname BlooddrinkerEffectScript extends ActiveMagicEffect ; https://forums.nexusmods.com/index.php?/topic/8698618-getrace-not-working/ GlobalVariable PROPERTY glNordEffect auto ; [default = GetValue() == 0.0] SPELL PROPERTY NordDamage1 auto Race PROPERTY NordRace auto ;Actor PROPERTY NordReference auto ; useless ; -- EVENTs -- (Target, Caster) ; https://www.creationkit.com/index.php?title=Cast_-_Spell ; mySpell.Cast(akSource, akTarget) ; akSource: "The ObjectReference from which to cast the spell. ; The source must be able to cast this spell (testings seem to show anything will work, regardless whether they have the spell or not)." ; akTarget: "An optional ObjectReference at which to aim the spell. ; If None is passed and the spell needs a direction, it will be aimed in a default direction." EVENT OnEffectStart(Actor akTarget, Actor akCaster) race r = akTarget.GetRace() Debug.Trace(self+" OnEffectStart() - target = " +akTarget+", with race = " +r) IF (r == NordRace) ELSE Debug.Notification("Target is not a Nord.") RETURN ; - STOP - ENDIF ;--------------------- float f = glNordEffect.GetValue() IF (f == 0.0) Debug.Notification("You hit a Nord.") glNordEffect.Mod(1) ; add 1 to gobalVar ;;; glNordEffect.setValue(f+1) ELSEIF (f == 1.0) NordDamage1.Cast(akCaster, akTarget) ENDIF ENDEVENT EVENT OnEffectFinish(Actor akTarget, Actor akCaster) Debug.Trace(self+" OnEffectFinish() - target " +akTarget+ ", caster = " +akCaster) ENDEVENT Edited May 11, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts