• 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!

Lua Get Skull when opponent get damage ?

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,838
Solutions
18
Reaction score
617
Location
Poland
Hello.
Im working for custom PvP system (for my OT) and i was looking for one function or something (I do not know what I call on it ;/)

On my Pvp system is used secureMode but all is OK (player cant attack opponent when attacker dont have secure mode on ).
Thats OK.

But i need help with onCast, support.

Now when player have SecureMode = off and cast area/wave spell the opponent dont receive damage <- That part is good, but attacker receive skull <- That part is bad.

How I can do something like this:
When attacker deal damage with area/wave spell he receive skull ?
Now its like: When attacker dont deal damage to enemy he also receive skull

Here is the script:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if(attacker and isPlayer(attacker) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) and getPlayerSecureMode(attacker)) then
		return false
	end
	return true
end

function onTarget(cid, target)
	if(isPlayer(target) and getCreatureTarget(cid) ~= target) then
		doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
		return true
	end
	return true
end

function onCast(cid, target)
    if (attacker and isPlayer(attacker) and isPlayer(target) and getCreatureTarget(cid) ~= target) then
		doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
        return false
    end
    return true
end
I declared in luascript.cpp the getPlayerSecureMode.

I need help with getting skull in onCast part of the script.

Anyone ?
 
Dont work ;/
If i attack area/wave spell without hand on (secure mode), now I deal damage (before i dont deal damage to enemy) and get Skull ;/

I found something on 7.6 :
Lua:
targetPlayer->skullType == SKULL_NONE)

But how I can make it for 8.54 ?
 
Last edited:
TFS flaws aren't my fault
Maybe something with this? :rolleyes:
PHP:
ReturnValue Combat::canDoCombat(const Creature* attacker, const Creature* target)
{
	if(!attacker)
		return RET_NOERROR;

	bool success = true;
	CreatureEventList combatEvents = const_cast<Creature*>(attacker)->getCreatureEvents(CREATURE_EVENT_COMBAT);
	for(CreatureEventList::iterator it = combatEvents.begin(); it != combatEvents.end(); ++it)
	{
		if(!(*it)->executeCombat(const_cast<Creature*>(attacker), const_cast<Creature*>(target)) && success)
			success = false;
	}


@Fresh
PHP:
function onCombat(cid, target)
    if(target and isPlayer(target) and getPlayerSecureMode(cid)) then
		doPlayerSendCancel(cid, "Turn secure mode off if you really want to attack unmarked players.")
        return false
    end
    return true
end
add it to creature events with type 'combat' and register in login.lua
It should block all types of attacks and possibility to target if player (attacker) has secure mode 'on'. :)
 
Back
Top