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 04-02-2010, 05:49 AM
Hellz Meteor Hellz Meteor is offline
Registered User
Join Date: May 2005
Posts: 3
Hellz Meteor is on a distinguished road
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.
Reply With Quote
  #2  
Old 04-02-2010, 06:14 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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.

Last edited by ffcmike; 04-02-2010 at 06:33 AM..
Reply With Quote
  #3  
Old 04-02-2010, 06:32 AM
Hellz Meteor Hellz Meteor is offline
Registered User
Join Date: May 2005
Posts: 3
Hellz Meteor is on a distinguished road
Quote:
Originally Posted by ffcmike View Post
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?
Reply With Quote
  #4  
Old 04-02-2010, 06:34 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Hellz Meteor View Post
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.
Reply With Quote
  #5  
Old 04-02-2010, 06:39 AM
Hellz Meteor Hellz Meteor is offline
Registered User
Join Date: May 2005
Posts: 3
Hellz Meteor is on a distinguished road
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:
Reply With Quote
  #6  
Old 04-02-2010, 06:43 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
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.
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 02:05 AM.


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