Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic add map event during running time. #2748

Open
lychees opened this issue Mar 13, 2022 · 1 comment
Open

Dynamic add map event during running time. #2748

lychees opened this issue Mar 13, 2022 · 1 comment
Labels
Event/Interpreter Feature Request Maps Map content related. For map events please use event/interpreter instead

Comments

@lychees
Copy link
Contributor

lychees commented Mar 13, 2022

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.

@lychees lychees changed the title Dynamic Create Map Event. Dynamic add map event in run time. Mar 13, 2022
@lychees lychees changed the title Dynamic add map event in run time. Dynamic add map event during running time. Mar 13, 2022
@fdelapena fdelapena added Feature Request Event/Interpreter Maps Map content related. For map events please use event/interpreter instead labels Mar 24, 2022
@fdelapena
Copy link
Contributor

The dynamic map generation is somehow a requirement for #2474, so sharing code with the implementation would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Event/Interpreter Feature Request Maps Map content related. For map events please use event/interpreter instead
Development

No branches or pull requests

2 participants