• 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!

Arrow Shower! for The Forgotten Server v0.3

Darkensser

New Member
Joined
Mar 30, 2008
Messages
20
Reaction score
0
Hello Guys!

I need Transformed this code for [8.4] The Forgotten Server v0.3 beta 2....

Original Post:

Good night.

First of all, thanks to:
Unknown Guy - Original Idea
BlackDemon - For melee Spectators (was used as base to)

This one its for lua, cvsed sources probbly only. (i dont remember the date of the sources that i'm working on, probbly 19 April).

Lets go.

Spells.cpp:
lua_register(luaState, "makeFood", SpellScript::luaActionMakeFood);
After this one add:
lua_register(luaState, "arrowShower", SpellScript::luaArrowShower);
Put this at the end of spells.cpp
int SpellScript::luaArrowShower(lua_State *L)
{
Spell* spell = getSpell(L);
Creature* creature = spell->game->getCreatureByID((unsigned long)lua_tonumber(L, -1));
lua_pop(L,1);
if(!creature)
return 0;
Player* player = creature->getPlayer();
if(player){
Item* item = player->GetDistWeapon();
if(creature->getFightType() != FIGHT_DIST || !item){
player->sendTextMessage(MSG_STATUS_SMALL, "You dont have any ammo to shot.");
spell->game->AddMagicEffectAt(creature->getPosition(), NM_ME_PUFF);
return 0;
}
SpectatorVec list;
SpectatorVec::iterator it;
spell->game->getSpectators(Range(player->getPosition()), list);

//Get total ammunition:
short ammoNeeded = item->getItemCount() - (list.size()-1);
short keyValue = 0xFF;
if(ammoNeeded < 0)
keyValue = (list.size()-1) - std::abs(ammoNeeded);

int dx, dy;
Position abstrata, nextStep;
abstrata = player->getPosition();
Tile* nextTile = NULL;

for(it = list.begin(); it != list.end(); ++it) {
Creature* targeted = dynamic_cast<Creature*>(*it);
if(targeted && targeted != player &&
Position::areInRange<7,5,0>(targeted->getPosition(), player->getPosition())){
if(keyValue != 0xFF)
keyValue--;
if(keyValue < 0) //Messy but works.
break;
spell->game->creatureMakeDamage(creature, targeted, creature->getFightType());

nextStep = (*it)->getPosition();
dx = abstrata.x - nextStep.x;
dy = abstrata.y - nextStep.y;
if(dx < 0)
nextStep.x++;
if(dx > 0)
nextStep.x--;
if(dy < 0)
nextStep.y++;
if(dy > 0)
nextStep.y--;

nextTile = spell->game->getTile(nextStep.x, nextStep.y, nextStep.z);
if(!nextTile || nextTile && (nextTile->hasProperty(BLOCKPATHFIND) || nextTile->__queryAdd(0, creature, 1, 0) != RET_NOERROR) ||
spell->game->internalTeleport((*it), nextStep) != RET_NOERROR){
spell->game->AddMagicEffectAt(targeted->getPosition(), NM_ME_HIT_AREA);
continue;
}
spell->game->AddMagicEffectAt(nextStep, NM_ME_HIT_AREA);
}
}
}
return 0;
}
Spells.h

After:
static int luaActionMakeFood(lua_State *L);
Add:
static int luaArrowShower(lua_State *L);
And finally the lua file:
function onCast(cid, creaturePos, level, maglv, var)
n = arrowShower(cid);
return n
end
-----------------------------------------------------------------


I need u help... :( thx.
Good Night,
Darkensser
 
Back
Top