About Store Forum Documentation Contact



Post Reply 
Npc Shooting Fireball at Player
Author Message
Palaxe Offline
Member

Post: #1
Npc Shooting Fireball at Player
Hi Everyone,
I been working in RPG and have a pretty good handle on it now. I'm to the point where I would like to have my hydra spit fireballs at me.
I been looking everywhere for a reference how this is done.
Would someone be so kind as to share a link or give me a hint where I can find how this is done.
Thanks smile
12-04-2013 06:28 PM
Find all posts by this user Quote this message in a reply
Fex Offline
Bronze Supporter

Post: #2
RE: Npc Shooting Fireball at Player
Its done the same way the player would spit fireballs.

Basically each NPC class will have a Memc<Fireballs> fireballs; member that your update and render each frame.

Look at how the fireballs are done in Ineisis (your single player RPG should be even easier, you only need to look at the client code, masically your store each projectile in a memc and update their positions each frame). Or in Esenthel RPG2.

Just make the inital pos the NPC pos, make initial dir vec Npc.pos - Plr.pos, or if you want to be fancy you can fire the ball so that it leads the player using something like:

(Npc.pos - Plr.pos) + Plr.movevecnormalized*Dist(Plr.pos, NPC.pos)/fltSpeedofProjectileinmetersPerSecond

If you want the AI to appear smarter use a ray/physhit to make sure the NPC has line of sight before firing at the player.
12-04-2013 07:09 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #3
RE: Npc Shooting Fireball at Player
(12-04-2013 07:09 PM)Fex Wrote:  Its done the same way the player would spit fireballs.

Basically each NPC class will have a Memc<Fireballs> fireballs; member that your update and render each frame.

Look at how the fireballs are done in Ineisis (your single player RPG should be even easier, you only need to look at the client code, masically your store each projectile in a memc and update their positions each frame). Or in Esenthel RPG2.

Just make the inital pos the NPC pos, make initial dir vec Npc.pos - Plr.pos, or if you want to be fancy you can fire the ball so that it leads the player using something like:

(Npc.pos - Plr.pos) + Plr.movevecnormalized*Dist(Plr.pos, NPC.pos)/fltSpeedofProjectileinmetersPerSecond

If you want the AI to appear smarter use a ray/physhit to make sure the NPC has line of sight before firing at the player.
Sweet, Thank you very much. This is a good place for me to start smile
12-04-2013 07:24 PM
Find all posts by this user Quote this message in a reply
Post Reply