• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Spell] Backstab

Synergy

New Member
Joined
Nov 24, 2011
Messages
334
Reaction score
0
Hi! I'm wondering if someone can make me a spell for my vocation "Rogue"

When you use the spell
example:

JaySwag: Backstab!

Boom, You are suddenly behind the target (teleporting or whatever) and you hit him with a hard strike


Is this possible?
 
I can do this script for you, for free so no more trollin' here... -.-

.../data/lib/050-functions.lua:
LUA:
function getTargetBehind(cid) -- function by WotT
	
	local target = getCreatureTarget(cid)
	local targetPos = getCreaturePosition(target)
	local direction = getCreatureLookDirection(target)
	local SQM = 1
	local positions = {
		north = {x = targetPos.x, y = targetPos.y-SQM, z = targetPos.z},
		south = {x = targetPos.x, y = targetPos.y+SQM, z = targetPos.z},
		west = {x = targetPos.x-SQM, y = targetPos.y, z = targetPos.z},
		east = {x = targetPos.x+SQM, y = targetPos.y, z = targetPos.z}
	}
	
	if(direction == NORTH) then
		return positions.south
	elseif(direction == SOUTH) then
		return positions.north
	elseif(direction == WEST) then
		return positions.east
	elseif(direction == EAST) then
		return positions.west
	end
	return true
end	

function isWalkable(cid,pos)
    local aux = pos
    aux.stackpos = 253
    if doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(aux).uid) == FALSE then
        return TRUE
    end
    return FALSE
end

.../spells/scripts/attack/backstab.lua:
LUA:
function onCastSpell(cid, var)
	local target = getCreatureTarget(cid)
	
	if(isWalkable(cid, getTargetBehind(cid))) then
		doTeleportThing(cid, getTargetBehind(cid))
		doPlayerCastSpell(cid, "Hard Strike") -- [url]http://otland.net/f35/doplayercastspell-cid-spell-80043/[/url]
	else
		doPlayerSendCancel(cid, "You cannot teleport to your target while the tile is blocked.")
		return false
	end
	
	return true
end

COMPILE:
source: http://otland.net/f35/doplayercastspell-cid-spell-80043/


Luascript.cpp:

after:
[CPP]
//getCreatureHealth(cid)
lua_register(m_luaState, "getCreatureHealth", LuaScriptInterface::luaGetCreatureHealth);[/CPP]
add this:
[CPP]
//doPlayerCastSpell(cid, spell)
lua_register(m_luaState, "doPlayerCastSpell", LuaScriptInterface::luaDoPlayerCastSpell);[/CPP]
after:

[CPP]
int32_t LuaScriptInterface::luaGetPlayerSex(lua_State* L)
{
//getPlayerSex(cid[, full = false])
bool full = false;
if(lua_gettop(L) > 1)
full = popNumber(L);

ScriptEnviroment* env = getEnv();
Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
else
lua_pushnumber(L, player->getSex(full));

return 1;
}[/CPP]
add this:
[CPP]
int32_t LuaScriptInterface::luaDoPlayerCastSpell(lua_State* L)
{
//doPlayerCastSpell(cid, spell)
std::string spell = popString(L);

ScriptEnviroment* env = getEnv();
Player* player = env->getPlayerByUID(popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}

ReturnValue ret = RET_NOERROR;
ret = g_spells->onPlayerSay(player, spell);
if(ret == RET_NOERROR || (ret == RET_NEEDEXCHANGE && !g_config.getBool(ConfigManager::BUFFER_SPELL_FAILURE)))
return true;

lua_pushboolean(L, true);
return 1;
}[/CPP]

Luascript.h

after:
[CPP]
static int32_t luaDoRemoveItem(lua_State* L);[/CPP]
add this:
[CPP]
static int32_t luaDoPlayerCastSpell(lua_State* L);[/CPP]

Done!

possible without compiling and source edit.
 
I can do this script for you, for free so no more trollin' here... -.-

.../data/lib/050-functions.lua:
LUA:
function getTargetBehind(cid) -- function by WotT
	
	local target = getCreatureTarget(cid)
	local targetPos = getCreaturePosition(target)
	local direction = getCreatureLookDirection(target)
	local SQM = 1
	local positions = {
		north = {x = targetPos.x, y = targetPos.y-SQM, z = targetPos.z},
		south = {x = targetPos.x, y = targetPos.y+SQM, z = targetPos.z},
		west = {x = targetPos.x-SQM, y = targetPos.y, z = targetPos.z},
		east = {x = targetPos.x+SQM, y = targetPos.y, z = targetPos.z}
	}
	
	if(direction == NORTH) then
		return positions.south
	elseif(direction == SOUTH) then
		return positions.north
	elseif(direction == WEST) then
		return positions.east
	elseif(direction == EAST) then
		return positions.west
	end
	return true
end	

function isWalkable(cid,pos)
    local aux = pos
    aux.stackpos = 253
    if doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(aux).uid) == FALSE then
        return TRUE
    end
    return FALSE
end

.../spells/scripts/attack/backstab.lua:
LUA:
function onCastSpell(cid, var)
	local target = getCreatureTarget(cid)
	
	if(isWalkable(cid, getTargetBehind(cid))) then
		doTeleportThing(cid, getTargetBehind(cid))
		doPlayerCastSpell(cid, "Hard Strike") -- [url]http://otland.net/f35/doplayercastspell-cid-spell-80043/[/url]
	else
		doPlayerSendCancel(cid, "You cannot teleport to your target while the tile is blocked.")
		return false
	end
	
	return true
end

COMPILE:
source: http://otland.net/f35/doplayercastspell-cid-spell-80043/


Luascript.cpp:

after:
[CPP]
//getCreatureHealth(cid)
lua_register(m_luaState, "getCreatureHealth", LuaScriptInterface::luaGetCreatureHealth);[/CPP]
add this:
[CPP]
//doPlayerCastSpell(cid, spell)
lua_register(m_luaState, "doPlayerCastSpell", LuaScriptInterface::luaDoPlayerCastSpell);[/CPP]
after:

[CPP]
int32_t LuaScriptInterface::luaGetPlayerSex(lua_State* L)
{
//getPlayerSex(cid[, full = false])
bool full = false;
if(lua_gettop(L) > 1)
full = popNumber(L);

ScriptEnviroment* env = getEnv();
Player* player = env->getPlayerByUID((uint32_t)popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
else
lua_pushnumber(L, player->getSex(full));

return 1;
}[/CPP]
add this:
[CPP]
int32_t LuaScriptInterface::luaDoPlayerCastSpell(lua_State* L)
{
//doPlayerCastSpell(cid, spell)
std::string spell = popString(L);

ScriptEnviroment* env = getEnv();
Player* player = env->getPlayerByUID(popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}

ReturnValue ret = RET_NOERROR;
ret = g_spells->onPlayerSay(player, spell);
if(ret == RET_NOERROR || (ret == RET_NEEDEXCHANGE && !g_config.getBool(ConfigManager::BUFFER_SPELL_FAILURE)))
return true;

lua_pushboolean(L, true);
return 1;
}[/CPP]

Luascript.h

after:
[CPP]
static int32_t luaDoRemoveItem(lua_State* L);[/CPP]
add this:
[CPP]
static int32_t luaDoPlayerCastSpell(lua_State* L);[/CPP]

Done!

LUA:
function getTargetBehind(cid) -- function by WotT
 
	local target = getCreatureTarget(cid)
	local targetPos = getCreaturePosition(target)
	local direction = getCreatureLookDirection(target)
	local SQM = 1
	local position = {
		[NORTH] = {x = targetPos.x, y = targetPos.y-SQM, z = targetPos.z},
		[SOUTH] = {x = targetPos.x, y = targetPos.y+SQM, z = targetPos.z},
		[WEST] = {x = targetPos.x-SQM, y = targetPos.y, z = targetPos.z},
		[EAST] = {x = targetPos.x+SQM, y = targetPos.y, z = targetPos.z}
	}
	return position[direction][1] or true
end
no need for 'if' statements. not sure of the 'true' I believe it should be 'false'.
 
Its wokring like charm, but the problem is that it should be like this, it going to teleport to target on the closetfreetile no just behind :/ because i want add damage on it. when player is close to the target it says something is blocking.

Please make it so you can get tped to any closetile around the target.
 
Its wokring like charm, but the problem is that it should be like this, it going to teleport to target on the closetfreetile no just behind :/ because i want add damage on it. when player is close to the target it says something is blocking.

Please make it so you can get tped to any closetile around the target.

That's even more easier but I got that idea first so, I wont release it xd
With "easier" I mean, you can do it aswell ...
 
Back
Top