EOSERV Forum > Programming > Stackable Buffs Turorial! o.o
Topic is locked.
Page: << 1 >>
Stackable Buffs Turorial! o.o
Author Message
Post #163889 Stackable Buffs Turorial! o.o

This here is an attempt to make a tutorial on how to add stackable stat buffs to your server code. Hope you like it. ;o


-First, we need to go to Character.hpp and find:

class Character : public Command_Source


-Put this above it:


struct Character_StatBuff

{

    std::string label;

    int time;

    short str;

    short intl;

    short wis;

    short agi;

    short con;

    short cha;

};


-Now we need to put something in the class. Find this:

class Character : public Command_Source

{

public:


-Put these anywhere under it (I like to keep my variables and prototypes seperate, but it doesn't matter):


std::list<Character_StatBuff *> statbuffs;


void UpdateStats();

bool Buff(std::string statname, int amount, int time, std::string label = "default");

void ClearBuffsLabeled(std::string label = "default");

void RemoveBuff(Character_StatBuff *thebuff);

void ClearBuffs();


-Ok, lets head off to character.cpp and find:

void Character::CalculateStats()


-Replace the entire function (assuming you know what a function is. o.o) with this:

https://tehsausage.com/paste/the-new-calculatestats-ryouken


-Now put all this junk above the function we just replaced:

https://tehsausage.com/paste/functions-and-such-ryouken


-Allright, lets go to world.cpp and find:

event = new TimeEvent(world_act_npcs, this, 0.05, Timer::FOREVER);

this->timer.Register(event);


-Put this below it:

event = new TimeEvent(world_timers, this, 1.0, Timer::FOREVER);

    this->timer.Register(event);


-Now for the last part, find:

void world_npc_recover(void *world_void)


-Put this above it:

https://tehsausage.com/paste/the-timer-o-ryouken



Thats all you have to do for the buff part. What you want to activate the buff is entirely up to you.

To activate a buff on a character, you simply put this line on code under whatever activates it:

character->Buff(<name of the stat|stats>, <amount>, <time>, <label string>);


The label is an optional thing you can put on the buff to identify it by incase you want to remove it later using this code:

character->ClearBuffsLabeled(<label string>);


Or if you just want to remove all buffs on the character, use this:

character->ClearBuffs();


The character pointer(character->) name varies depending on what function its in obviously, so it could be: from-> or this-> and sometimes other names.


Anyways, I'm sure this tutorial confused people more than helped them. ;.; But thats why I'm here to answer any questions. Please tell me if this works or not, because I had to remove a lot of stuff that my server uses from here, that way it wouldn't be cluttered. Also I may of missed a few thing. I'm pretty sure I got it all, but just incase. o.o

11 years, 35 weeks ago
Post #163924 Re: Stackable Buffs Turorial! o.o

Very nice tutorial +1

11 years, 35 weeks ago
Post #166450 Re: Stackable Buffs Turorial! o.o


okay i think i understand some of this, im just not sure what else needs to be done. xd

bool buffspell(x);
void clearbuffslabeled(x);
void clearbuffs(x);

x=spell id/buffid

that goes in character->public Command_Source?

(I get that i have to use different x values for each buff etc, just not writing everything out now.)

---
Hail Satan!
11 years, 31 weeks ago
Post #166456 Re: Stackable Buffs Turorial! o.o

I'm confused, o.o what have you added so far? I'm not sure what you're having trouble with. ;o

11 years, 31 weeks ago
Post #166457 Re: Stackable Buffs Turorial! o.o

I'm not, I dont even have eoserv downloaded, I'm asking you if I'm interpreting everything correctly.

---
Hail Satan!
11 years, 31 weeks ago
Page: << 1 >>
Topic is locked.
EOSERV Forum > Programming > Stackable Buffs Turorial! o.o