Graal Forums

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

Hellz Meteor 04-02-2010 05:49 AM

Projectiles?
 
What kind of method or function should I look at to create a projectile that will do something to a player once it touches them?

I am really new to GS2, and I couldn't figure it out in GS1 either, so basic instruction would be best.

for example, Player1 Shoots a projectile that moves in a straight line. Player 2 gets hit by it and says "Im hit!"


Thanks in advance.

ffcmike 04-02-2010 06:14 AM

For shooting a projectile, before calling shoot you need to set the parameters that will be recieved when the projectile lands:
PHP Code:

setshootparams(param1param2etc);
shoot(xyzanglezanglepoweraninameaniparam1aniparam2etc); 

Practical example would be:
PHP Code:

setshootparams("clientside"player.accountdamageamount);
shoot(player.xplayer.yplayer.zgetangle(vecx(player.dir),vecy(player.dir)), 01"aniname"); 

While on an advanced level there is the issue of the detection being serverside or clientside among other things such as abstracting all projectile landing occurrences into a single system, the simplest way to do this would be to have the following code within a weapon:

PHP Code:

//#CLIENTSIDE
function onActionProjectile(param1param2etc){
  
player.chat "Im hit!";


Parameters being what was set before the projectile was shot via setshootparams.

I don't think Clientside onActionProjectile is either accurate or synced with the serverside version of the function however, on Classic I use custom detection on the onActionProjectile2(x, y, params) event which occurs whenever a projectile hits anything and not just your player.

Hellz Meteor 04-02-2010 06:32 AM

Quote:

Originally Posted by ffcmike (Post 1566605)
While on an advanced level there is the issue of the detection being serverside or clientside among other things such as abstracting all projectile landing occurrences into a single system, the simplest way to do this would be to have the following code within a weapon:

PHP Code:

//#CLIENTSIDE
function onActionProjectile(param1param2etc){
  
player.chat "Im hit!";


Parameters being what was set before the projectile was shot via setshootparams.

I don't think Clientside onActionProjectile is either accurate or synced with the serverside version of the function however, on Classic I use custom detection on the onActionProjectile2(x, y, params) event which occurs whenever a projectile hits anything and not just your player.

I don't think I will need it to be super accurate at the moment, just looking for a basic function that I could test, which you answered.

So if I call the onActionProjectile function, it affects the player that the projectile hits, not the player who shot it, correct?

ffcmike 04-02-2010 06:34 AM

Quote:

Originally Posted by Hellz Meteor (Post 1566606)
So if I call the onActionProjectile function, it affects the player that the projectile hits, not the player who shot it, correct?

Correct, keep in mind this needs to be within a Clientside weapon script.

Hellz Meteor 04-02-2010 06:39 AM

Thanks for the updated post.

Also, there would only work on actual players and not NPCs, correct?

Ah I might have to find people to test it on once I figure out what I want to do with it... D:

ffcmike 04-02-2010 06:43 AM

The same works for NPCs yes, both Serverside and Clientside, although there is "onActionSProjectile" as opposed to "onActionProjectile" Serverside for projectiles that are shot via objects on the server rather than players.

These 2 functions are also recieved by the Control NPC for whenever a projectile lands anywhere on the server, except the first 2 parameters are the x and y coordinates of where it hit.


All times are GMT +2. The time now is 01:29 AM.

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