Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-09-2010, 07:46 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
How to shoot? (Formerly "Learning.")

Hey,
I kind of know the really basic stuff but still, I'm new to scripting and I want to learn. I'm trying to script a simple weapon that throw anything. I first try to just throw an arrow, but the only thing I have is a shadow flying forward. If anyone can help me, I'd really like to know how exactly the functions work and where to put what in the parameters. Let's say I want my character to throw shuriken.png?

I have few mores questions after this one is solve, I'll just post them after that one. Thanks by the way for the help!
Reply With Quote
  #2  
Old 03-09-2010, 09:18 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Not sure what you're asking for, but I think you're trying to use shoot(), which is described here: http://wiki.graal.us/shoot

You can change the projectile's image in the last parameter:
Graal Script Code:
//#CLIENTSIDE
function onWeaponFired()
{
  
temp.angle getangle(vecx(player.dir), vecy(player.dir));
  
shoot(player.xplayer.yplayer.ztemp.angle00"arrow""barrow0.png");

If arrow.gani is too complicated you can make your own single-frame gani.
Reply With Quote
  #3  
Old 03-10-2010, 06:30 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
Thanks, that's working.
Now, I did a new projectile called val_shuriken.png and a new gani called temp_shuri.gani. I've replaced "arrow" and "barrow0.png" but I guess I'm doing something wrong because now there's nothing shooting at all.

NPC Code:
//#CLIENTSIDE
function onWeaponFired()
{
setani("shoot",0);
temp.angle = getangle(vecx(player.dir), vecy(player.dir));
shoot(player.x, player.y, player.z, temp.angle, 0, 0, "temp_shuri", "val_shuriken.png");
freezeplayer(0.3);
}

Reply With Quote
  #4  
Old 03-10-2010, 07:27 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
post the gani please
__________________
.
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 03-10-2010, 09:02 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
I just made all those thing kind of fast just to test the script.

The Shuriken: Name:  val_shuriken.png
Views: 285
Size:  285 Bytes
The Gani : temp_shuri.gani
Reply With Quote
  #6  
Old 03-10-2010, 09:09 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Black_knights55 View Post
Thanks, that's working.
Now, I did a new projectile called val_shuriken.png and a new gani called temp_shuri.gani. I've replaced "arrow" and "barrow0.png" but I guess I'm doing something wrong because now there's nothing shooting at all.

NPC Code:
//#CLIENTSIDE
function onWeaponFired()
{
setani("shoot",0);
temp.angle = getangle(vecx(player.dir), vecy(player.dir));
shoot(player.x, player.y, player.z, temp.angle, 0, 0, "temp_shuri", "val_shuriken.png");
freezeplayer(0.3);
}

Make sure the image in your gani is set to PARAM1.
Let me try to explain shoot a little bit better:

level.shoot(start x, start y, start z, direction of shot, z-angle, strength, gani, gani params);


By editing strength, you can specify strength based on the gravity settings for your server/client, increasing strength increases speed of the shot.

By changing z-angle you can make your shot arch in the air using some trigonometric math.

If you want to change your gravity, you can simply do gavity=5 (for example), which is a global variable. If you change it on the clientside, it will only affect that person's gravity, but if you change it serverside, it will affect the whole server. If you change your gravity high enough, shots will fly over walls, etc.

Quote:
Originally Posted by Black_knights55 View Post
I just made all those thing kind of fast just to test the script.

The Shuriken: Attachment 50548
The Gani : Attachment 50547
You need to change your shuriken sprite's image to PARAM1 (on the left side of the gani editor), right now it is equal to the name of the image, but if you look in the lower right side of the gani editor it says "def param1", that means wherever PARAM1 is placed, that image will be there. By using PARAM1, you also make the image accessible by script, which is exactly what you need to do for the shoot function. However, if you don't plan to change the image at all, you can simply leave the param1 part of the shoot command blank (like "") and simply specify a gani to use.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #7  
Old 03-10-2010, 10:18 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
Thanks, I really appreciate your explanations. But, when I use the weapon, nothing is shooting. The player freeze and play the ani "shoot" but there no projectile. I don't understand why it doesn't just shoot that shuriken lol.
Reply With Quote
  #8  
Old 03-10-2010, 10:33 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Black_knights55 View Post
Thanks, I really appreciate your explanations. But, when I use the weapon, nothing is shooting. The player freeze and play the ani "shoot" but there no projectile. I don't understand why it doesn't just shoot that shuriken lol.
I can't check the GANI now (on Mac), but try setting it to "sword", then listen for the slash sound. You will also see shadows shooting if it works. The code should be similar to

Graal Script Code:
temp.player.+ (vecx(player.dir) * 1.5);
temp.player.+ (vecy(player.dir) * 2);
temp.0;

temp.angle = (player.dir 1) * (pi 2);
temp.zangle 0;
temp.power 0;

temp.ani "sword";
temp.ani.param "";

player.level.shoot(xyzanglezanglepoweraniani.param); 
__________________
Reply With Quote
  #9  
Old 03-10-2010, 11:03 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
Yes it's working. But when I put my custom gani and image, it doesn't. Probably something with the gani I did wrong.
Reply With Quote
  #10  
Old 03-11-2010, 12:10 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by Black_knights55 View Post
Yes it's working. But when I put my custom gani and image, it doesn't. Probably something with the gani I did wrong.
The gani is working fine for me, except for the PARAM1 thing that Tigairius mentioned. Maybe it's not uploaded properly?
Reply With Quote
  #11  
Old 03-11-2010, 02:10 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
I updated the gani with the PARAM1 thing, but not sure I did it well. Here's the new one.

temp_shuri.gani

Maybe with the upload... I've put the .gani in levels/ganis/, is that ok? Or it has to be in another specific folder?
Reply With Quote
  #12  
Old 03-11-2010, 06: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
Quote:
Originally Posted by Black_knights55 View Post
Maybe with the upload... I've put the .gani in levels/ganis/, is that ok? Or it has to be in another specific folder?
if you have levels/ganis it should be the right folder because it should be set to allow .gani files.
If you're unsure, you can still check the folder configuration
Name:  foldconfig.png
Views: 235
Size:  30.3 KB
You should have things like this:

file *.gani

and

file ganis/*.gani
Reply With Quote
  #13  
Old 03-11-2010, 10:04 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by alexandralove View Post
if you have levels/ganis it should be the right folder because it should be set to allow .gani files.
If you're unsure, you can still check the folder configuration
Attachment 50550
You should have things like this:

file *.gani

and

file ganis/*.gani
An easier way to check is doing "/find filename". It should show up as downloadable. If not, the folder config is wrong.
__________________
Reply With Quote
  #14  
Old 03-13-2010, 02:23 PM
Black_knights55 Black_knights55 is offline
Registered User
Join Date: Jan 2008
Posts: 24
Black_knights55 is on a distinguished road
Thanks for your help! I made an error when writing the rights, so it wasn't able to detect the gani. So now, it throw the "shuriken" but after like half a second, the shuriken disappears and there's only the shadow left. When I tried with the "arrow.gani" the arrow was there all the time, and my gani is exactly the same, except it's single direction. Is there something I have to do with the gani to keep it visible when throwing it?

EDIT: Sorry, found my mistake. It just worked all fine. Thanks a lot for all your help. It really helped me understand all that stuff lol.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:51 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.