|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Archive::Quests Archive area for Quests's posts that were moved here after an inactivity period of 90 days. |
|
|
|
09-11-2004, 01:46 PM
|
Fire Beetle
|
|
Join Date: Sep 2004
Posts: 12
|
|
review my work?
was wondering if someone could review my work. ive been testing out a few things.
please respond with any errors i have.
Code:
#practice script
sub EVENT_SAY
{
if($text=~/hail/i)
{
quest::say("Greetings $name. I can perform multiple [tasks] for you.");
}
if($text=~/what tasks/i)
{
quest::say("I can raise your [level] to whatever you wish, I can [save] your
progress, and summon a [weapon] for you");
}
if($text=~/level/i)
{
quest::say("State the level you wish to be.");
}
$level = $level;
if($text=~/$level/i)
{
quest::level($level);
quest::say("You have been leveled");
}
if($text=~/save/i)
{
quest::save();
quest::say("You have been saved");
}
if($text=~/what weapon/i)
{
quest::say("I can summon a random magical weapon for you. Decide now whether you want
it or not.");
}
if($text=~/yes/i)
{
$random = int(rand(55261,24773,25989,22982,26031,54065,43148,7823));
quest::summonitem($random);
quest::say("Your weapon has been summoned.");
}
}
sub EVENT_ITEM
{
{
quest::say("I do not require payment of any kind.");
if($item1 > 0){quest::summonitem("$item1");}
if($item2 > 0){quest::summonitem("$item2");}
if($item3 > 0){quest::summonitem("$item3");}
if($item4 > 0){quest::summonitem("$item4");}
if($platinum != 0 || $gold !=0 || $silver != 0 || $copper != 0) {
quest::givecash($platinum, $gold, $silver, $copper);}
}
}
also, so im not accused of stealing, the return items/cash piece at the end i got from sotonin. saw it in one of his quests and decided to use it since it is really useful thanks sotonin
|
|
|
|
09-11-2004, 01:50 PM
|
Demi-God
|
|
Join Date: May 2004
Posts: 1,177
|
|
It's ok. i didnt write it either, i got it from somebody here on the forums and posted it for all to use. glad you got some use from it. )
|
09-11-2004, 02:18 PM
|
Dragon
|
|
Join Date: Jan 2004
Posts: 860
|
|
Code:
$level = $level;
if($text=~/$level/i)
{
quest::level($level);
quest::say("You have been leveled");
}
This block of code is completely not what you want. $level = $level; will not change anything at all. if($text=~/$level/i) will only be true if they say whatever $level is. Since you didn't really give it any value it'll never be true. Or does $level store the current level of the user? If so then it will level them to their current level. essentially doing nothing at all.
Code:
$random = int(rand(55261,24773,25989,22982,26031,54065,43148,7823));
This is also not going to do what you want at all. rand doesn't accept input, so it'll ignore anything you give it. You will end up with a completely random number between 0 and the max rand can make.
|
09-11-2004, 02:39 PM
|
Fire Beetle
|
|
Join Date: Sep 2004
Posts: 12
|
|
what i was trying to do with the $level = $level thing was i wanted the person to just say a number, then use quest::level($level) to level them up to there desired level.
edit---
maybe this would work?
Code:
{
int $level;
if($text=~/$level/i)
{
quest::level($level);
}
}
|
|
|
|
09-11-2004, 04:28 PM
|
Demi-God
|
|
Join Date: Jun 2004
Location: Heaven.
Posts: 1,260
|
|
Quote:
Originally Posted by 8ball
what i was trying to do with the $level = $level thing was i wanted the person to just say a number, then use quest::level($level) to level them up to there desired level.
edit---
maybe this would work?
Code:
{
int $level;
if($text=~/$level/i)
{
quest::level($level);
}
}
|
Try this.
Code:
{
if($text >= $ulevel)
{
quest::say("You are now level $text.");
quest::level($text);
}
if($text == $ulevel)
{
quest::say("You are already level $ulevel.");
}
if($text <= $ulevel)
{
$difference = ($ulevel-$text);
$levelto = ($text);
quest::say("Are you sure you want to de-level $difference levels? [Yes] or [No].");
}
if($text=~/yes/i)
{
if($difference != 0)
{
quest::level($levelto);
$difference="0"
$levelto="0"
}
else
{
quest::say("Yes what?");
}
}
if($text=~/no/i)
{
if($difference != 0)
{
quest::say("Alright then.");
$difference="0"
$levelto="0"
}
else
{
quest::say("No what?");
}
}
}
I think that should work. But not sure?
__________________
namespace retval { template <class T> class ReturnValueGen { private: T x; public: ReturnValueGen() { x = 0; }; T& Generator() { return x; }; }; } int main() { retval::ReturnValueGen<int> retvalue; return retvalue.Generator(); }
C++ is wonderful.
|
|
|
|
09-11-2004, 05:10 PM
|
Fire Beetle
|
|
Join Date: Sep 2004
Posts: 12
|
|
thanks ill try that
|
09-11-2004, 05:35 PM
|
Dragon
|
|
Join Date: Jan 2004
Posts: 860
|
|
That code should work alright, but it'll be really weird because "hi" is >= "20". so if the input any text like hailing the NPC it'll try to level("Hail") the and that will probably cause problems.
|
|
|
|
09-11-2004, 06:20 PM
|
Demi-God
|
|
Join Date: Jun 2004
Location: Heaven.
Posts: 1,260
|
|
Quote:
Originally Posted by animepimp
That code should work alright, but it'll be really weird because "hi" is >= "20". so if the input any text like hailing the NPC it'll try to level("Hail") the and that will probably cause problems.
|
It is? err.. Lets try this..
Code:
{
if($text == $text)
{
if($text <= 255)
{
$xlevel = ($text);
if($xlevel >= $ulevel)
{
quest::say("You are now level $text.");
quest::level($xlevel);
}
if($xlevel == $ulevel)
{
quest::say("You are already level $ulevel.");
}
if($xlevel <= $ulevel)
{
$difference = ($ulevel-$xlevel);
$levelto = ($xlevel);
quest::say("Are you sure you want to de-level $difference levels? [Yes] or [No].");
}
if($text=~/yes/i)
{
if($difference != 0)
{
quest::level($levelto);
$difference="0";
$levelto="0";
$xlevel="0";
}
else
{
quest::say("Yes what?");
}
}
if($text=~/no/i)
{
if($difference != 0)
{
quest::say("Alright then.");
$difference="0"
$levelto="0"
}
else
{
quest::say("No what?");
}
}
else
{
quest::say("What was that?");
}
}
}
Mind you Its 2:20 AM Im very sleepy, this could be very very wrong, lol.
__________________
namespace retval { template <class T> class ReturnValueGen { private: T x; public: ReturnValueGen() { x = 0; }; T& Generator() { return x; }; }; } int main() { retval::ReturnValueGen<int> retvalue; return retvalue.Generator(); }
C++ is wonderful.
|
|
|
|
09-12-2004, 04:50 AM
|
Fire Beetle
|
|
Join Date: Sep 2004
Posts: 12
|
|
thank you thats exactly what i was looking for
|
09-12-2004, 12:58 PM
|
Hill Giant
|
|
Join Date: Dec 2003
Posts: 166
|
|
For the random weapon thing, you could probably pick a random index out of an array -- ie, something like:
Code:
my @nums = (55261,24773,25989,22982,26031,54065,43148,7823);
srand();
my $weapon = $nums[int(rand() * ($#nums + 1))];
print "random weapon: $weapon\n";
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 02:32 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|