Aller au contenu

Fishing Spot Script


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
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 :),

 
//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!");
   }
}

#2
420

420
  • Members
  • 190 messages
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 .


#3
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
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.

#4
420

420
  • Members
  • 190 messages
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 .


#5
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
Thankyou, Is there a way to limit the amount of fish they can catch or?

#6
Thayan

Thayan
  • Members
  • 244 messages
//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 .


#7
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
Alright, how do I use this to limit it?

#8
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#9
Thayan

Thayan
  • Members
  • 244 messages
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).

#10
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
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 :)

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


#11
420

420
  • Members
  • 190 messages

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 :)

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

-420

#12
Guest_NWN Dragon-Blade_*

Guest_NWN Dragon-Blade_*
  • Guests
a 24 hour would probably be better