Jump to content

Checking if player has items with keyword.


Recommended Posts

I've done this a long time ago but can't remember how.

Scenario - Player is going to light a fire and needs certain Misc. Objects. I am fine for scropting this part - check for wood, check for torch. To light the fire, as in real life, you can't just hold a torch to the wood (logs) and wait. Player requires at least 1 of 2 types of objects which I have already added Keywords to, they are...

Kindling - dry rag, broom bristles, dry hay... so far.

Accelerant - oil, alcohol... so far

 

I want the script to check that the player has at least 1 item from either of the keyword categories - Kindling or Accelerant.

I presume I am correct that this is the right way to do this but saying that 'Forms' come to mind and I don't remember how to do that either.

Help required please. Thank you.

Link to comment
Share on other sites

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Easiest solution to me would be to skip the keywords and use two separate formlists. One that contains all 'kindling' items and one that contains all 'accelerant' items. A GetItemCount on the formlist would return true if the player had at least one of anything on the given formlist. Running through the formlist entry by entry with a GetItemCount on the entry would let you find the first one that the player has with at least the desired amount. Downside is that it lends itself to using up whatever comes first with an every increasing stockpile of the later varieties.

 

That said, there is HasKeyword. I'm just not sure how you are going to obtain the item to check for the keyword. It would be usable if you made the fire pit a 'container' that the player needed to place the item within before it could be lit. The container's OnItemAdded event could check the incoming item for the appropriate keyword and send anything non-matching back to the player. Downside is that there is another layer of interaction that the player must go through.

 

Not knowing for sure how you want to approach your situation, cannot give more than some basic ideas.

Link to comment
Share on other sites

Expanding a little more IsharaMeradin suggestion (and also is how i would do it):


- Make a trigger box Activator and the container that "OnActivate()" (the trigger box) will "GetItemCount" 1 of each items required.

- If the player doesn't have all items a "No Items Message" will show up.

- If all items are in player's inventory, will remove 1 of each items from the player and place them in the container.

- The container will "OnItemAdded()" with 1 of each items, execute the light up function. > disable/enable, remove item, delete item, etc...



And you can expand it a little more and make it even more realistic by adding a certain amount of "wait" for the campfire to lit and wait for the "SendAnimationEvent" to finsh (with the necessary animation been send to the player to be executed), so that it looks as the player is placeing the items in the campfire and then lighting it up.


* This needs two Scripts, one for the Activator and one for the Container.

Edited by maxarturo
Link to comment
Share on other sites

Ok, this is something I haven't done before and am asking for help. What I can do/have done is make an activator triggerbox near the fire with a short script that just shows a message when activated. I placed a container (chest) behind the fireplace. Now, I'm not sure about what has been suggested. If I run a GetItemCount for every possible 'piece' of kindling and accelerant (more will be added later) then I don't see the reason for the chest and this method is what I have previously used to light other fires earlier in the mod when the player only had access to certain kindling and accelerant - this was a lot of 'GetItemCount… &&… &&… && for each combination and they were limited at the beginning. Now the player's items have expanded I need a quicker check.

Anyway, I've done the basic set up, now how is this scripted?

https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2134440&parId=B60C11D037429D8E%21191&o=OneUp

 

https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2134441&parId=B60C11D037429D8E%21191&o=OneUp

 

Link to comment
Share on other sites

- Formlist isn't a quicker solution but is actually a slower one (it'll make your script slower).

- Container : read carefully what's been posted.

- You can do this without a "container" if you choose to, the container was added by IsharaMeradin for a specific reason.

* For most scene event there isn't just one way to do things, but this depends on the modder's ability to innovate and think outside the box.

- If you are going to add combination to the items required for the fire to lit, for example :

If Player has 6 items and each combination requires two of them, then you will end up with 12 items combination, so whatever you do you'll end up with a huge script since you are using and will be adding more than two items.

Combination of items won't work with Form list, unless you make a Form list for each combination, then again you will end up with a huge number of Form lists combination.

- This is the perfect time and circumstance for you to remember how to script and do things, especially since you had all that experience and you already knew all this stuff, you will just need a few hours to a couple of days. Your new best friend "www.creationkit.com".


- You can't depend on others making you Scripts and saying over and over again that, "you knew but forgot how", you need to start from somewhere sometime. (It's been around three month since i posted you the first script and you still haven't remember how to do things).

I hope that this didn't offend you...

Edited by maxarturo
Link to comment
Share on other sites

Please don't be !, i'm just saying this with all good intentions.


A little advice : Stop further develop of you mod, make a small room - cell and try to make this work without the help of anyone (just www.creationkit.com).

I guarantee you 100% by the time you accomplish making the scripts work your modding abilities will have level up sky high, you already have a good taste of how things works, invest one week into this and after that your whole mod will transform into the ideas that your brain can produce !.

You already have the imagination that a good mod requires...

Link to comment
Share on other sites

I know you have good intentions and let me add this.

Every script posted by yourself and others who have helped me, I have more or less used 'as is'. But what you need to know is that from examining any one of the posted scripts, it has refreshed my mind a little and from that one script I have made 3,4,5...10 others - these are the ones, obviously, I don't ask for help with because they work using the guidance of the scripts posted here. I am not just using the scripts written for me, I elaborate upon them, alter them, f**k them up a lot. So from that one script that is kindly posted here to solve an issue I have made many, about 25 so far.

So I get you want me to learn on my own but if I ask for help then it means I am literally 'stuck'. Or I have an idea that I think will work and after a day of it not working then I need help.

The input, advice and guidance of all on this forum is NOT wasted on me. Once I get something right, I don't get it wrong again.

Link to comment
Share on other sites

I've been exactly in the same place you are right now (as every other modder has at one point), and after i managed to level up my modding - scripting abilities, all of those 25 + more scripts ended up becoming one global script to be use for all circumstances.

You are clever enough to see the difference and why i advise you to do this.


Still, if you create a script and you have problems with it, i'll provide unconditional assistance !.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...