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

Monster no hit other monster

115820

Member
Joined
Feb 27, 2011
Messages
193
Solutions
1
Reaction score
5
Location
London, England
I want a script when Monster Spell no hit other Monster only THE PLAYER. Like : When Demon use UE dont hit other DEMON with UE.

OtVersion : 8.6
TFS : 0.3.6
 
Why not just use a variation of mass heal?
Not tested..

Save this as demon greatfireball.lua inside of data\spells\scripts\monster
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onTargetCreature(creature, target)

    local min, max = -100, -125

    local master = target:getMaster()
    if target:isMonster() and not master or master and master:isMonster() then
        return true
    end
   
    doTargetCombatHealth(0, target, COMBAT_FIREDAMAGE, min, max, CONST_ME_FIREAREA)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

then you add it to your monster's file like say demon.xml
this would go in the <attacks> node, mess around with the interval and chance
Code:
<attack name="demon greatfireball" interval="2000" chance="15" />
 
Or just use the creature's name, not tested
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onTargetCreature(creature, target)

    local min, max = -100, -125

    if target:getName() == creature:getName() then
        return true
    end
   
    doTargetCombatHealth(0, target, COMBAT_FIREDAMAGE, min, max, CONST_ME_FIREAREA)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
 
Or just use the creature's name, not tested
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onTargetCreature(creature, target)

    local min, max = -100, -125

    if target:getName() == creature:getName() then
        return true
    end
  
    doTargetCombatHealth(0, target, COMBAT_FIREDAMAGE, min, max, CONST_ME_FIREAREA)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
Why not just use a variation of mass heal?
Not tested..

Save this as demon greatfireball.lua inside of data\spells\scripts\monster
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))

function onTargetCreature(creature, target)

    local min, max = -100, -125

    local master = target:getMaster()
    if target:isMonster() and not master or master and master:isMonster() then
        return true
    end
  
    doTargetCombatHealth(0, target, COMBAT_FIREDAMAGE, min, max, CONST_ME_FIREAREA)
    return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

then you add it to your monster's file like say demon.xml
this would go in the <attacks> node, mess around with the interval and chance
Code:
<attack name="demon greatfireball" interval="2000" chance="15" />


I use demon like exemple. U create new monster. And the new monster have a spell kill area. I need him no kill other monster with that spell
 
I use demon like exemple. U create new monster. And the new monster have a spell kill area. I need him no kill other monster with that spell
Well then learn to program and fix it yourself.. this was only an example, one of which was never tested...
 
I have not coded for 0.3 for a while, but it should look something like this:
Code:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if master and isPlayer(master) then
            return true
        end

        return false
    end

    return true
end
 
Last edited:
I have not coded for 0.3 for a while, but it should look something like this:
Code:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if master and not isPlayer(master) then
            return false
        end
    end

    return true
end
Dont work. I already that script. Dont show ERROR, nothing in TFS. But monster continue attack eachother.
 
I register in creatureevents, login.lua.
i use that in login.lua registerCreatureEvent(cid, "noattack") and this <event type="statschange" name="noattack" event="script" value="noattack.lua"/> in xml.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Venom Spider" nameDescription="a Venom Spider" race="venom" experience="501700000" speed="280" manacost="485">
   <health now="900040" max="900040"/>
   <look type="219" corpse="6060"/>
   <targetchange interval="5000" chance="8"/>
   <strategy attack="100" defense="0"/>
   <flags>
     <flag summonable="0"/>
     <flag attackable="1"/>
     <flag hostile="1"/>
     <flag illusionable="1"/>
     <flag convinceable="0"/>
     <flag pushable="0"/>
     <flag canpushitems="1"/>
     <flag canpushcreatures="0"/>
     <flag targetdistance="1"/>
     <flag staticattack="90"/>
     <flag runonhealth="0"/>
   </flags>
   <attacks>
     <attack name="Magician4" interval="350" chance="100" min="-31500" max="-47100"/>
   </attacks>
   <defenses armor="15" defense="17">
     <defense name="speed" interval="1000" chance="13" speedchange="334" duration="5000">
       <attribute key="areaEffect" value="redshimmer"/>
     </defense>
   </defenses>
   <elements>
     <element earthPercent="0"/>
     <element energyPercent="0"/>
     <element firePercent="0"/>
     <element icePercent="0"/>
   </elements>
   <immunities>
     <immunity outfit="1"/>
     <immunity drunk="1"/>
   </immunities>
<script>
<event name="noattack"/>
</script>
   <loot>
     <item id="2160" countmax="10" chance="3250"/><!-- CC -->
     <item id="2160" countmax="6" chance="23000"/><!-- CC -->
     <item id="2510" chance="1800"/><!-- plate shield -->
   </loot>
</monster>
I update everything. But continue attack enchother.
 
Thats not how you should register a creaturescript event in a monster.

Code:
<script>
    <event name="EventName"/>
</script>

That's the correct way.


Sorry I actually didn't see you put it there i'm sleepy. It should be executing.
But you shouldn't register it to players.
Edit: Try this
Code:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if not master or not isPlayer(master) then
            return false
        end
    end

    return true
end
 
Last edited:
Thats not how you should register a creaturescript event in a monster.

Code:
<script>
    <event name="EventName"/>
</script>

That's the correct way.


Sorry I actually didn't see you put it there i'm sleepy. It should be executing.
But you shouldn't register it to players.
Edit: Try this
Code:
function onStatsChange(cid, attacker, type, combat, value)
    -- This should block all damage monster cause on eachother expect player summons
    if isMonster(cid) and isMonster(attacker) then
        local master = getCreatureMaster(cid)
        if not master or not isPlayer(master) then
            return false
        end
    end

    return true
end
Thanks so much. Muito obrigado mesmo Matheus. (so agora vi que e brasileiro) Serio. Mt Obrigado.
 
Back
Top