OK so I have been playing around with the idea of a pet bonding system on my shard but what I really want to pull off would require a bit of implementation into the POL Core. I've been messing with the source code a bit so I'm beginning to discover what I'm getting into and what can and should be changed. But I want a chance to also give this to the community so you can script your own customized pet bonding systems for your shards. My idea is of course to handle as little as possible by the core and pass this off to scripts and hooks so you can do what you want. So here is what I'm thinking of at this moment:
- Implementing NPC.bonded - Boolean value. (Already implemented this)
- Possibly implement a CanDie hook for NPCs or if NPC.bonded = 1, handle NPC death more like player death where a corpse is created but the actual mobile is not destroyed, just .dead gets set to true and add a call to deathbonded.src instead of death.src. (The first would probably be a harder implementation, the second I've already done in my core but it takes away a small bit of customization)
- A Resurrect function will likely be needed but it shouldn't be too much of a problem.
- Should ghosts of NPCs only be visible by their .masters?
- Everything else should be handled by AI scripts...
Completely open to discussion here but as I said, I'm looking to export things to scripts so you can customize instead of hardcoding it into the core.
Pet bonding system
Re: Pet bonding system
Basically I've looked a little further into this and much of this is already implemented, just more control is needed.
CanDie already does run for NPCs so I added something extra to it. Return 2;
When Return 2; is called in CanDie, the following happens:
NPC.dead is set to 1 but the NPC still exists.
Frozen/paralyzed is set to 0.
A corpse is produced.
death.src is run with a second parameter for the NPC.
The AI script IS NOT STOPPED! You'll have to script a "ghost" ai yourself.
I decided to not implement a .bonded member since it won't be used within the core itself. This should instead be handled by CProps. CanDie return 2 only affects NPCs. If done for players, it will be treated as if it returned 1 (normal death).
CanDie already does run for NPCs so I added something extra to it. Return 2;
When Return 2; is called in CanDie, the following happens:
NPC.dead is set to 1 but the NPC still exists.
Frozen/paralyzed is set to 0.
A corpse is produced.
death.src is run with a second parameter for the NPC.
The AI script IS NOT STOPPED! You'll have to script a "ghost" ai yourself.
I decided to not implement a .bonded member since it won't be used within the core itself. This should instead be handled by CProps. CanDie return 2 only affects NPCs. If done for players, it will be treated as if it returned 1 (normal death).