The attack is one of the most fundamental functions in a d20 game.  It is also one of the most complicated.
 It starts out simply enough:
[assuming the routine is a method of the attacker’s class]

Function Hit(vDefender as Thing) as Boolean
     Return RollDice(1,20) + Me.AttackBonus >= vDefender.ArmorClass
End Function

But Lothar the Fighter has earned Weapon Focus(Longsword) Feat, which means his attack bonus will be higher when he’s using a longsword.  That means we need to know the weapon. 

Function Hit(vDefender as Thing, vWeapon as Thing) as Boolean
     Return RollDice(1,20) + Me.AttackBonus(vWeapon) >= vDefender.ArmorClass
End Function

Lothar happens to be a hill giant attacking a dwarf, so the dwarf gets a special dodge bonus.  That means ArmorClass depends on the attacker.

Function Hit(vDefender as Thing, vWeapon as Thing) as Boolean
     Return RollDice(1,20) + Me.AttackBonus(vWeapon) >= vDefender.ArmorClass(Me)
End Function

Now here is where it starts to get messy.  Lothar is struck by a vampire and loses a level.  The next day he fails the save and loses the level permanently.  So the level at which a feat or quality was gained matters.

Function AttackBonus(vWeapon as Thing) as Long
      Dim Bonus as long = 0
                For each L in Me.Levels
                                If L.WeaponFocus(vWeapon.WeaponType)  Then Bonus +=2
      Return Bonus
End Function

The game engine will require more information than whether or not a hit was successful.  If Lothar fires into a grapple, he might hit a different target.   The amount and type of damage from a successful hit are relevant to damage reduction and death from massive damage.  What if Lothar is subject to a shape change and only some of his qualities apply while others rely on his new form?

As the developer takes into account additional feats, active spells, and special qualities, the number of function calls can climb exponentially.  How can the developer minimize the overhead while producing the required outputs without a big bowl of “spaghetti code”?  Stay tuned and we’ll discuss some strategies in upcoming articles.

Katy loved her balloons even before she found out they were magical.  One day, they took her to a place with colors beyond her imagination.  Her heart filled with emotions she’d never known before: joy, wonder and awe, she even fell in love.

But then the other feelings came, fear, self-doubt and finally the pain of rejection on learning her true love could not return her affections.  She sunk into despair as all of her colors turned gray.

She scrambled to the wall and reached for the balloons, desperate to return to the safety and comfort of her two-dimensional world.

Forbidden Love
By Wakefield Mahon

“We can never be together you know. It would be abomination against nature. Don't look at me like that with those cool blue eyes. I know, I feel the same way. But my family would disown me. Forget my family, NOBODY thinks it is a good idea for a werewolf and vampire to mate.”

(On a related note. Check out Underworld: Awakening; it's pretty awesome.)

Disco is Dead
By Wakefield Mahon
Taryn Blakely was music royalty, the “queen of disco”, and she refused to leave. Whenever someone entered the building to evict her, she began her song. They’d start to dance and wake up, dazed and exhausted, outside the club.
Mary and her brother David walked into the decrepit discotheque and Taryn started her song. David ignored her completely and Mary looked at her with sympathetic eyes. They made it to the center of the room and disconnected the disco ball. Taryn nodded then faded away.
“So sad,” Mary signed to her brother. “Even without hearing it’s hard not to dance.”

~Rest in Peace Donna (Disco will never die)

Killing Time
By Wakefield Mahon

We were driving up Interstate 17 and I asked Joe where we were going.
“Killing time, man.”
I shook my head. Joe has this laidback way about him. I noticed the exit for Bloody Basin Road a mile up ahead. “Didn’t they make a movie about that road?”
“Yeah a bunch of yahoos desecrating the ancient burial ground.”
“Do they get what’s coming to them?”
“No clue. I never watch that horror movie crap.”
“So, do you think people ever get ideas from movies like that?”
Joe grimaced. “You’d think they’d be scared, but sometimes they just get drunk or high and have to show just how brave they are.”
“We’re talking in the hypothetical right?”
Joe drove turned off on the exit in chilling silence.
We pulled up on a group of rowdy young men, obviously drunk out of their minds. Joe jumped out of the truck with grandfather’s tomahawk in hand.
“Hey look here come the ghosts!”The loudest guy had just relieved himself on Gentle Bear’s grave.
She was my grandmother. I guess that makes this a family affair, a fight to the death if necessary. I think I understand what Joe was saying now. “It’s killing time.”

“I’m telling you Jimbo, I saw her splashing in the rain and I knew it was destination.”
“You mean destiny? Larry, I swear you concoct the wildest stories.”
“Don’t make fun of me; I knew it was love at first sight, even the street sign said so.”
“Good Lord, Larry, you mean the corner of  Love and First street, down by the bakery? That’s your crazy cousin Clara.”
“She was prettiest girl I’d ever seen.  Makes sense, the sign said ‘Fine Cousin’.”
“You mean cuisine - and stick with the food. Just because you’ve heard of kissing cousins doesn’t make it a good idea.”
100 words