MoveEvent Swimming v8.1! :)

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
I didnt fount any script for this, so i made own.

Meybe it isnt to much optimized, but its one way how it was possible to do.

swimming.lua
Code:
function onStepIn(cid, item, position, fromPosition)
if isPlayer(cid) == TRUE then
swimvalue = 3330 --storagevalue to check
diveroutfit = { lookType = 267, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0 }
standardoutfit = { lookType = getPlayerStorageValue(cid, 3331), lookHead = getPlayerStorageValue(cid, 3332), lookBody = 

getPlayerStorageValue(cid, 3333), lookLegs = getPlayerStorageValue(cid, 3334), lookFeet = getPlayerStorageValue(cid, 3335), lookAddons = 

getPlayerStorageValue(cid, 3336) }
isswimming = getPlayerStorageValue(cid, swimvalue)
if (isswimming == -1) or (isswimming == 2) then
pozycja = {x = 124, y = 58, z= 7}
	if item.itemid == 4632 then
		pos = {x = position.x, y = position.y - 2, z = position.z}
	elseif item.itemid == 4633 then
		pos = {x = position.x - 2, y = position.y, z = position.z}
	elseif item.itemid == 4634 then
		pos = {x = position.x, y = position.y + 2, z = position.z}
	elseif item.itemid == 4635 then
		pos = {x = position.x + 2, y = position.y, z = position.z}
	elseif item.itemid == 4636 then
		pos = {x = position.x + 2, y = position.y + 1, z = position.z}
	elseif item.itemid == 4637 then
		pos = {x = position.x - 2, y = position.y + 1, z = position.z}
	elseif item.itemid == 4638 then
		pos = {x = position.x + 2, y = position.y - 1, z = position.z}
	elseif item.itemid == 4639 then
		pos = {x = position.x - 2, y = position.y - 1, z = position.z}
	elseif item.itemid == 4640 then
		pos = {x = position.x + 2, y = position.y + 2, z = position.z}
	elseif item.itemid == 4641 then
		pos = {x = position.x - 2, y = position.y + 2, z = position.z}
	elseif item.itemid == 4642 then
		pos = {x = position.x + 2, y = position.y - 2, z = position.z}
	elseif item.itemid == 4643 then
		pos = {x = position.x - 2, y = position.y - 2, z = position.z}
	end
	setPlayerStorageValue(cid, 3331, getCreatureOutfit(cid).lookType)
	setPlayerStorageValue(cid, 3332, getCreatureOutfit(cid).lookHead)
	setPlayerStorageValue(cid, 3333, getCreatureOutfit(cid).lookBody)
	setPlayerStorageValue(cid, 3334, getCreatureOutfit(cid).lookLegs)
	setPlayerStorageValue(cid, 3335, getCreatureOutfit(cid).lookFeet)
	setPlayerStorageValue(cid, 3336, getCreatureOutfit(cid).lookAddons)
	setPlayerStorageValue(cid, swimvalue, 1)
	doSetCreatureOutfit(cid, diveroutfit, 60000)
	doSendMagicEffect(fromPosition, 2)
	doTeleportThing(cid, pos, TRUE)
	doSendMagicEffect(pos, 53)
elseif isswimming == 1 then
	if item.itemid == 4632 then
		dir = 2
	elseif item.itemid == 4633 then
		dir = 1
	elseif item.itemid == 4634 then
		dir = 0
	elseif item.itemid == 4635 then
		dir = 3
	elseif item.itemid == 4636 then
		dir = 3
	elseif item.itemid == 4637 then
		dir = 1
	elseif item.itemid == 4638 then
		dir = 3
	elseif item.itemid == 4639 then
		dir = 2
	elseif item.itemid == 4640 then
		dir = 3
	elseif item.itemid == 4641 then
		dir = 1
	elseif item.itemid == 4642 then
		dir = 3
	elseif item.itemid == 4643 then
		dir = 1
	end
	doSetCreatureOutfit(cid, standardoutfit, 1)
	doMoveCreature(cid, dir)
	setPlayerStorageValue(cid, swimvalue, 2)
end
end
	return TRUE
end
and now, to movements.lua
Code:
	<movevent event="StepIn" actionid="3333" script="swimming.lua"/>
For sure, it works only on desert tiles.
Now you're creating on map tiles from id: 4632-4643 and set actionid = 3333

As water you should use itemid: 4622.

Remember to make PROTECTION ZONE on water, becouse server will crash after killing on water.
 
Last edited:

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
Would you mind translating this before you post it on a english-speaking forum? :D

But anyway, thanks so very much.
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
Hah sure, some words are really in Polish. I'll change.
 

STiX

Intermediate OT User
Joined
Aug 22, 2007
Messages
437
Best answers
0
Reaction score
105
Location
Western Australia
I'm sure a lot of people owning 8.1 servers were looking for this. Good job and nice to see that you make a script that reflects what the majority of members want.
 

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
I havent test it, but i will test it later.

Anyways, nice script ;)
 

Nexoz

New Member
Joined
Jul 30, 2007
Messages
86
Best answers
0
Reaction score
0
It misses one thing, speedchange =p, when someone goes swimming his speed decreases slightly.
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
Heh, i tested it only on rookgaard on 1 lev. :)

Are You sure that speed is changed?
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
nice script ...
but it need check if isPlayer or no ;p
or some monsters/npcs will enter =]

about speed change..
tiles have speeds
if you want swim slow edit your items.otb
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
I think that is already done on some tile in the official .otb file. Atleast it was on Radonia, which uses the official .otb file, that tile was part of the randomization included in TFS, so people could walk on some of the tiles of water, with slower speed ofcourse.
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
nice script ...
but it need check if isPlayer or no ;p
or some monsters/npcs will enter =]
Monster will not enter becouse there will be PZ. But NPC ofcoure did, so i'll add it.
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
Monster will not enter becouse there will be PZ. But NPC ofcoure did, so i'll add it.
yeah .. monsters will not enter?.. you put pz on borders ? ;p
monsters maybe can walk on borders
if the monster walk on border with 3333 actionid.. don't matter if the water is pz .. he go enter.. and can't exit .. because setPlayerStorageValue is only for players.

other thing...
Code:
swimvalue = 3330 --storagevalue to check
diveroutfit = { lookType = 267, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0 }
standardoutfit = { lookType = getPlayerStorageValue(cid, 3331), lookHead = getPlayerStorageValue(cid, 3332), lookBody = 
getPlayerStorageValue(cid, 3333), lookLegs = getPlayerStorageValue(cid, 3334), lookFeet = getPlayerStorageValue(cid, 3335), lookAddons = 
getPlayerStorageValue(cid, 3336) }
isswimming = getPlayerStorageValue(cid, swimvalue)
this actions need be player to work..
if monster walk will show error because can't getStorageValue > Player not found.

only it.. :thumbup:
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
yeah .. monsters will not enter?.. you put pz on borders ? ;p
monsters maybe can walk on borders
if the monster walk on border with 3333 actionid.. don't matter if the water is pz .. he go enter.. and can't exit .. because setPlayerStorageValue is only for players.
Yes there should be PZ on borders too, so it will not set storage for monster.
other thing...
Code:
swimvalue = 3330 --storagevalue to check
diveroutfit = { lookType = 267, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0 }
standardoutfit = { lookType = getPlayerStorageValue(cid, 3331), lookHead = getPlayerStorageValue(cid, 3332), lookBody = 
getPlayerStorageValue(cid, 3333), lookLegs = getPlayerStorageValue(cid, 3334), lookFeet = getPlayerStorageValue(cid, 3335), lookAddons = 
getPlayerStorageValue(cid, 3336) }
isswimming = getPlayerStorageValue(cid, swimvalue)
this actions need be player to work..
if monster walk will show error because can't getStorageValue > Player not found.

only it.. :thumbup:
But ok, i added Player Check. :)

Good?
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
no no .. you don't understand...

yeah i know .. you added one isplayer check...
but this check need be like this...
Code:
function onStepIn(cid, item, position, fromPosition)
[B][SIZE=6]if isPlayer(cid) == 1 then[/SIZE][/B]
swimvalue = 3330 --storagevalue to check
diveroutfit = { lookType = 267, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0 }
standardoutfit = { lookType = getPlayerStorageValue(cid, 3331), lookHead = getPlayerStorageValue(cid, 3332), lookBody = 
getPlayerStorageValue(cid, 3333), lookLegs = getPlayerStorageValue(cid, 3334), lookFeet = getPlayerStorageValue(cid, 3335), lookAddons = 
getPlayerStorageValue(cid, 3336) }
isswimming = getPlayerStorageValue(cid, swimvalue)
[B][SIZE=4]if isPlayer(cid) == 1[/SIZE][/B] and (isswimming == -1) or (isswimming == 2) then
 if item.itemid == 4632 then
  pos = {x = position.x, y = position.y - 1, z = position.z}
 elseif item.itemid == 4633 then
  pos = {x = position.x - 1, y = position.y, z = position.z}
 elseif item.itemid == 4634 then
  pos = {x = position.x, y = position.y + 1, z = position.z}
 elseif item.itemid == 4635 then
  pos = {x = position.x + 1, y = position.y, z = position.z}
 elseif item.itemid == 4636 then
  pos = {x = position.x + 1, y = position.y + 1, z = position.z}
 elseif item.itemid == 4637 then
  pos = {x = position.x - 1, y = position.y + 1, z = position.z}
 elseif item.itemid == 4638 then
  pos = {x = position.x + 1, y = position.y - 1, z = position.z}
 elseif item.itemid == 4639 then
  pos = {x = position.x - 1, y = position.y - 1, z = position.z}
 elseif item.itemid == 4640 then
  pos = {x = position.x + 1, y = position.y + 1, z = position.z}
 elseif item.itemid == 4641 then
  pos = {x = position.x - 1, y = position.y + 1, z = position.z}
 elseif item.itemid == 4642 then
  pos = {x = position.x + 1, y = position.y - 1, z = position.z}
 elseif item.itemid == 4643 then
  pos = {x = position.x - 1, y = position.y - 1, z = position.z}
 end
 setPlayerStorageValue(cid, 3331, getCreatureOutfit(cid).lookType)
 setPlayerStorageValue(cid, 3332, getCreatureOutfit(cid).lookHead)
 setPlayerStorageValue(cid, 3333, getCreatureOutfit(cid).lookBody)
 setPlayerStorageValue(cid, 3334, getCreatureOutfit(cid).lookLegs)
 setPlayerStorageValue(cid, 3335, getCreatureOutfit(cid).lookFeet)
 setPlayerStorageValue(cid, 3336, getCreatureOutfit(cid).lookAddons)
 setPlayerStorageValue(cid, swimvalue, 1)
 doSetCreatureOutfit(cid, diveroutfit, 60000)
 doSendMagicEffect(fromPosition, 2)
 doTeleportThing(cid, pos, TRUE)
 doSendMagicEffect(pos, 53)
elseif isswimming == 1 then
 if item.itemid == 4632 then
  dir = 2
 elseif item.itemid == 4633 then
  dir = 1
 elseif item.itemid == 4634 then
  dir = 0
 elseif item.itemid == 4635 then
  dir = 3
 elseif item.itemid == 4636 then
  dir = 3
 elseif item.itemid == 4637 then
  dir = 1
 elseif item.itemid == 4638 then
  dir = 3
 elseif item.itemid == 4639 then
  dir = 2
 elseif item.itemid == 4640 then
  dir = 3
 elseif item.itemid == 4641 then
  dir = 1
 elseif item.itemid == 4642 then
  dir = 3
 elseif item.itemid == 4643 then
  dir = 1
 end
 doSetCreatureOutfit(cid, standardoutfit, 1)
 doMoveCreature(cid, dir)
 setPlayerStorageValue(cid, swimvalue, 2)
end
else
    return False
end
 return TRUE
end
or this will show errors like PlayerNotFound when one monster walk on the border with actionid 3333.

i hope you understand now =]
;*
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
i exactly understand what you mean from 135 minutes already :)

But i quess that array with outfits (where are included storagevalues) is checked only when is used? example: setPlayerStorageValue(cid, swimvalue, 1)

Or i'm wrong? :)
 

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
392
Best answers
0
Reaction score
0
Location
Brazil
@up ..

erm... yeah when is used.. or when you stepIn.. if it's a monster or npc .. this line don't go work .. will show error.. PlayerNotFound..
Code:
standardoutfit = { lookType = getPlayerStorageValue(cid, 3331), lookHead = getPlayerStorageValue(cid, 3332), lookBody = 
getPlayerStorageValue(cid, 3333), lookLegs = getPlayerStorageValue(cid, 3334), lookFeet = getPlayerStorageValue(cid, 3335), lookAddons = 
getPlayerStorageValue(cid, 3336) }
because can't get storage of npc/monsters.
;p
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
Ok, TRUE


Btw. In RL Tibia there is also PZ on borders, but NPC still can stepIn so i added this checking.
 

STiX

Intermediate OT User
Joined
Aug 22, 2007
Messages
437
Best answers
0
Reaction score
105
Location
Western Australia
Have no idea why you guys are worring about NPCs stepping in the water. Who has their npcs wandering around town aimlessly anyway lol.

@Ontopic: Great job and pretty quick release too.
 
Top