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
  #16  
Old 07-29-2009, 09:50 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Programmer View Post
I suggest you look through the Graal Wikipedia. It will help you a lot quicker than asking for help here. It may also benefit you to collaborate with another scripter so you can learn more about the language.
Seriously, the GraalWiki needs some updates/changes. When I go on there to look for a function, I get about 200 unrelated pages and none of them having to do with what I'm looking for.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Darlene159; 07-30-2009 at 03:22 AM..
Reply With Quote
  #17  
Old 07-31-2009, 05:56 AM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
LOL'd at the deleted posts.

Jamerson, you may want to make a success rate on this. So maybe try
PHP Code:
temp.success int(random(1,50));
if (
success == 1) {
//continue

Also use "setani(jamerson_shovel,null);" and "freezeplayer(1);"
Reply With Quote
  #18  
Old 07-31-2009, 01:20 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Novice View Post
LOL'd at the deleted posts.

Jamerson, you may want to make a success rate on this. So maybe try
PHP Code:
temp.success int(random(1,50));
if (
success == 1) {
//continue

Also use "setani(jamerson_shovel,null);" and "freezeplayer(1);"
That's not even his problem... yet a success rate is not bad. Even thought I think that's a little too low D:
Reply With Quote
  #19  
Old 07-31-2009, 01:33 PM
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
Remember that random also creates a floating point, so you'd most likely want to check if 'success' was <=1, instead of just == 1. Can also simplify the matter by using int() on the random value.
Reply With Quote
  #20  
Old 07-31-2009, 01:37 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by DustyPorViva View Post
Remember that random also creates a floating point, so you'd most likely want to check if 'success' was <=1, instead of just == 1. Can also simplify the matter by using int() on the random value.
He is using int() :S
Reply With Quote
  #21  
Old 07-31-2009, 01:48 PM
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
Hm... I don't remember seeing that before. Oh well! Still better to use <= though, as you can then create higher chances and such.
Reply With Quote
  #22  
Old 07-31-2009, 01:58 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
To clarify on what Dusty said, you really should have a player class with some basic item functions, e.g.

PHP Code:
public function addItem(itemquantity) {
  
// checks to make sure quantity is valid, etc.
  
  
this.clientr.item.(@ item) += quantity;
  
this.addWeapon(item);
  
  
// perhaps some logging?
}

public function 
removeItem(itemquantity) {
  
// checks to make sure quantity is valid
  
  
this.clientr.item.(@ item) = max(0this.clientr.item.(@ item) - quantity); // the 'max' prevents the quantity from falling below zero
  
if (this.clientr.item.(@ item) <= 0) {
    
this.removeWeapon(item);
  }
  
// perhaps some logging?
}

public function 
getItemQuantity(item) {
  return 
this.clientr.item.(@ item);

You would create a class called "player" or so, then join it to the player in the onActionPlayerOnline function in the Control-NPC, like...

PHP Code:
function onActionPlayerOnline() {
  
player.join("player");

You could then do stuff like

PHP Code:
  temp.prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"}; 
  
player.addItem(randomstring(prizes), 1); 
which would automatically handle adding the weapon, changing the quantity, and logging (if you added that).

Also, you should use player.level.name, not player.level. The former is a string, which is what you want, while the latter is an object. Unfortunately, Graal does some funny stuff which will let that work, but it's poor scripting to do so.
__________________
Reply With Quote
  #23  
Old 07-31-2009, 02:02 PM
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 cbk1994 View Post
Also, you should use player.level.name, not player.level. The former is a string, which is what you want, while the latter is an object. Unfortunately, Graal does some funny stuff which will let that work, but it's poor scripting to do so.
I think this is one of the most frequent problems I encounter... I never remember and using the former actually works most of the time until I randomly encounter the time that player.level won't work and I sit for a day or two trying to figure out why the **** my script isn't working correctly.
Reply With Quote
  #24  
Old 07-31-2009, 02:06 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 DustyPorViva View Post
I think this is one of the most frequent problems I encounter... I never remember and using the former actually works most of the time until I randomly encounter the time that player.level won't work and I sit for a day or two trying to figure out why the **** my script isn't working correctly.
It can be quite confusing, and understandably so. The same applies to player.ani.
__________________
Reply With Quote
  #25  
Old 07-31-2009, 06:09 PM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Quote:
Originally Posted by Pelikano View Post
That's not even his problem... yet a success rate is not bad. Even thought I think that's a little too low D:
I know, I was just giving an example and an idea.
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:41 PM.


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