Inspired by this code link to post (btw i use tfs 1.5 by nekiro)
I reworked the script to work like this:
1.Players can summon dummy only in houses.
2.Monster is attacking players in pz
Before my change I couldnt spawn dummy in either PZ or house.
I changed
to
After that I could spawn this dummy in house. But then I had problems with attacking this dummy so i solved this problem in combat.cpp by adding requirement like this:
But its not over... I still can't use spells and in spells.cpp I can't do the same because
have no target definition so i cant use target->getName() to find Training Dummy in this code
and I don't want to set aggressive="0" for all spells. I want to enable spells only for Training Dummy. Not so they are usable in all pz places.
Anyone have idea how to fix it so I can not only attack but also use spells on Training Dummy that is located in house(pz)
SOLVED.
I reworked the script to work like this:
1.Players can summon dummy only in houses.
2.Monster is attacking players in pz
Before my change I couldnt spawn dummy in either PZ or house.
I changed
LUA:
local creature = Game.createMonster(config.monsterName, player:getPosition())
Code:
local creature = Game.createMonster(config.monsterName, player:getPosition())
Code:
//pz-zone
if (attacker->getZone() == ZONE_PROTECTION) {
// Check for a specific property or name
if (target->getName() == "Training Dummy") { // Replace with the actual name
return RETURNVALUE_NOERROR; // Allow attack
}
return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE;
}
Code:
bool Spell::playerSpellCheck(Player* player) const
Code:
if ((aggressive || pzLock) && !player->hasFlag(PlayerFlag_IgnoreProtectionZone) && player->getZone() == ZONE_PROTECTION) {
player->sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
return false;
}
Anyone have idea how to fix it so I can not only attack but also use spells on Training Dummy that is located in house(pz)
Post automatically merged:
SOLVED.
LUA:
if ((aggressive || pzLock)
&& !player->hasFlag(PlayerFlag_IgnoreProtectionZone)
&& player->getZone() == ZONE_PROTECTION) {
Creature* target = player->getAttackedCreature();
if (target && target->getName() == "Training Dummy") {
// Allow spells on the Training Dummy without restrictions in the protection zone
// Do not return here; allow further spell checks and cooldowns to proceed
} else {
player->sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
return false;
}
}
Last edited: