• 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?
 
if you know something about lua you can look up the omnislash spell here on otland and use it as a base for that spell, when I get home I can try and help you out if I got the time, sorry I can't help more
 
There is a function to get the player's direction, determining the location of the square behind you.
Then you can check that square for a creature/player, if true, initiate spell.
 
Oh you want me to prove it, and steal the script? Go troll somewhere else.
Jayswag, I'll pm you the script.

Btw, I'm sorry if I looked like I was trolling, which I clearly did I guess.
Was planning to pm the script anyways.
 
Last edited:
Sherice you are the reason why Open-Tibia is going to hell.

You and all the other inbred asses do not share anything they've made and when it comes down to it all you are just a spammer. Is there any point in posting a snide remark like I have this script, but you cannot have it.
 
Yeah, that's why I noticed my wrong, and edited my post.
NOTE: It was before you posted.

If you want to know why I didn't post it here, yes, I'm an idiot and don't want to post it here. Ban me for it or whatever, but it's my choice, since it's my script.
 
i actually like that sherice aint giving it to im cuz if we just made stuff for everyone that asked the forum would be full of leaches
 
Well it really helped me anyways.
Your a good person Sherice, thanks so much :)
And I won't release this script anywhere by respect to him.

Thanks / J
 
Sherice you are the reason why Open-Tibia is going to hell.

You and all the other inbred asses do not share anything they've made and when it comes down to it all you are just a spammer. Is there any point in posting a snide remark like I have this script, but you cannot have it.

because you helped so much with your 33 posts since oct 2008.....
 
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!
 
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!

Can u show a video please? :P
 
[23/05/2012 22:02:11] Lua Script Error: [Spell Interface]
[23/05/2012 22:02:11] data/spells/scripts/attack/backstab.lua:onCastSpell
[23/05/2012 22:02:11] data/global.lua:1436: attempt to call global 'getCreatureLookDirection' (a nil value)
[23/05/2012 22:02:11] stack traceback:
[23/05/2012 22:02:11] [C]: in function 'getCreatureLookDirection'
[23/05/2012 22:02:11] data/global.lua:1436: in function 'getTargetBehind'
[23/05/2012 22:02:11] data/spells/scripts/attack/backstab.lua:4: in function <data/spells/scripts/attack/backstab.lua:1>




This is my error mr.

Please help
 
Back
Top