Tested on TFS 0.3.4pl2
Short script to detect and punish anti-paralyze bots (after X uses of bot it slow player until relog).
In creature.h below:
Paste:
In configmanager.h above:
Paste:
In configmanager.cpp above:
Paste:
In creature.cpp:
below:
paste:
below:
paste:
below:
paste:
at end of file paste:
below:
paste:
below:
paste:
In config.lua paste:
Maybe it doesnt work with normal paralyze rune.
My paralyze rune isnt spell. It's action.
actions.xml
paralyze.lua script:
Short script to detect and punish anti-paralyze bots (after X uses of bot it slow player until relog).
In creature.h below:
PHP:
friend class LuaScriptInterface;
PHP:
uint64_t addParalyzeTime;
uint32_t antiParalsUnderTime;
void removeParalyze();
PHP:
LAST_NUMBER_CONFIG
PHP:
PARAL_SLOW,
PARAL_MIN_TIME,
PARAL_CHECKS,
PHP:
m_loaded = true;
PHP:
m_confNumber[PARAL_SLOW] = getGlobalNumber("paralyzeSlow", 10);
m_confNumber[PARAL_MIN_TIME] = getGlobalNumber("paralyzeMinTime", 200);
m_confNumber[PARAL_CHECKS] = getGlobalNumber("paralyzeChecks", 3);
below:
PHP:
void Creature::removeCondition(ConditionType_t type)
{
PHP:
if(type == CONDITION_PARALYZE)
removeParalyze();
PHP:
void Creature::removeCondition(Condition* condition)
{
PHP:
if(condition->getType() == CONDITION_PARALYZE)
removeParalyze();
PHP:
void Creature::removeCondition(const Creature* attacker, ConditionType_t type)
{
PHP:
if(type == CONDITION_PARALYZE)
removeParalyze();
PHP:
void Creature::removeParalyze()
{
if(OTSYS_TIME() - addParalyzeTime > g_config.getNumber(ConfigManager::PARAL_MIN_TIME))
return;
addParalyzeTime = 0;
++antiParalsUnderTime;
if(antiParalsUnderTime > g_config.getNumber(ConfigManager::PARAL_CHECKS) && getBaseSpeed() > g_config.getNumber(ConfigManager::PARAL_SLOW))
setBaseSpeed((uint32_t) getBaseSpeed() - (getBaseSpeed() / 100 * g_config.getNumber(ConfigManager::PARAL_SLOW)));
std::cout << getName() << " bot-antiparalyze " << antiParalsUnderTime << " times, basespeed: " << getBaseSpeed() << std::endl;
}
PHP:
onIdleStatus();
PHP:
addParalyzeTime = 0;
antiParalsUnderTime = 0;
PHP:
if(condition->startCondition(this))
{
conditions.push_back(condition);
onAddCondition(condition->getType());
PHP:
if(condition->getType() == CONDITION_PARALYZE)
addParalyzeTime = OTSYS_TIME();
PHP:
paralyzeSlow = 10 -- decrease basespeed percent
paralyzeMinTime = 200 -- if unparalyze time under (miliseconds) count it as too fast
paralyzeChecks = 3 -- after how many too fast unparalyzes punish player (slow)
My paralyze rune isnt spell. It's action.
actions.xml
PHP:
<action itemid="2278" event="script" value="paralize.lua" allowfaruse="1"/>
PHP:
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20000)
setConditionFormula(condition, -0.9, 40, -0.9, 0)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (not (isDruid(cid) or isSorcerer(cid))) and (getPlayerGroupId(cid) <= 3) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation cannot use this rune.")
return FALSE
end
if (getPlayerMana(cid) < 700) and (getPlayerGroupId(cid) <= 3) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough mana points.")
return FALSE
end
if (not (isPlayer(itemEx.uid))) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You may use paralyze only on players.")
return FALSE
end
if(getTilePzInfo(getCreaturePosition(cid)) == TRUE or getTilePzInfo(getCreaturePosition(itemEx.uid)) == TRUE) and (getPlayerGroupId(cid) <= 3) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can't paralyze in protection zone.")
return FALSE
end
doAddCondition(itemEx.uid, condition)
doPlayerAddMana(cid, -700)
if(item.type > 1) then
doTransformItem(item.uid, item.itemid, item.type-1)
else
doRemoveItem(item.uid)
end
return true
end