Jump to content

need help on a script based on races


lorg8472

Recommended Posts

I'm trying to make a weapon that starts different events depending on the race of the target.

I added an explosion to the projectile and its magic effect with this simple script, but it doesn't work

 

Scriptname prova extends activemagiceffect
race property humanrace auto
Event OnEffectStart(Actor akTarget, Actor akCaster )
race targetRace = akTarget.getrace()
debug.notification("target is" + targetrace)
debug.trace(targetrace)
if targetRace == humanrace
debug.trace("is human")
debug.notification("IS HUMAN")
else
debug.trace("NONE")
debug.notification("NONE")
endif
endevent

 

The problems are : debug.notification ("target is " + targetrace) outputs "Race" instead of the actual race.

the if statement always outouts "none" , even when I'm shooting humans

 

Can anyone explain me where I'm wrong?

Thanks

Edited by lorg8472
Link to comment
Share on other sites

You're passing a race record to the string, therefore it shows that it is a race, if you want to show the name of the race you should be using GetName() from F4SE, if you don't want to use script extender then you need to use a message record, a quest and an alias, then you can use a text replacement tag in your message body.

 

In the quest you must set a reference alias with the fill type set to Specific Reference with no reference assigned and set as optional, you will fill the reference with the script right before displaying the message.

 

In the message you must set the quest as the "Owner Quest".

 

Let's say that your alias is named TargetActor, in the body of the message you'd write:

target is <Alias.Race=TargetActor>

Reference here: https://www.creationkit.com/index.php?title=Text_Replacement

 

Then you can call your message like this:

Scriptname prova extends activemagiceffect
race property humanrace auto
Message Property RaceMessage Auto
ReferenceAlias Property TargetActor Auto 
Event OnEffectStart(Actor akTarget, Actor akCaster )  
        TargetActor.ForceRefTo(akTarget)
        RaceMessage.Show()      
        race targetRace = akTarget.getrace()        
        if targetRace == humanrace
            debug.trace("is human")
            debug.notification("IS  HUMAN")
        else
            debug.trace("NONE")
            debug.notification("NONE")
        endif       
endevent  
Edited by DieFeM
Link to comment
Share on other sites

I've forgot to mention that for the alias method you need to tick a checkbox for it to store the actor name and therefore show it in the message, otherwise it will show just dots, but there are two very similar named options and i don't recall which one it is, stores text or uses stored text, I think that marking both should work.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...