Tsukihime 1,489 Posted October 25, 2012 (edited) Effect: Set Variable -Tsukihime When you use an item or skill, you can perform an operation on a variable. Download Script: Download here Required: Effect Manager Usage Tag your item/skill with <eff: set_var id op value> Where`id` is the ID of the variable to set `val` is an operand `op` will operate on the selected variable using val: = assign val to variable ID + add val to variable ID - subtract val from variable ID * multiply variable ID with val / divide variable ID by val % mod variable ID by val ** raise variable ID to the power val << left shift by val >> right shift by val & bitwise AND ^ bitwise XOR | bitwise OR Edited March 3, 2016 by Tsukihime Share this post Link to post Share on other sites
Stefan 0 Posted November 12, 2012 Hi There, Would it be possible to link variable-effects on states/classes/actors? For example: <eff: set_var-guard (var_id) + 1> (if having state: increasing variable when getting damage) or: <eff: set_var-attack (var_id) = 1> (if beeing actor (actor id): set variable when attacking/using skill) Share this post Link to post Share on other sites
Tsukihime 1,489 Posted November 12, 2012 (edited) Yes, you just determine which object you want the effect to apply to, which trigger, and then alias the method. alias :state_effect_set_var_guard :effect_set_var alias :actor_effect_set_var_attack :effect_set_Var It would not be meaningful for me to have 40 triggers when you're only using one, for example. Edited November 12, 2012 by Tsukihime Share this post Link to post Share on other sites
Internetakias 1 Posted February 10, 2013 (edited) The script doesn't seem to work when the scope is set to none. Any chance of fixing that? Edited February 10, 2013 by Internetakias Share this post Link to post Share on other sites
Apellonyx 17 Posted March 27, 2013 I have a variable set up that will increase every time the player uses the attack skill. The problem, however, is that it also increases when an enemy uses the attack skill. I am aware that the script allows for conditions to be set up, but I'm not sure what syntax to use so the variable will only change when an actor uses the skill. Any ideas? PS: I've tried these already, and none of them work: <cond_eff: set_var if actor?> <cond_eff: set_var if user.actor?> <cond_eff: set_var if @battler.actor?> <cond_eff: set_var if user == $game_actors[0]> (Clearly, I'm not a scripter, because these are all just random ideas I got out of searching through the other scripts in my database.) Share this post Link to post Share on other sites
Tsukihime 1,489 Posted March 27, 2013 (edited) Try adding this line def effect_set_var(user, item, effect) return unless user.actor? # <--- id, op, value = effect.value1 if op == "=" $game_variables[id] = value else $game_variables[id] = $game_variables[id].send(op, value) end end Edited March 27, 2013 by Tsukihime Share this post Link to post Share on other sites
Apellonyx 17 Posted March 27, 2013 It worked! Ah, you rock. I had set up a skill damage formula that calculated damage with the variable in question, and the fact that it was being used by my enemies to strengthen MY attacks was just killing me, so this made it all better. Once again, you rock. Share this post Link to post Share on other sites
rpgmakers 0 Posted May 6, 2013 (edited) Hi Tsukihime, first of all I wanna say that this is the most useful script I've seen so far on this site. I am having a little problem though. I am trying to set the value of a variable through 2 weapons like this: Weapon1: <eff: set_var 2 = 1> Weapon2: <eff: set_var 2 = 2> So if I equip weapon1 the varible is 1. If I equip weapon2 the varible is 2. The problem is that the variable remains 2 allways, even if I equip weapon 1 again. The index of weapon2 is higher than the index of weapon1 if that has any importance. So do you have any idea what's causing this? Thanks. Edited May 6, 2013 by rpgmakers Share this post Link to post Share on other sites
rpgmakers 0 Posted May 6, 2013 Ok, so here is what I did and it works for me: In the Game_Battler class I added: def weapon_effect_set_var_unequip(obj, effect)end under: def weapon_effect_set_var_equip(obj, effect)id, op, value = effect.value1if op == "="$game_variables[id] = valueelse$game_variables[id] = $game_variables[id].send(op, value)endmsgbox_p($game_variables[id])end And then I changed: alias :weapon_effect_set_var_unequip :weapon_effect_set_var_equip with alias :weapon_effect_set_var_unequip :weapon_effect_set_var_unequip Please let me know if you see anything wrong in this. Thanks. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted May 6, 2013 Ya you're basically saying when you unequip something, don't do anything. Have you tried tagging it with this instead? <eff: set_var-equip 2 = 1> <eff: set_var-equip 2 = 2> This will tell it to run only when you equip it. Share this post Link to post Share on other sites
rpgmakers 0 Posted May 6, 2013 Yeah I tried but unfortunately it doesn't work for me. It doesn't matter anyway, it works the other way so... Thanks. Share this post Link to post Share on other sites
Komujeese 0 Posted June 14, 2015 I started a new threat about this, because previously I could not reply to this thread. I thought it had been closed or something, but I guess not. I apologize for the double post. Probably had something to do with the fact that I just registered this account today. I'm pretty much a newb when it comes to RPG Maker. I'm trying make use of Tsukihime's script Set Variable. But I don't know much scripting or programming. Basically I'd need to have a skill being used in battle be able to trigger an event or affect a variable. Something like when the actor uses Tickle, the variable increases by 1, which triggers an event where the enemy says: "Hihihi". When the variable raises to 2, the enemy goes "hohohoho". And so on. Can someone tell me how to do this? Share this post Link to post Share on other sites