# Recover Mp = Variable (x) + item bonus to var (y)

#### Nol

##### Veteran
I'd like to limit Mp regen in my world, by making it so that Mages only regenerate when sleeping, and 10% of their Mmp + (bonus from a stat) + (bonus from items)

I envision creating a variable :

Var 1 = Bonus from stat of Actor 1

Var 2 = Bonus from equipement of actor 1

Var 3 = Var 1 + Var 2 + 10% Mmp

Regen MP : Add Var 3

Etc for each actor, (probably the long and painfull way, but if it works...)

but i dont know how i could give items a bonus to a variable, while having this bonus be lost if said item is unequiped.

Also... Is there another more elegant way to do this ?

Nol

#### Andar

##### Veteran
Since that sleep is an event, you can simply set the regular MP regeneration to zero outside that event and give a calculated number of MP when the event is processed.

The only problem is the time of the equipped parts - it is simple if you only check what is equipped when the event is processed, but that would allow the player to use different equipment during day and only equip the special bonus item when planning to sleep. That way the equipment doesn't give a direct bonus but is checked and gives a bonus by the event.

It is possible to count the time the player has the items equipped when not sleeping, but that would require a bit more on mathematics and the use of a carefully designed parallel process.

#### Nol

##### Veteran
Since that sleep is an event, you can simply set the regular MP regeneration to zero outside that event and give a calculated number of MP when the event is processed.

Indeed my reasoning so far, the calculation is the part that has me thinking still ;

The only problem is the time of the equipped parts - it is simple if you only check what is equipped when the event is processed, but that would allow the player to use different equipment during day and only equip the special bonus item when planning to sleep. That way the equipment doesn't give a direct bonus but is checked and gives a bonus by the event.

Spoken like a true Munchkin lol

I'm tempted to let this one slide, the game is not an easy "hold my hand" type, but while that way of abusing the system wouldn't hurt it much, it does have some Lore-related problems..

It is possible to count the time the player has the items equipped when not sleeping, but that would require a bit more on mathematics and the use of a carefully designed parallel process.

In the home made table top game this project is derived from, it take 24h (or a sleep cycle) for an items effect to come into action ; but that feels impossible to replicate here, doesn't it ?

Do you know by any chance how i can add a variable modification to an item, and if said modification will, by default be linked to the equipped state ?

#### Andar

##### Veteran

Do you know by any chance how i can add a variable modification to an item, and if said modification will, by default be linked to the equipped state ?

You can't link a variable to an equipped item (or any other passive object) directly, that's why I said you'll need a parallel process. And while parallel processes can cause problems when used without thinking, they are in the engine for a reason - because sometimes you need them.

What you need to do is a combination of two parallel processes - one to create time, because without a time process the game has no time.

And the second parallel process needs to check everything that needs time to take action, counting the time cycles the equipment is worn and comparing it to the conditions for the effects. That is the process that needs to be written carefully, because you need one process checking everything (it would be very bad to have different parallel processes checking different items as that will cause confusion).

#### Nol

##### Veteran
The only problem is the time of the equipped parts - it is simple if you only check what is equipped when the event is processed

Oh i thought that meant there was a "simple way" of doing it ?

Did you mean conditional checks by naming all the Mp regen items, and checking for their presence or not ?

I'm not up to the task of parralel processes yet, it feels daunting to someone who doesnt have the syntax for most basic damage formulas

#### Andar

##### Veteran
yes, if you ignore the time just use a conditional branch for checking which items are equipped, and add a bonus based on that.

That way is simple, but not short - you still need one conditional branch for each item and each actor.

Anything else requires a plugin or a combination of script commands.

#### Nol

##### Veteran
Yeah that's impossible, with over 300 anticipated items, even if only 1/5 give a bonus, and with 30 actors... it's my life that will be conditionnal ^^

What about a stacking state added by the item ? and said state using a script line to add a Var ?

My worry is that those wont be removed with the item

#### Andar

##### Veteran
no, in such a case you should either ask for a small plugin handling that directly or look for a way to gain the same effect from existing plugins.

One possibility that comes to mind is using a passive state plugin. Those plugins activate states on notetags, and those notetags can (depending on the plugin) be placed on equipment. This is what you could try with such a plugin:

make your equipments give states to the actors, and have those states do nothing (and no icen etc).

Then in the event you only need to check the actors for states, and it doesn't matter from which item the states come.

Still a lot of work on eventing, and has the problem that each state can only be there once on the actor.

Another option is a plugin that runs a common event on equip - in that case the common event can count up or down the variable.

Again an indirect way, but possible.

A third way is requiring a bit of scripting knowledge: you can use the meta function (see help file) to access the tags you write yourself, and use a small script to add the values of the tags in your equipment. That might be the best option, but I don't know how the meta function handles several notetags of the same type, you'll probably need help writing that scripted loop.

#### Nol

##### Veteran
I've asked for too many plugins already ; The State workaround is something that speaks to me, so i'll head that way for now, and possibily change it later when i understand more about coding.

As usual, this was very helpful, thank you.

### Latest Profile Posts

At work.
Co: "This bug drove me insane. I tried a lot of things to debug, it just stuck".
Me: "How did you debug it?"
Co: *shows a complicated debugging method using breakpoints and everything*
Me: "What about ... " *casually prints a stack trace in the try/catch exception
Co: "Wait, you can do that??"
Totally original and unique OC
So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

I can't stop buying resource packs I'll never use, or engines for that matter, or free resources as my two terabyte external will attest. I am a digital hoarder I guess. Some people get drunk off the silly juice when they are bored, I just buy shiny digital nonsense I don't need.