- Joined
- Nov 17, 2010
- Messages
- 6,795
- Solutions
- 581
- Reaction score
- 5,359
Edit: Improved code here.
Going to release a Training Monk script that me and my friend created long ago.
In short it's very easy to set-up, you can have it in any direction, and you should have no errors.
Tested on 0.3.7 TFS.
Only known bug: if someone get's kicked from trainers due to anti-idle, trainers will stay 'alive'.
However if another player or the logged out player logs in again, and steps out of the tile they will de-spawn as normal.
Now, on to the quick video demonstration, installation and mapping process!
------------------
------------------
Mapping the Area
Grey tile = Non-walkable object. Such as a wall.
Brown tile = itemID 452 (brown unpressed pressure plate.)
Green tile = actionID 45555
----------------
Monster data/monster/monsters.xml
----------------
Simple Trainer data/monster/trainers.xml
----------------
Movements.xml data/movements/movements.xml
----------------
Script data/movements/scripts/xikinitrainers.lua
----------------
Some quick Q&A
Q: Why is my monster not spawning?
A: You either haven't set-up the map properly, or the target monster does not exist. Check monsters.xml
Q: Why is my monster not de-spawning?
A: You have most likely named the monster incorrectly. The filename of the monster does not matter. Only the actual name of the monster.
Q: The monsters are spawning oddly!
A: Ensure you follow the picture and set-up your map the same way. Direction doesn't matter.
Q: Can I use different tiles under the trainers?
A: If you can adjust the script properly then yes. Otherwise just use what is stated.
Q: Does the green tile have to have a specific itemID?
A: No. As long as the tile has the correct actionID the monsters will spawn fine.
Q: Can I use any non-walkable tile for the grey tiles?
A: Yes. Any wall, bush, tree, mountain side, pole.. any object should work. Untested with water, lava, tables, et cetera. However, if your having troubles just test with a couple different objects.
Hopefully this covers most everything!
Give a like if you wish, and post some screenshots of your creative training grounds below!
Credit where credit is due.
Xikini, myself, for the idea and the initial script.
Transcending, my friend, for the final script shown here.
Cheers,
Xikini
Going to release a Training Monk script that me and my friend created long ago.
In short it's very easy to set-up, you can have it in any direction, and you should have no errors.
Tested on 0.3.7 TFS.
Only known bug: if someone get's kicked from trainers due to anti-idle, trainers will stay 'alive'.
However if another player or the logged out player logs in again, and steps out of the tile they will de-spawn as normal.
Now, on to the quick video demonstration, installation and mapping process!
------------------
Mapping the Area
Grey tile = Non-walkable object. Such as a wall.
Brown tile = itemID 452 (brown unpressed pressure plate.)
Green tile = actionID 45555
----------------
Monster data/monster/monsters.xml
Code:
<monster name="trainers" file="trainers.xml"/>
Simple Trainer data/monster/trainers.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Trainers" nameDescription="a trainer" race="undead" experience="0" speed="100" manacost="0">
<health now="123456" max="123456"/>
<look typeex="5787" corpse="5968"/>
<targetchange interval="2000" chance="100"/>
<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="1"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="1"/>
<flag hidename="0"/>
</flags>
<attacks>
<attack name="melee" interval="2000" skill="1" attack="1"/>
</attacks>
<defenses armor="0" defense="0">
<defense name="healing" interval="10000" chance="100" min="123000" max="123001">
<attribute key="areaEffect" value="blueshimmer"/>
</defense>
</defenses>
<loot>
<item id="12649" countmax="1" chance="100000"/><!-- gold coin -->
</loot>
</monster>
Movements.xml data/movements/movements.xml
Code:
<movevent event="StepIn" actionid="45555" script="xikinitrainers.lua" />
<movevent event="StepOut" actionid="45555" script="xikinitrainers.lua" />
Script data/movements/scripts/xikinitrainers.lua
Code:
-- Credits to Xikini & Bert McCutchen for Idea's and Script
--Name of monster that will be spawned
local monsterName = "Trainers"
--Item ID of tile to spawn monster on
local spawningTileID = 446
function onStepIn(cid, item, position, fromPosition)
--Positions to spawn monsters
local topLeftPos = {x = (position.x - 1), y = (position.y - 1), z = position.z}
local topRightPos = {x = (position.x + 1), y = (position.y - 1), z = position.z}
local bottomLeftPos = {x = (position.x - 1), y = (position.y + 1), z = position.z}
local bottomRightPos = {x = (position.x + 1), y = (position.y + 1), z = position.z}
--spawn the monsters on any position that has the designated spawning tile
--spawning tiles will only be spawned on if it matches to the spawning locations
--top left
if getTileThingByPos(topLeftPos).itemid == spawningTileID then
doSendMagicEffect(topLeftPos, CONST_ME_FIREATTACK)
doCreateMonster(monsterName, topLeftPos)
end
--top right
if getTileThingByPos(topRightPos).itemid == spawningTileID then
doSendMagicEffect(topRightPos, CONST_ME_FIREATTACK)
doCreateMonster(monsterName, topRightPos)
end
--bottom left
if getTileThingByPos(bottomLeftPos).itemid == spawningTileID then
doSendMagicEffect(bottomLeftPos, CONST_ME_FIREATTACK)
doCreateMonster(monsterName, bottomLeftPos)
end
--bottom right
if getTileThingByPos(bottomRightPos).itemid == spawningTileID then
doSendMagicEffect(bottomRightPos, CONST_ME_FIREATTACK)
doCreateMonster(monsterName, bottomRightPos)
end
return true
end
function onStepOut(cid, item, position, fromPosition)
--Positions to despawn spawn monsters
local topLeftFromPos = {x = (fromPosition.x - 1), y = (fromPosition.y - 1), z = fromPosition.z, stackpos = 253}
local topRightFromPos = {x = (fromPosition.x + 1), y = (fromPosition.y - 1), z = fromPosition.z, stackpos = 253}
local bottomLeftFromPos = {x = (fromPosition.x - 1), y = (fromPosition.y + 1), z = fromPosition.z, stackpos = 253}
local bottomRightFromPos = {x = (fromPosition.x + 1), y = (fromPosition.y + 1), z = fromPosition.z, stackpos = 253}
--delete any creature by the name of monsterName from specific positions
--top left
if isMonster(getThingFromPos(topLeftFromPos).uid) then
if getCreatureName(getThingFromPos(topLeftFromPos).uid) == monsterName then
doRemoveCreature(getThingFromPos(topLeftFromPos).uid)
doSendMagicEffect(topLeftFromPos, CONST_ME_POFF)
end
end
--top right
if isMonster(getThingFromPos(topRightFromPos).uid) then
if getCreatureName(getThingFromPos(topRightFromPos).uid) == monsterName then
doRemoveCreature(getThingFromPos(topRightFromPos).uid)
doSendMagicEffect(topRightFromPos, CONST_ME_POFF)
end
end
--bottom left
if isMonster(getThingFromPos(bottomLeftFromPos).uid) then
if getCreatureName(getThingFromPos(bottomLeftFromPos).uid) == monsterName then
doRemoveCreature(getThingFromPos(bottomLeftFromPos).uid)
doSendMagicEffect(bottomLeftFromPos, CONST_ME_POFF)
end
end
--bottom right
if isMonster(getThingFromPos(bottomRightFromPos).uid) then
if getCreatureName(getThingFromPos(bottomRightFromPos).uid) == monsterName then
doRemoveCreature(getThingFromPos(bottomRightFromPos).uid)
doSendMagicEffect(bottomRightFromPos, CONST_ME_POFF)
end
end
return true
end
Some quick Q&A
Q: Why is my monster not spawning?
A: You either haven't set-up the map properly, or the target monster does not exist. Check monsters.xml
Q: Why is my monster not de-spawning?
A: You have most likely named the monster incorrectly. The filename of the monster does not matter. Only the actual name of the monster.
Q: The monsters are spawning oddly!
A: Ensure you follow the picture and set-up your map the same way. Direction doesn't matter.
Q: Can I use different tiles under the trainers?
A: If you can adjust the script properly then yes. Otherwise just use what is stated.
Q: Does the green tile have to have a specific itemID?
A: No. As long as the tile has the correct actionID the monsters will spawn fine.
Q: Can I use any non-walkable tile for the grey tiles?
A: Yes. Any wall, bush, tree, mountain side, pole.. any object should work. Untested with water, lava, tables, et cetera. However, if your having troubles just test with a couple different objects.
Hopefully this covers most everything!
Give a like if you wish, and post some screenshots of your creative training grounds below!
Credit where credit is due.
Xikini, myself, for the idea and the initial script.
Transcending, my friend, for the final script shown here.
Cheers,
Xikini
Last edited: