Refund Item Price when Used

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Howdy! :kaohi:

I'm hoping to create a fun (and hopefully pretty simple) little perk for a merchant character.

What I'm hoping to create is a script that, when the actor has a certain notetag, refunds them a percentage of an item's cost whenever they use an item. Something along the lines of <refund(x,y)> where X is the percentage of the price to refund, and Y is the chance for the refund to happen. So someone with the tag <refund(30,50)> would have a 50% chance to refund 30% of an item's cost upon use.

For future-proof sake (and for anyone else that may want to use this script), having the tag work on actor/class/weapon/armor/state(?) would be really nice. It'd be pretty cool if this could have a message in the battle log too, if that isn't too difficult.

Hopefully that all makes sense. If there's anything you'd like me to clarify or elaborate on, please make sure to ask.

Thank you! :kaothx:
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Sounds interesting, have a question though, how will the effects stack?

Like if I have these:

Actor: Refund 30,50
State: Refund 40,30

Does the chances get simply added? How about the refund %?
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Huh, hadn't thought of that.

I'd imagine it would be easiest to understand for players if both values stacked additively. So for your example, it the two notetags would add up to a 80% chance to refund 70% of the cost.

With that said, it should probably cap at 100 for both. Otherwise, you could get to the point where you can buy an expensive potion, and actually make money off of using it. :p Having a configurable max for both might not be a bad idea, though.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I see.. Im working on something, though I cant finish it anytime soon as Im at work. xD
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Here is the script:
Take note though that it shows the refund message in the battlelog before the message for the actual effect of the item.
Code:
So it looks like this:

Actor Uses Item
Refund Message
Item Effect
I wanted to minimize how many methods I alias so I just kept it at that xD

The refund message is skipped if the refund value is 0

Also, I dont know how this goes when it comes to compatibility because its only tested on a blank project. Though since I only aliased 1 method, this should work fine as long as its not above a script that overwrites that method. For safest bet, put it below all other scripts.
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
@Engr. Adiktuzmiko just a heads up, instead of using nested if, you can actually just use "feature_objects". It includes all the relevant data like actors, classes, equips, states, together.

Edit:
Also, this is just a wild guess, but are u sure it won't be refunded more than once if the scope of the item is area? or at least have repeat more than once?
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Ooh I see.. I'm practically used to defining each of the objects individually now, I'll probably try that next time xD

It might be refunded more than once for AoE items, didn't test it but since the current one is hooked to item_apply, it will probably run per target/repeat. Most items in my games were single target potions so I never really thinked about how it goes for aoe items or those with repeat.

Cant test/fix it right now though, maybe tomorrow.
 
Last edited:

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Awesome! I tried it out in both a blank project, and my actual project, and things seem to be working great, with the exception of multi-target items. Like you both theorized, so long as the actor with the tag used the item, it will trigger the refund for each target. :p

On the bright side though, the inverse doesn't seem to be the case. An actor without the tag targeting an ally with the tag doesn't falsely trigger the refund.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I just updated the script, it now hooks on use_item so it now works only once per item use instead of per target/repeat.

I also shortened it with Theo's suggestion.

So far no problems in my multi-use item test.

PS: Your enemies can't use items right? Coz if they do and they have the tag, it would add the refund to the party xD
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Sorry that it took so long to get back to you, been away from the PC for a few days.

Tested it out, and the multi-target refund seems to work properly now! I did find one other thing that should probably be addressed, though. Any items that can be used, but not consumed, can still trigger a refund. Not a huge deal, but something I thought I should bring up.

Also, while I don't have any enemies that use items, that's a good thing to keep in mind. Would look a bit silly :kaoblush:
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I did find one other thing that should probably be addressed, though. Any items that can be used, but not consumed, can still trigger a refund. Not a huge deal, but something I thought I should bring up.
The script may not handle such case, but that is the developer's responsibility to not use it. It's not technically broken.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
So you have items that isn't consumed when used? I'll add a check for that when I get the time.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
There's a few, yeah. Completely forgot about seeing how to the would interact until I triggered it be chance while playtesting. :kaoswt: Sorry about that.

No rush though, whenever you have the time is perfectly fine.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I updated the script to not include non-consumables.

@TheoAllen - the problem is that since the refund tags can be used in actors, classes etc there can easily exist a situation where you have a refund tag active and a non-consumable item that the developer cannot really avoid unless he avoid using non-consumables at all.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Everything seems to be working perfectly! Thank you for all your help! :kaothx:
 

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