Jump to content


Photo

D20 Custom Hit Formula

d20 d&d custom to hit

  • This topic is locked This topic is locked
22 replies to this topic

#1 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 25 January 2013 - 10:26 AM

Hi! I'm new to the RPM scene and I'm having some trouble getting my formulae to work the way I want, and I was hoping for some help.
 
I'm currently using the Victor's Custom Hit Formula and N.A.S.T.Y. Extra Stats scripts, and I'm trying to recreate a formula that emulates a Dungeons and Dragons attack roll.

Spoiler



I've been trying to emulate this by incorporating AC as new stat via the N.A.S.T.Y. Extra Stats scrips and then using a formula like <hit formula> rand(20) + a.atk > b.xstats.ac </hit formula>, but I'll be the first to admit that my knowledge of Ruby scripting and formulae is woefully inadequate, and I can't seem to find information specifically about how to write formulae properly. Any help on coming up with a script that will do this (or better yet, a formula that will work with the scripts I have) would be GREATLY appreciated.
 
Thank you all for your time, consideration, and aid!



#2 ekomega

ekomega

    Advanced Member

  • Ace Member
  • 268 posts

Posted 25 January 2013 - 04:37 PM

With victor's custom hit and the extra stats, I'd put this in his tags, and maybe change it to

 

 <hit formula>

1+rand(20) +a.atk >= b.xstats.ac

</hit formula>

 

I'm not sure how exactly the syntax works out with that, but it should return true (hit) if the equation is valid, otherwise, it returns false (miss).  Then your damage in the normal skill damage box would be 1+rand(6) or whatever.

 

 

Why not just use the normal defense stat as AC, and ignore extra stats?  Then it would just be:

 

<hit formula>

1+rand(20) +a.atk >= b.def

</hit formula>

 

And you're a.atk should be reasonable, like 1-20 (like DnD).


Edited by ekomega, 25 January 2013 - 04:43 PM.


#3 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 26 January 2013 - 12:55 AM

Thanks! Is the extra 1 in

 

 

<hit formula>

1+rand(20) +a.atk >= b.def

</hit formula>

 

necessary? Sorry if that seems like a silly question, just not sure why it needs to be there. So if I wanted to also include an element based on character level, would I do

 

<hit formula>

1+rand(20) +a.atk +a.level >= b.def

</hit formula>

 

? Also, do I need to add an extra section to Victor's script to accomodate that formula? The scripting itself is fairly well gibberish to me, but if that's what I need to do then I'd like to learn how. Thanks again!



#4 ekomega

ekomega

    Advanced Member

  • Ace Member
  • 268 posts

Posted 26 January 2013 - 01:38 AM

I don't think you need to add anything to Victor's script.  It specifically allows this notetag to happen.

 

This works fine:

<hit formula>

1+rand(20) +a.atk +a.level >= b.def

</hit formula>

 

rand(20) generates a number from 0 to 19.  So 1+rand(20) generates a number from 1 to 20, which more accurately approximates DnD.

 

Test it out and let me know if there's any problems.



#5 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 26 January 2013 - 05:10 AM

I'm not sure how exactly the syntax works out with that, but it should return true (hit) if the equation is valid, otherwise, it returns false (miss).

Nop, it returns true for miss, and false for hit.

The maker don't checks for hits, it checks for misses.

 

The formulas posted works, if it don't work it's a issue with this custom stat script you're using that don't return the value correctly.


Edited by Victor Sant, 26 January 2013 - 05:14 AM.

Posted Image


#6 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 26 January 2013 - 01:22 PM

Fantastic! I removed the extra stats script and the formula worked perfectly  :)  Alright, last question: I would also like to mimic the way that certain spells in D&D operate off of a saving throw by the defender. If I'm understanding this correctly, the formula for the skill should look something like:

 

<hit formula>

10 +a.mat >= 1 +rand(20) +b.mdf +b.level *.07
</hit formula>

 

In addition, would it be possible to set things up so that the subject took half of the damage of the spell even on a miss?

 

Thanks again for the help, this will move my game forward nicely!



#7 ekomega

ekomega

    Advanced Member

  • Ace Member
  • 268 posts

Posted 26 January 2013 - 02:06 PM

Your hit formula for a spell looks reasonable, but I'm assuming the b.level*.07 is some level-based saving throw increase.  The one problem that I can foresee there is I'm not sure if b.def, b.level, or a.mat, etc., is an integer or a float.  If they're integers, which I think they are, your b.level*.07 part is a float, and that is going to produce problematic results.  You can't just convert the float to an integer, because with the numbers you're using, b.level*.07 will just be 0.

 

For the half damage miss, you'd have to put

 

if $variable == false (damage formula) else 0.5*(damage formula)

 

The $variable would be the one Victor uses in the hit formula script that holds the true/false value for hit/miss.



#8 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 26 January 2013 - 04:14 PM

Unfortunate about not being able to multiply the level, that would have been nice for rogue and caster attack progression.

 

Also unfortunately, I did one test battle where it worked, and now it doesn't again. I removed the extra stats script, haven't added any new ones, and copied the formula directly from the post into the actor's notes section. If it would be helpful, I can post some screenshots of what my classes/database entires look like . . . Sorry for the additional trouble!



And by "not working", I mean that everyone in the battle misses with every attack. Four party members and three enemies, and they all just miss over and over again. I also tested this by lowering everything's defense so the formula was effectively

 

<hit_formula>

1+rand(20) +a.atk <= 1

</hit_formula>

 

and everything still missed, so it's not just a random number issue.



#9 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 26 January 2013 - 07:10 PM

<hit_formula>
1+rand(20) +a.atk <= 1
</hit_formula>
this formula will never work.
you formula says "if (atk + rand(20) + 1) is lower than 1" wich is impossible to happen.
 
you must use the "higher than" sign (>=) not the "lower than" (<=)

Edited by Victor Sant, 27 January 2013 - 07:53 AM.

Posted Image


#10 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 27 January 2013 - 01:41 AM

Darn butterfingers. I wrote the formula correctly in the program, just hit the wrong button in the post.

 

<hit_formula>

1+rand(20) +a.atk >= 1

</hit_formula>

 

is what I did in the game, and everyone still missed.



#11 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 27 January 2013 - 07:50 AM

did you use this exactly this tag? <hit_formula>? or you just typed it wrong here?

the tag is <hit formula> with white space, not underline.


Posted Image


#12 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 27 January 2013 - 09:18 AM

Just typed it wrong . . . again . . . My deepest apologies for wasting your time with not one, but TWO incorrect posts :-( The exact formula that my battlers are using is:

 

<hit formula>
1+rand(20) +a.atk +a.level >= b.def
</hit formula>

 

Copied from my notetag, which was copied from ekomega's response. All of my battlers have attack scores of 2 or 3, are at level 4, and defense around 15. It makes sense that they should be missing about 50% of the time. Just not every single attack.



#13 ekomega

ekomega

    Advanced Member

  • Ace Member
  • 268 posts

Posted 27 January 2013 - 01:39 PM

The RNG in VX Ace is not that great.  Using Tsukihime's Random Hits script, which lets a skill hit between a and b times (you set a and b, it randomly determines a number between them), you'll get 5 skill uses in a row that hit the same number of times.  That's unlikely.

 

You should try and get a larger sample size, or better yet, set conditions where hit is guaranteed (a.atk+a.level > b.def), and then get back to us.



#14 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 27 January 2013 - 06:57 PM

Correct whitespacing is VERY important.

In my tests i had the spacing corrected but just now i thought this could be the issue.

 

For some reason the +a.level returns a error, and if a error is found on a formula, it returns false.

always adds spacing before and after math signs.

 

1 + rand(20) + a.atk + a.level >= b.def

 

This worked fine here, and if don't works for you, then it's another script causing incompatibility,


Posted Image


#15 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 27 January 2013 - 07:05 PM

Alright, I ran a few more battle tests with

 

<hit formula>
a.atk +a.level >= b.def
</hit formula>

 

and

 

<hit formula>
a.atk +a.level > b.def
</hit formula>

 

and set everyone's defense to 1 for both tests. Everybody missed on every attack. Then, just to be interesting, I tried

 

<hit formula>
a.atk > 1
</hit formula>

 

and

 

<hit formula>
100 > 1
</hit formula>

 

Everybody missed every time. I've removed every script except for Victor's. I feel like I'm missing something really, really basic here, but I'm not sure what it is . . .



#16 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 28 January 2013 - 12:19 AM

where exactly you're placing you formula?


Posted Image


#17 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 28 January 2013 - 01:07 AM

Ok, I went ahead and started a whole new project, clear of absolutely everything except the Victor Basic script and the Custom Hit script. I removed all of the actors except one, and removed the Hit and Evade Parameters from that one actor's class. Then I copied the exact formula from your last post and and pasted it into that actor's notetag. Then I went to a monster, removed its Hit and Evade Parameters, and pasted the formula into its notetag.

 

It looks like this.

 

Tested again, same results. Everything misses, all the time. Tried it again with all of the formulas that I posted before. The only way anything hits is if I add the Hit parameters back in, but when I do that the hits only follow the Hit parameter, not the formula in the tag. I had an idea for work-around (a long and annoying work-around), but if you can see anything really obvious and stupid that I'm doing wrong that I can fix and make this work, I would really love that. Thank you once again for your time and your patience with a new user :-)


Edited by wer_dragan, 28 January 2013 - 03:28 AM.


#18 Victor Sant

Victor Sant

    Advanced Member

  • Ace Member
  • 778 posts

Awards Bar:

Users Awards

Posted 28 January 2013 - 05:01 AM

that's your problem...
#------------------------------------------------------------------------------
# Skills and Items note tags:
#   Tags to be used on the Skills and Items note box in the database

#
#  <hit formula>
#  formula
#  </hit formula>
#   Setup the custom hit formula for the action. The formula can be any valid
#   ruby command.
The note tag isn't for actors, it's for skills and items.

Edited by Victor Sant, 28 January 2013 - 05:05 AM.

Posted Image


#19 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 28 January 2013 - 08:25 AM

Agh! I can't believe I missed that! So sorry for wasting your time, Victor :-( Thanks again.



#20 wer_dragan

wer_dragan

    Member

  • Ace Member
  • 17 posts

Posted 30 January 2013 - 11:18 AM

The attack rolls are working perfectly, thanks for all your help :-) I had a few more questions about modifications. For the half-damage on a miss, would

 

if $variable == false (damage formula) else 0.5*(damage formula)

 

go in the script, or in the formula?

 

Also, would it be possible to create a similar stipulation where if the random number generated was between x and y, that it would do double damage instead (to re-create the critical hit formula of D&D)? Or would that be simplest to accompished just using the + Crit % property on weapons?







Also tagged with one or more of these keywords: d20, d&d, custom to hit

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users