Drug Addiction effect

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
In one of my games, I am trying to make an "addiction" effect for various drug items. If you use it a certain amount of times, it gives you an addiction which debuffs you until you get rid of the addiction or take more of the drug. I can do some of this with variables, but I don't know how to have the event always running without placing it on every single map (I would like it attached to characters if at all possible, but there doesn't seem to be an option for that), and I don't know anything about scripting. I also would like for the debuff state to affect whoever gets the addiction, instead of the current options for selecting specific party members. I hope this makes sense.
 

Ultim

Kartoffel.
Veteran
Joined
May 21, 2014
Messages
787
Reaction score
117
First Language
Arabic
Primarily Uses
The only way to do that(I think) is the one you mentioned.I'll see if I can help...
 

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
I would use a Common Event for that.

Set the Common Event to be a Parallel process, and tag it to a Switch, say, "Addicted"

I would have that Common Event add a debuff state to every addicted player.  Make sure the Event performs a Wait, for, say 60 turns so the Event does not hog the CPU.  

If the player successfully treats the addiction, turn off the Switch.

Also, if the State is set not to auto-remove (through damage/turns/steps), it should persist even in battle.  Technically, after an Inn, it wouldn't be there, but the Addiction would come back within a second (as soon as the Wait completed)

I use a Common Event for "being in very hot rooms damages all the PCs unless they are protected against heat"  It works in every map with no modification on my part.  I just set the "Hot Room" switch and the Common Event starts running.
 
Last edited by a moderator:

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
I would use a Common Event for that.

Set the Common Event to be a Parallel process, and tag it to a Switch, say, "Addicted"

I would have that Common Event add a debuff state to every addicted player.  Make sure the Event performs a Wait, for, say 60 turns so the Event does not hog the CPU.  

If the player successfully treats the addiction, turn off the Switch.

Also, if the State is set not to auto-remove (through damage/turns/steps), it should persist even in battle.  Technically, after an Inn, it wouldn't be there, but the Addiction would come back within a second (as soon as the Wait completed)

I use a Common Event for "being in very hot rooms damages all the PCs unless they are protected against heat"  It works in every map with no modification on my part.  I just set the "Hot Room" switch and the Common Event starts running.
So you don't have to have the event running on every map, just in the common event database? If that works, that would solve that problem. However, I do have another. How can the item add the state to the correct party member when the only option is to add to specific ones, not the one using the item (such as in a battle, or whatever).

EDIT: The common event in the database works, now if the other problem could be solved...
 
Last edited by a moderator:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
If you can explain exactly what rules you want to use for addiction and curing addiction (how many times does a character need to use the drug, what happens to the "addiction" variable once you take more of the drug to temporarily get rid of the addiction and how soon can it come back, how do you "get rid of the addiction", what kind of debuffs will be applied, etc.), then I can probably help you event or script this.

To answer your most recent question, items can add states to their target in the "Effects" box.  If the idea behind your question is that we don't know at this point whether the target character is "near addiction" or not, then what you can do is add a dummy state, and then run a common event which checks the "addiction level" variable for each character with that Dummy State applied and then applies the Addicted State to the character if appropriate (and then clears the Dummy States from all your characters).  I think Hime also has a script that stores the user or target of an item/skill into a variable, but I can't find it at the moment if it exists.
 

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
Basically, this is what would happen.

  1. Player/Party member uses drug on themselves. This adds +1 to the variable for addiction to that drug, and only applies to themselves.
  2. Player/Party member keeps using that drug, until the addiction variable reaches addiction (for instance, 3).
  3. Addiction State is added on Player/Party member, who then can get rid of it through continued drug use (let's say that when they take the drug they are addicted to, the state goes away for a period of time, and then is re-added by the variable which still exists on the Player/Party member. The only way they could permanently lose the addiction is by getting rid of the variables.)
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
There are reasons why it would be more convenient for you, in the long run, to add in an "Addiction" property (and perhaps a few other properties) to the Game_Actor class and work with that, but it would also require you to make a little use of Ruby code here and there.  So if you feel like you're comfortable working with Ruby, we could go that route.

But for now, here's what you'll need to do to event this system.  (I am assuming that each actor has a single "Addiction" level, and does not need to have addiction levels for each type of item (so that, for example, the Nectar item and the Powder item would both contribute to the same addiction level).  If you do need it separated by item type, you'll need to create the following logic for each type of item.)

  1. Create/designate the following in the database:
    • The actual Addicted state, which debuffs a character
    • A "dummy" state simply used to aid in Step #2; this state should have no actual gameplay effects
    • A variable for each party member that tracks their "addiction level"
    • A variable for each party member that tracks their "immunity time" from the withdrawl symptoms after taking another dose of the drug
    • A switch that tracks whether to run the Immunity Time event (see Step #4)
  2. Create a new Common Event "Addictive Item Use" (trigger: None).  In this common event, make a conditional branch for each Actor to check whether the Dummy State applied.  If an actor has the dummy state applied, then add 1 to their corresponding addiction level variable, then check whether this variable is equal to or greater than 3 (or however high it needs to be to cause Addiction).  If so, remove the Addicted state from that actor (unintuitive, I know - but just do it), display a message "Actor has become Addicted" if the variable is exactly 3), set the appropriate Immunity Time variable to the desired amount (I'll use 10 as an example), and turn ON the Immunity Timer switch (I'll use Switch #9 as an example). 
  3. Find all items in your database that are Addictive.  In the Effects box, add the following two Effects:
    • Add State: Dummy State (999%)
    • Common Event: "Addictive Item Use"
  4. Make a second new Common Event "Addiction Immunity Timer" (trigger: Parallel, Switch #9).  In this common event, wait for a period of time (for example, 1200 frames would be 20 seconds), then decrease each actor's Immunity Time variable by 1.  Then, check whether each actor's Addiction Level variable is equal to or greater than 3; if so, check whether that actor's corresponding Immunity Time variable is less than or equal to 0 - if so, apply the Addicted state to that actor.
    • Once you've done this for all actors, I recommend (it's optional, but it will save a lot of processing power) checking to see whether ANY actors have Immunity Time greater than or equal to 1 (if you can't script this, then you can do it by nesting a bunch of conditional branches inside the "Else" part of the branch), and if no actors have Immunity Time >= 1, then turn off Switch #9 because this event won't need to run again until someone takes another addictive item.
  5. For events that completely remove Addiction from an actor, I recommend setting their Immunity Time variable to 0 as well as their Addiction Level.  For events that lower an actor's Addiction Level, simply include a check at the end of the event for each actor's Addiction Level - if it's less than 3, remove the Addicted State from that actor and set the corresponding Immunity Time back to 0.
I think that should give you everything you need.  Basically, what this whole setup is doing is having the item mark whoever it was used on (using the Dummy State), then increasing that actor's addiction level and setting up a "countdown" to experiencing the effects of Addiction, if the addiction level is high enough.  Once the countdown ends for an actor, the temporary "no withdrawl" period is over and they experience the ill effects of Addiction.  Despite the fact that a single event controls the countdown, it can separately check each actor's appropriate variables to determine whether to apply the Addiction state.

Let me know if you have trouble making any of this work in your game.
 

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
I followed your instructions, but for some reason it doesn't seem to be working. Here is some screenshots of the common events.

Addiction Event:

Addiction Timer:

 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
You've got some of the right structure down, but there are a few mistakes that I see with your eventing.

1) In the first event, you are setting the Addiction Level variables to 1 if a dummy state is applied - you need to increment them by 1 instead.  Because you keep setting them to 1, they can never be greater than or equal to 3 so the real Addicted state is never applied.

2) You're doing something weird with a "Drug Addiction Time" variable.  The two sets of variables you need are a set of Addiction Level Variables, one for each actor (which you have created properly)... and a set of Immunity Time variables, one for each actor (which you have not created).  I can't think of any reason you would want a global Addiction Time variable.

3) Do not decrease the Addiction Levels at the beginning of the second event, unless you decided that want an actor's susceptibility to becoming addicted to decay over time.  What you need to decrease in this part of the event are the Immunity Time variables for each actor.

4) In the first event, you are increasing the "Drug Addiction Time" variable by 8.  What you need to do is either set the actor's Immunity Time variable to 8, or increase it by 8 if you prefer.  I recommend setting it to 8, so you can't take six drugs at a time to get an ultra-long period of immunity, but if you want to allow this, I don't think it will be a problem.

5) Whichever method you choose in #4, you need to do it whenever the Addiction Level is greater than OR equal to 3, along with setting the switch to ON.  The only thing that should be different between > 3 and = 3 is the message.

6) In the second event, do not nest checks within "Else" branches.  It is entirely possible that two characters' immunity will wear off at the same time, and they should both become Addicted in that same 20-second cycle.  Allow your event to check each character's status regardless of what it did with the previous character.

Give it one more try and correct your events according to the above, and if that doesn't work, give me screenshots of your new events and I'll write out the event here if necessary.
 

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
I seem to have gotten the first event to work, but the second one where the addiction is supposed to be applied doesn't apply it.
Addiction Event:

 
Addiction Timer:
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Your events looks good at first blush, except for one thing I forgot to mention originally - you should be removing the Dummy State for all actors at the end of the first Common Event.  I don't think this is what caused the problem you're seeing, though.  Just answer these for me and if they don't seem like the reason for your troubles, I'll event it myself in Ace to see whether I'm doing anything wrong.

1) Have you tried waiting 4-5 minutes after using the third Addiction item on an actor?  The way you have it set up, it will take over 3 minutes for the Addiction to set in.  You can also reduce the Wait frames from 1200 to a smaller number like 20 for testing, so that you don't need to wait so long.

2) Are you using any scripts that modify the way that events work?
 

cthulhusquid

Veteran
Veteran
Joined
Aug 19, 2013
Messages
341
Reaction score
294
First Language
English
Primarily Uses
RMVXA
Everything seems to work now, but one last question. How long does each frame last in the game, so I can fine tune the timing properly? Is it 60 seconds real time, or something else entirely?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Good, I'm very glad it works!  Just remember to take away the Dummy States at the end of the first event (not doing so would allow the addicton levels from one actor's drug use to "spread" to others).

Most things are 60 frames per second (FPS), as long as everything is running smoothly.  When the game lags, it processes fewer frames per second - both from a graphical and gameplay sense, I think.  So while 1200 frames is normally 20 seconds, a really slow computer (or a game where tons and tons of events are processing at once) might take 25 or 30 seconds to run it.  You can check your current FPS by pressing F2 while playing the game.

Animations are run at 15 FPS instead of 60, for some reason.  But most event commands that use frames (like the Wait you used here, or the Tint Screen event command) are 60 as long as there's no lag.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top