Jump to content

Photo

GetRace Not Working?

race getrace script problem question

  • Please log in to reply
10 replies to this topic

#1
OneOnOne1162

OneOnOne1162

    Enthusiast

  • Members
  • PipPip
  • 219 posts

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 by OneOnOne1162, 11 May 2020 - 02:19 AM.


#2
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 9,096 posts

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

 



#3
OneOnOne1162

OneOnOne1162

    Enthusiast

  • Members
  • PipPip
  • 219 posts

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.



#4
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 9,096 posts

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.



#5
OneOnOne1162

OneOnOne1162

    Enthusiast

  • Members
  • PipPip
  • 219 posts

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 by OneOnOne1162, 11 May 2020 - 10:14 AM.


#6
Ghaunadaur

Ghaunadaur

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,192 posts

GetRace() should work on both, the actor base and the reference. If it's a leveled actor try: akTarget.GetLeveledActorBase().GetRace()



#7
OneOnOne1162

OneOnOne1162

    Enthusiast

  • Members
  • PipPip
  • 219 posts

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."



#8
Ghaunadaur

Ghaunadaur

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,192 posts

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 by Ghaunadaur, 11 May 2020 - 02:16 PM.


#9
OneOnOne1162

OneOnOne1162

    Enthusiast

  • Members
  • PipPip
  • 219 posts

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)
   endif
else
Debug.Notification("Target is not a Nord.")
endif
EndEvent
 
Race Property NordRace  Auto  
 
GlobalVariable Property NordEffect  Auto  
 
SPELL Property NordDamage1 Auto
 
Actor Property NordReference  Auto  

Edited by OneOnOne1162, 11 May 2020 - 03:26 PM.


#10
ReDragon2013

ReDragon2013

    Old hand

  • Members
  • PipPipPip
  • 551 posts

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

Spoiler

Edited by ReDragon2013, 11 May 2020 - 04:24 PM.






Also tagged with one or more of these keywords: race, getrace, script, problem, question

Page loaded in: 1.065 seconds