Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-18-2012, 11:30 PM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Custom Projectile (Bow)

I'm trying to make a custom bow with new images for my world, I found a script online that uses the command I need: "shoot" but I could not find it in the commands list so I don't know how to completely use it properly. Also I can't figure out how to make the arrows do damage, this is what I have so far.

// NPC made by E-Man
if (created) {
setimg woodenbow.png;
}
if (playertouchsme) {
toweapons Wooden Bow;
}
if (weaponfired && playerdir=0) {
freezeplayer 0.6;
setani shoot,woodenbow1.png;
sleep 0.2;
shoot playerx-0.8,playery+0.5,2,pi/2,0,0,eman_woodenarrow,;
}
if(weaponfired && playerdir=1){
freezeplayer 0.6;
setani shoot,woodenbow1.png;
sleep 0.2;
shoot playerx-1,playery+2,2,pi,1,0,eman_woodenarrow,;
}
if(weaponfired && playerdir=2){
freezeplayer 0.6;
setani shoot,woodenbow1.png;
sleep 0.2;
shoot playerx+0.2,playery+3,2,1.5*pi,.5,0,eman_woodenarr ow,;
}
if(weaponfired && playerdir=3){
freezeplayer 0.6;
setani shoot,woodenbow1.png;
sleep 0.2;
shoot playerx+1.3,playery+2,2,pi*2,1,0,eman_woodenarrow, ;
}



Also for some reason when I shoot left the arrow is transparent, I think that may be because of the shoot command though.
Reply With Quote
  #2  
Old 06-18-2012, 11:46 PM
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
Shoot inherits basic gani properties. In this case you can just set the graphics in the gani for each direction and they will be set automatically when fired. You can also simplify the script like so:

PHP Code:
if (weaponfired) {
  
freezeplayer 0.6;
  
setani shoot,woodenbow1.png;
  
sleep 0.2;
  
shoot playerx-0.8,playery+0.5,2,pi/2*playerdir,0,0,eman_woodenarrow,;

Reply With Quote
  #3  
Old 06-18-2012, 11:59 PM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Quote:
Shoot inherits basic gani properties. In this case you can just set the graphics in the gani for each direction and they will be set automatically when fired. You can also simplify the script like so:

PHP Code:
if (weaponfired) {
freezeplayer 0.6;
setani shoot,woodenbow1.png;
sleep 0.2;
shoot playerx-0.8,playery+0.5,2,pi/2*playerdir,0,0,eman_woodenarrow,;
}
Making the script shorter is cool, but that is not the problem I have, I need to know what the variables in the command "shoot" are, and I need to figure out why is it when I shoot only left, it is transparent, and I need to figure out how to injure npc baddies. Also that script that you said shoots weird, if you shoot left, the arrow up, if you shoot up, the arrow goes right, it goes one direction more clockwise than it should.

(Btw, how do you put a script in a PHP Code box?)
Reply With Quote
  #4  
Old 06-19-2012, 12:06 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
PHP Code:
  - new script command 'shoot' for shooting projectiles:
    
shoot x,y,z,angle,zangle,power,gani,ganiparams;
      
x,and specify the starting position
      angle 
shoot angle (when looking from the top): east is 0,
        
north 3.14/2west is 3.14south 3.14*3/2)
      
zangle the angle in vertical direction0 means the
        projectile is shoot horizontal
3.14/2 means straight to the
        sun
      power 
the shoot power which is used to shoot the projectile;
        if 
it's 0 then the projectile is shoot like an old arrow
        (doesn'
t fall downmoves 20 tiles each second)
      
gani the animation that is used for the projectilethe
        animation can be multidirectional
the engine automatically
        selects the best direction 
for the flying directionthe
        animation can have 1 step 
(not animated) or 7 stepsthen the
        engine is automatically choosing the good animation step 
for
        
the projectile flying angle when its raising then step 1 is
        taken
when flying horizontal it is step 4when it is short before
        the impact then the engine displays step 7
    When the projectile is landing 
or hitting an object then some actions
    are triggered
With the command 'setshootparams <params>;' you can set
    the parameters that the called scripts get
call 'setshootparams' before
    shooting the projectile
.
    
Client-side events:
      - 
actionprojectile:
        
is triggered when a projectile lands on the player/npc,
        
in #p(0), #p(1) etc. you have the parameters set with the
        
command setshootparams
    Server
-side events:
      - 
actionprojectile:
        
is triggered when a client has used the 'shoot' command to shoot a
        projectile 
and the projectile is landedin #p(0) and #p(1) you have
        
the x and y position of the impact in case you want to place an explosion
        
or similar things on the ground (the control-npc is automatically warped
        to the level where the impact happened
); #p(2),#p(3) etc. contain the
        
params set with 'setshootparams' (before shooting the projectile)
      - 
actionsprojectile:
        
is triggered when a server-side script has shot a projectile and the projectile
        is landed
in #p(0) and #p(1) you have the x and y position of the impact
        
(the control-npc is automatically warped to the level where the impact
        happened
); #p(2),#p(3) etc. contain the params set with 'setshootparams'
        
(before shooting the projectile)
    
Projectiles are easy to use and don't take a lot of bandwidth because only
    the shooting of the projectile needs to be sent, the movement is calculated on
    the different computers. The projectile is flying like a heavy object thrown
    through the air: the horizontal movement speed keeps the same (moves
    horzspeed=cos(zangle)*speed tiles all 0.05 seconds), the vertical speed is
    initialized as vertspeed=sin(zangle)*speed and is decreased by 0.1 all 0.05 seconds;
    then the new position (calculated all 0.05 seconds) is
    newx = x + cos(angle)*horzspeed, newy = y - sin(angle)*horzspeed,
    newz = z + vertspeed 
Reply With Quote
  #5  
Old 06-19-2012, 12:49 AM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Can you give me an example line that uses "shoot because that is kind of confusing. I mainly don't get the variables of : z, angle, zangle, and ganiparams. Also I still don't know how to use setshootparams or how to call it, and setshootparams is to do damage, right?
Reply With Quote
  #6  
Old 06-19-2012, 01:27 AM
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 E_Man View Post
Can you give me an example line that uses "shoot because that is kind of confusing. I mainly don't get the variables of : z, angle, zangle, and ganiparams. Also I still don't know how to use setshootparams or how to call it, and setshootparams is to do damage, right?
GS2 example of the shoot command:

Quote:
Originally Posted by cbk1994 View Post
PHP 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.aniParam "";
shoot(xyzanglezanglepoweranianiParam); 
Remove the parentheses and a couple other GS2 bits and you're good to go.
__________________
Reply With Quote
  #7  
Old 06-19-2012, 03:02 AM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
GS2 example of the shoot command:
I can't use gs2 scripts since I'm trial, but I may be able to figure out how to use the general variables in this command with gs1 with your script. But what is pi, it's in both gs1 and gs2 scripts, is that 3.14 or does it mean something else?
Reply With Quote
  #8  
Old 06-19-2012, 03:36 AM
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 E_Man View Post
But what is pi, it's in both gs1 and gs2 scripts, is that 3.14 or does it mean something else?
Programming languages typically work in radians instead of degrees. There's 2pi radians in a circle.



Notice how the radians on the circle (they have pi attached) compare to the degrees.

So to get the angle bullets should fly at, we can do..
PHP Code:
(player.dir 1) * (pi 2
Let's say I'm facing left, which means my dir is 1.



So we can start filling in values for that expression

PHP Code:
(1) * (pi 2
simplifies to..

PHP Code:
* (pi 2
which simplifies using basic math to simply pi. If we look on that circle, we can see where the angle pi lies.



This is where our bullets will fly. Try the same thing for any direction and you'll find the angle matches up to the direction the player is facing.
__________________
Reply With Quote
  #9  
Old 06-19-2012, 03:23 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Since graal functions work in radians, pi is an important variable seeing as pi *2 is equivalent to 360 degrees.

Apart from that it has no further significance.
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 10:15 PM.


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