ID:273705
 
Well, yea this is annoying. I don't get a good way to do it.

I'm trying to do this Type Chart:

http://www.serebii.net/games/type.shtml

-It exactly works for The Battle, For when someone is using an Attack, for Damage Calculation basically.

Then the Attack Effects.

Check this:

-http://www.serebii.net/attackdex-bw/absorb.shtml
-http://www.serebii.net/attackdex-bw/acid.shtml

Check in both the "Battle Effect". They're different right? Well, i don't want to do for every attack

if(Attack == "Absorb")
//blabla


What's a good way to do it?
Ocean King wrote:
Well, yea this is annoying. I don't get a good way to do it.

I'm trying to do this Type Chart:

http://www.serebii.net/games/type.shtml

-It exactly works for The Battle, For when someone is using an Attack, for Damage Calculation basically.

I would use an multi dimention associative array and define each one as a multiplyer

attack["normal"]["normal"] = 1
attack["fire"]["fire"] = 0.5 //fire vs fire = half
attack["water"]["fire"] = 2 //water vs fire = double




Then the Attack Effects.

Check this:

-http://www.serebii.net/attackdex-bw/absorb.shtml
-http://www.serebii.net/attackdex-bw/acid.shtml

Check in both the "Battle Effect". They're different right? Well, i don't want to do for every attack

> if(Attack == "Absorb")
> //blabla
>

What's a good way to do it?

This you would want to have an effects list and then check if that effect is in that attacks list. I would store the attacks as datums.
In response to Pirion
Pirion wrote:
This you would want to have an effects list and then check if that effect is in that attacks list. I would store the attacks as datums.

Hmp. I didn't understand that. And yes, i'm doing attacks as Datums.
Pirion's method of handling type multipliers is probably the best way to handle it; I've tried a couple of other methods, and it was the best, though I'd recommend numbers with macros instead of associated text strings.

#define FIRE 1
#define WATER 2
#define THUNDER 3

attacks[FIRE][WATER] = 0.5
attacks[WATER][FIRE] = 2


and so on. It reduces the risk of typos, etc. though it makes entering the list in the first place a huge pain, because you're no longer using associations.

Here's a chart I made 2-3 years ago, though it looks like I used a list and text strings to get my type trump (just replace the list with #define values and you can use my above example)

var/list/Types = list("normal","fire","water","electric","grass","ice","fighting","poison","ground","flying","psychic","bug","rock",\
"ghost","dragon","dark","steel")

//replace that list with

#define NORMAL 1
#define FIRE 2

//and so on

//However, you could use a list like that to grab type names using
//their number from the defined values if you wanted to.
//just don't use them in creating attack datums, I can't
//tell you how many typos I made like that before I caught on

var/list/Type_trumps = list(\
//End all lines with ),\ except the last, which is just ))
/* No. Fir Wat Elec Gra. Ice Fight pois. grou fly psy bug roc gho dra dar steel*/
/* Normal */ list( 1, 1, 1 , 1 , 1 ,1 ,2 ,1 ,1, 1, ,1 ,1 ,1 ,0, 1, 1, 1),\
/* Fire */ list( 1, 0.5, 2 , 1 ,0.5 ,0.5, 1, 1, 2, 1, ,1 ,0.5 ,2 ,1 ,1, ,1 ,0.5),\
/* Water */ list( 1, 0.5, 0.5,2 , 2 ,0.5, 1, 1, 1, 1, ,1 ,1 ,1 ,1 ,1 ,1 ,0.5),\
/* Elec */ list( 1, 1, 1, 0.5, 1, 1, 1, 1, 2, 0.5, 1 ,1 ,1 ,1 ,1 ,1 ,0.5),\
/* Grass */ list( 1, 2, 0.5,0.5,0.5 ,2, 1, 2, ,0.5 ,2 ,1 ,2 ,1 ,1 ,1 ,1 ,1),\
/* Ice */ list( 1, 2, 1, 1, 1, 0.5, 2, 1, 1, 1, 1, 1, ,2 ,1 ,1 ,1 ,2),\
/* Fight */ list( 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ,0.5 ,0.5,1 ,1 ,0.5,1),\
/* Poison */ list( 1, 1, 1, 1, 0.5,1, 0.5, 0.5, 2, 1, 2, 0.5 ,1 ,1 ,1 ,1 ,1),\
/* ground */ list( 1, 1, 2, 0, 2, 2, 1, 0.5, 1, 1, 1, 1, ,0.5,1 ,1 ,1 ,1),\
/* Fly */ list( 1, 1, 1, 2, 0.5,2, 0.5, 1, 0, 1, 1, 0.5 ,2 ,1 ,1 ,1 ,1),\
/* Psy */ list( 1, 1, 1, 1, 1, 1, 0.5, 1, 1, 1, 0.5, 2, ,1 ,2 ,1 ,2 ,1),\
/* bug */ list( 1, 2, 1, 1, 0.5, 1, 0.5, 1, 0.5, 2, 1, 1, ,2 ,1 ,1 ,1 ,1),\
/* Rock */ list(0.5,0.5, 2, 1, 2, 1, 2, 0.5, 2, 0.5, 1, 1, ,1 ,1 ,1 ,1 ,2),\
/* Ghost */ list( 0, 1, 1, 1, 1, 1, 0, 0.5, 1, 1, 1, 0.5 ,1 ,2 ,1 ,2 ,1),\
/* Dragon */ list( 1, 0.5, 0.5,0.5,0.5, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1),\
/* Dark */ list( 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 2, 1, 0.5, 1, 0.5, 1),\
/* Steel */ list(0.5,2, 1, 1, 0.5,0.5, 2, 0, 2, 0.5, 0.5,0.5,0.5,0.5,0.5,0.5,0.5))



Also, for each effect, I'd create separate "effect" datums, for each general effect. Then, I'd change the variables around as necessary (so all the different absorbs, drains, etc. can use the same datum, you just define different percentages).

For persistent effects like poison, though, I originally used bits to switch effects on and off. However, I think I'd use a list or a static variable or two now, depending on how many of these effects could be applied at once.
In response to Jeff8500
By Effects i mean, for Example Absorb, Acid, etc. Some of them lower/increases your stats, other increases/decreases ENEMY stats, others does dmg. etc.

And wow, we've static variables? Omfg.
In response to Ocean King
_>, yeah, BYOND has static variables, though I worded that terribly. I mean just use a variable or two.

Because stat effects (like increases/decreases) wear away over time and stack, I'd use a list of effect datums for those. Absorb, however, is an instant effect, rather than a persistent one, so that would have to only be called once.
mob/Pokemon
var/list/effects

mob/Trainer
proc
ItsMyTurn()
ApplyPokemonEffects()

ApplyPokemonEffects()
for(var/mob/Pokemon/P in sent out)
for(var/battleeffect/BE in P.effects)
BE.persistenteffect()


There's a bit of an example of what I mean for effects like stat reductions.

AttackEffect
proc
InstantEffect()
PersistentEffect()
Instant
Absorb
InstantEffect()
Enemy.HP *= 0.5
User.HP += Enemy.HP //not realistic in the least
Persistent
Growl
InstantEffect()
Enemy.attack -= 3
Enemy.effects += src
PersistentEffect()
turncount++
if(turncount > 3)
Enemy.attack +=3
del(src)


Terribly inconsistent examples, but you should get the gist of it.
In response to Jeff8500
Basically the Hard Thing is, for every attack you have to do Something Different.
Then if it's a Turn attack you need to deactivate it in the next turn, some does damage. It's pretty confusing this.