How on earth does Omnitype work?

I was battling Giratina but it was immune to almost everything. I ended up catching it and I looked on the wiki about omnitype but what i found was kinda vague, and I didn’t understand it, could anyone explain it to me?

It has the resistances, immunities, and weaknesses as if it had all 18 types at once, but it only gets STAB from ghost and dragon. I heard it was bugged though (I think it calculates ghost and dragon twice). This means it’s immune to psychic, ghost, fighting, ground, poison, electric, dragon, and normal.

ohhh, that makes sense, dang thats complicated… thanks for the explanation!

No problem.

There is also a bug that bug and grass type moves do No damage