Hey. This code will allow GM's to run with CTRL. It has some special features too, unlike the regular ones.
Features
Only thing that could be better in my opinion is removing the "teleport" effect when the GM is shown again. This requires a very simple source edit and if you want to know how to do it, I can show you (if you know how to compile).
Installation
1. Open events/events.xml
Find method="onTurn" for class="Player" and set it to enabled="1". If you cannot find it then paste this:
2. Place this in events/scripts/player.lua
(Replace current onTurn if it's not used, or if it only has another version of a onLook-run script.)
Features
- Ghost while running. Because I believe it looks ugly and not serious to run through walls in front of regular players, and also GM's running in general (in front of players), I made it ghost while you run and turn you back to normal as you stop. Will remain ghost if you stop in a wall or similar and return to normal once you leave it.
- Smooth turning. If you have used a similar script, you know the turns are not smooth.
- Throws you down roofs etc if you try to run out from it (but never below ground floor).
Only thing that could be better in my opinion is removing the "teleport" effect when the GM is shown again. This requires a very simple source edit and if you want to know how to do it, I can show you (if you know how to compile).
Installation
1. Open events/events.xml
Find method="onTurn" for class="Player" and set it to enabled="1". If you cannot find it then paste this:
XML:
<event class="Player" method="onTurn" enabled="1" />
2. Place this in events/scripts/player.lua
(Replace current onTurn if it's not used, or if it only has another version of a onLook-run script.)
Lua:
-- Used in onTurn.
local tempGhostPlayerEvents = tempGhostPlayerEvents or {}
local function removeGhost(cid)
local player = Player(cid)
if tempGhostPlayerEvents[cid] then
if player then
local tile = Tile(player:getPosition())
if tile:hasFlag(TILESTATE_FLOORCHANGE) then
tempGhostPlayerEvents[cid] = addEvent(removeGhost, 350, cid)
return
end
local tileItems = tile:getItems() or {}
table.insert(tileItems, tile:getGround())
for _, item in ipairs(tileItems) do
if item:hasProperty(CONST_PROP_BLOCKSOLID) then
tempGhostPlayerEvents[cid] = addEvent(removeGhost, 350, cid)
return
end
end
player:setGhostMode(false, false)
end
tempGhostPlayerEvents[cid] = nil
end
end
local playerLastTurn = playerLastTurn or {}
function Player:onTurn(direction)
if not self:getGroup():getAccess() or self:getAccountType() < ACCOUNT_TYPE_GOD then
return true
end
local lastTurn = playerLastTurn[self:getId()]
if self:getDirection() ~= direction and (not lastTurn or os.mtime() - lastTurn > 200) then
return true
end
local cid = self:getId()
if not self:isInGhostMode() or tempGhostPlayerEvents[cid] then
self:setGhostMode(true, false)
stopEvent(tempGhostPlayerEvents[cid]) -- Stop previous event
tempGhostPlayerEvents[cid] = addEvent(removeGhost, 350, self:getId())
end
playerLastTurn[self:getId()] = os.mtime()
local pos = self:getPosition()
pos:getNextPosition(direction)
while not Tile(pos) and pos.z < 7 do
pos.z = pos.z + 1
end
self:teleportTo(pos, true)
return true
end
Last edited: