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

Creaturescript request

azzkaban

Monster Maker
Joined
Feb 23, 2010
Messages
1,101
Reaction score
194
Location
Iquique Chile
Hi! I need little scrip:

Example:

I have boss 10000000 hitpoints.
You need attack and take 5000000 hitpoints and open teleport.

- You attack boss ( dont need kill, only deal 5.000.000 hitpoints) boss take 5.000.000 hp loss and open teleport.

Can you help me? Rep+ for you.
Thanks.
 
PHP:
local bossName = 'hero'
local bossHealth = 50 --in percents
local teleportPosition = {x=1234,y=1234,z=1234}
local teleportToPosition = {x=1234,y=1234,z=1234} --where tp teleport

local function getPercent(number, all)
	return (number / all) * 100
end

function onCombat(cid, target)
local health = math.ceil(getPercent(getCreatureHealth(target), getCreatureMaxHealth(target)))
if isMonster(target) and health <= bossHealth and getCreatureStorage(target, 1000) == -1 then
	doCreatureSetStorage(target, 1000, 1)
	return doCreateTeleport(1387, teleportToPosition, teleportPosition)
end
return true
end
And register into login.lua
 
Lua:
<event type="combat" name="boss" event="script" value="boss.lua"/>
and on login.lua:
Lua:
registerCreatureEvent(cid, "boss")

also, you should register it to your monster...
so go to your boss.xml file and add this inside:
Lua:
<script>
        <event name="boss"/>
</script>

----
Last but not least, you might want the teleport to disappear after a few seconds/minutes/hours... if you want it use this script... if you dont use oskar1121 and you will be just fine..
Lua:
local bossName = 'hero'
local bossHealth = 50 --in percents
local teleportPosition = {x=1234,y=1234,z=1234}
local teleportToPosition = {x=1234,y=1234,z=1234} --where tp teleport
local timelast = 60 -- time in seconds to the teleport to disappear

local function removeTeleport()
    local tele = getTitleItemById(teleportPosition, 1387)
       if tele.uid > 0 then
          doRemoveItem(tele.uid)
          doSendMagicEffect(teleportPosition, CONST_ME_POFF)
       end
end

local function getPercent(number, all)
    return (number / all) * 100
end

function onCombat(cid, target)
local health = math.ceil(getPercent(getCreatureHealth(target), getCreatureMaxHealth(target)))
if isMonster(target) and health <= bossHealth and getCreatureStorage(target, 1000) == -1 then
    doCreatureSetStorage(target, 1000, 1)
    addEvent(removeTeleport, timelast * 1000)
    return doCreateTeleport(1387, teleportToPosition, teleportPosition)
end
return true
end

Hope it helps =)
 
Lua:
<event type="combat" name="boss" event="script" value="boss.lua"/>
and on login.lua:
Lua:
registerCreatureEvent(cid, "boss")

also, you should register it to your monster...
so go to your boss.xml file and add this inside:
Lua:
<script>
        <event name="boss"/>
</script>

----
Last but not least, you might want the teleport to disappear after a few seconds/minutes/hours... if you want it use this script... if you dont use oskar1121 and you will be just fine..
Lua:
local bossName = 'hero'
local bossHealth = 50 --in percents
local teleportPosition = {x=1234,y=1234,z=1234}
local teleportToPosition = {x=1234,y=1234,z=1234} --where tp teleport
local timelast = 60 -- time in seconds to the teleport to disappear

local function removeTeleport()
    local tele = getTitleItemById(teleportPosition, 1387)
       if tele.uid > 0 then
          doRemoveItem(tele.uid)
          doSendMagicEffect(teleportPosition, CONST_ME_POFF)
       end
end

local function getPercent(number, all)
    return (number / all) * 100
end

function onCombat(cid, target)
local health = math.ceil(getPercent(getCreatureHealth(target), getCreatureMaxHealth(target)))
if isMonster(target) and health <= bossHealth and getCreatureStorage(target, 1000) == -1 then
    doCreatureSetStorage(target, 1000, 1)
    addEvent(removeTeleport, timelast * 1000)
    return doCreateTeleport(1387, teleportToPosition, teleportPosition)
end
return true
end

Hope it helps =)

Thank you! Rep+ for you and oskar1121 :D

- - - Updated - - -

Mmm, I test script of oskar and kakaher and not work :p
 
Just register into login.lua, without monster file.
Hmm.. Any wrongs?

any error in console, but not work.

This is the boss

XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Larvatros" nameDescription="a larvatros" race="venom" experience="0" speed="0" manacost="0">

*******************************************************************************************
*                     LARVATROS: This monster Was made by Amy Azzkaban                    *
*                                     TIBIA 9.10+                                         *
*                                   Monstruo armable                                      *
* ADVERTENCIA: El item ID de este monstruo puede variar dependiendo del que usa tu OT     *
*******************************************************************************************

	<health now="10000" max="10000"/>
	<look typeex="15460"/>
	<targetchange interval="5000" chance="8"/>
	<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="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="100"/>
		<flag runonhealth="0"/>
	</flags>
<script>
        <event name="boss"/>
</script>
<attacks> 
<attack name="melee" interval="2000" min="0" max="-700"/> 
<attack name="Explosion" interval="3000" chance="30" min="-120" max="-600"/> 
<attack name="Death Strike" interval="2000" chance="40" min="-120" max="-2600"/> 
<attack name="divine missile" interval="4500" chance="33" min="-480" max="-1431"/> 
<attack name="Terra Strike" interval="4500" chance="30" min="-0" max="-1487"/> 
<attack name="paralyze" interval="3500" chance="25"/> 
</attacks> 
<defenses armor="70" defense="70"> 
<defense name="healing" interval="1000" chance="25" min="57" max="293"> 
<attribute key="areaEffect" value="blueshimmer"/> 
</defense> 
</defenses> 
	<immunities>
		<immunity outfit="1"/>
		<immunity lifedrain="1"/>
		<immunity paralyze="1"/>
		<immunity invisible="1"/>
	</immunities>
	<voices interval="5000" chance="10">
		<voice sentence="cri cri" yell="0"/>
		<voice sentence="bbbbb" yell="1"/>
	</voices>
</monster>

In boss I add this:

<script>
<event name="boss"/>
</script>
 
PHP:
local bossName = 'hero'
local bossHealth = 50 --in percents
local teleportPosition = {x=1234,y=1234,z=1234}
local teleportToPosition = {x=1234,y=1234,z=1234} --where tp teleport
local timelast = 60 -- time in seconds to the teleport to disappear
 
local function removeTeleport()
local tele = getTitleItemById(teleportPosition, 1387)
if tele.uid > 0 then
	doRemoveItem(tele.uid)
	return doSendMagicEffect(teleportPosition, CONST_ME_POFF)
end
return true
end
 
local function getPercent(number, all)
    return (number / all) * 100
end
 
function onCombat(cid, target)
local health = math.ceil(getPercent(getCreatureHealth(target), getCreatureMaxHealth(target)))
if isMonster(target) and getCreatureName(target):lower() == bossName and health <= bossHealth and getCreatureStorage(target, 1000) == -1 then
    doCreatureSetStorage(target, 1000, 1)
    addEvent(removeTeleport, timelast * 1000)
    return doCreateTeleport(1387, teleportToPosition, teleportPosition)
end
return true
end
And into login.lua (only login.lua, no monster file) add:
PHP:
registerCreatureEvent(cid, "boss")
And creaturescripts.xml
PHP:
<event type="combat" name="boss" event="script" value="boss.lua"/>

And what are you doing with a boss? Do you kill him?
 
Back
Top