Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   push back (https://forums.graalonline.com/forums/showthread.php?t=86428)

GULTHEX 06-19-2009 07:29 PM

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

Darlene159 06-19-2009 08:21 PM

Quote:

Originally Posted by GULTHEX (Post 1500260)
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.

Soala 06-19-2009 08:27 PM

Try a function like when hit, depending on the direction where the character is hit, it moves the player from +/- X/Y by #,# ?

DustyPorViva 06-19-2009 10:03 PM

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.


All times are GMT +2. The time now is 08:15 PM.

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