Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,880
First Language
English
Update



NxRiP.jpg


Demo: http://db.tt/ZBuWIe8f

Instructions: Talk to fairy

Overview

This script is called an "Event Wrapper", which is appropriate because it provides methods that allow you to dynamically create events using script calls.

Currently it supports roughly only 25% of what the event editor can actually do. Things I haven't implemented include branching, move routes, and actor/enemy related commands.

Branching includes loops, choice selection, conditional branching, and basically anything where the indent is not 0.

When this script is completed, not only would you be able to create events easily using a standard set of method calls, but you can also have support for

-unlimited, arbitrary page conditions (including custom page conditions)

-unlimited choice options (not just 4), because you have full control over the branching logic

-unlimited pages

-unlimited self-switches without having to use odd script calls

This script is not a replacement for the event editor.

If you can do something with the event editor, use it.

However, there are many cases where the event editor simply cannot help you, especially when it comes to dynamic content that may be generated during the game. Examples include custom actors that are created in-game, or items that are dropped onto the map that may be picked up later.

A sample script that allows you to create a battle event:



Code:
def make_battle_event(x, y)
  event = Event.new(x, y)
  event.character_name = "monster2"
  event.character_index = 2
  event.call_battle(1)
  $game_map.add_event(event)
end
Here, all I needed to do was say tell it to add a command that calls a battle with troop ID 1, which is a slime. I also set the character name and index to the slime character, and then just added it to the game map.

I've put together a demo to show various functions in action:

I will have to re-design certain parts of the script. In particular

1. conditions should be accessed through Event.condition, to make it more flexible and clear

2. Maybe a better way to handle branching should be considered. This is what I have planned so far:



Code:
event = Event.new(...)
event.show_choices("choice1, "choice2")
event.option_branch("choice1")
#perform branch commands
event.end_branch
event.option_branch("choice2")
#perform more stuff
event.end_branch
Basically, if you want to branch, you must make it clear that you're starting a branch, and the script will do all of the indenting and set-up for you.

Similarly, to close a branch, you must say "end_branch" because you must decrease the indent by 1, and also insert an empty command to tell the interprer that the branch is finished.
 
Last edited by a moderator:

Levi

Veteran
Veteran
Joined
Jun 7, 2012
Messages
798
Reaction score
144
First Language
English
Primarily Uses
Dear jesus yes!

-unlimited, arbitrary page conditions (including custom page conditions)-unlimited choice options (not just 4), because you have full control over the branching logic

-unlimited pages

-unlimited self-switches without having to use odd script calls
:wub:
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,880
First Language
English
I have implemented choice selection.

HIeBr.jpg


You kind of have to match branch opens with branch ends, and we know how easy it is to mess up when it comes to parentheses matching.

Ideally, there should be a way for you to create branches without having to explicitly tell the engine to build the necessary indent structure.

I am currently rewriting it to use ruby's block syntax to make it so much cleaner



Code:
event.branch_option(1) {
  event.add_command...
}
event.branch_option(2) {
  event.add_command...
}
This is so much cleaner, but I will have to see how to do it first.

Here's a test script for the choices to see how it's done.

Place it below Event Tester.

It demonstrates a simple multi-option choice, and then shows how to nest choices.

It's really ugly at the moment and easy to mess up, but it serves as a comparison between different implementations.

Code:
# this adds the choice test to the demo. Place this below the Event Tester

class Game_Interpreter

  def choose_reward(event)
    # randomly generate an amount when event is created
    count = rand(20) + 1
    event.show_text('actor1', 4)
    event.add_message("Which reward would you like?")

    event.show_choices(["Life Up", "Mana Up"], 0)
    event.choice_branch(0)
    event.show_text
    event.add_message("Received %d Life Up!" %count)
    event.add_item(9, count)
    event.end_branch
    event.choice_branch(1)
    event.show_text
    event.add_message("Received %d Mana Up!" %count)
    event.add_item(10, count)
    event.end_branch
    event.play_se("item1")
  end

  def make_choice_event(x, y)
    event = Event.new(x, y)
    event.character_name = "actor1"
    event.character_index = 4
    event.show_text("actor1", 4)
    event.add_message("Select an option")
    event.show_choices(["Pork", "Beef", "Chicken", "Miso Soup",
                        "Turkey", "Duck", "Rabbit", "Lamb"], 0)

    # pork branch
    event.choice_branch(0)
    event.show_text("actor1", 4)
    event.add_message("Pork? Wrong!")
    event.end_branch
    # beef branch
    event.choice_branch(1)
    event.show_text("actor1", 4)
    event.add_message("Beef? Maybe...but no!")
    event.end_branch
    # chicken branch
    event.choice_branch(2)
    event.show_text("actor1", 4)
    event.add_message("Not even close")
    event.end_branch

    #miso soup branch
    event.choice_branch(3)
    event.show_text("actor1", 4)
    event.add_message("Oh, that sounds about right!!")

    # start reward choices
    choose_reward(event)
    # end reward choices

    event.control_self_switch("A", 0)
    event.end_branch

    # turkey branch
    event.choice_branch(4)
    event.show_text("actor1", 4)
    event.add_message("Getting colder")
    event.end_branch
    # duck branch
    event.choice_branch(5)
    event.show_text("actor1", 4)
    event.add_message("Ducks aren't that great")
    event.end_branch
    # rabbit branch
    event.choice_branch(6)
    event.show_text("actor1", 4)
    event.add_message("Rabbits shouldn't be on this list")
    event.end_branch
    # lamb branch
    event.choice_branch(7)
    event.show_text("actor1", 4)
    event.add_message("Well, lamb is fine I guess...but nope")
    event.end_branch

    event.set_page(1)
    event.character_name = "actor1"
    event.character_index = 4
    event.self_switch = "A"
    event.show_text("actor1", 4)
    event.add_message("Good job!")
    $game_map.add_event(event)
  end

  def run_test
    # create events
    make_music_event
    make_recruit_event
    make_scrolling_event(1, 5)
    make_chest_giver_event(3, 5)
    make_battle_event(6, 6)
    make_choice_event(5, 5)
  end
end
 
Last edited by a moderator:

Latest Threads

Latest Profile Posts

Steam page is now live!
1632768058957.png
just discovered thig game called Willowbrooke Post... beautiful artstyle if I do say so myself... does anyone know what this kind of style is called??
In one of my game projects, I am working on an arena where you can fight combatants or bet on monsters, and, man, it is taking so long, lmao. I do not think that it helps that I am using an evented combat system with a lot of things that I have to edit.
Time to take a little break from the project to work on another for Skyrim. Shouldn't take too long, as it's just fulfilling an easy to do request(more than likely I'll get beaten to the punch but...) this also gives me an excuse to play Skyrim again LOL.
Dawg.gifKhat.gif
I made two new friends today. I'm not sure which style I like the best..?

Forum statistics

Threads
115,416
Messages
1,089,700
Members
150,161
Latest member
kepsing
Top