Download

Update archetype from the editor using code

I have an actor to manage the dialogs in game. It has an array where I store the dialogs, phrases, etc, and also the code to manage all.

I can fill the array with new dialogs from the text editor without restart the UDK editor, using the BrushBuilder trick what Chosker showed me a long time ago.

I copy to clipboard all the dialogs, press a custom button in the UDK editor, and all that text is sent to the dialog actor, filling the array from the clipboard. This way I don’t need to restart the editor.

Works well, but I need to select manually the dialog actor, then select in the menu “Update archetype from this instance” (because I have a archetype instance in the map). This is a bit tedious when I’m on the big map, and I have to go to where the Dialog actor is, update it, and then go back to where I’m testing.

There are some way to update from code? Some “archetype.update()” (that not works).

I have never been able to execute unrealscript from the editor, so i’d also be interested in this if you figure something out.

Try this:

class myEditorTool extends BrushBuilder;

var float somevariableshere;

event bool Build()
{
	local WorldInfo WI;
    local pawn P;

	WI = class'Engine'.static.GetCurrentWorldInfo();
	
	foreach Wi.AllActors(class'pawn', P)
    {
	   `log("pawn"@P);
    }
}

defaultproperties
{
    BitmapFilename="DownArrowBlue"
    ToolTip="Your text for the buttom"
}

Wow, this is excellent! Thanks so much :slight_smile:

Thanks to Chosker :slightly_smiling_face:

I can’t take credit for it, I only brought back ancient knowledge :smiley:

unrealscript editor commands are really limited and sadly I don’t know anything that could help you

however I must ask, why do you save dialogues in a level actor? such text doesn’t really have a reason to exist in the world (it’s just static text after all) and not only it makes the editing really inconvenient (as you’ve found), it will make localization a nightmare if you ever decide to add languages to your game

So you are the custodian of ancient UDK knowledge :slight_smile:

I use this system because that way I don’t have to restart UDK in every test.

The actor contains two arrays, one for dialogs with the player and the other for phrases. They both use structs to store texts, cues, wavs and commands that are executed when using each phrase. I can program relatively complex behaviors using these dialogues, I can branch according to the characteristics of the NPC, if he is a man or a woman, or the memory that he has (he was attacked, you bought him something, you did some mission for him, etc).

The system I use is this:

  • I edit the dialogs, a simple text file, in Notepad ++.

  • I select everything (ctrl + A), copy (ctrl + C) and in UDK I press the BrushBuilder icon. All texts go from the clipboard to the actor.

  • The actor is an archetype, so I have to update it, I have to find it on the map, select it and press “update archetype”. This is the step that I want to save.

Ideally, it would be possible to update it by script after the second step, but it seems that it is not possible. I can think of two ways to make it easier:

a) Use the Editor’s bookmarks, for example #4 to get in front of the archetype and do manually the update, and #0 to return to the test place.

b) Don’t use archetypes, put the actor directly on the map, in a stream level, and so I don’t have to update. Closing the editor saves the stream level, and I can use it in different maps.

About using different languages, I don’t see the problem. I have it in a simple text file all the texts, all the cues and wavs and all the commands. With a script I can extract the texts, number them, give them to a translator, and with the translated file back, recompose with another script a new text file for that language. Put the actor on the map, use the BrushBuilder to fill the arrays, save it as an archetype, so I already have an archetype for each language, ready to drop them on the map with a spawn according to the selected language.

Cues and Wavs, as they are also saved in that text file, just replace the text in the package, for example \sounds_EN by \sounds_ES, to get the new cue/wav in another language.

Here the problem is going to be to get all those cues and wavs, that only with the tests I have more than 10,000 lines of text. I think that in principle I will use voices for some dialogues and the most will only be subtitles.