Void Expanse Tutorials right in here!

Started by ninekorn, July 07, 2018, 12:18:21 PM

ninekorn

discontinued 2023 july 29th . by ninekorn

Wilmore

Great! Thanks a lot for doing this 8) IΓÇÖm really looking forward watching this.
It doesn't matter what we think of God, but what He thinks of us.       - Pascal

ninekorn

#2
It's not complete though. You're gonna have to give me a little bit more time to get everything else that you asked for covered. Maybe I'll do a second part tomorrow or monday or next weekend!  ;)

Lurler

Awesome video, thank you. I'm sure many people would find it useful!

Though there is much easier way to add NPCs :)
And that's the way it is done in Pariahs Bane expansion. You don't really need to override any scripts of the original game, you can just use a hook to a specific function and add your NPC generation code there.
Plus if you override any scripts it means you can't use other mods together with this one at the same time as there would be conflict between different overrides.
But oh, well :)

Wilmore

Thanks a lot, @ninekorn! This was great! I have now (finally) been able to spawn my own NPC, using your method. I do see Lurler's concern for this possibly being incompatible with other mods. However, so far, this is the only real tutorial I have seen that I have been able to use. This community needs such step-by-step tutorials.

Looking forward to the next part!

PS: Another question, is there any way to spawn NPCs after the world has been generated? Or do you really need to do it as the world is created?
It doesn't matter what we think of God, but what He thinks of us.       - Pascal

Lurler

Quote from: Wilmore on July 09, 2018, 11:31:32 AM
PS: Another question, is there any way to spawn NPCs after the world has been generated? Or do you really need to do it as the world is created?
Yes, there is a way, and that is precisely what Pariah's Bane expansion does :)

ninekorn

It was my pleasure Wilmore! I am using this specific NPC generation example in the tutorial myself in my mods. I might change that in the future but I didn't intend to use anyone else's mod's for my mods.

I only checked the Pariah's Bane expansion scripts when I was searching for special functions with Notepad++ but never read the scripts fully. I will probably do a supplement tutorial on how to use that and where to put the variables after I study the Pariah's Bane Expansion scripts!

Lurler

Quote from: ninekorn on July 10, 2018, 04:01:39 AM
I only checked the Pariah's Bane expansion scripts when I was searching for special functions with Notepad++ but never read the scripts fully. I will probably do a supplement tutorial on how to use that and where to put the variables after I study the Pariah's Bane Expansion scripts!
Sure!
I just checked and there are basically just 2 scripts in the expansion:
dlc1_core_functionality.js
and
dlc1_GenerateGalaxy.js
They are quire self expanatory I think. One of them generates all new content that the expansion provides, new systems, stations, npcs, etc.

Wilmore

So, when will you have the next part ready? Really looking forward to it :-)
It doesn't matter what we think of God, but what He thinks of us.       - Pascal

ninekorn

Hi!
There is a very high probability that I will work on a second tutorial tomorrow amongst releasing my pre-Beta Virtual Desktop (Oculus Rift only) for Void Expanse! ;)

ninekorn

#10
TUTORIAL 1.5

Eh well... I am a bit late. It's already Sunday night. I've been working on that Virtual Reality Desktop that has customizable Oculus Touch buttons just for Void Expanse. I was able to make a Oculus Touch stabilizer for when you aim at the Virtual screen, otherwise the shakyness is terrible and you can't even double click anything... Also, I had to code a way for the program to change controls when Void Expanse is the Foreground application on the computer.

Anyway, so the tutorial part 1.5 comes with only a script (part 2 will be a video explaining the script and also making it even better because I didn't have enough time this weekend). The script is based on the Original tutorials of the Atomic Torch team for Void Expanse where you speak to an NPC and an NPC gives you a quest. In that script you will find also the way that I am coding my NPC's that have dialogue. I add a menu for "going back to the last options" and also a menu to "quit the dialogue" even though a "Goodbye" button already exists for that. I just think it is more "User Friendly" to follow what is written there on the screen and click where the NPC tells you to click.

Steps to make this work:

1. If you still have the tutorial files from part 1, use them. Otherwise, this won't work.
2. Go Inside your mod folder, then the data folder, and then create a Folder named topics.
3. Inside of that folder, create a folder named "generic_quests".
4. Inside of that folder, create a Notepad file with your right mouse button and name the file "tutorial_quest.js".
In order to do that, you also need to change the extension to .js, so if you can't see the extension of your     notepad, go in your folder "view" options at the top and then click the option "file name extension" (on Windows 10). Otherwise, you can Google "how to see file extension Windows XP-Vista-7-8" and you will find tons of articles to help you out.
5. in that same folder, create a file named "tutorial_quest.xml".
6. Remove what is Inside of the xml file if there is anything and paste the following code Inside of the XML file and then save it and close it:


<?xml version="1.0" encoding="utf-8"?>

<root>
<header>
<id>tutorial_quest</id>
<title>tutorial quest</title>
<enabled>1</enabled>
</header>

<data>
<category>quests</category>

<variables>
<var>quest_system_id</var>
<var>quest_base_id</var>
</variables>

<flags>
<flag>add_on_init</flag>
</flags>

<singleplayer>1</singleplayer>
<multiplayer>1</multiplayer>

</data>

</root>



7. Then open the created "tutorial_quest.js" file and if there is anything in there, remove it, and copy and paste the following code and then save it and close it:

using(generator);
using(items);
using(npc);
using(console);
using(ship);
using(player);
using(storage);
using(game);

function OnCheckRequirements()
{
    var npc_id = topic.GetCurrentNpcShipId();

    if (npc.GetTag(npc_id, "class") == "TUTORIALNPC")
    {
        return true;
    }
    return false;
}

var quest_system_id = 0;
var quest_base_id = 0;

function OnDialogue(args)
{
    var input = topic.GetInput();
    var state = topic.GetState();

    var npc_id = topic.GetCurrentNpcShipId();

    if (state == 0)
    {
        if (input == NO_INPUT)
        {
            topic.AddPhrase("Hello there!");
            topic.AddChoice(1, "I want to make money");
            topic.AddChoice(5, "End dialogue");
        }
   
        else if (input == 1) {
            topic.AddPhrase("So, you want to make money huh?");
            topic.AddChoice(2, "Do you want a quest?");
            topic.AddChoice(5, "End dialogue");
            topic.AddChoice(NO_INPUT,"Go back to the previous page");
        }

        else if (input == 2)
        {
            topic.AddPhrase("So? What is your choice?");
            topic.AddChoice(3, "Yes!");
            topic.AddChoice(5, "No!");
        }
         
        else if (input == 3)
        {
            topic.AddPhrase("If you want to mine minerals click on the following dialog option! This is going to give you a quest.");
            topic.AddChoice(4, "Tutorial Quest here! This is a mining tutorial quest where you need to buy 50 Glepsite Ores and come back with it so that I can give you rewards.");
            topic.AddChoice(2, "Go back to the previous page");
            topic.AddChoice(5, "If you are not interested for the moment, you can come back later. Click here to have the option to close the dialogue.");
        }

        else if (input == 4)
        {
            topic.AddPhrase("Great! That's good news! Finally, someone who wants to mine minerals. Good luck!");

            var ship_id = topic.GetCurrentNpcShipId();
            var sys_id = ship.GetSystemID(ship_id);

            quest_system_id = sys_id;
            quest_base_id = ship.GetCurrentBase(ship_id);

            topic.QuestStart("tutorial_mining_quest", "go mine for rewards");
            topic.QuestAddMark("tutorial_mining_quest", quest_system_id);
            topic.QuestAddLocalMarkObject("tutorial_mining_quest", quest_system_id, quest_base_id);
            topic.QuestAddLog("tutorial_mining_quest", "Go get a mining device and mine 50 Glepsite and go back to tutorialNPC");
            topic.SetState(100);
            topic.RefreshTopics();
        }

        else if (input == 5)
        {
            topic.AddPhrase("See you next time!");
            topic.AddChoice(6, "Click here to leave the dialogue!");
        }

        else if (input == 6)
        {
            topic.DialogueBreak();
        }
    }

    else if (state == 100)
    {     
        if (input == NO_INPUT)
        {
            topic.AddChoice(1, "How do I mine asteroids?");
            topic.AddChoice(2, "If you got the minerals, click here!");
            topic.AddChoice(3, "End dialogue");
        }
        else if (input == 1)
        {
            topic.AddPhrase("Get a civilian mining device and then when you undock from the station, find the brown/orange dots on your map and come back to me when you have a least 50 Glepsite ore. ");
            topic.AddChoice(NO_INPUT, "Go back to the previous page");
            topic.AddChoice(3, "End dialogue");
        }
        else if (input == 2)
        {
            var hasCargo = ship.HasCargoAmount(PLAYER_SHIP, "ore_glepsite", 50);

            if (hasCargo)
            {
                topic.AddPhrase("Good job! And thank you for the minerals! Here's your reward.");

                ship.RemoveCargoByType(PLAYER_SHIP, "ore_glepsite", 50);
                ship.AddItem(PLAYER_SHIP, "consumable_structure", 5);

                topic.QuestAddLog("tutorial_mining_quest", "test");
                topic.QuestSetState("tutorial_mining_quest", QuestState.Finished);
                player.AddQuestRewardExperience(PLAYER, 500);

                topic.SetState(200);
                topic.RefreshTopics();
            }
            else
            {
                topic.AddPhrase("You don't even have the minerals?! I am a busy man. Come back when you have them and don't disturb me again for no reasons.");
                topic.AddChoice(NO_INPUT, "Go back to the previous page");
                topic.AddChoice(3, "End dialogue");
            }
        }
        else if (input == 3)
        {
            topic.AddPhrase("See you next time!");
            topic.AddChoice(4, "Click here to leave the dialogue!");
        }

        else if (input == 4) {
            topic.DialogueBreak();
        }       
    }

    else if (state == 200)
    {
        if (input == NO_INPUT)
        {
            topic.AddPhrase("Hello there!");
            topic.AddPhrase("I don't need any more minerals!");
            topic.AddChoice(1, "End dialogue");
        }
        else if (input == 1)
        {
            topic.AddPhrase("See you next time!");
            topic.AddChoice(2, "Click here to leave the dialogue!");
        }

        else if (input == 2)
        {
            topic.DialogueBreak();
        }
    }
}




8. If you've done this right, you should have the same NPC from tutorial 1 that will give you a quest to go mine 50 Glepsite Ore minerals and he will reward you when you come back with a cargo of those minerals. But he will only reward you IF you choose to finish the quest, otherwise, you can still have a dialogue with him for other stuff that you can add in the future.

9. Tutorial 2 will cover this whole part but as I said, the Virtual Desktop Application pretty much shrunk my whole weekend's free time to make tutorials and so I couldn't make a video right now, but for the community and you Willmore, I really at least wanted to share an easy script for having an NPC give a quest before the next Video tutorial.

Wilmore

Thank you again ninekorn! Just a specific question:

The value "TUTORIALNPC", where is that pointing? Is it the ID of the NPC (the name of the xml file) from the previous part of the tutorial? I changed that while "copying" your method, so should I then change it to the ID of my NPC ("special_jonas_temple")?
It doesn't matter what we think of God, but what He thinks of us.       - Pascal

Wilmore

Quote from: Lurler on July 10, 2018, 04:19:34 AM
Sure!
I just checked and there are basically just 2 scripts in the expansion:
dlc1_core_functionality.js
and
dlc1_GenerateGalaxy.js
They are quire self expanatory I think. One of them generates all new content that the expansion provides, new systems, stations, npcs, etc.

It would be great if you could create a video tutorial on how to use these, similar to what ninekorn did. You might find the scripts self explanatory, but for a person not so used to neither the structure of the game files nor JavaScript, a brief video tutorial with explanations would be most welcome!
It doesn't matter what we think of God, but what He thinks of us.       - Pascal

ninekorn

Quote from: Wilmore on July 16, 2018, 07:00:46 AM
Thank you again ninekorn! Just a specific question:

The value "TUTORIALNPC", where is that pointing? Is it the ID of the NPC (the name of the xml file) from the previous part of the tutorial? I changed that while "copying" your method, so should I then change it to the ID of my NPC ("special_jonas_temple")?

Yes Wilmore. In the npcgenerator.js script, exactly where we created the npc in the tutorial, you have to use the class IF you specify to check for the class in the function ''OnCheckRequirements''!

Wilmore

#14
I am sorry. I can't get it to work. No dialogue pops up when I click my NPC, "Jonas Temple".

So 2 questions:

1. Do NPCs, scripts and so on load dynamically, or do I need to create a new world everytime I want to add something to the mod?

2. My line from NPCGenerator.js looks like this:
Quote
id = generator.AddNPCShipToSystem("Jonas Temple", "JonasTemple", 1, "special_jonas_temple", sys_id, chosenBase.coord.x, chosenBase.coord.y, { class: "agent", unique_id: "jonastemple", meta: "human", sex: "male" }); // Jonas Temple
What string should I use in stead of your "TUTORIALNPC"? I can't get it to work with either "Jonas Temple", "JonasTemple" or "special_jonas_temple"...
It doesn't matter what we think of God, but what He thinks of us.       - Pascal