Forum > Serverside Modding

[TRINITY] Spells Scale from Level

(1/2) > >>

Phabulous:
Ello Modcraft,

If anyone would be so kind as to help me, I'm trying my darndest to enable players to learn spells Cata-style, in that they learn a spell once and it scales as they level.
I think I MIGHT be able to retro-fit something like this from Skyfire to work, but my skills in C++ don't extend past modest boss encounters.

Could anyone assist me or point me to someone who could?

Laniax:
I think, from a realistic point of view, your best of to let players auto-learn spellranks.

Example:

Warrior level 50 learns mortal strike, and on level 53, the second rank of mortal strike is available. Normally the player would need to visit his/her class trainer to get this second rank, but you could teach it automatically on level-up.

Do your research, check how functions like Player::giveLevel work and Player::addSpell

Phabulous:
I haven't been able to find a pointer to check if a player has already learned a rank of a spell. I can add Mortal Strike to a warrior who reaches an appropriate level, but I haven't figured out how to check if the previous rank of a spell has already been learned before auto-learning the next rank. I appreciate the help but I'd also appreciate another nudge.

Laniax:

--- Quote from: "Phabulous" ---I haven't been able to find a pointer to check if a player has already learned a rank of a spell. I can add Mortal Strike to a warrior who reaches an appropriate level, but I haven't figured out how to check if the previous rank of a spell has already been learned before auto-learning the next rank. I appreciate the help but I'd also appreciate another nudge.
--- End quote ---

Create a pointer to a unit which is a trainer that will be used to get the available spells from. So my advice is to make a global trainer which can learn every spell and create a Unit* pointer to him.

Then you can use unit->GetTrainerSpells() to get all the spells he learns, and then in a for loop you can check if each spell is available to be learned by player->GetTrainerSpellState.

Something like:


--- Code: ---
TrainerSpellData const& trainer_spells = unit->GetTrainerSpells();

for (TrainerSpellMap::const_iterator itr = trainer_spells.spellList.begin(); itr != trainer_spells.spellList.end(); ++itr)
{

// spell not found, cheat?
TrainerSpell const* trainer_spell = trainer_spells->Find(itr->first);
if (!trainer_spell)
return;

// learn nothing else then spells that are green(available) at the trainer.
if (_player->GetTrainerSpellState(trainer_spell) != TRAINER_SPELL_GREEN)
return;

 // then if thats good u can learn the spell here
}

--- End code ---

I only wrote this out of the top of my head, without an IDE so beware for errors, its just for pointing in the right direction.

schlumpf:
You may as well have a look at Player::GetTrainerSpellState(trainer_spell). That will look somewhere in Player, where you already are, if a spell is available. Therefore, there needs to be information inside of Player, if a spell is learnable. You shouldn't need to have a virtual trainer for doing this, being only indirection from Player to Trainer to Player.

Navigation

[0] Message Index

[#] Next page

Go to full version