BossFightComponent destroys game object when deactivated
BossFightComponent destroys game object when deactivated
Is there any way to prevent a BossFightComponent from destroying itself and its parent game object after deactivating? I have boss fights that I'd like to be able to stop and restart, but I can't do that very easily if the component destroys itself and everything related to it.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: BossFightComponent destroys game object when deactivated
I don't really have the time at the moment to figure out a solution for your question. But off the top of my head you can probably dynamically spawn a new bossfight if the old one is destroyed when turned off.
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: BossFightComponent destroys game object when deactivated
It was pretty easy to figure out once I had time to investigate. Try this code:
Code: Select all
function start()
if myboss == nil then
spawn("boss_fight", self.go.id.level, 0, 0, 0, 0, "myboss")
myboss.bossfight:addMonster(mimic_1.monster)
myboss.bossfight:setMusic("boss_fight_generic")
myboss.bossfight:setBossName("Mimic")
myboss.bossfight:activate()
end
end
function stop()
if myboss ~= nil then
myboss.bossfight:deactivate()
end
end
Re: BossFightComponent destroys game object when deactivated
Well yeah, of course you can respawn the entire object. Duh. That's what my system currently does. But I was hoping to actually take advantage of the component system and attach a BossFightComponent to an object that also has a floor trigger, a script, etc. to make the logic cleaner.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: BossFightComponent destroys game object when deactivated
I misunderstood. Anyway, that behavior is likely hardcoded to clean up the parent entity when the boss fight is deactivated.