Author Topic: Fishing Spot Script  (Read 330 times)

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« on: February 27, 2011, 08:23:09 pm »


               I am currently making fishing spot NPC's in my module, but ive noticed the flow of fish is to high and i was wondering if there is a way to limit it. I am currently using it through a conversation with the NPC. This is the script from it. the NPC fishing spots info is:    Tag: FISHING_SPOT         res-ref: zep_armorstan001
Any help would be appreciated '<img'>,

 
//Put this on action taken in the conversation editor
#include "nw_i0_tool"
void main()
{
object oPC = GetPCSpeaker();
if (d100()<=50)
   {
   RewardPartyXP(50, oPC, FALSE);
   CreateItemOnObject("cray_fish", oPC);
   SendMessageToPC(oPC, "You caught a caryfish!");
   AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY2));
   }
else if (d100()<=3)
   {
   SendMessageToPC(oPC, "A crayfish bites you!");
 effect  eEffect = EffectDamage(1, DAMAGE_TYPE_PIERCING, DAMAGE_POWER_NORMAL);
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
   AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_STEAL));
   }
if (d100()<=7)
   {
   RewardPartyXP(100, oPC, FALSE);
   CreateItemOnObject("salmon_fish", oPC);
   }
else if (d100()<=40)
   {
   RewardPartyXP(40, oPC, FALSE);
   CreateItemOnObject("trout", oPC);
   SendMessageToPC(oPC, "You caught a trout!");
   }
else if (d100()<=3)
   {
   RewardPartyXP(200, oPC, FALSE);
   CreateItemOnObject("salmon_fish001", oPC);
   SendMessageToPC(oPC, "You caught a blow-fish!");
   }
}
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Fishing Spot Script
« Reply #1 on: February 27, 2011, 11:17:46 pm »


               OK, what exactly do you want to happen because the logic for the if/else if statements are way off. Do you want the PC to be able to catch more than one fish at once or only one fish a percentage of the time? If it's the latter, at what % do you want each fish to spawn?

-420
               
               

               


                     Modifié par 420, 27 février 2011 - 11:18 .
                     
                  


            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« Reply #2 on: February 28, 2011, 12:17:45 am »


               I want them to be able to catch one fish per percentage of the time, but I want it to be either of them, But i need a way to limit them so the PC's dont keep doing this over and over again.
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Fishing Spot Script
« Reply #3 on: February 28, 2011, 07:02:24 pm »


               Try this, I corrected a spelling error and added a line of feedback that was missing:


//Put this on action taken in the conversation editor
#include "nw_i0_tool"
void main()
{
object oPC = GetPCSpeaker();
int nPercent = d100();

if (nPercent <= 50)//50% chance to catch a crayfish
   {
   RewardPartyXP(50, oPC, FALSE);
   CreateItemOnObject("cray_fish", oPC);
   SendMessageToPC(oPC, "You caught a crayfish!");
   AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY2));
       if (nPercent <= 3)//3% of the time the crayfish you caught bites you
       {
       SendMessageToPC(oPC, "A crayfish bites you!");
       effect  eEffect = EffectDamage(1, DAMAGE_TYPE_PIERCING, DAMAGE_POWER_NORMAL);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
       AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_STEAL));
       }
   }
else if (nPercent >= 51 &&
         nPercent <= 90)//40% chance to catch a trout
   {
   RewardPartyXP(40, oPC, FALSE);
   CreateItemOnObject("trout", oPC);
   SendMessageToPC(oPC, "You caught a trout!");
   }
else if (nPercent >= 91 &&
         nPercent <= 97)//7% chance to catch a salmon
   {
   RewardPartyXP(100, oPC, FALSE);
   CreateItemOnObject("salmon_fish", oPC);
   SendMessageToPC(oPC, "You caught a salmon!");
   }

else if (nPercent >= 98)//3% chance to catch a blow-fish
   {
   RewardPartyXP(200, oPC, FALSE);
   CreateItemOnObject("salmon_fish001", oPC);
   SendMessageToPC(oPC, "You caught a blow-fish!");
   }
}


-420
               
               

               


                     Modifié par 420, 28 février 2011 - 07:03 .
                     
                  


            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« Reply #4 on: February 28, 2011, 09:38:57 pm »


               Thankyou, Is there a way to limit the amount of fish they can catch or?
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Fishing Spot Script
« Reply #5 on: March 01, 2011, 04:35:08 pm »


               //Put this on action taken in the conversation editor
#include "nw_i0_tool"
void main()
{
object oPC = GetPCSpeaker();
int nPercent = d100();
int nFishCaught = GetLocalInt(oPC, "GetTotalFishCaught");
int nFishLimit = 10; //Change this number to the limit of fish they can catch
if (nFishCaught > nFishLimit) {
SendMessageToPC(oPC, "You have caught your limit of fish.");
return;
}

if (nPercent <= 50)//50% chance to catch a crayfish
{
RewardPartyXP(50, oPC, FALSE);
CreateItemOnObject("cray_fish", oPC);
SendMessageToPC(oPC, "You caught a crayfish!");
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY2));
if (nPercent <= 3)//3% of the time the crayfish you caught bites you
{
SendMessageToPC(oPC, "A crayfish bites you!");
effect eEffect = EffectDamage(1, DAMAGE_TYPE_PIERCING, DAMAGE_POWER_NORMAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_STEAL));
}
}
else if (nPercent >= 51 &&
nPercent <= 90)//40% chance to catch a trout
{
RewardPartyXP(40, oPC, FALSE);
CreateItemOnObject("trout", oPC);
SendMessageToPC(oPC, "You caught a trout!");
}
else if (nPercent >= 91 &&
nPercent <= 97)//7% chance to catch a salmon
{
RewardPartyXP(100, oPC, FALSE);
CreateItemOnObject("salmon_fish", oPC);
SendMessageToPC(oPC, "You caught a salmon!");
}

else if (nPercent >= 98)//3% chance to catch a blow-fish
{
RewardPartyXP(200, oPC, FALSE);
CreateItemOnObject("salmon_fish001", oPC);
SendMessageToPC(oPC, "You caught a blow-fish!");
}
SetLocalInt(oPC, "GetTotalFishCaught", nFishCaught++);
}
               
               

               


                     Modifié par Thayan, 01 mars 2011 - 10:11 .
                     
                  


            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« Reply #6 on: March 01, 2011, 06:59:05 pm »


               Alright, how do I use this to limit it?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Fishing Spot Script
« Reply #7 on: March 01, 2011, 09:27:41 pm »


               Note that 8th line in his script, It reads.: 

int nFishLimit = 10; //Change this number to the limit of fish they can catch


He currently has it set for a fish limit of 10.   If you want to change it to a differant ammount. Just change the number and recompile it.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Fishing Spot Script
« Reply #8 on: March 01, 2011, 10:12:57 pm »


               Yep. Oh - and I didn't actually run it through the compiler but it shoudl work. Also, to make it a little more clean, you might want to change the following line:
if (GetLocalInt(oPC, "GetTotalFishCaught") > nFishLimit) {

to

if (nFishCaught > nFishLimit) {


It'll work either way though (assuming it compiles).
               
               

               
            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« Reply #9 on: March 01, 2011, 11:06:42 pm »


               Thanks,If the PC gets rid of the fish, will that variable still be there? If so how would I get that off? And it did compile '<img'>
               
               

               


                     Modifié par NWN Dragon-Blade, 01 mars 2011 - 11:08 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Fishing Spot Script
« Reply #10 on: March 02, 2011, 01:36:09 am »


               

NWN Dragon-Blade wrote...

Thanks,If the PC gets rid of the fish, will that variable still be there? If so how would I get that off? And it did compile '<img'>

Are you looking for a limit per day (24 hours) or a limit on fishy inventory items?

-420
               
               

               
            

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
Fishing Spot Script
« Reply #11 on: March 15, 2011, 02:33:08 am »


               a 24 hour would probably be better