Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Bomb & Bow (https://forums.graalonline.com/forums/showthread.php?t=74897)

HazeOfTime 06-26-2007 03:56 AM

Bomb & Bow
 
Does anyone have the default bomb and bow script, like the one used in classic?

Angel_Light 06-26-2007 04:06 AM

cant you use the default ones or do want to see the script? I'm not sure hwo they do there bow probably just shootarrow and stuff here's how I would do bombs

PHP Code:

//#CLIENTSIDE
function onWeaponFired() { 
if (
player.bombs 0) { 
  
setani("lay"NULL); 
  
freezeplayer(0.2); 
if (
isOnMap) { 
  
temp.px player.- (64 getMapX(player.level)) + 0.5 vecx(player.dir)*2
  
temp.py player.- (64 getMapY(player.level)) + 0.5 vecy(player.dir)*2
  
putBomb(1temp.pxtemp.py); 

else { 
  
putbomb(1,player.vecx(player.dir)*2player.0.5 vecy(player.dir)*2); 

  
player.bombs --; 




DustyPorViva 06-26-2007 04:12 AM

Why do you have to do all that detection for the player if they're on the map?
Last time I checked player.x/y gave the coordinates relative to the player on the gmap.

Angel_Light 06-26-2007 04:15 AM

if your in the top left level it does otherwise it doesnt

DustyPorViva 06-26-2007 04:20 AM

Hmmm, odd, I've never had that problem.

zokemon 06-26-2007 06:57 AM

Quote:

Originally Posted by Angel_Light (Post 1322566)
cant you use the default ones or do want to see the script? I'm not sure hwo they do there bow probably just shootarrow and stuff here's how I would do bombs

PHP Code:

//#CLIENTSIDE
function onWeaponFired() { 
if (
player.bombs 0) { 
  
setani("lay"NULL); 
  
freezeplayer(0.2); 
if (
isOnMap) { 
  
temp.px player.- (64 getMapX(player.level)) + 0.5 vecx(player.dir)*2
  
temp.py player.- (64 getMapY(player.level)) + 0.5 vecy(player.dir)*2
  
putBomb(1temp.pxtemp.py); 

else { 
  
putbomb(1,player.vecx(player.dir)*2player.0.5 vecy(player.dir)*2); 

  
player.bombs --; 




Much shorter version:
PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  if (
player.bombs <= 0) return; 
  
setani("lay""");
  
freezeplayer(0.2);
  
putBomb(1player.x%64 0.5 vecx(player.dir)*2player.y%64 vecy(player.dir)*2);
  
player.bombs --; 


Good use of math reduces the need to use if checks.
And why did you have + 0 on the Y for the map and + 0 on the x and + 0.5 for the Y off a map?

coreys 06-29-2007 08:13 AM

Psh. Math.


All times are GMT +2. The time now is 08:51 AM.

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