Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-19-2009, 07:29 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Cool push back

okay how do i make it if you are hit by a projectile it pushes you back
because i tried making one

and when i fired it
when it hit the person

put them in the corner of the map

so i really need some help
Reply With Quote
  #2  
Old 06-19-2009, 08:21 PM
Darlene159 Darlene159 is offline
Administrator
Darlene159's Avatar
Join Date: Aug 2001
Location: Florida
Posts: 12,470
Darlene159 has much to be proud ofDarlene159 has much to be proud ofDarlene159 has much to be proud ofDarlene159 has much to be proud ofDarlene159 has much to be proud ofDarlene159 has much to be proud of
Quote:
Originally Posted by GULTHEX View Post
okay how do i make it if you are hit by a projectile it pushes you back
because i tried making one

and when i fired it
when it hit the person

put them in the corner of the map

so i really need some help
If you post the script, maybe someone can help you with it.
__________________
FORUM RULES
GRAAL BIBLE (Lots of useful info)
INFO ABOUT REPUTATIONS.
INFO ABOUT INFRACTIONS.
HOW TO APPLY FOR THE NON-GRAAL RELATED FORUM (<<READ THOROUGHLY!)

SUPPORT: http://support.toonslab.com

NOTE: YOU ARE RESPONSIBLE FOR YOUR OWN POSTS.
READ>THINK>POST
Reply With Quote
  #3  
Old 06-19-2009, 08:27 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Try a function like when hit, depending on the direction where the character is hit, it moves the player from +/- X/Y by #,# ?
Reply With Quote
  #4  
Old 06-19-2009, 10:03 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
hitplayer(this.id,0,hitfromx,hitfromy);

If you're using the default system, that should work. It will hit the player away from the given 'hitfromx/y'. this.id should find your own player, but I'm not entirely sure.

So... probably something like this...

Projectile:
PHP Code:
  temp.sx = (player.x+1.5) - (this.x+1.5);
  
temp.sy = (player.y+2) - (this.y+2);
  
temp.sangle getangle(sx,sy);
  
setshootparams("arrow",sangle); // You MUST send the angle at which the projectile is flying.
  
shoot(this.x,this.y,this.z,sangle,0,0,"projectilegani",null); 
Now this probably looks nothing like the projectile you're using, as I've rigged this in an NPC to shoot projectiles at my player. The point is, however, to pass the angle the projectile is traveling in setshootparams(). This is because projectiles that actually hit objects do not send which direction they are coming from, so you have to eventually calculate that yourself.

So onto the weapon itself(you should have one global weapon or such that all players get to handle projectile hits).:
PHP Code:
//#CLIENTSIDE
function onActionProjectile(obj,sangle) {
  if (
obj == "arrow") {                      // Is it an arrow? You should do these sort of checks
    
temp.hitx player.x+1.5+cos(sangle+pi); // Calculate where the projectil came from
    
temp.hity player.y+2-sin(sangle+pi);
    
hitplayer(this.id,0,hitx,hity);
  }

When the projectile hits the player, it will take the angle of the projectile, reverse it(by adding pi to it), and then calculate it 1 tile away from the player. This will give you an accurate idea of where the projectile landed a tile away, therefor letting you hit the player from there.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.