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 01-08-2012, 04:28 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Throwing bushes and stuff

I've been scripting my own movement system for a server, and I've been pondering over ways to make my script more efficient, which hopefully some of you can help me with.

First off, I've started working on a bush-throwing method for my movement script. What I've got at the minute is not terribly efficient in my opinion, as my script triggers the server from clientside, places a bush with putnpc2, and the class npc moves akin to a thrown bush.
With this, there is a noticeable delay between throwing the bush and the bush actually appearing, so I was wondering if there were any more efficient ways to achieve the same result.

Also, it seems when the player dies and then begins to move again, his default movement re-enables, and my movement script ceases to function. The only way I've managed to remedy this problem is by scheduling an event every 0.05 seconds to disable default movement until the player's hearts are above 0.
Again, I'd like to know if there is any function which executes when the player is revived.

Anything you guys can suggest will most likely be better than what I have, and it's much appreciated.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 01-08-2012, 04:32 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
Projectiles for the bush.

As for death problem, script your own health system, or alternatively when the player is hit with health <= damage, toggle a flag that says the player is dead and DON'T subtract the health. Let the death flag overwrite all other movement.
Reply With Quote
  #3  
Old 01-08-2012, 04:36 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Quote:
Originally Posted by DustyPorViva View Post
Projectiles for the bush.

As for death problem, script your own health system, or alternatively when the player is hit with health <= damage, toggle a flag that says the player is dead and DON'T subtract the health. Let the death flag overwrite all other movement.
Ah, thanks for that death alternative.

I'm not great with projectiles, so I'll need a few pointers as to how to recreate the path taken by a thrown bush.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #4  
Old 01-08-2012, 04:39 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 iBeatz View Post
Ah, thanks for that death alternative.

I'm not great with projectiles, so I'll need a few pointers as to how to recreate the path taken by a thrown bush.
This is what I used, it's not exact but it was close enough for me:

shoot(player.x,player.y,2,dir*(pi/2)+(pi/2),.25,1.1,"ce_thrownobj",player.attr[3]);

Also read up on:
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 01-08-2012, 05:23 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
For mine, I wrote a simple clientside projectile system using triggerserver/triggerclient to spawn them locally inside arrays, as I didn't think that projectiles offered quite what I needed to emulate Graal's exactly, but I might've been wrong about that.
Reply With Quote
  #6  
Old 01-08-2012, 05:45 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 Hezzy002 View Post
I didn't think that projectiles offered quite what I needed to emulate Graal's exactly, but I might've been wrong about that.
I'd say so too, there was always a lot of small problems you could only try to work around.
  • onActionProjectile is too sensative for when attempting to emulate old arrows/darts.
  • onActionProjectile2 is inconstant between Serverside and Clientside.
  • If you have custom damage or movement systems, you can't specify conditions for projectiles to ignore certain players.
  • There have been problems with the built-in isblockingprojectiles variable syncing from Serverside to Clientside in NPCs.
  • It's impossible to adjust the speed of projectiles, while allowing them to collide with wall tiles.
  • No way to shoot projectiles only within your client, without them syncing to other players.

In short, it's great if you're only trying to stick closely to Graal's built-in systems. Otherwise it's necessary to script your own projectile system if you want something perfectly reliable.
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 07:34 AM.


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