Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2011, 11:57 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
How to handle custom swords

The thread title says it all.

I'm nearly done with my custom Item system and Inventory, but I'm still not sure how to handle custom swords.

I was thinking that I could maybe add a weapon to the player, that is called like the sword with a "-" in front of it , eg "-Sword of Doom" , and that has a script that reacts to the Button S, and take that weapon away when another sword is equipped.

But that seems awfully complicated. I'm sure you guys have probably thought of a much better way to do it. So which way should I do it?
Reply With Quote
  #2  
Old 01-22-2011, 12:09 AM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Use one weapon script that handles all possible swords I guess? I'm not sure I understand the question.
__________________
Testbed user: I figured since I can never find any scripters it was time to take desperate measures...and...TEACH MYSELF 0.0
Reply With Quote
  #3  
Old 01-22-2011, 01:08 AM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Like Maui said, you'd be better off using a single wNPC to handle the said equiping/inventory system, and have a database NPC to store/use all informations about each sword.
Using a wNPC for each sword is way too messy imo.

You could have custom variables with of course a sword attribute in your ganis. With a well organized template, manipulating the weapon's img using the weapon's name is much better, which is what most servers do. The rest should be a piece of cake next
Reply With Quote
  #4  
Old 01-22-2011, 01:18 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
My suggestion:

One database NPC named, say, Swords, formatted like so:

PHP Code:
function onInitialized() {
  
this.trigger("created"); // re-add values on start incase they were removed
}

function 
onCreated() {
  
this.sword.clearVars(); // empty variables so strays aren't left over to cause problems
  
  // Super Sword
  
this.sword.supersword.swordName "Super Sword";
  
this.sword.supersword.attackSpeed 0.2;
  
this.sword.supersword.damage 20;
  
  
// ****ty Sword
  
this.sword.****tysword.swordName "****ty Sword";
  
this.sword.****tysword.attackSpeed 1.2;
  
this.sword.****tysword.damage 1;
}

public function 
getSword(swordID) {
  return 
this.sword.(@ swordID).link();

then have a single weapon, named something like -Swords, that controls equipping of swords (have the inventory trigger it when the player equips a new sword)

PHP Code:
function onSwordEquipped(swordID) {
  
temp.sword Swords.getSword(swordID);
  
  
player.clientr.sword.swordName sword.swordName;
  
player.clientr.sword.attackSpeed sword.attackSpeed;
  
// etc..

Then in the clientside of -Swords you can read from the clientr variables.

(anyone ever realize what a weird word "sword" is?)
__________________
Reply With Quote
  #5  
Old 01-22-2011, 01:26 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
(anyone ever realize what a weird word "sword" is?)
Yes .

It's better than Sharp Metal Stick.
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #6  
Old 01-22-2011, 06:24 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
Thanks cbk1994! I'll do it that way when I get to it.
Right now I'm doing the HUD first.

Man, I forgot how much fun Graal coul be!
Reply With Quote
  #7  
Old 01-22-2011, 06: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
Your char seems really out of place with the rest of your graphics.
__________________
Quote:
Reply With Quote
  #8  
Old 01-22-2011, 06:45 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
Quote:
Originally Posted by fowlplay4 View Post
Your char seems really out of place with the rest of your graphics.
And there goes the fun!
You know, I don't care. I'm doing this for me, for fun. Because I always loved Graal (Graal 1.4 got me hooked, when there was offline multiplayer for up to 4 players, I would always make fun levels for me and my friends to play on with gamepads). I don't hire anyone, I don't hog this forum with posts about my server. It will probably never be a full-on playable server, but that's not what I'm aiming for. The way is the goal. The 50€ for 6 months Developers Gold are well spent, if you think about how short games that cost 10€ more are nowadays and the amount of time you can have with playing around on your server.

Maybe I could make custom bodies, but that's a pain in the ass.
Reply With Quote
  #9  
Old 01-22-2011, 07:08 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
Quote:
Originally Posted by AlexanderK View Post
And there goes the fun!
You know, I don't care. I'm doing this for me, for fun. Because I always loved Graal (Graal 1.4 got me hooked, when there was offline multiplayer for up to 4 players, I would always make fun levels for me and my friends to play on with gamepads). I don't hire anyone, I don't hog this forum with posts about my server. It will probably never be a full-on playable server, but that's not what I'm aiming for. The way is the goal. The 50€ for 6 months Developers Gold are well spent, if you think about how short games that cost 10€ more are nowadays and the amount of time you can have with playing around on your server.

Maybe I could make custom bodies, but that's a pain in the ass.
js, could use some black lines or sprites to fit geez.
__________________
Quote:
Reply With Quote
  #10  
Old 01-22-2011, 07:26 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
Quote:
Originally Posted by fowlplay4 View Post
js, could use some black lines or sprites to fit geez.
I'm sorry if you're offended by my post, I kind of overreacted.

But the other day I have been reading a few threads in this forum, and don't get me wrong, the scripting community is great and has been very helpful to me, but the attitude of some people in this forum is horrible. A lot of newbies get ridiculed, there is a lot of nagging, and people who rent servers are frowned upon because why would you rent a server? My post above is why.
Reply With Quote
  #11  
Old 01-22-2011, 07:36 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by AlexanderK View Post
I'm sorry if you're offended by my post, I kind of overreacted.

But the other day I have been reading a few threads in this forum, and don't get me wrong, the scripting community is great and has been very helpful to me, but the attitude of some people in this forum is horrible. A lot of newbies get ridiculed, there is a lot of nagging, and people who rent servers are frowned upon because why would you rent a server? My post above is why.
We only ridicule people who come here and expect freebies instead of genuinly wanting to learn.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #12  
Old 01-22-2011, 09:23 PM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
My method to handling is a tad different. I use -sword system which handles slicing/charging/spining/updating tiles, but I have individual sword weapons. When a player selects a sword I trigger a function serverside of the sword weapon which handles the stat modifiers and sets a clientr val with the sword name/sword image/inventory position. When player selects another sword I find the sword the player has by a clientr value I set, then after it returns the mods to normal then update the clientr val and then trigger the mods in the new sword.
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #13  
Old 01-25-2011, 05:51 PM
AlexanderK AlexanderK is offline
Registered User
AlexanderK's Avatar
Join Date: Mar 2006
Location: Germany
Posts: 79
AlexanderK is on a distinguished road
Send a message via MSN to AlexanderK
Quote:
Originally Posted by cbk1994 View Post
SUPER LONG QUOTE
I tried to do it like you suggested, but it didn't work, so I put in some echoes. It seems like the .link() doesn't survive the return. What could I do to fix that? I guess I just have to get every single value by itself, don't I?
These are the echoes:
HTML Code:
trigger1 in -Inventory
trigger2 in -SWeapons
ID:Sword1
trigger3 in database npc
damage before returning:20
damage after return:
And this is my code (which is basically yours but with different names for variables)
weapon -SWeapons:
PHP Code:
function onSWeaponEquipped(sweaponID) {
  echo(
"trigger2 in -SWeapons");
  echo(
"ID:"@sweaponID);
  
temp.sweapon sweapons.getSWeapon(sweaponID);
  echo(
"damage after return:"@temp.sweapon.damage);
  
clientr.sweapon.sweaponName sweapon.sweaponName;
  
clientr.sweapon.attackSpeed sweapon.attackSpeed;
  
clientr.sweapon.damage sweapon.damage;
  
clientr.sweapon.typus sweapon.typus;
  
clientr.sweapon.typus2 sweapon.typus2;


database npc sweapons:
PHP Code:
function onInitialized() {
  
this.trigger("created"); // re-add values on start incase they were removed
}

function 
onCreated() {
  
this.sweapon.clearVars(); // empty variables so strays aren't left over to cause problems
  
  //No Weapon
  
this.sweapon.none.sweaponName NULL;
  
this.sweapon.none.attackSpeed NULL;
  
this.sweapon.none.damage NULL;
  
this.sweapon.none.typus NULL;
  
this.sweapon.none.typus2 NULL;
  
  
// Sword 1
  
this.sweapon.Sword1.sweaponName "Sword 1";
  
this.sweapon.Sword1.attackSpeed 0.2;
  
this.sweapon.Sword1.damage 20;
  
this.sweapon.Sword1.typus "slash";
  
this.sweapon.Sword1.typus2 "normal";
  
}

public function 
getSWeapon(sweaponID) {
  echo(
"trigger3 in database npc");
  
temp.test this.sweapon.(@ sweaponID).link();
  echo(
"damage before returning:"@temp.test.damage);
  return 
temp.test;

Reply With Quote
  #14  
Old 01-25-2011, 10:55 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
Odd, I thought link worked like that.

This ought to work:

PHP Code:
function onInitialized() {
  
this.trigger("created"); // re-add values on start incase they were removed
}

function 
onCreated() {
  
this.sweapon.clearVars(); // empty variables so strays aren't left over to cause problems
  
  //No Weapon
  // added the below statement;
  // make sure to change the name ("SwordNone") for each sword, it doesn't
  // matter what it is, it just needs to be unique (it would be a good idea to prefix
  // it with Sword to prevent conflicts with other objects)
  
this.sweapon.none = new TStaticVar("SwordNone");
  
this.sweapon.none.sweaponName NULL;
  
this.sweapon.none.attackSpeed NULL;
  
this.sweapon.none.damage NULL;
  
this.sweapon.none.typus NULL;
  
this.sweapon.none.typus2 NULL;
  
  
// Sword 1
  
this.sweapon.Sword1 = new TStaticVar("Sword1");
  
this.sweapon.Sword1.sweaponName "Sword 1";
  
this.sweapon.Sword1.attackSpeed 0.2;
  
this.sweapon.Sword1.damage 20;
  
this.sweapon.Sword1.typus "slash";
  
this.sweapon.Sword1.typus2 "normal";
  
}

public function 
getSWeapon(sweaponID) {
  echo(
"trigger3 in database npc");
  
// removing link() from here since it now points to an actual object
  
temp.test this.sweapon.(@ sweaponID);
  echo(
"damage before returning:"@temp.test.damage);
  return 
temp.test;

__________________
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:23 PM.


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