Aller au contenu

Photo

Altering script?


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

#1
Who said that I

Who said that I
  • Members
  • 492 messages

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

 



#2
Proleric

Proleric
  • Members
  • 2 354 messages
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.
  • Lightfoot8 aime ceci

#3
Who said that I

Who said that I
  • Members
  • 492 messages

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! :D



#4
Proleric

Proleric
  • Members
  • 2 354 messages
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?
  • Lightfoot8, Who said that I et Grani aiment ceci

#5
meaglyn

meaglyn
  • Members
  • 809 messages

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.


  • Lightfoot8, Squatting Monk et 3RavensMore aiment ceci

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

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. 


  • Squatting Monk aime ceci

#7
Who said that I

Who said that I
  • Members
  • 492 messages
@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. :)

#8
Who said that I

Who said that I
  • Members
  • 492 messages

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. 


  • Proleric aime ceci

#9
Who said that I

Who said that I
  • Members
  • 492 messages

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