Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-09-2010, 10:33 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Boomerang

This is the boomerang script, I made for Classic iPhone a month or two ago. Basic collision detection for hitting players is in the script, but will require modification for things like throwing it diagonally initially.

PHP Code:
//#CLIENTSIDE

function onWeaponFired() {
  
// Check if boomerang is out
  
if (this.active) return;
  
// Player animation
  
setani("grab""");
  
freezeplayer(0.1);
  
// Throw boomerang
  
beginBoomerang();
}

function 
beginBoomerang() {
  
// Initialize Boomerang
  
this.boomerang_x player.vecx(player.dir);
  
this.boomerang_y player.1.5 vecy(player.dir);
  
this.boomerang_dir player.dir;
  
this.boomerang_ang 0;
  
// Activate
  
this.active true;
  
// Draw boomerang
  
drawBoomerang();
  
// Loop
  
setTimer(0.05);
}

function 
onTimeout() {
  
// Check if deactivating
  
if (!this.active) {
    
hideBoomerang();
    return;
  }
  
// Move boomerang
  
if (this.boomerang_ang < (pi 2)) {
    
this.boomerang_x += vecx(this.boomerang_dir) * cos(this.boomerang_ang) * 2;
    
this.boomerang_y += vecy(this.boomerang_dir) * cos(this.boomerang_ang) * 2;
    
this.boomerang_ang += (pi 16);
  } else {
    
temp.newangle getangle(this.boomerang_x player.1.5this.boomerang_y player.1.5);
    
this.boomerang_x += cos(temp.newangle) * cos(this.boomerang_ang) * 1.5;
    
this.boomerang_y -= sin(temp.newangle) * cos(this.boomerang_ang) * 1.5;
    if (
this.boomerang_ang pi) {
      
this.boomerang_ang += (pi 16);
    }
    if (
this.boomerang_x in |player.xplayer.3| && this.boomerang_y in |player.yplayer.3|) {
      
this.active false;
    }
  }
  
// Draw boomerang
  
updateBoomerang();
  
// Hit Objects
  
temp.plyr testplayer(this.boomerang_x 0.5this.boomerang_y 0.5);
  if (
temp.plyr 0) {
    if (
this.lasthit == 0) {
      
this.lasthit 5;
      
// Hit Player
      
temp.obj players[temp.plyr];
    } else {
      
this.lasthit--;
    }
  }
  
// Loop
  
setTimer(0.05);
}

function 
drawBoomerang() {
  
with (findimg(1)) {  
    
thiso.boomerang_x;
    
thiso.boomerang_y;
    
ani "classic_boomerang";
    
layer 1;
  }
}

function 
hideBoomerang() {
  
hideimg(1);
}

function 
updateBoomerang() {
  
with (findimg(1)) {  
    
thiso.boomerang_x;
    
thiso.boomerang_y;
  }

Included the gani that it uses as well, it uses the default sprites.
Attached Files
File Type: gani classic_boomerang.gani (493 Bytes, 480 views)
__________________
Quote:
Reply With Quote
  #2  
Old 08-09-2010, 10:46 PM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Isn't it generally undesirable to use "global" showimgs, those with an index below 200, as they only seem to be updated every other frame (From what I saw the other day) and there's more efficient ways to do it (In terms of network usage) that also have the advantage of letting you control it on each individual client, allowing you to interpolate or extrapolate it in order to smooth it?
Reply With Quote
  #3  
Old 08-11-2010, 02:00 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by 12171217 View Post
Isn't it generally undesirable to use "global" showimgs, those with an index below 200, as they only seem to be updated every other frame (From what I saw the other day) and there's more efficient ways to do it (In terms of network usage) that also have the advantage of letting you control it on each individual client, allowing you to interpolate or extrapolate it in order to smooth it?
I've never had complaints about using the global indexes with animations before, and the 'efficiency' gains don't really seem worth it to me.

Feel free to script your version and post it.
__________________
Quote:
Reply With Quote
  #4  
Old 08-11-2010, 02:16 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by fowlplay4 View Post
I've never had complaints about using the global indexes with animations before, and the 'efficiency' gains don't really seem worth it to me.

Feel free to script your version and post it.
Same here. Most of the time it is "good enough". Plus, clientside interpolation could potentially go out of control if you have 100 people using boomerangs like mad (especially if on an iPhone).
Reply With Quote
  #5  
Old 08-11-2010, 09:32 AM
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 napo_p2p View Post
(especially if on an iPhone)
Don't worry about that. The iPhone client seems to run better than the PC one
__________________
Reply With Quote
  #6  
Old 09-14-2010, 02:28 AM
LordOfPi13 LordOfPi13 is offline
Classic iPhone LAT
LordOfPi13's Avatar
Join Date: Jul 2010
Location: California
Posts: 45
LordOfPi13 is an unknown quantity at this point
Send a message via AIM to LordOfPi13
Quote:
Originally Posted by napo_p2p View Post
Same here. Most of the time it is "good enough". Plus, clientside interpolation could potentially go out of control if you have 100 people using boomerangs like mad (especially if on an iPhone).
Some people still have the first generation iPod Touch... sooooooooooo....
Reply With Quote
  #7  
Old 09-14-2010, 10:58 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Cool. First post for a gs2 boomerang I've ever seen. :x GJ.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #8  
Old 09-15-2011, 01:19 PM
irock1 irock1 is offline
Registered User
Join Date: Aug 2011
Posts: 20
irock1 can only hope to improve
Setlevel2 dosent work on it to warp players
Reply With Quote
  #9  
Old 09-15-2011, 05:30 PM
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 irock1 View Post
Setlevel2 dosent work on it to warp players
You probably have used setLevel2 clientside. setLevel2 only works serverside. To use setLevel2 in a weapon such as this, I'd recommend using the triggerServer function to send the player object to the server, and then setting that player's level there.

Ie.
Clientside:
PHP Code:
triggerServer("gui"name"SetLevel"player object here); 
Serverside:
PHP Code:
function onActionServerSide() {
  if(
params[0] == "SetLevel"){
    
// your setlevel stuff here
  
}

__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #10  
Old 09-15-2011, 09:50 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 iBeatz View Post
Clientside:
PHP Code:
triggerServer("gui"name"SetLevel"player object here); 
There's never any reason to send the player's account in a trigger.
__________________
Reply With Quote
  #11  
Old 09-30-2011, 10:47 AM
irock1 irock1 is offline
Registered User
Join Date: Aug 2011
Posts: 20
irock1 can only hope to improve
No, I want to make it warp players on touch..
__________________
YOUR A
Reply With Quote
  #12  
Old 10-07-2011, 01:50 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
post your problems in npc scripting, not on threads.
also BUMP!
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
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 12:21 PM.


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