• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Spell push monster spell.

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
109
Location
Brazil
This spell is ONLY to monsters not to players.

When monster use this spell it teleport the target to monster position, or teleport monster to player position, good to kill shooters etc XD
First you need the function choose(...)
Add it on 050-function.lua:
LUA:
function choose(...) -- by mock
    local arg = {...}
    return arg[math.random(1,#arg)]
end
Do the same to:
LUA:
function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end
Add it on spells.xml
Code:
<instant name="mock_push_monster" words="mock_push_monster" enabled="0" event="script" value="monsters/push.lua"></instant>
Now add this file on spells/scripts/monsters push.lua:
LUA:
function onCastSpell(cid, var) -- By Mock the bear
	local c = getCreatureTarget(cid)
	local cid2 = cid
	if isCreature(c) then
		if math.random(1,2) == 1 then
			local p = getCreaturePosition(cid)
			local n = 0
			while true do
				n = n+1
				p.x = p.x+choose(-1,1)
				p.y = p.y+choose(-1,1)
				if isWalkable(p,true) or n > 15 then
					doTeleportThing(c,p)
					break
				else
					p = getCreaturePosition(cid)
				end
			end
		else
			local p = getCreaturePosition(c)
			local n = 0
			while true do
				n = n+1
				p.x = p.x+choose(-1,1)
				p.y = p.y+choose(-1,1)
				if isWalkable(p,true) or n > 15 then
					doTeleportThing(cid,p)
					break
				else
					p = getCreaturePosition(c)
				end
			end
		end
		doCreatureSay(cid2,'Muhuhaha!!',19)
	end
	return false
end

And to finish select a monster to use it.
Add it:
Code:
<attack name="mock_push_monster" interval="1000" chance="25"/>
In this example i will add it on warlock.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="warlock" nameDescription="a warlock" race="blood" experience="4000" speed="220" manacost="0">
  <health now="3200" max="3200"/>
  <look type="130" head="19" body="71" legs="128" feet="128" addons="1" corpse="6080"/>
  <targetchange interval="5000" chance="30"/>
  <strategy attack="100" defense="0"/>
  <flags>
    <flag summonable="0"/>
    <flag attackable="1"/>
    <flag hostile="1"/>
    <flag illusionable="0"/>
    <flag convinceable="0"/>
    <flag pushable="0"/>
    <flag canpushitems="1"/>
    <flag canpushcreatures="1"/>
    <flag targetdistance="4"/>
    <flag staticattack="90"/>
    <flag runonhealth="800"/>
  </flags>
  <attacks>
    <attack name="mock_push_monster" interval="1000" chance="25"/> <!--Here is the tag ;D -->
    <attack name="melee" interval="2000" min="-60" max="-180"/>
    <attack name="physical" interval="1000" chance="35" range="7" min="-85" max="-185">
      <attribute key="shootEffect" value="energy"/>
    </attack>
    <attack name="manadrain" interval="1000" chance="17" range="7" min="-35" max="-75"/>
    <attack name="speed" interval="1000" chance="12" range="7" speedchange="-1" duration="40000">
      <attribute key="areaEffect" value="redshimmer"/>
    </attack>
    <attack name="fire" interval="2000" chance="45" range="7" radius="3" target="1" min="-150" max="-220">
      <attribute key="shootEffect" value="burstarrow"/>
      <attribute key="areaEffect" value="firearea"/>
    </attack>
    <attack name="firefield" interval="1000" chance="20" range="7" radius="2" target="1">
      <attribute key="shootEffect" value="fire"/>
    </attack>
    <attack name="energy" interval="2000" chance="25" length="8" spread="0" min="-165" max="-245">
      <attribute key="areaEffect" value="energy"/>
    </attack>
    <attack name="speed" interval="6000" chance="10" range="5" speedchange="-600" duration="20000">
      <attribute key="areaEffect" value="redshimmer"/>
    </attack>
  </attacks>
  <defenses armor="25" defense="30">
    <defense name="healing" interval="1000" chance="25" min="60" max="100">
      <attribute key="areaEffect" value="blueshimmer"/>
    </defense>
    <defense name="invisible" interval="5000" chance="1" duration="5000"> --each 7 sec invi duration 5 sec
      <attribute key="areaEffect" value="redshimmer"/>
    </defense>
  </defenses>
  <immunities>
    <immunity physical="0"/>
    <immunity energy="1"/>
    <immunity fire="1"/>
    <immunity poison="1"/>
    <immunity lifedrain="0"/>
    <immunity paralyze="1"/>
    <immunity outfit="1"/>
    <immunity drunk="1"/>
    <immunity invisible="1"/>
  </immunities>
  <voices interval="5000" chance="10">
    <voice sentence="Learn the secret of our magic! YOUR death!"/>
    <voice sentence="Even a rat is a better mage than you."/>
    <voice sentence="We don't like intruders!"/>
  </voices>
  <loot>
    <item id="2148" countmax="100" chance1="100000" chancemax="0"/>
    <item id="1986" chance="400"/>
    <item id="2600" chance="10000"/>
    <item id="2124" chance="1000"/>
    <item id="2689" countmax="1" chance="11000"/>
    <item id="7368" countmax="4" chance="1200"/>
    <item id="2167" chance="3000"/>
    <item id="2114" chance="1400"/>
    <item id="2151" countmax="2" chance="1100"/>
    <item id="1987" chance="100000">
      <inside>
        <item id="2148" countmax="50" chance1="80000" chancemax="0"/>
        <item id="2146" countmax="2" chance="1400"/>
        <item id="2178" countmax="1" chance="2500"/>
        <item id="2679" countmax="4" chance="20000"/>
        <item id="2047" chance="15000"/>
        <item id="2411" chance="5000"/>
        <item id="2792" countmax="5" chance1="6666" chancemax="0"/>
        <item id="2793" countmax="2" chance1="6666" chancemax="0"/>
        <item id="2656" chance="2000"/>
        <item id="2466" chance="588"/>
        <item id="2436" chance="1428"/>
        <item id="2123" chance="1000"/>
      </inside>
    </item>
  </loot>
</monster>
 
Last edited:
[12/06/2010 09:53:20] [Error - Spell Interface]
[12/06/2010 09:53:20] data/spells/scripts/monster/push.lua:onCastSpell
[12/06/2010 09:53:20] Description:
[12/06/2010 09:53:20] data/spells/scripts/monster/push.lua:17: attempt to call global 'isWalkable' (a nil value)
[12/06/2010 09:53:20] stack traceback:
[12/06/2010 09:53:20] data/spells/scripts/monster/push.lua:17: in function <data/spells/scripts/monster/push.lua:6>
it's weird, i thought that function was already on 0.3.6pl1 perhaps it has another name
mind posting it here?

this works the same, i guess
LUA:
if queryTileAddThing(cid, p) == RETURNVALUE_NOERROR or n > 15 then
 
@Cybershot
Ups :o
now the function isWalkable is on theread. thx
 
lawl i really hate my monster when i added him this atk xDDDD
 
Funny script but why you use choose(-1,1) math.random(-1,1) makes it cooler.
Also monster can push itself or u in a protection zone.
 
Funny script but why you use choose(-1,1) math.random(-1,1) makes it cooler.
Also monster can push itself or u in a protection zone.

Hmm, math.random will return from -1 to 1 (including 0 i guess), choose(-1, 1) will return -1 or 1. Well, always he can make:
Code:
local smth = math.random(2) == 1 and -1 or 1
 
Ye thats the point.. It can return 0 so you don't get teleported to diagonal of monster everytime.
 
Yes teleport to the same monster pos its bad :S

Huh don't understand you. If you mean that it is bad if you get teleported on the pos of the monster than you forget that you have isWalkable function..
 
@Rhux
no -.-
i said os bad to SAME pos of the monster not at side of the monster. i use isWalkable to player not be teleported insede a wall
 
Code:
function isWalkable(pos, creature, proj, pz)-- by Nord
        if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
        if getTopCreature(pos).uid > 0 and creature then return false end
        if getTileInfo(pos).protection and pz then return false, true end
        local n = not proj and 3 or 2
        for i = 0, 255 do
                pos.stackpos = i
                local tile = getTileThingByPos(pos)
                if tile.itemid ~= 0 and not isCreature(tile.uid) then
                        if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                                return false
                        end
                end
        end
        return true
end

Where put it?
In 50-function.lua?
 
hello mock thanks, hmm how i can make some spell like "exori con" with repel only one or two square? thanks 4 all ;)
 
Back
Top