Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-29-2007, 09:08 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Question Is this script right?

I just need the script looked over for errors. It's a harpoon weapon.
Graal Script Code:
//#CLIENTSIDE
function onCreated() {
  
client.max_harpo_ammo 10;
  
client.harpo_ammo=10;
  
this.harpo_on 0;
}
function 
onWeaponFired() {
  if (
this.harpo_on 0) {
    
this.harpo_on 1;
    if (
this.harpo_on && client.harpo_ammo 0) {
      
replaceani("walk""graalaxy_harpoon_walk");
      
replaceani("graalaxy_harpoon_empty_walk""graalaxy_harpoon_walk");
      
replaceani("idle""graalaxy_harpoon_idle");
      
replaceani("graalaxy_harpoon_empty_idle""graalaxy_harpoon_idle");
      
replaceani("sword""graalaxy_harpoon_shoot");
      
replaceani("graalaxy_harpoon_empty_shoot""graalaxy_harpoon_shoot");
    } else if (
this.harpo_on && client.harpo_ammo 0) {
      
replaceani("walk""graalaxy_harpoon_empty_walk");
      
replaceani("graalaxy_harpoon_walk""graalaxy_harpoon_empty_walk");
      
replaceani("idle""graalaxy_harpoon_empty_idle");
      
replaceani("graalaxy_harpoon_idle""graalaxy_harpoon_empty_idle");
      
replaceani("sword""graalaxy_harpoon_empty_shoot");
      
replaceani("graalaxy_harpoon_shoot""graalaxy_harpoon_empty_shoot");
    }
  } else if (
this.harpo_on 1) {
    
this.harpo_on 0;
    
replaceani("graalaxy_harpoon_walk""walk");
    
replaceani("graalaxy_harpoon_empty_walk""walk");
    
replaceani("graalaxy_harpoon_idle""idle");
    
replaceani("graalaxy_harpoon_empty_idle""idle");
    
replaceani("graalaxy_harpoon_shoot""sword");
    
replaceani("graalaxy_harpoon_empty_shoot""sword");
  }
}
function 
onKeyPressed(keycodekeychar) {
  if (
this.harpo_on && keychar "r") {
    if (
client.harpo_ammo 0) {
      
setani("graalaxy_harpoon_reload"" ");
      
client.harpo_ammo client.max_harpo_ammo;
    }
  }
  if (
keychar "s" && client.harpo_ammo 0) {  
  
client.harpo_ammo -= 1;
  
setshootparams("damage"3);
  
temp.shootangle getangle(vecx(player.dir), vecy(player.dir));
  
shoot(player.x+vecx(player.dir), player.y+vecy(player.dir), player.ztemp.shootangle00"graalaxy_harpoon_arrow"NULL);
  }

__________________
Reply With Quote
  #2  
Old 05-29-2007, 09:09 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Graal Script Code:
//#CLIENTSIDE
function onCreated() {
  
client.max_harpo_ammo 10;
  
client.harpo_ammo=10;
  
this.harpo_on 0;
}
function 
onWeaponFired() {
  if (
this.harpo_on 0) {
    
this.harpo_on 1;
    if (
this.harpo_on && client.harpo_ammo 0) {
      
replaceani("walk""graalaxy_harpoon_walk");
      
replaceani("graalaxy_harpoon_empty_walk""graalaxy_harpoon_walk");
      
replaceani("idle""graalaxy_harpoon_idle");
      
replaceani("graalaxy_harpoon_empty_idle""graalaxy_harpoon_idle");
      
replaceani("sword""graalaxy_harpoon_shoot");
      
replaceani("graalaxy_harpoon_empty_shoot""graalaxy_harpoon_shoot");
    } else if (
this.harpo_on && client.harpo_ammo 0) {
      
replaceani("walk""graalaxy_harpoon_empty_walk");
      
replaceani("graalaxy_harpoon_walk""graalaxy_harpoon_empty_walk");
      
replaceani("idle""graalaxy_harpoon_empty_idle");
      
replaceani("graalaxy_harpoon_idle""graalaxy_harpoon_empty_idle");
      
replaceani("sword""graalaxy_harpoon_empty_shoot");
      
replaceani("graalaxy_harpoon_shoot""graalaxy_harpoon_empty_shoot");
    }
  } else if (
this.harpo_on 1) {
    
this.harpo_on 0;
    
replaceani("graalaxy_harpoon_walk""walk");
    
replaceani("graalaxy_harpoon_empty_walk""walk");
    
replaceani("graalaxy_harpoon_idle""idle");
    
replaceani("graalaxy_harpoon_empty_idle""idle");
    
replaceani("graalaxy_harpoon_shoot""sword");
    
replaceani("graalaxy_harpoon_empty_shoot""sword");
  }
}
function 
onKeyPressed(keycodekeychar) {
  if (
this.harpo_on && keychar "r") {
    if (
client.harpo_ammo 0) {
      
setani("graalaxy_harpoon_reload"" ");
      
client.harpo_ammo client.max_harpo_ammo;
    }
  }
  if (
keychar "s" && client.harpo_ammo 0) {  
  
client.harpo_ammo -= 1;
  
setshootparams("damage"3);
  
temp.shootangle getangle(vecx(player.dir), vecy(player.dir));
  
shoot(player.x+vecx(player.dir), player.y+vecy(player.dir), player.ztemp.shootangle00"graalaxy_harpoon_arrow"NULL);
  }

You missed a quote
But, bad practise is using "=" inside if statements, change them to "=="
__________________
Reply With Quote
  #3  
Old 05-29-2007, 09:12 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Wrong again.

Graal Script Code:
//#CLIENTSIDE
function onCreated() {
  
client.max_harpo_ammo 10;
  
client.harpo_ammo=10;
  
this.harpo_on 0;
}
function 
onWeaponFired() {
  if (
this.harpo_on 0) {
    
this.harpo_on 1;
    if (
this.harpo_on == && client.harpo_ammo 0) {
      
replaceani("walk""graalaxy_harpoon_walk");
      
replaceani("idle""graalaxy_harpoon_idle");
      
replaceani("sword""graalaxy_harpoon_shoot");
    } else if (
this.harpo_on == && client.harpo_ammo == 0) {
      
replaceani("walk""graalaxy_harpoon_empty_walk");
      
replaceani("idle""graalaxy_harpoon_empty_idle");
      
replaceani("sword""graalaxy_harpoon_empty_shoot");
    }
  } else if (
this.harpo_on == 1) {
    
this.harpo_on 0;
    
replaceani("walk""walk");
    
replaceani("idle""idle");
    
replaceani("sword""sword");
  }
}
function 
onKeyPressed(keycodekeychar) {
  if (
this.harpo_on == && keychar == "r") {
    if (
client.harpo_ammo == 0) {
      
setani("graalaxy_harpoon_reload"" ");
      
client.harpo_ammo client.max_harpo_ammo;
    }
  }
  if (
keychar == "s" && client.harpo_ammo 0) {  
  
client.harpo_ammo -= 1;
  
setshootparams("damage"3);
  
temp.shootangle getangle(vecx(player.dir), vecy(player.dir));
  
shoot(player.x+vecx(player.dir), player.y+vecy(player.dir), player.ztemp.shootangle00"graalaxy_harpoon_arrow"NULL);
  }

__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #4  
Old 05-29-2007, 09:13 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Ziro, what was the error?

Quote:
Originally Posted by Chompy View Post
But, bad practise is using "=" inside if statements, change them to "=="
Does it change anything?
__________________
Reply With Quote
  #5  
Old 05-29-2007, 09:20 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
For example.

1) replaceani("walk", "graalaxy_harpoon_walk");
That replaces the WALKING ani with graalaxy_harpoon_walk.
2) replaceani("graalaxy_harpoon_walk", "graalaxy_harpoon_empty_walk");
That tries to replace a DEFAULT ani named graalaxy_harpoon_walk, which obviously doesn't exist.
3) replaceani("walk", "graalaxy_harpoon_empty_walk");
That does the trick! And to replace the harpoon walk ani to the default walk ani...
4) replaceani(walk", "walk");
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #6  
Old 05-29-2007, 09:21 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by xXziroXx View Post
Wrong again.
Huh?
__________________
Reply With Quote
  #7  
Old 05-29-2007, 09:22 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
nice, but now it doesn't change the ganis when u run out of ammo
__________________
Reply With Quote
  #8  
Old 05-29-2007, 10:41 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Chompy View Post
You missed a quote
But, bad practise is using "=" inside if statements, change them to "=="
Double equal signs are used for comparison, while a single is used for assignment.
__________________
Reply With Quote
  #9  
Old 05-31-2007, 01:33 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
if ( var = true )

could set var to true. There is a limited protection for this so whole scripts don't get screwed up.

I would recommend disabling the players weapons for this script, then custom scripting the onKeyPressed() instead of replacing the anis of sword, etc.

I personally would disagree with this:

Graal Script Code:
if (this.harpo_on == && keychar == "r") { 
I don't like that styling much, but it's purely personal preference. Most people think that so long as they are related that's okay. You could also do something like this:

Graal Script Code:
function onKeyPressedkeycodekeychar )
{
  if ( 
this.harpo_on == false )
  {
    return 
false;
  }
  if ( 
keychar == "r" )
  {
    if ( 
client.harpo_ammo != )
    {
      return 
false;
    }
    
    
// Set gani, change ammo, etc.
  
}

Also, I advise against using client.harpoon_ammo; you could use a this. variable, and then have it base encoded, and unencode it for checks. Something like this:

Graal Script Code:
function setAmmoammo )
{
  
this.ammo base64encodeammo );
}
function 
getAmmo()
{
  return 
base64decodethis.ammo );

This way it's harder to hack--though if it's a good hacker, they could just modify the code, hehe.

Nice script though; better than I used to do for guns.

(I used to modify sprites.png, and then change the arrows so they looked like bullets, then shoot arrows at everyone! Hah!)
__________________
Reply With Quote
  #10  
Old 08-13-2007, 07:37 AM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
ah yes true, but- that script would be like a sword that ghost bullets shoot out of, there is no paramater for the shoot() function.
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #11  
Old 08-13-2007, 06:20 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Talk about thread revivification.
__________________
Do it with a DON!
Reply With Quote
  #12  
Old 10-12-2007, 10:54 PM
BonzaiXxXSRStudios BonzaiXxXSRStudios is offline
Since 2001
BonzaiXxXSRStudios's Avatar
Join Date: Jul 2007
Location: Atlanta, Georgia USA
Posts: 108
BonzaiXxXSRStudios is on a distinguished road
Send a message via MSN to BonzaiXxXSRStudios
2 months later...tell me about it. ;D
__________________


Nutos (Jasler) and Yoke (lDarkDragonl) at Bonzai and Storm Reach Studios
Reply With Quote
  #13  
Old 10-12-2007, 11:46 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
HTML Code:
//#CLIENTSIDE
function onCreated() {
  client.max_harpo_ammo = client.harpo_ammo =10;
}

function onWeaponFired() {
  this.gunOn = !this.gunOn;
  if (this.gunOn == true) {
    if (client.harpo_ammo > 0) {
      temp.gani = {"_walk", "_idle", "_shoot"};
    } else {
      temp.gani = {"_empty_walk", "_empty_idle", "_empty_shoot"};
    }
  } else {
   temp.gani = {"walk", "idle", "sword"};
  }
  temp.base = {"walk", "idle", "sword"};
  for (temp.i: temp.base) {
    temp.syn = (temp.gani[temp.base.index(temp.i)].starts("_")? "graalaxy_harpoon_": null);
    replaceani(temp.i, temp.syn.trim() @ temp.gani[temp.base.index(temp.i)]);
  }
}
slight mods
__________________
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 10:04 AM.


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