What's new

Mods Boat System script mod

Status
Not open for further replies.

kubus10

User
Joined
Jun 6, 2013
Messages
14
Reaction score
0
Jest to skrypt na podr?? ma?? ??deczk?. Skrypt nie jest m?j.
Wyglada to tak :

Utw?rz plik xml w (Server / Mod) o nazwie BoatSystem i wklej kod
[XML]<?xml version="1.0" encoding="UTF-8"?>
<mod name="BoatSystem" enabled="yes" author="MatheusMkalo" forum="XTibia.com">

<config name="BoatSystemLib"><![CDATA[
mydirs= {
[1] = {type = 1, ids = {3587, 3590, 3591}, xy = {0, -1}},
[2] = {type = 2, ids = {3592, 3595, 3596}, xy = {1, 0}},
[3] = {type = 1, ids = {3587, 3590, 3591}, xy = {0, 1}},
[4] = {type = 2, ids = {3592, 3595, 3596}, xy = {-1, 0}}
}

allids = {3587, 3590, 3591, 3592, 3595, 3596}

function newEndb(endb, dir)
local xx = endb.x
local yy = endb.y
for i = 1, #dir do
xx = xx+mydirs[dir].xy[1]
yy = yy+mydirs[dir].xy[2]
end
return {x=xx, y=yy, z=endb.z}
end

function doMoveBoat(post, dir, cid)
local newboat = {}
for i,s in ipairs(post) do
local backu = getThingPos(s)
doRemoveItem(s, 1)
doCreateItem(mydirs[dir].ids, 1, {x=backu.x+mydirs[dir].xy[1], y=backu.y+mydirs[dir].xy[2], z=backu.z})
table.insert(newboat, getThingFromPos({x=backu.x+mydirs[dir].xy[1], y=backu.y+mydirs[dir].xy[2], z=backu.z, stackpos=1}).uid)
end
if mydirs[dir].type ~= post.type and mydirs[dir].type == 1 then
doCreateItem(getThing(newboat[1]).itemid, 1, {x=getThingPos(newboat[1]).x+1, y=getThingPos(newboat[1]).y-1, z=getThingPos(newboat[1]).z})
doRemoveItem(newboat[1], 1)
doCreateItem(getThing(newboat[3]).itemid, 1, {x=getThingPos(newboat[3]).x-1, y=getThingPos(newboat[3]).y+1, z=getThingPos(newboat[3]).z})
doRemoveItem(newboat[3], 1)
elseif mydirs[dir].type ~= post.type and mydirs[dir].type == 2 then
doCreateItem(getThing(newboat[1]).itemid, 1, {x=getThingPos(newboat[1]).x-1, y=getThingPos(newboat[1]).y+1, z=getThingPos(newboat[1]).z})
doRemoveItem(newboat[1], 1)
doCreateItem(getThing(newboat[3]).itemid, 1, {x=getThingPos(newboat[3]).x+1, y=getThingPos(newboat[3]).y-1, z=getThingPos(newboat[3]).z})
doRemoveItem(newboat[3], 1)
end
if cid then
doTeleportThing(cid, {x=getCreaturePosition(cid).x+mydirs[dir].xy[1], y=getCreaturePosition(cid).y+mydirs[dir].xy[2], z=getCreaturePosition(cid).z}, false)
end
end

function getPosBoat(cid, pos)
local pcid = not pos and getCreaturePosition(cid) or pos
local check = getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).itemid == mydirs[1].ids[2] and 1 or 2
if check == 1 then
return {getThingFromPos({x=pcid.x, y=pcid.y-1, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y+1, z=pcid.z, stackpos=1}).uid, type = check}
elseif check == 2 then
return {getThingFromPos({x=pcid.x-1, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x+1, y=pcid.y, z=pcid.z, stackpos=1}).uid, type = check}
end
return false
end

function reverse(t)
local result = {}
for i = #t, 1, -1 do
table.insert(result, t == 1 and 3 or t == 2 and 4 or t == 3 and 1 or t == 4 and 2)
end
return result
end

]]></config>

<movevent type="StepIn" actionid="6616" event="script"><![CDATA[
domodlib("BoatSystemLib")
local t = {4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
local postart = {x=968, y=1001, z=7, stackpos=1}
local posback = {x=994, y=978, z=7, stackpos=1}
local delay = 350
if toPosition.x == posback.x and toPosition.y == posback.y then
doCreatureSetNoMove(cid, true)
for i = 1, #reverse(t) do
addEvent(function() doMoveBoat(getPosBoat(cid), reverse(t), cid) end, i*delay)
end
addEvent(doCreatureSetNoMove, delay*#reverse(t)+100, cid, false)
addEvent(function() doItemSetAttribute(getThingFromPos(postart).uid, "aid", 6616) end, delay*#t+100)
elseif toPosition.x == postart.x and toPosition.y == postart.y then
doCreatureSetNoMove(cid, true)
for i = 1, #t do
addEvent(function() doMoveBoat(getPosBoat(cid), t, cid) end, i*delay)
end
addEvent(doCreatureSetNoMove, delay*#t+100, cid, false)
addEvent(function() doItemSetAttribute(getThingFromPos(posback).uid, "aid", 6616) end, delay*#t+100)
end
]]></movevent>

<movevent type="StepIn" actionid="6617" event="script"><![CDATA[
domodlib("BoatSystemLib")
if not isInArray(allids, getThingFromPos({x=toPosition.x, y=toPosition.y, z=toPosition.z, stackpos=1}).itemid) then
doTeleportThing(cid, fromPosition, false)
end
]]></movevent>

</mod>[/XML]

Ustawienia skryptu:
[XML]local t = {4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
local postart = {x=968, y=1001, z=7, stackpos=1}
local posback = {x=994, y=978, z=7, stackpos=1}
local delay = 350[/XML]

local t - nr odpowiadaj?ce kierunkowi 1-p??noc 2-wsch?d 3-po??dnie 4- zach?d
local postart - pozycja z kt?rej ??dka startuje
local postback - pozycja ko?cowa
local delay - op??nienie

USTAWIENIA W RME:
-robimy 3 sqm walkable sea id-4820
-na ty robimy ??dke i w ?rodkowej cz??ci ustawiamy actionid-6617
-w miejscu gdzie nasza ??dka ma dop?yna? te? robimy walkable sea id-4820

Skrypt testowany na tfs 0.3.6 tibia 8.6
 

kubus10

User
Joined
Jun 6, 2013
Messages
14
Reaction score
0
Odp: Boat System script mod

nie wiem..testowa?em tylko pod 8.6
 
Status
Not open for further replies.
Top