Skip to content
Alchyr edited this page Apr 23, 2020 · 14 revisions

Creating an Event.

The first thing you want to do is create a class that extends AbstractEvent (or any abstract class that extends it)

Here is a very simple example of an event.

public class MyFirstEvent extends AbstractImageEvent {

    //This isn't technically needed but it becomes useful later
    public static final String ID = "My First Event";

    public MyFirstEvent(){
        super(ID, "My body text", "img/events/eventpicture.png");
        
        //This is where you would create your dialog options
        this.imageEventText.setDialogOption("My Dialog Option"); //This adds the option to a list of options
    }

    @Override
    protected void buttonEffect(int buttonPressed) {
        //It is best to look at examples of what to do here in the basegame event classes, but essentially when you click on a dialog option the index of the pressed button is passed here as buttonPressed.
    }
}

A more advanced example of a custom event can be found Here

Adding the Event

Now that you have created your event, you will want to add that event to one of the games event pools. Thankfully that process is now handled by BaseMod.

All you need to do is call this method in receivePostInitialize:

BaseMod.addEvent(String eventID, Class<? extends AbstractEvent> class, String dungeonID)

  • eventID : The ID of the event. This should be the same as in your eventStrings.json
  • class : The class of the event you are adding.
  • dungeonID : The ID of the dungeon whose pool you want to add the event to. (e.g. Exordium.ID, TheCity.ID, TheBeyond.ID). Leaving off this argument adds the event to all pools.

A quick example using the method above would be:

@Override
public void receivePostInitialize() {
    BaseMod.addEvent(MyFirstEvent.ID, MyFirstEvent.class);
    BaseMod.addEvent(MySecondEvent.ID, MySecondEvent.class, TheCity.ID);
}

Custom Event Conditions

In some cases, you might want your event to have more specific spawning conditions or change what kind of event it is. For that, you should use this method:

BaseMod.addEvent(AddEventParams params)

  • AddEventParams : The detailed parameters for the event to add. This should be built using AddEventParams.Builder.

The method should be called as BaseMod.addEvent(new AddEventParams.Builder(eventID, eventClass).create());

Additional methods to add more conditions should be appended on the builder before the create() call. For example:

new AddEventParams.Builder(MySecondEvent.ID, MySecondEvent.class).dungeonID(TheCity.ID).create()

Builder methods:

  • dungeonID(String dungeonID) dungeonIDs(String... dungeonIDs) : Limits the event to appearing in the specified acts. If not specified, the event can appear in any act.

  • playerClass(AbstractPlayer.PlayerClass playerClass) : Limits the event to appearing when playing the specified character.

  • spawnCondition(Condition spawnCondition) : This lets you implement any condition you want. This will be checked at the start of an act to determine whether the event should be added to the pool.

  • bonusCondition(Condition bonusCondition) : This lets you implement any condition you want. This will be checked when a random event is rolled to determine whether the event can currently appear.

  • overrideEvent(String overrideEventID) : This will cause the event to override the specified event. There are two modes of replacement: Override and Full Replace.

    Override will conditionally replace the event when it is encountered using bonusCondition. If the conditions fail, the normal event will occur. Spawn condition has no effect, as spawning is based on the original event.

    Full Replace will perform the spawnCondition check when the dungeon is instantiated, completely replacing the original event if it returns true. If it returns false, the original event will appear as normal.

    By default, the Override type will be used. To use Full Replace, specify the type using the next method:

  • eventType(EventUtils.EventType eventType) : This specifies the type of event.

    EventType.NORMAL : Normal events can only be seen once, regardless of where they can appear.

    EventType.ONE_TIME : SpecialOneTimeEvents can only be seen once, but are rarer.

    EventType.SHRINE : Shrines can be seen once per act (but are added back to the list when save and quit occurs). Shrines are also rarer than normal events.

    EventType.OVERRIDE/EventType.FULL_REPLACE : As described for overrideEvent. If this type is used but an override event is not specified, it will be treated as a normal event.

Clone this wiki locally