Quote
Originally posted by BryceCubed:
**I forgot to mention this in my opening post, or I didn't think that it was important to mention, but I was thinking about having the bad guy hurl spears at the player and he would get points if he stops a spear that would otherwise hurt him.
**
Ok, this suggestion comes off the top of my head without any thought going into it(well, not much really, heh).
Anyhow, what you can do is set up a global, name it something like gb_hps. Set up a second global and name it something like gb_hasblocked. Make a keydown event with the same key as the blocking key(z) and have it set gb_hasblocked to 1. Next set up an event that ticks down at a rate a bit longer than what your npc's attack rate is(if you have the bad guy hurling spears every 2 seconds, have the event timer set to run at 4 second intervals or so).
So you have the following:
gb_hps;
gb_hasblocked;
keydown z {sets gb_hasblocked to 1}
evt_timer { timer set to a couple seconds longer than attack cycle of npc }
With the above, do the following:
Set evt_timer upon entering the area, clear gb_hasblocked, and set gb_hps to equal the player's current hitpoints.
Whenever evt_timer reaches 0 have it call an event evt_hitcheck.
evt_hitcheck should look something like this:
evt_hitcheck { conditional ((if gb_hps > current hitpoints) OR (gb_hasblocked == 0)) then clean gb_hasblocked and set gb_hps to equal the player's current hitpoints. If the conditional is false(ie, gb_hps is less than or equal to player's current hitpoints(ie, he hasn't taken damage or has been healed) AND the gb_hasblocked global is tripped to 1) then you would do the following: award your training points, then clear gb_hasblocked, set gb_hps to equal player's current hitpoints, and then trigger the timer.
Basically, since you can't trigger an event upon the NPC attacking(wouldn't that be nice?), you would need to synthesize it. What the above does is check the player's current hitpoints against what they were a few seconds previously. If they are the same or higher then he didn't take damage or has been healed(a way around healing would be either have this early enough in the game when the player doesn't have access to healing potions, or to make the condtional check to make sure gb_hps is equal to current hitpoints. Thus if the player got hit and healed it would not count.. but I like the greater than conditional, personally). I added the additional check to see if the player blocked(gb_hasblocked), so that if the player is just running around dodging they won't get points.
This system isn't perfect; they can tap the block key then run around dodging missiles, tap it again, keep dodging, and they will get credit for blocking. They could also block, get hit by a missile, chug a healing potion(if available) and if they are fast enough get credit for blocking.
But the above should be a quick and dirty way to get it done. Hopefully there is a better solution out there though.
Good luck.
------------------
"Usenet is like a herd of performing elephants with diarrhea --
massive, difficult to redirect, awe-inspiring, entertaining, and a
source of mind-boggling amounts of excrement when you least expect
it." -- Gene Spafford, 1992