Jump to content


Photo

Set Variable

effect

  • Please log in to reply
11 replies to this topic

#1 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 24 October 2012 - 08:04 PM

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 by Tsukihime, 03 March 2016 - 03:22 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#2 Stefan

Stefan

    Advanced Member

  • Member
  • 37 posts

Posted 12 November 2012 - 04:47 PM

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)

#3 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 12 November 2012 - 05:47 PM

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 by Tsukihime, 12 November 2012 - 05:47 PM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#4 Internetakias

Internetakias

    Member

  • Member
  • 18 posts

Posted 10 February 2013 - 12:12 AM

The script doesn't seem to work when the scope is set to none. Any chance of fixing that?


Edited by Internetakias, 10 February 2013 - 12:12 AM.


#5 Apellonyx

Apellonyx

    Random New Guy

  • Member
  • 33 posts
  • LocationUnder Your Bed
  • RM Skill - Designer

Posted 27 March 2013 - 04:58 AM

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.)


Spoiler

#6 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 27 March 2013 - 05:16 AM

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 by Tsukihime, 27 March 2013 - 05:17 AM.

All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#7 Apellonyx

Apellonyx

    Random New Guy

  • Member
  • 33 posts
  • LocationUnder Your Bed
  • RM Skill - Designer

Posted 27 March 2013 - 04:24 PM

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.


Spoiler

#8 rpgmakers

rpgmakers

    Member

  • Member
  • 26 posts

Posted 06 May 2013 - 06:56 AM

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 by rpgmakers, 06 May 2013 - 07:15 AM.


#9 rpgmakers

rpgmakers

    Member

  • Member
  • 26 posts

Posted 06 May 2013 - 08:29 AM

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.value1
if op == "="
$game_variables[id] = value
else
$game_variables[id] = $game_variables[id].send(op, value)
end
msgbox_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.



#10 Tsukihime

Tsukihime

    Advanced Member

  • Member
  • 7120 posts
  • LocationToronto
  • RM Skill - Coder

Awards Bar:

Users Awards

Posted 06 May 2013 - 09:41 AM

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.
All of my work can be found on my website:

banner200x40.png

You can follow me on any of these platforms:

logo_facebook40x40.pnglogo_twitter40x40.pnglogo_youtube40x40.pnglogo_patreon40x40.pnglogo_instagram40x40.png

Go here for Bugs and Requests.
 
Want to become a beta tester for my plugins before they are released to the public?

#11 rpgmakers

rpgmakers

    Member

  • Member
  • 26 posts

Posted 06 May 2013 - 12:08 PM

Yeah I tried but unfortunately it doesn't work for me.

It doesn't matter anyway, it works the other way so...

Thanks.



#12 Komujeese

Komujeese

    Newbie

  • Member
  • 2 posts

Posted 14 June 2015 - 07:05 AM

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?







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users