Jump to content

Need help with scripts (items and inventory)


Recommended Posts

                                                                                                                                                                 SOLVED
Now I need to figure out how to allow me to change weapons to anything other than a bow... (or remove arrows with a keyword when equipping something other than a bow)
Because the current script will instantly equip my invisible bow again


                                                                                                                                             SOLVED
I'm making a mod with throwing knives. I'm using an empty bow mesh. arrows with knives model and a new throwing (shooting) animations.


I was somehow able to find a script that allows me to add and equip an invisible bow to my inventory when equipping my arrows (throwing knives) and remove it when removing the arrow-knives.
Actually, my question is, is it possible to somehow unify the script for all throwing knives from the mod, so as not to make separate scripts for each type of throwing knife? Maybe using keywords or something....

my shameful script

  Reveal hidden contents

 

Edited by JellyFishInLoop
Link to comment
Share on other sites

Since you are creating your own base weapon forms, you can place part of your code on an ObjectReference script attached to the weapon.  These scripts can know what kind of ammo to equip/unequip.

I am however not seeing the counterpart, attaching a script to the ammo that can know what kind of weapon to equip/unequip.  My guess is that you'll need to test it in an elseif cascade.

 

Link to comment
Share on other sites

  On 3/16/2024 at 7:30 PM, xkkmEl said:

Since you are creating your own base weapon forms, you can place part of your code on an ObjectReference script attached to the weapon.  These scripts can know what kind of ammo to equip/unequip.

I am however not seeing the counterpart, attaching a script to the ammo that can know what kind of weapon to equip/unequip.  My guess is that you'll need to test it in an elseif cascade.

 

Expand  

Unfortunately, in my case, I need to bind the script specifically to the ammo, and this seems to be impossible to do in the creation kit.
But I sort of figured it out and I needed to use WornHasKeyword
 

Edited by JellyFishInLoop
Link to comment
Share on other sites

You might want to try this out instead:

  Reveal hidden contents

This should be attached to the player alias.

  • When the player equips the throwing knives, the invisible bow is equipped.
  • When the player equips any other weapon, the throwing knives are unequipped.
  • When the player unequips the throwing knives, the invisible bow is unequipped.

Link to comment
Share on other sites

  On 3/16/2024 at 10:16 PM, IsharaMeradin said:

You might want to try this out instead:

 

  Reveal hidden contents

This should be attached to the player alias.

  • When the player equips the throwing knives, the invisible bow is equipped.
  • When the player equips any other weapon, the throwing knives are unequipped.
  • When the player unequips the throwing knives, the invisible bow is unequipped.

 

Expand  

can i somehow use a my keyword for these kniv(f)es, so as not to register each type separately (for each material)?

 

Edited by JellyFishInLoop
Link to comment
Share on other sites

In Ishara's cascading elseif example, you can just replace the conditions by whatever suits your needs.

She is testing the base object for equality with a specific base form "tttIronKnives" , but you can just as well test HasKeyword like so:

If (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myKnifeKeyword)
	...
elseif (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myShurikenKeyword)
	...

Just create the keywords, add them to the Ammo forms, and populate your properties to access them.

Use as many keywords as you need to identify your different cases.

 

Link to comment
Share on other sites

  On 3/16/2024 at 11:00 PM, xkkmEl said:

In Ishara's cascading elseif example, you can just replace the conditions by whatever suits your needs.

She is testing the base object for equality with a specific base form "tttIronKnives" , but you can just as well test HasKeyword like so:

If (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myKnifeKeyword)
	...
elseif (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myShurikenKeyword)
	...

Just create the keywords, add them to the Ammo forms, and populate your properties to access them.

Use as many keywords as you need to identify your different cases.

 

Expand  

Thanks!
I more or less understood how it works.

Link to comment
Share on other sites

  On 3/16/2024 at 11:00 PM, xkkmEl said:

In Ishara's cascading elseif example, you can just replace the conditions by whatever suits your needs.

She is testing the base object for equality with a specific base form "tttIronKnives" , but you can just as well test HasKeyword like so:

If (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myKnifeKeyword)
	...
elseif (akBaseObject as Ammo) && (akBaseObject as Ammo).hasKeyword( myShurikenKeyword)
	...

Just create the keywords, add them to the Ammo forms, and populate your properties to access them.

Use as many keywords as you need to identify your different cases.

 

Expand  

hmm, can I ask a one more question....
Can I equip/unequip items by certain keywords

 

Edited by JellyFishInLoop
Link to comment
Share on other sites

Alright here is an untested modification.  Basically, it uses two index matching arrays as properties.  The ammo array is searched when ammo is equipped and the index matching weapon is equipped while the ammo is locally stored.  When any other weapon is equipped the weapon array is checked and if the weapon is not in the array the locally stored ammo is unequipped.  If the ammo is unequipped, the ammo array will be searched and the index matching weapon unequipped.

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 3/17/2024 at 2:11 AM, IsharaMeradin said:

Alright here is an untested modification.  Basically, it uses two index matching arrays as properties.  The ammo array is searched when ammo is equipped and the index matching weapon is equipped while the ammo is locally stored.  When any other weapon is equipped the weapon array is checked and if the weapon is not in the array the locally stored ammo is unequipped.  If the ammo is unequipped, the ammo array will be searched and the index matching weapon unequipped.

  Reveal hidden contents

 

Expand  

I don't quite understand how it works, but I'll try to learn Arrays stuff.....
As i understand this is what I need for manipulating with groups of items
Thank you very much for such detailed examples (for ready-made scripts lol)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...