First of all, you should list what server version you are using.
I added all of the above functionality into my server.
The first thing is easy (change non-hostile monster to hostile monster)
There are 2 ways to do this.
- You can remove the creature, then add a new creature that looks exactly the same, edit the new creature's health to match the current creature, and doMonsterSetTarget(cid, target) to the player that attacked the first creature. (This is the Lazy way)
- You can edit the source (some already have edits for this I think) so that the storage value "hostile" is linked to this.
If you have your source, you can check if it has this in monster.cpp
Code:
bool Monster::isHostile() const
{
std::string value;
if(!getStorage("hostile", value))
return mType->isHostile;
return booleanString(value);
}
Or add it yourself.
That will allow you to set the storage value of "hostile" to 1, which would mean it is hostile, and if -1, it means it is not hostile.
Now... for creatures only being hostile towards certain players, there is a really bad way of doing this. (Which I used for my original species server)
First, you make a onCombat script, that says something like:
Code:
if getPlayerStorageValue(target, "enemy") == 1 then
return true
else
if target == getCreatureTarget(cid) then
doMonsterChangeTarget(cid)
end
return false
end
and link that creaturescript to the monster you want to only be hostile to certain players (it will still follow around players, kind of like a dog, but it will only damage players and switch targets quickly when following a non-hostile player)
There is another way to do it, which is edit the source and make groups of allies, and enemies, and ignored monsters etc. (Which I have in my The Imagined Server) but that takes time, and isn't yet complete so I don't want to release a tutorial for it yet.