I'm currently thinking of the most convenient way to implement the attack chart into my Pokemon game. Basically, some attacks do less damage,some do more, and some don't do any at all depending on the type of attacks. I'd really rather not make this long and overcomplicated. Does anyone have any ideas on how I should make it?
http://www.serebii.net/games/type.shtml
ID:157222
Apr 21 2010, 2:54 pm
|
|
In response to tenkuu
|
|
Thanks for the help but could you please go into more detail about it? I sort of understand what you're telling me but what would the type-number ordering be? And what is the point of var/type_chart[whatever][whatever]? Thanks.
|
In response to tenkuu
|
|
Yeah, and if you were to cut out one type so that there was only 16, you could use bits.
|
In response to DisturbedSixx
|
|
The ordering of the numbers for the types is irrelevant so long as it's consistent (hence the use of constants). The assignment statements are putting numbers into the array, so that type_chart[NORMAL][FIRE] tells you how much damage NORMAL takes from FIRE (or FIRE takes from NORMAL I forget which way he set up it).
Anyway, that's the wrong way to input these values. What you should do is this: var/const The consts match the order of the types given in the chart you linked. 1 corresponds to normal damage, .5 to half, 2 to double, and 0 to no damage. To determine the damage multiplier of an attack, look up DAMAGE_CHART[defender_type][attack_type]. For pokemon with multiple types, look up the value for each type and multiply the results together, so you'd get DAMAGE_CHART[defender_type_1][attacker_type] * DAMAGE_CHART[defender_type_2][attack_type]. A pokemon's (or attack's) type is technically just a number, which is where the constants are useful, so that you can define something's type to be ELECTRIC rather than 4. You just need to copy the 17x17 base grid from the website you linked. You don't need any of the hybrid types in it, because as I said those are simply found by multiplying the values gotten from each type. |
In response to Garthor
|
|
Okay thank you very much.
|
In response to Garthor
|
|
Am I doing something wrong? It's giving me these errors:
Calculations.dm:109:error: : invalid expression Calculations.dm:110:error: : invalid expression Calculations.dm:108:error: =: constant initializer required var/const Do I need to finish all of the rows first? |
In response to DisturbedSixx
|
|
If I remember correctly, you cannot break open those parenthesis () like that - do not get them confused with braces {}.
You need to escape the newlines: X = list(\ |
In response to DisturbedSixx
|
|
Whoops, the list should be under its own var/ thing, not var/const.
And you shouldn't have list=(, just list(. |
In response to Garthor
|
|
Okay thanks.
|
In response to DisturbedSixx
|
|
Ya, I have a question.
I am using something similar to this. Or, at least can use something like this to make my objective simpler. I tried this out, but how would I change a variable with it? Like... damagevar *= DMGCHART[type1][type2] Thats the only way I can think of. Thanks for any help. |
In response to Sensaku
|
|
That's pretty much it. Calculate the base damage, then multiply it by DMGCHART[A][B].
|
Ideally you'd want to #define a type to a number since that's essentially how the actual games work. The type-number ordering is important as it makes calculating hidden power simple as well as some other aspects.
Then you'd want to fill this chart in on world/New() with all 1's and then go through and just fill in specific cases where there's a weakness, resist or immunity.
You really need to only worry about the first half of that chart.