Wirless
7.6 is the best :D
Hello I am trying to edit source of 7.6 yur ots and I want to make it possible to learn spells from Items these items will be Item_Scroll that I have not yet added to items but will be in near future so I tought easiest way is to see how it works with npcs and try make it into actions this is what I came up with
ifdef __LearnSpellx__
int ActionScript::luaActionLearnSpell(lua_State *L){
//Learnspell(Spellname?)
int cid = (int)lua_tonumber(L, -3); //this is the creatureid of player i guess
const char* words = Item->getDescription(); //Get the name of the spell you want to learn from the item description ( it will be random).
lua_pop(L,3); //It was there at npc.cpp so we leave it
Creature* creature = player; // Mhm yes player
Item* ITEM_SCROLL = player->getItem(itemid); // Item and checking its id to make sure it is the item
Item->getDescription() = Spell we are going to learn
LearnSpell->Item->getDescription() = LearnSpell -> from Item -> Description
Player *player = creature? dynamic_cast<Player*>(creature) : NULL; // was in npc.cpp
if (player)
{
if (player->knowsSpell(words)) //words is the description^ atleast i think it is?
{
player->SendCancel("You know this spell already.");
}
else
{
player->learnSpell(words); //learn the spell
player->sendMagicEffect(player->pos, NM_ME_MAGIC_ENERGIE); //effect
player->sendCancel((std::string("To use it say: ") + std::string(words) + ".").c_str()); //send cancel in white above text chat?
}
}
return 0;
}
#endif __LearnSpellx__
and what could go wrong i mean it probably wont work i cant check but is there any other way I could do it? Its my first time trying to put more complex code in c++
ifdef __LearnSpellx__
int ActionScript::luaActionLearnSpell(lua_State *L){
//Learnspell(Spellname?)
int cid = (int)lua_tonumber(L, -3); //this is the creatureid of player i guess
const char* words = Item->getDescription(); //Get the name of the spell you want to learn from the item description ( it will be random).
lua_pop(L,3); //It was there at npc.cpp so we leave it
Creature* creature = player; // Mhm yes player
Item* ITEM_SCROLL = player->getItem(itemid); // Item and checking its id to make sure it is the item
Item->getDescription() = Spell we are going to learn
LearnSpell->Item->getDescription() = LearnSpell -> from Item -> Description
Player *player = creature? dynamic_cast<Player*>(creature) : NULL; // was in npc.cpp
if (player)
{
if (player->knowsSpell(words)) //words is the description^ atleast i think it is?
{
player->SendCancel("You know this spell already.");
}
else
{
player->learnSpell(words); //learn the spell
player->sendMagicEffect(player->pos, NM_ME_MAGIC_ENERGIE); //effect
player->sendCancel((std::string("To use it say: ") + std::string(words) + ".").c_str()); //send cancel in white above text chat?
}
}
return 0;
}
#endif __LearnSpellx__
and what could go wrong i mean it probably wont work i cant check but is there any other way I could do it? Its my first time trying to put more complex code in c++