Closed sirsteve1 closed 2 years ago
Hi, @sirsteve1 !
Beforehand: I want to make clear, that solution that hooks-into script, in order to implement feature, won't be accepted in upstream. In case of respawn, something like WorldObjects::resetPositionToTA
makes lot more sense.
As for overriding function, for the sake of experiments, in principle, something like vm.registerInternalFunction("sleepabit", [](Daedalus::DaedalusVM&){ ... });
can work for you.
Thank you, that is good to know.
As I continued scanning the code I found out that for a feature like respawning it makes also sense to use the wld_settime function, as this is (in vanilla gothic2) used only for initializing the game and during sleeptime, thus it is also a good point without overriding any function or hooking into game scripts.
For the sake of interest:
So, just to keep you informed. I managed to implement a respawn system. Monsters are respawned after a specific amount of days (random range of e.g. 3 to 14 days). Selected monsters, orcs and humans are not respawned.
I still have a problem when entering Jharkendar the first time. Somehow some WayPoints of dead bodies that are spawned are not found, I don't know why... When I deactivate the system, everything works. When entering Jharkendar the first time Wld_settime is called which processes the respawn system. Need to dig a bit here...
I also try to implement an optin, making it possible to activate / deactivate the respawn system within the game menu. If I won't be able to do that I would simply add an cli option. For ingame support I added two marvin commands (show and clear).
As soon as I have a good state I would create a PR.
Just want to mention again WorldObjects::resetPositionToTA
wld_settime
reaches it
switching between game-locations also calls for resetPositionToTA
deactivate the respawn system within the game menu.
Game menu is script driven, so it;s outside of OpenGothic. Here my recommendation is to introduce new section/value to *.ini file. Script has limited access to ini, therefore it will be possible to build custom-menu as a mod.
Somehow some WayPoints of dead bodies that are spawned are not found, I don't know why...
If you mean c_npc::waypoint
- they can be invalid(see https://github.com/Try/OpenGothic/issues/324), more robust way would be to look into npc daily timetable(Npc::routines
) and fetch from it.
Just want to mention again
WorldObjects::resetPositionToTA
wld_settime
reaches it switching between game-locations also calls for resetPositionToTAdeactivate the respawn system within the game menu.
Game menu is script driven, so it;s outside of OpenGothic. Here my recommendation is to introduce new section/value to *.ini file. Script has limited access to ini, therefore it will be possible to build custom-menu as a mod.
Somehow some WayPoints of dead bodies that are spawned are not found, I don't know why...
If you mean
c_npc::waypoint
- they can be invalid(see #324), more robust way would be to look into npc daily timetable(Npc::routines
) and fetch from it.
The problem here are not waypoints that are used by the respawn system but normal waypoints used during initialization of Jharkendar. When I deactivate the system, the dead bodies are inserted as they should. When respawning I always use the waypoint of the killed monster (npc waypoint) and check the npc world param to ensure not trying to respawn a monster within the wrong world.
The problematic waypoints are following:
Yet all other NPCs seem to get initialized correctly.
Solved as described in my PR #350
Dear Try and community
I am currently playing around with the code of OpenGothic to get used to the whole mechanics and the source code, also to work on bugs on my own. For starting off I tried to implement a way of respawning monsters. I am currently at the state of registering the respawn after specific monsters died (e.g. excluded dragons, orcs and summoned monsters). The monsters are respawned directly, leading to a permanent fight as the enemys are instantly there again.
My question: Is there a way to hook to the sleepabit function from the original game without recompiling it? Or is there a way to use the npc tickroutine to check wheather the hero is lying in bed or something like this?
Thanks and best regards