Howdy! 👋
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! 🙏
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 %?
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. 😛 Having a configurable max for both might not be a bad idea, though.
I see.. Im working on something, though I cant finish it anytime soon as Im at work. xD
Ah, no problem. Thank you for picking up my request! 😊
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.
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. 😛
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.
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
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 😊
So you have items that isn't consumed when used? I'll add a check for that when I get the time.
There's a few, yeah. Completely forgot about seeing how to the would interact until I triggered it be chance while playtesting. 😅 Sorry about that.
No rush though, whenever you have the time is perfectly fine.
Everything seems to be working perfectly! Thank you for all your help! 🙏