Jump to content
Heavy Traffic ×

Papyrus and Alias Actor(s)


silhouett

Recommended Posts

I have created a quest and have 10 Alias or slots say to fill for actors

I want to be able to fill the first empty Alias with in a script that each actor has attached.

I also want to be able to remove or clear that actors Alias so that another actor with the same script can fill the empty place.

 

Actor has script that when a certain thing event triggers it it will add the actor to a quest Alias

if the quest alias is cleared the next actor with the same script can just fill that spot when there event is activated.

 

Any Papyrus people (Quest guys) want to show me a quick bit of code.

 

 

 

Thank You

Link to comment
Share on other sites

Generally, you would get your answer faster by browsing the Creation Kit wiki Script Objects list for the appropriate scripts: http://www.creationkit.com/fallout4/index.php?title=Category:Script_Objects

 

Check these, they will have what you want:

To clear an alias:

rRefAlias.Clear()

To fill an empty alias:

rRefAlias.ForceRefIfEmpty(rNewRef)

And maybe something like this would do, it compiled at least, but has not been tested:

Quest Property rQuest Auto
ReferenceAlias rRefAlias

Function ClearFromAlias()
    If (rRefAlias)
        rRefAlias.Clear()
        rRefAlias = None
    EndIf
EndFunction

Function AddToAlias()
    ClearFromAlias()
    int i = 10 ; the number of aliases you have
    While(i > 0)
        i -= 1
        rRefAlias = rQuest.GetAlias(i) as ReferenceAlias
        If (rRefAlias && rRefAlias.ForceRefIfEmpty(Self))
            Debug.MessageBox("Added to Alias: " + i)
            i = 0
        EndIf
    EndWhile
EndFunction

Just an idea. If the functions - and especially casts - do not work, you need to rethink that so that it works with ReferenceAliases properly. There was no function in Quest Script to get a ReferenceAlias out, only Alias, so the cast to Reference Alias is there to make it compile. It wither will or will not work. Your Papyrus log should tell you if it fails to cast it.

Link to comment
Share on other sites

Umm... okay. No problem. The Aliases (of type "ReferenceAlias" I assumed) have indices, starting from 0, going up, to identify them. Maybe they could be considered a sort of array... if that was what you meant. Also, that way of doing it (counting from 10 down) works in reverse, by filling the last one, then the second last one, etc. The ReferenceAlias variable should keep track of the alias the current actor is in. I assume Self still refers to the object the script runs on.

 

What sort of a problem did you have?

Edited by Contrathetix
Link to comment
Share on other sites

  • 2 weeks later...

this works well now, I was having an issue that some how the reference I was using was not containing the actor but using your array method worked fine.

I pre-establish the links in the quest so as each actor is placed in the ref they are linked to the last actor counting down so 9 is linked to 10 and 10 to a terminal
this works fine and I figured out how to removed the reference and maintain the linking however if I move the Terminal to say position 11 and change the links so 11 goes to 10 and 10 to the next actor etc it wont work ??? I am ok with it working with 1 terminal and 9 actors but curious as to why it fails above that number.

Link to comment
Share on other sites

In the OP you said you have 10 alias slots, so I put this in the code:

    int i = 10 ; the number of aliases you have
    While(i > 0)
        i -= 1
        <cycle through aliases and blaablaablaa>
    EndWhile

You would need to raise the value of i to something higher if you want more aliases. When i = 10, it goes through aliases [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], which is ten. If you add an alias with an ID of 10, the loop will still start at 9, because i = 10 and it is decreased on each loop (including first one). So you could try changing i to the number of aliases you have. Another option would be to use a script command to calculate the number of aliases your quest has, but I dod not find one when I last had a look.

 

I have no idea what you are trying to achieve, so that is all I can comment at the moment. You just asked how to fill a bunch of aliases with a script attached to an actor. Good luck with your project, though. Sounds interesting. :thumbsup:

 

Edit: Another option would be to use a loop like this, because the wiki says GetAlias() will return None of an alias of that ID does not exist (so if you stop when GetAlias returns None, you can cycle it upwards from 0). If that would be more closer to what you originally had in mind. It should work with an arbitrary amount of aliases, and it should count from 0 upwards as you first wanted. Apologies for any confusion, I am just throwing around ideas. However, if that one below fails to end, it will run forever, and you do not want that! So the above example is still safer.

Quest Property rQuest Auto
ReferenceAlias rRefAlias

Function ClearFromAlias()
    If (rRefAlias)
        rRefAlias.Clear()
        rRefAlias = None
    EndIf
EndFunction

Function AddToAlias()
    ClearFromAlias()
    int i = -1 ; starts from 0, goes upwards
    bool b = True
    While (b)
        i += 1
        rRefAlias = rQuest.GetAlias(i) as ReferenceAlias
        If !(rRefAlias)
            Debug.MessageBox("Stop! No more reference aliases remain. First empty: " + i)
            b = False
        ElseIf (rRefAlias.ForceRefIfEmpty(Self))
            Debug.MessageBox("Added to Alias: " + i)
            b = False
        EndIf
    EndWhile
EndFunction
Edited by Contrathetix
Link to comment
Share on other sites

  • Recently Browsing   0 members

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