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:
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:
After this one add:lua_register(luaState, "makeFood", SpellScript::luaActionMakeFood);
Put this at the end of spells.cpplua_register(luaState, "arrowShower", SpellScript::luaArrowShower);
Spells.hint 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;
}
After:
Add:static int luaActionMakeFood(lua_State *L);
And finally the lua file:static int luaArrowShower(lua_State *L);
-----------------------------------------------------------------function onCast(cid, creaturePos, level, maglv, var)
n = arrowShower(cid);
return n
end
I need u help... thx.
Good Night,
Darkensser
Good Night,
Darkensser