I am trying to copy the properties of a skill to an item via script. I have managed to do almost everything correctly, but I don't know how to copy the effects of a skill to an item. For instance, I have item.meta = skill.meta, and it works. I have item.occasion = skill.occasion, and it works. However, I can't seem to get the effects (add states, parameter effects, etc) portion of the skill to copy over to the item. How do I do this properly?
MZ How do you copy a skill's effects to an item? (Solved)
Javascript/Plugin Supportcan you give more context on why and how you're doing this?
internally the engine handles all skills as items, so there should be no problem at all if done correctly.
but what are you copying to for example, because the database is read-only unless you do a lot of reprogramming.
and what do you want to achieve by doing this in javascript instead of just making the item in the database?
internally the engine handles all skills as items, so there should be no problem at all if done correctly.
but what are you copying to for example, because the database is read-only unless you do a lot of reprogramming.
and what do you want to achieve by doing this in javascript instead of just making the item in the database?
What I'm doing is creating a custom script to create scrolls. I have a lot of spells, and I want to create randomly generated scrolls out of them that add to the database as they get generated. Also, if I need to make changes to the spells down the road, I don't want to edit so many scrolls each time I make a change. Having one item that I can duplicate and then take the properties of the spell will save a lot more time if I do need to make changes to a lot of spells. I have everything working but the effects portion.
Wouldn't you do this by creating a common event and setting the effect to call that event? Maybe I'm missing something... A little clarification would be useful.
Edit after seeing your second post:
Yeah... For your spell and Scroll, create a common event.
You can actually store all effects in a single common event and use Label and jump to label to route the process to the correct event.
When casting a spell or using the scroll, a variable called "Efect" or whatever you want to call it would get set to the value of the effect you want.
In the common event, the first part is just a big conditional branch that checks the value of "Event" and then jumps to the label where the actual effect is processed. After the event processes, it jumps to a label called Finish, which sets "effect" to 0 and terminates the process.
As long as both the X spell and the Scroll of X are both setting the Effect variable to the same value and calling the custom event, then they should function th same. If you want to modify an effect, you need only edit the common event in the block where the effect is processed.
Edit 2:
Also, you may have to create the spell and the scroll or potion or whatever manually for each effect you want to assign. But once created, as long as they are setting Effect to the correct value, you'll never have to touch them again, as the modification to that single effect common event would carry over globally...
Edit after seeing your second post:
Yeah... For your spell and Scroll, create a common event.
You can actually store all effects in a single common event and use Label and jump to label to route the process to the correct event.
When casting a spell or using the scroll, a variable called "Efect" or whatever you want to call it would get set to the value of the effect you want.
In the common event, the first part is just a big conditional branch that checks the value of "Event" and then jumps to the label where the actual effect is processed. After the event processes, it jumps to a label called Finish, which sets "effect" to 0 and terminates the process.
As long as both the X spell and the Scroll of X are both setting the Effect variable to the same value and calling the custom event, then they should function th same. If you want to modify an effect, you need only edit the common event in the block where the effect is processed.
Edit 2:
Also, you may have to create the spell and the scroll or potion or whatever manually for each effect you want to assign. But once created, as long as they are setting Effect to the correct value, you'll never have to touch them again, as the modification to that single effect common event would carry over globally...
Why not just create a bunch of items with the skill info in them and have an event that randomly gives one to the party? no script needed
Items can do damage, apply negative states and target enemies
Items can do damage, apply negative states and target enemies
For further clarification. I have a custom individual item system, and the script I am making is also meant to work with my other script that randomly generates treasure and places them in shops and enemy drops. Each item is unique. Everything is working but the effects. I am not sure how to transfer them from skill to item via script.
Isn't it easier to make the scroll perform the skill bound to it, instead of becoming a copy? You should be able to do that without script or plug-ins, by triggering a common event that makes the user perform the skill on last target.
yes - the last suggestion above is a much better way to handle this.
I would create a variable on the item (probably the way of a self-variable plugin) and have that variable store the skill id. then either by item notetag with a appropiate plugin or by common event I would execute that skill with a force-action-script command.
no need to copy any data at all, just needs a way to store the skill id in the item created.
I would create a variable on the item (probably the way of a self-variable plugin) and have that variable store the skill id. then either by item notetag with a appropiate plugin or by common event I would execute that skill with a force-action-script command.
no need to copy any data at all, just needs a way to store the skill id in the item created.
No need for a plug-in to set the variable. You can set the variable in the damage formula, like this:
V[1] = 2 ; 0
The 0 at the end is needed so the item won't do damage to the target, other than the damage done by the skill.
I don't think this works when using a self-var plug-in. Since gameVariables.setValue(1, 2) would not work with self vars.
no, he can't
he wants to create a lot of these scrolls with different skills embedded in them, which means each scroll will need a different variable.
using general variables for that would require reserving several hundred ones...
a self-variable would come with its own function to set it
Nah, you can overwrite that variable with each use. As long as the variable is always the same for one scroll.
exactly that is the problem - he plans to make dozens or hundreds of scrolls dynamically, and that means your way needs dozens or hundreds of different variables
see
But the ID only needs to be remembered as long as the currently used scroll is active. As soon as the connected skill is cast, the ID is not important anymore and can be forgotten, so it shouldn't be a problem to overwrite that value when the next scroll is used.
He can use the same variable over and over, since each time right before the common event is triggered, the var will be set with the damage formula.
Only if they have blanco scrolls that need to remember skills, they would need a unique variable. But even then in stead of saving the ID in the variable, it would be much easier to simply replace the empty scroll with a pre-made scroll when a skill is saved into it.
He can use the same variable over and over, since each time right before the common event is triggered, the var will be set with the damage formula.
Only if they have blanco scrolls that need to remember skills, they would need a unique variable. But even then in stead of saving the ID in the variable, it would be much easier to simply replace the empty scroll with a pre-made scroll when a skill is saved into it.
which part of "he creates dozens of different scrolls" have you not read?
you cannot store two dozen id numbers into one variable AT THE SAME TIME.
your method would mean that he has to use the scroll before he can create a different scroll
but he clearly stated that he will create different scrolls that can then be stored for later use.
You don't need to store them all in the variable at the same time... You store them in the damage formula of the item, then, only wen the scroll is used, you put them in the variable.
The values do not need to be in the variable, unless the scroll is used. And, if the scroll just works like a skill, he can not use more than 1 scroll at the same time.
If he wants to create scrolls, in-game, it would be easier to replace the empty scroll with a pre-made scroll.
For example, when he has an empty scroll, and want to save Avada Kadavra in it, then instead of actually changing the blanco scroll, he just removes it from the inventory, and adds the Avada Kadavra scroll to the inventory in its place.
This means, he does not need to make plenty of variables, but he needs to make different items. Which he needs anyway, otherwise there is no way of telling which scroll has which skill saved into it.
I've done this kind of thing before, but not with scrolls, but with books. They don't trigger a skill, but read a story. The think both systems have in common is: They use the damage formula to save the ID in a variable before use.
Just to make sure, I have recreated it the whole thing, and it works like a charm. I didn't miss or misread any parts on how many scrolls they want. Even with a thousand unique scrolls, it will still work. He'd need a 1000 items, but only 1 variable.
The values do not need to be in the variable, unless the scroll is used. And, if the scroll just works like a skill, he can not use more than 1 scroll at the same time.
If he wants to create scrolls, in-game, it would be easier to replace the empty scroll with a pre-made scroll.
For example, when he has an empty scroll, and want to save Avada Kadavra in it, then instead of actually changing the blanco scroll, he just removes it from the inventory, and adds the Avada Kadavra scroll to the inventory in its place.
This means, he does not need to make plenty of variables, but he needs to make different items. Which he needs anyway, otherwise there is no way of telling which scroll has which skill saved into it.
I've done this kind of thing before, but not with scrolls, but with books. They don't trigger a skill, but read a story. The think both systems have in common is: They use the damage formula to save the ID in a variable before use.
Just to make sure, I have recreated it the whole thing, and it works like a charm. I didn't miss or misread any parts on how many scrolls they want. Even with a thousand unique scrolls, it will still work. He'd need a 1000 items, but only 1 variable.
I figured it out and was finally able to create the script to get the effects to copy from the skill to the item properly when it creates a clone of the original item and adds it into the database. Also, I just want to thank all of you for the suggestions.
Original thread: https://forums.rpgmakerweb.com/threads/how-do-you-copy-a-skills-effects-to-an-item-solved.146843/