Game Development Reference
In-Depth Information
Our PoisonCoundown variable, which we created in the preceding code, is now
being used as well. Each time the function is called (in our case, every 0.5 seconds),
we add one to the count. Next, we create an if statement that clears our timer once
we've accumulated 10 seconds worth of damage.
Want to have the DoT effect last longer?
Simply set the integer in our if(PoisonCountdown >= 10)
statement to be greater than 10!
Change your pawn's default inventory, so that it uses our new weapon and give it a
spin! Once hit, you'll notice that the pawn flashes red very briefly, each time damage
is received. Take a look at your log to see exactly how much health is drained with
each hit.
How it works...
Because our MyWeapon class is so modular, we're able to create brand new functionality
by only having to override one function within the class. When our instant hit projectile
( ProcessInstantHit() ) hits our TutorialPawn , it calls the PoisonPlayer()
function within that class.
PoisonPlayer() then calls our PoisonDmg() function every half second. PoisonDmg()
then sets a number of attributes, such as the amount of damage taken during each hit,
where the pawn is hit, and how long the effect will last.
There's more...
Now that we have a projectile, which poisons our enemies, what's stopping us from creating
a grenade that does the same, or even a pickup? See if you can create an object that causes
poison damage when the pawn picks it up with the use function, or if a pawn
runs it over (collides).
Looking further down the road, one excellent idea would be to create a grenade or
explosive that heals people over time.
Take a look at the Bump() and Touch() functions in your pawn.
Search Nedrilad ::

Custom Search