View Single Post
  #5  
Old 02-27-2008, 01:59 PM
Striat
Sarnak
 
Join Date: Aug 2006
Posts: 60
Default

Wanted to make a suggestions for something that may make quest globals a little more functional for you
[QUOTE=trevius;143734]

Code:
sub EVENT_SAY {
  if ($text=~/hail/i && $level_quest == undef) {
    quest::say("Hello, $name, you don't have a flag defined for this quest yet.  Would you like a flag?");}

  if ($text=~/flag/i && $level_quest == undef) {
    quest::say("Hello, $name, you don't have a flag defined for this quest yet.  Would you like a flag?");
quest::setglobal("level_quest", 1, 5, "F"); 
}

  if ($text=~/hail/i && $level_quest == 1) {
    quest::say("Hello, $name, you are flagged with 1 for this quest.");}

    }
    $level_quest = undef;
    }
}
For this, I'd write it,

Code:
sub EVENT_SAY {
  if ($text=~/hail/i && $level_quest == undef) {
    quest::say("Hello, $name, you don't have a flag defined for this quest yet.  Would you like a flag?");}

  if ($text=~/flag/i) {
  if ($qglobals{level_quest} == 1) {
  quest::say("Hello, $name, you are flagged with 1 for this quest.");
  }
  elsif ($qglobals{level_quest} != 1) {
    quest::say("Hello, $name, you don't have a flag defined for this quest yet.  Would you like a flag?");
quest::setglobal("level_quest", 1, 5, "F"); 
}
}
}
Using the hases prevents you from having to undef variable each time. You can write is alot cleaner too.

I've written countless progression quests and here is another example of how you can write it to end up with cleaner text, etc.

Code:
sub EVENT_SAY {
if ($text=~/hail/i) {
    if ($qglobals{generaltom} == 4) {
       quest::say("You have proven yourself well, $name.  For this next task, I'll need you to destroy the vicious sabertooth outside of the vilalge.  He has run off with alot of our children");
    }
    elsif ($qglobals{generaltom} == 3) {
    quest::say("Now, I'll need you to kill some deer to make the ceremonial headdress.");
    }
    elsif ($qglobals{generaltom} == 2) {
    quest::say("Great, I'll need you to forage some green ikk berries to make the die for the ceremonial clothing.");
    }
    elsif ($qglobals{generaltom} == 1) {
    quest::say("Seek out the alchemist and obtain the recipe for making the ceremonial headdress
    }
    else {
    quest::say("You really handled that tiger well, $name!   Good luck with your journeys");
     }
 }
}
Reply With Quote