The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: Grafikal on May 16, 2009, 02:21:24 AM

Title: [Resolved] Stealing, Math Help
Post by: Grafikal on May 16, 2009, 02:21:24 AM
So... I'm making an advanced Stealing Event system. I'm basically finished, I just need to find a suitable equation that the game should run through to determine if a player successfully steals from his target or not. I've downloaded several different Stealing Event systems and analyzed them all and not a single one of them holds up equally as efficient at a player's level 1 to a player's level 99. Each system I've looked at uses simple addition or subtraction to determine such things but I feel like that is totally not the way to go and that percentages will hold up a lot better. Now with this... I need help coming up with a suitable equation ._.

What I want it to be set on is a player's AGI vs enemy's AGI.

Please help ._.    
I'm going braindead
Title: Re: Stealing, Math Help
Post by: Falcon on May 16, 2009, 02:29:57 AM
I don't want to give you the formula, but you need three variables.

Average Party Agi
Average Enemy Agi

Determine how much greater(or less than) the player's agi is than the enemies'.

Throw in a random element, modify it based on the percent difference of the agi's, then see if it's greater than a constant.

Try something like that.
Title: Re: Stealing, Math Help
Post by: Grafikal on May 16, 2009, 02:56:10 AM
Yeah, I think I'll probably move along with using the Party's average AGI.

I don't think determining the Enemy Troop's average AGI is very efficient though. In VX you can have up to 8 enemies in a troop. In the event that the equation for determining an Enemy Troop's average AGI is EnemyAGI[1..8]/8 and you come across a troop with 8 enemies in it, then that is very accurate. However, if that's the equation, then what if you come across a troop with only 3 enemies in it? That's where the equation becomes screwy since 5 of the 8 enemy slots will be equal to 0, which I'm sure you know would significantly lower the outputted number for an average.

I could probably do something like making 8 different common events and having each one correspond to how many enemies are in a troop. So if there were 8 enemies in a troop, the 'steal' would call the common event pertaining to EnemyAGI[1..8]/8 whereas if there were 3 enemies in a troop, the 'steal' would then call the common event that pertains to EnemyAGI[1..3]/3.
My problem here then, is how do I get VX to recognize the difference between how many enemies are in a troop because VX conditionals don't check the number of enemies in a troop, but do check what enemy has appeared. (And I don't think using what enemies appear would work since there are infinite possibilities as to what combination of enemies you can have in a troop.)
Ideally, I'd like to have the skill 'Steal' call the common event that holds the conditional branches that check the number of enemies in a troop, then from there determine which new common event to call with the corresponding and correct equation in it.
Title: Re: Stealing, Math Help
Post by: Falcon on May 16, 2009, 03:07:07 AM
Wait, scrap that idea.

Instead of average, just use the actor's agi and the target's.
Title: Re: Stealing, Math Help
Post by: modern algebra on May 16, 2009, 03:11:41 AM
Well, since there is a target to this, why have average enemy troop rather than the enemy targetted?

However, as far as I know, there is no way to grab in an event what enemy is targetted without a script, so maybe average of troop is best if you intend to avoid scripting in a whole

I would suggest you have a battle event in every troop that calculates enemy agi as soon as the battle starts. It's not hard, since you will know how many enemies are in the party. Average it then, and merely calculate steal w.r.t. that.

As for a formula, it depends on how you want the skill to evolve, which I don't know.

The easiest way is to random a number from 100, and then check if that number is < (Player Agi - Enemy Agi)
Title: Re: Stealing, Math Help
Post by: Grafikal on May 16, 2009, 03:20:49 AM
Ah. I see. I think that calculating a troop's average AGI inside of each battle event would work fine. It's mostly just copy/paste stuff anyways asides from changing the one number that divides the average. Also that way, I can maintain the same variable for each battle.

As far as the skill evolving. It essentially evolves as the player levels and their AGI increases. I'm just going to have to run some numbers through a few equations and see which ones hold up best from level 1 to 99 since I don't want the skill to be overpowered at a higher level than it is at a lower level. I would like to maintain a similar chance throughout without setting what the chance is every time (like just setting it at 50% at letting it go). Then of course I plan on including several items or accessories that increase the chance to steal. But that'll be added after I figure out what I'm going to do about the math.

Thanks for your help guys. :)
Title: Re: Stealing, Math Help
Post by: Grafikal on May 16, 2009, 07:41:53 AM
I have another question. Is there a way to change the Game_Enemy script (around lines 154-156), into a variable of some sort that I can track in game?

I want to try and make the variable amount of gold you can steal from an enemy equal to a percentage of the total gold that the enemy wields after being defeated.

Those lines are here:
Code: [Select]
#--------------------------------------------------------------------------
  # * Get Gold
  #--------------------------------------------------------------------------
  def gold
    return enemy.gold
  end
Title: Re: Stealing, Math Help
Post by: Falcon on May 16, 2009, 04:11:45 PM
If VX works similiar to XP you can use a call script command and set an variable equal to the gold.

I can't help you there, since I don't have XP, I'm sure another scripter can give you the code.
Title: Re: Stealing, Math Help
Post by: modern algebra on May 16, 2009, 06:38:16 PM
Yeah,

Code: [Select]
$game_variables[x] = $game_troop.members[y].gold
Title: Re: Stealing, Math Help
Post by: Grafikal on May 16, 2009, 07:08:16 PM
Wait, so if I place what you wrote there, in a call script, then Y is going to equal what exactly? What gold is that. Is that the enemy troops combined gold that'll be won at the end of a battle?
Title: Re: Stealing, Math Help
Post by: Falcon on May 16, 2009, 07:11:32 PM
X is the variable number you want the target's gold stored in. Y is the target number.
Title: Re: Stealing, Math Help
Post by: Grafikal on May 16, 2009, 07:13:37 PM
Oh, the ID within the troop? Alright. That sounds easy enough then. Very cool. This also sets well within still being an event system as well. Thanks for your help again guys!
Title: Re: Stealing, Math Help
Post by: Grafikal on May 22, 2009, 08:25:24 AM
Hmm... I was thinking... How does VX know what enemy you're targeting?

... I'm just...going to throw this out there, but in a conditional branch, would it be possible to use the script command in the conditional branch to check if
Code: [Select]
$data_enemies[1] = (whatever actor's target is)
?

My point, is... if this is possible... to do this 8 times in 1 common event. Essentially checking what you're targeting. This way the stealing system actually functions on whatever your target is instead of some average of a troop.

Cause then if my little
Code: [Select]
$game_enemies[1] = blah
, is true, then I would script command
Code: [Select]
$game_enemies[1].agi = $game_variables[x]
and then use X as my point to start calculating for the steal. (or actually, der, i could just set a variable = enemy 1 in the troop's agi...)

If it's false then it would just move to the next conditional branch checking if data_enemies2 is targeted and so on.

*(hoping that it is possible)*
Title: Re: Stealing, Math Help
Post by: modern algebra on May 22, 2009, 05:15:24 PM
It stores target in the action. So maybe:
Code: [Select]
$game_party.members[x].action.target_index

would return what you want. I can't say for sure though without testing. I don't know when it's cleared or anything. To test it, in the CE just put:

Code: [Select]
p $game_party.members[x].action.target_index

And see if it returns correctly.

If it does, then you could use conditionals, but you'd have to put a double equal, so:

Code: [Select]
$game_party.members[x].action.target_index == 1

etc...
Title: Re: Stealing, Math Help
Post by: Grafikal on May 22, 2009, 05:21:42 PM
Ohhhhhhhhh snap. Awesome.

So
Code: [Select]
$game_party.members[x].action.target_index == 1
is checking if the the current actor's skill or attack is targeting enemy ID 1 in the troop? correct? Or is that X to determine the actor and the number 1 is equal to the enemy's index of actor ID X's target?

So to check if actor X is targeting enemy 2, it would be that == 2?

I'll have to check this asap before I leave for Athens in a couple hours ._.  

edit: Oh and what's that 'p' for? nvm

edit2: ok so I got to testing it. I received this error:
Spoiler for:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi41.tinypic.com%2F1zm12xw.jpg&hash=90db72cdbb5c65a6bc9a4fce6f9d672f81bbcd92)

I have this written in the condtional:
Code: [Select]
$game_party.members[1].action.target_index == 1

I get the same error when I test it alone with a common event here:
Code: [Select]
p $game_party.members[1].action.target_index

Title: Re: Stealing, Math Help
Post by: Grafikal on June 03, 2009, 12:24:48 AM
Quick bump :)
Title: Re: Stealing, Math Help
Post by: modern algebra on June 03, 2009, 01:20:26 AM
Well, the action has to exist. Which means you have to be taking an action and it has to be in battle. I can take aothe rlook at it sometime, but I don't remember getting an error when I first tried it out.
Title: Re: Stealing, Math Help
Post by: Grafikal on June 03, 2009, 01:40:39 AM
How would I set it up in a way that it is linked with an action? I just started a fresh project to check it out again.

I linked the first skill (Dual Attack) with a common event which has a script command with
Code: [Select]
p $game_party.members[1].action.target_index
in it.

The skill completes, damage is resolved, and then I get the same error.

Also to double check, I tried the conditional script inside of a conditional branch. It returned the same thing.

Am I using the script correctly by placing it in a common event and linking it with a skill?

Edit:: I attached the project, to show you how I have it. It's probably wrong  :-[
Title: Re: Stealing, Math Help
Post by: modern algebra on June 03, 2009, 01:46:35 AM
Yeah you would be, but I'm curious, how many actors are in your party?

The error is reporting that $game_party.members[1] is nil, which tells me you only have one actor in your party. That would cause the error. It should be $game_party.members[0]
Title: Re: Stealing, Math Help
Post by: Grafikal on June 03, 2009, 01:59:26 AM
Haha, wow. I forgot it starts with 0 ._.

Well I checked it out. At this point I don't get an error. I just get a message that returns '0'. I figure that's from using
Code: [Select]
p $game_party.members[1].action.target_index

I just tried out the conditional branch instead using
Code: [Select]
$game_party.members[0].action.target_index == 0

and

it

worked! :D

I'm not sure how I could make this up to you :)
Thanks for all your help. I'm positive that this topic ... is finally resolved ._. lol

Also, I take it that the enemy ID's would range from 0..7?
Title: Re: [Resolved] Stealing, Math Help
Post by: modern algebra on June 03, 2009, 02:24:27 AM
yes.