• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

[0.4_DEV] How does one make an NPC Killable

Herpicus

Web Developer
Joined
Jun 21, 2008
Messages
1,644
Reaction score
94
Location
British Columbia
[0.3.7] How does one make an NPC Killable

As the title says, How does one make an NPC Killable

I had a friend do this for me a while back so I know its possible.

The NPC are already attackable but no damage can be dealt.
Any and all help is appreciated.^_^
 
Last edited:
It's simple. You just need to define functions for the ondeath and a few other things. Just inherit from the default creature class. Can be copied from monsters. Half awake and on iPod. Sorry for shityy description
 
Shitty desciption is better than no description :P

But yeah, I was trying what you said before you posted it for about 20 min xD
I am but a mapper, not a scripter :(
 
Last edited:
@up umm,
Code:
if(readXMLString(root, "attackable", strValue))
		attackable = booleanString(strValue);
so onAttack would work(transform is actually deleteThing(target.uid), and then spawn monster in same place, BUT it will work)
 
Ok I FOUND THIS!!

All NPCs Killable

i think maybe work?+


Tibian ped0bear
npcwj.png
 
NPC.xml:
Code:
attackable="true"

npc.h:
Code:
bool isImmune(CombatType_t) const {return true;}
bool isImmune(ConditionType_t) const {return true;}

to:
Code:
bool isImmune(CombatType_t) const {return [B]false[/B];}
bool isImmune(ConditionType_t) const {return [B]false[/B];}

+ onKill that makes corpse (Don't remember if you would need to use doRemoveCreature).

Code:
function onKill(cid, target, flags, damage)
	if(isNpc(target)) then
		local pos = getCreaturePosition(target)
		doRemoveCreature(target) -- not sure about this one tho.
		doCreateItem(2025, 2, pos)
		local corpse = doCreateItem(ID_OF_CORPSE, 1, pos)
		doItemSetAttribute(corpse, "description", "He has been killed by ".. getCreatureName(cid))
	end
	return true
end
 
NPC.xml:
Code:
attackable="true"

npc.h:
Code:
bool isImmune(CombatType_t) const {return true;}
bool isImmune(ConditionType_t) const {return true;}

to:
Code:
bool isImmune(CombatType_t) const {return [B]false[/B];}
bool isImmune(ConditionType_t) const {return [B]false[/B];}

+ onKill that makes corpse (Don't remember if you would need to use doRemoveCreature).

Code:
function onKill(cid, target, flags, damage)
	if(isNpc(target)) then
		local pos = getCreaturePosition(target)
		doRemoveCreature(target) -- not sure about this one tho.
		doCreateItem(2025, 2, pos)
		local corpse = doCreateItem(ID_OF_CORPSE, 1, pos)
		doItemSetAttribute(corpse, "description", "He has been killed by ".. getCreatureName(cid))
	end
	return true
end

dont work.
 
Well i remember, that i had a YourOTS server and there was a npc outside of the city that can be killed, i remember that when i killed that npc the corpse was a item id 0 (or that floor black with red)
 
Back
Top