Author Topic: Altering script?  (Read 484 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Altering script?
« on: September 13, 2015, 08:10:54 pm »


               

Alright, well am using CNR script but was pondering on having a small alteration on the feeding animals part (partly due to the fact it is not functional in my module) 


 


so what I wanted to accomplish (with the help of someone around here helping me rebuild the script for me cause I have no real clue how to do this and would like to get this finished)  is to create a conversation with the cow/chicken and give you the option to feed the chicken/cow the corn/cornmeal you have in your inventory.


 


Personally not entirely sure how to go about this properly so hoping someone out here is willing to help me out with this...I would really appreciate that....


 


 


http://neverwinterva...l-resources-cnr


 



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Altering script?
« Reply #1 on: September 13, 2015, 10:20:29 pm »


               This is a classic "give the quest item to the quest giver if you have it" conversation, except that the cow says "moo" instead of "have you found the macguffin?"


See how far you can get with Lilac Soul / quest tutorial etc - I'll gladly help if you post your first attempt.
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Altering script?
« Reply #2 on: September 14, 2015, 09:54:54 pm »


               

awesome! Well with my limited skills I managed to get it done... 


 


The dialogue goes as follow with the chicken:


 


"cluck?"


 


Feed the chicken?


+ Yes



 


Onactiontaken- tab


 


void main()


{

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Take "cnrCornRaw" from the PC.

    DestroyObject(GetItemPossessedBy(oPC, "cnrCornRaw"));

}

 


++ Chicken laid an egg!



 


Onactiontaken - tab


 


void main()


{

    // Get the PC who is in this conversation.

    object oPC = GetPCSpeaker();

 

    // Give "cnrchickenegg" to the PC.

    CreateItemOnObject("cnrchickenegg", oPC);

}

 


- No


 


 


What I want to add...


 


Okay this is something I am a bit confused on how to do this (remember complete newb here but trying!) I would want to add a line that counts how many times you have given the chicken grain before it will lay an egg.


 


so for example you would need to feed the chicken like 6 pieces of grain before it will lay an egg.


 


any help would be awesome! '<img'>



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Altering script?
« Reply #3 on: September 14, 2015, 10:29:44 pm »


               You can use a local variable as a counter.


SetLocalInt(oPC, "TimesFed", GetLocalInt(oPC, "TimesFed") + 1);

Incidentally, how are you checking that the PC actually has the corn?
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Altering script?
« Reply #4 on: September 15, 2015, 12:23:40 am »


               

I'd highly recommend checking out some of the scripting guides and tutorials here. I think papermonk's guide, nwn_scripting_guide_1.0.pdf.7z  has a wealth of useful information you might want to read through some of.   Some of what's in there is also in the Lexicon, which is an invaluable resource. I think checking these out would be worth your time.



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Altering script?
« Reply #5 on: September 15, 2015, 01:48:53 am »


               

the chicken does have an inventory.  you could just place the grain in the chickens inventory(stomach).  then add to the chickens HB script to check how much grain it has eaten and lay an egg on the ground as needed. 



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Altering script?
« Reply #6 on: September 15, 2015, 08:12:29 am »


               @proleric I thought of that too though was not entirely sure how to write that so thanks!


Right now I have not really set it up...


@maeglyn thanks i will and have but sometimes i find it a bit of a brain grinder (i blame the language barrier) like with the quest script rutorial on the lexicon but will  give it a go.


@Lightfoot8 no inventory, want to keep it as much in conversation as possible. '<img'>
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Altering script?
« Reply #7 on: September 15, 2015, 03:18:36 pm »


               


You can use a local variable as a counter.

 



SetLocalInt(oPC, "TimesFed", GetLocalInt(oPC, "TimesFed") + 1);

Incidentally, how are you checking that the PC actually has the corn?

 




 


 




#include "nw_i0_plot"

int StartingConditional()

{

    //check inventory of oPC for oQuestItem and get iNumItems

    string sMark = "cnrCornRaw";

    int nMarkCount = 1;

    object oMark = GetObjectByTag(sMark);

    if(GetNumItems(GetPCSpeaker(),sMark) >= nMarkCount)

        return TRUE;

    return FALSE;

}

 

 



the script I used to check if the pc has at least 1 grain. The chicken will only take 1 at the time. 



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Altering script?
« Reply #8 on: September 16, 2015, 09:37:26 pm »


               

okay well just want to thank everyone who has helped me understand this a bit better and helped me get the solution for it, I really appreciate it '<img'>