Hello guys,
Say I take this simple onstepin script
Is it possible to add a line which will, for example, give the player 50% chance to be teleported to the location?
Also how would I add a line which would deal damage to the player if they are teleported? I like reading the code and going through various scripts to create edits of my own (I'm not entirely experienced enough to just write code from scratch that is 100% functioning properly so I look at other code/scripts to use as an example). So I had the idea of simply taking this line:
And add it to:
Would that work?
Thanks in advance
Say I take this simple onstepin script
Lua:
local config = {
[9238] = Position(33456, 31346, 8),
[9239] = Position(33199, 31978, 8)
}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
return true
end
local targetPosition = config[item.uid]
if not targetPosition then
return true
end
player:teleportTo(targetPosition)
targetPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, '')
return true
end
Also how would I add a line which would deal damage to the player if they are teleported? I like reading the code and going through various scripts to create edits of my own (I'm not entirely experienced enough to just write code from scratch that is 100% functioning properly so I look at other code/scripts to use as an example). So I had the idea of simply taking this line:
Lua:
doTargetCombatHealth(0, player, COMBAT_PHYSICALDAMAGE, -200, -200, CONST_ME_DRAWBLOOD)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, '')
Lua:
player:teleportTo(targetPosition)
targetPosition:sendMagicEffect(CONST_ME_WATERSPLASH)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, '')
return true
end
Thanks in advance