Is there any script I could use to change the alignment of a monster from attack-on-sight to attack-when-attacked? I want to make a spell that lets you “tame” monsters.
Casting a spell to turn monsters good
Actually this would be more simple than you think. All of the NPCs are loaded into memory when the server starts. You could copy some of the code from HandleSaveNPC. This is the routine that runs when you save an NPC from the NPC editor.
So when you cast the spell, you could just have it run a new sub routine, change the behaviour by doing NPC(NPCNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY.
Then just use some of the code from the HandleSaveNPC to update the NPC for everybody else.
If you have some programming knowledge, and knowledge of the engine itself, this shouldn’t be too hard.
However, this simple code would only work for a unique NPC. It would change the core data of the NPC, thus all of those NPCs would then be friendly. This would work if you only had 1 spawning of an NPC. Otherwise you will have to start going more complex, and adding an array for MapNPC, then adding code that would over-ride the core behaviour variable.