Skip to content

Dynamic add map event during running time. #2748

@lychees

Description

@lychees

Hi, it is me again.
I am working on a roguelike game these days, and turn out to use easyrpg as my game engine since it is open source so that I can use cpp as my scripting languages.

What I am going to do is to generate a map as well as some map events(boxes, monsters, etcs)

telegram-cloud-photo-size-5-6154510470007074861-y

I don't know how to create a event class mannually, so I copy a existing map event and events.emplace_back() it into the list. But when I pushed more than 20 boxes, it crashed :(

	// Add One Box
	for (const auto& ev : map->events) {
		events.emplace_back(GetMapId(), &ev);
		if (events.back().GetName() != "Box") {
			events.pop_back();
		} else {
			auto& t = events.back();
			t.SetId(events.size());
			Scene_Map* scene = (Scene_Map*)Scene::Find(Scene::Map).get();
			scene->spriteset->CreateSprite(&t, LoopHorizontal(), LoopVertical());
			break;
		}
	}

image
(But reset the position of the exising one is safe, so what I do now it copy them as many as possible in the editor, and then randomize their position in the code.)

So my question is is there a way that I can dynamic add a map event? (e.g. regenerate monsters)
My code is here: lychees@eed14c0#diff-178bf271cafc0ba6a7f089f62f3aef281fac6d750b47e38eb2e6a1aae2945f86.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EasyRPGNew functionality exclusive to EasyRPG PlayerEvent/InterpreterFeature RequestMapsMap content related. For map events please use event/interpreter instead

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions