try with prints.no error on the console just does not work
local effects = {
[COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
[COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
[COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
[COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
[COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
[COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
[COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA,
[COMBAT_HEALING] = CONST_ME_MAGIC_GREEN
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
print(1)
print(creature:getName():lower())
if Monster(creature) and creature:getName():lower() == "rat" then
print(2)
print(primaryType)
if primaryType ~= COMBAT_HEALING then
print(3)
print(special.creatures.boss.cave_rat[1])...
Server ver?Board Rules for Requests
This board is getting a bit messy if we continue this way. Also if you follow these rules, your request/support can be solved faster. Include the following things when creating a new thread: A good thread name Examples of bad thread names: - Help - Help plx! - Problem - Script...otland.net
Melee attack? Spell?
function onThink(creature)
local health, difference, boss, pos = 0, 0, Tile(Position(33732, 31559, 12)):getTopCreature(), creature:getPosition()
local spectators = Game.getSpectators(Position(33735, 31559, 12), false, false, 12, 12, 12, 12)
for i = 1, #spectators do
local spec = spectators[i]
if spec:getName():lower() == 'boss' then
health = spec:getHealth()
difference = (boss:getMaxHealth() - boss:getHealth())
spec:addHealth( - difference)
spec:say('test', TALKTYPE_MONSTER_SAY)
return true
end
end
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
hello, no more requirements.I still haven't played around with TFS 1.3 yet, but I know you'd want to do this with
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
So whenever it takes damage, you simply just find monster y, and send the damage to them instead.
How you go about finding monster y is up to you though.
without more information about the event / script requirements it's impossible to help.
You don't seem to understand at all. lmaohello, no more requirements.
all damage that monster 1 takes monster 2 will take the same damage.
this I said in the post, you need a scenario I explain in the topicYou don't seem to understand at all. lmao
Monster 2 is the crux of the issue. If we don't know the requirements required to find monster 2, it's impossible to script.
Is monster 2 stationary?
Can there be multiple monster 2's?
Is it only in 1 location / room where monster 2 can exist?
We need to know what scenario we are dealing with, and then we can script it for that scenario.
Hence..
without more information about the event / script requirements it's impossible to help.
So, only 1 creature.this I said in the post, you need a scenario I explain in the topic
-
a room 2 monster player attack 1 monster damage all damage that monster takes monster 2 will take the same damage.
monster two is in the room.
just what I need is this creaturescript of damage
data/events/events.xml
-- make sure this is enabled.<event class="Monster" method="onSpawn" enabled="1" />
data/events/scripts/monster.lua
function findBossId(position)
local spectators = Game.getSpectators(position, false)
for i = 1, #spectators do
if Monster(spectators[i]) then
if spectators[i]:getName():lower() == "cave rat" then
local temp_id = spectators[i]:getId()
if temp_id > special.creatures.boss.cave_rat[1] then
special.creatures.boss.cave_rat[1] = temp_id
end
end
end
end
end
function Monster:onSpawn(position, startup, artificial)
-- boss
if self:getName():lower() == "cave rat" then
addEvent(findBossId, 0, position)
end
-- creature that hurts boss
if self:getName():lower() == "rat" then
self:registerEvent("onHealthChange")
end
return true
end
data/creaturescripts/creaturescripts.xml
<event type="healthchange" name="onHealthChange" script="onHealthChange.lua" />
data/creaturescripts/scripts/onHealthChange.lua
local effects = {
[COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
[COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
[COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
[COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
[COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
[COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
[COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA,
[COMBAT_HEALING] = CONST_ME_MAGIC_GREEN
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if Monster(creature) and creature:getName():lower() == "rat" then
if primaryType ~= COMBAT_HEALING then
local boss_monster = Monster(special.creatures.boss.cave_rat[1])
if boss_monster then
doTargetCombat(attacker, boss_monster, primaryType, -primaryDamage, -primaryDamage, effects[primaryType])
doTargetCombat(attacker, boss_monster, secondaryType, -secondaryDamage, -secondaryDamage, effects[secondaryType])
return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
end
end
return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
data/lib/core/core.lua
dofile('data/lib/core/xikini_tables.lua')
data/lib/core/xikini_tables.lua
special = {
creatures = {
boss = {
cave_rat = {0} -- (boss_creatureid)
}
}
}
int LuaScriptInterface::luaDoTargetCombatHealth(lua_State* L)
{
//doTargetCombatHealth(cid, target, type, min, max, effect[, origin = ORIGIN_SPELL])
Creature* creature = getCreature(L, 1);
if (!creature && (!isNumber(L, 1) || getNumber<uint32_t>(L, 1) != 0)) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
Creature* target = getCreature(L, 2);
if (!target) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
CombatType_t combatType = getNumber<CombatType_t>(L, 3);
CombatParams params;
params.combatType = combatType;
params.impactEffect = getNumber<uint8_t>(L, 6);
CombatDamage damage;
damage.origin = getNumber<CombatOrigin>(L, 7, ORIGIN_SPELL);
damage.primary.type = combatType;
damage.primary.value = normal_random(getNumber<int32_t>(L, 4), getNumber<int32_t>(L, 5));
Combat::doCombatHealth(creature, target, damage, params);
pushBoolean(L, true);
return 1;
}
is everything tested and none works is there any other way to make this idea?
You literally posted the code you needed to change it to.It's a default function in the source for tfs 1.3
If you aren't using tfs 1.3, change it to whatever function your server uses.
doTargetCombat
doTargetCombatHealth
this I already did.You literally posted the code you needed to change it to.
from
doTargetCombat
to
doTargetCombatHealth
and you got the exact same error?this I already did.
try with prints.no error on the console just does not work
local effects = {
[COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
[COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
[COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
[COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
[COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
[COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
[COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA,
[COMBAT_HEALING] = CONST_ME_MAGIC_GREEN
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
print(1)
print(creature:getName():lower())
if Monster(creature) and creature:getName():lower() == "rat" then
print(2)
print(primaryType)
if primaryType ~= COMBAT_HEALING then
print(3)
print(special.creatures.boss.cave_rat[1])
local boss_monster = Monster(special.creatures.boss.cave_rat[1])
if boss_monster then
print(4)
doTargetCombatHealth(attacker, boss_monster, primaryType, -primaryDamage, -primaryDamage, effects[primaryType])
doTargetCombatHealth(attacker, boss_monster, secondaryType, -secondaryDamage, -secondaryDamage, effects[secondaryType])
return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
end
end
return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
rattry with prints.
Lua:local effects = { [COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD, [COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA, [COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA, [COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA, [COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA, [COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA, [COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA, [COMBAT_HEALING] = CONST_ME_MAGIC_GREEN } function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) print(1) print(creature:getName():lower()) if Monster(creature) and creature:getName():lower() == "rat" then print(2) print(primaryType) if primaryType ~= COMBAT_HEALING then print(3) print(special.creatures.boss.cave_rat[1]) local boss_monster = Monster(special.creatures.boss.cave_rat[1]) if boss_monster then print(4) doTargetCombatHealth(attacker, boss_monster, primaryType, -primaryDamage, -primaryDamage, effects[primaryType]) doTargetCombatHealth(attacker, boss_monster, secondaryType, -secondaryDamage, -secondaryDamage, effects[secondaryType]) return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin end end end return creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin end
I don't think I can solve this over OtLandrat
2
1
3
1073824432