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 02-11-2009, 04:22 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
Shoots

2 questions.
A: Can someone explain me a simple shoot script(for bullets like on era)

B:Why is shootarrow etc. clientside only?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #2  
Old 02-11-2009, 04:25 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
PHP Code:
// Will shoot a projectile in the direction of the player
//#CLIENTSIDE
function onCreated() {
  
temp.startx player.x+vecx(player.dir);
  
temp.starty player.y+vecy(player.dir);
  
temp.startz player.z;
  
temp.angle getangle(vecx(player.dir), vecy(player.dir));
  
temp.zangle 0;
  
temp.power  0;
  
temp.ani "arrow"// projectile ani
  
temp.aniparam0 0;
  
temp.aniparam1 0;
  
// etc
  
shoot(temp.startxtemp.startytemp.startztemp.angletemp.zangletemp.powertemp.anitemp.aniparam0temp.aniparam1); // etc with the aniparams

__________________
Reply With Quote
  #3  
Old 02-11-2009, 05:00 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Chompy View Post
PHP Code:
// Will shoot a projectile in the direction of the player
//#CLIENTSIDE
function onCreated() {
  
temp.startx player.x+vecx(player.dir);
  
temp.starty player.y+vecy(player.dir);
  
temp.startz player.z;
  
temp.angle getangle(vecx(player.dir), vecy(player.dir));
  
temp.zangle 0;
  
temp.power  0;
  
temp.ani "arrow"// projectile ani
  
temp.aniparam0 0;
  
temp.aniparam1 0;
  
// etc
  
shoot(temp.startxtemp.startytemp.startztemp.angletemp.zangletemp.powertemp.anitemp.aniparam0temp.aniparam1); // etc with the aniparams

May I suggest the following changes for the starting position:
PHP Code:
  temp.startx player.1.5 vecx(player.dir);
  
temp.starty player.vecy(player.dir); 
Reply With Quote
  #4  
Old 02-11-2009, 09:04 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Crow View Post
May I suggest the following changes for the starting position:
becaause?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #5  
Old 02-11-2009, 09:12 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Deas_Voice View Post
becaause?
Because the coordinates I suggested are approximately the center of the player. If I recall correctly, that should work better with projectiles. Don't hurt me if it does not
Reply With Quote
  #6  
Old 02-11-2009, 10:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Crow View Post
May I suggest the following changes for the starting position:
PHP Code:
  temp.startx player.1.5 vecx(player.dir);
  
temp.starty player.vecy(player.dir); 
A little bird told me that since projectiles use gani's they can be projected from the player's position(player.x,player.y) and not hit the player
__________________
Reply With Quote
  #7  
Old 02-11-2009, 11:06 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Chompy View Post
A little bird told me that since projectiles use gani's they can be projected from the player's position(player.x,player.y) and not hit the player
Good to know ;P
Reply With Quote
  #8  
Old 02-12-2009, 03:22 AM
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
Quote:
Originally Posted by Crow View Post
Good to know ;P
More specifically, since shoot() uses a gani, and the gani's follow the same proportions as the player(size-wise), all you have to do is put the projectile in the gani in the center(like it should be anyways). Shoot() the projectile from player.x,player.y, and the projectile will visually originate from the center of the player.
Reply With Quote
  #9  
Old 02-12-2009, 05:59 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Looking at this just brought something to my attention, is there vecz(), i know it seems pointless and most likely is, but just curious. o.O
__________________
Deep into the Darkness peering...
Reply With Quote
  #10  
Old 02-12-2009, 06:09 AM
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
Quote:
Originally Posted by Angel_Light View Post
Looking at this just brought something to my attention, is there vecz(), i know it seems pointless and most likely is, but just curious. o.O
No, because it would always return 0, seeing as in relation to player direction, you can only move in two planes.
Reply With Quote
  #11  
Old 02-12-2009, 08:22 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
shoot(temp.startx, temp.starty, temp.startz, temp.angle, temp.zangle, temp.power, temp.ani, temp.aniparam0, temp.aniparam1);


with the numbers or just like written above?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #12  
Old 02-12-2009, 08:01 PM
thatdwarf thatdwarf is offline
Former UN Dev Admin
Join Date: Nov 2005
Posts: 42
thatdwarf is on a distinguished road
just like written above as long as those variables are defined
You can see in Chompy's script where those variables (temp.startx, temp.angle, etc) are given values.

You can very well just put all the numbers/math in the appropriate location in the shoot() function, but it's very messy, and considered bad practice to use "magic numbers", meaning numbers without clear meaning.

Defining the variables beforehand gives the code more readability ^_^
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 01:03 AM.


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