GetWeapon() or something similiar

Place to get help with not working mods / modding interface.
Post Reply
Raught19
Inserter
Inserter
Posts: 30
Joined: Mon Apr 25, 2016 6:39 am
Contact:

GetWeapon() or something similiar

Post by Raught19 »

I'm trying to set weapon accuracy for different guns, but the same ammo.

For example:

HeavyGun1 deals 200% more damage, but has a chance to miss 20% of the time with ammo1.

SmallGun deals normal damage but never misses when using ammo1.

Is there a lua function that calls for the player's active weapon so I can specify the chances per weapon? I found one for the index, but that just returns the numbered slot its in.

Any help would be greatly appreciated!

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: GetWeapon() or something similiar

Post by Adil »

Well, you take that number and use it with the get_inventory() or something and in the end you get the desired items.

Though I don't understand what you're hoping to do after that. You can't just alter the attack parameters, nor there is accuracy parameter for machinegun and pistol.
Or actually, there's no accuracy checks for the bullets as they're instant.

Without runtime scripts, you can try altering ammunition prototypes to be real projectiles like shotgun pellets and cannon-projectile.
Then you could try specifying direction_deviation in weapon attack_parameters.

However, the prototypes are least documented element of the game, and I have only vague memory of making attempts of altering cannon turret accuracy. I don't remember or possess results on that but I believe that attack_parameters from gun override those of ammo, whenever they collide.
Also, they say such change of attack parameters might bork up gun turret ai as it relies on knowing the exact damage that will be dealt to enemy. (At least until 0.13 release.)
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Raught19
Inserter
Inserter
Posts: 30
Joined: Mon Apr 25, 2016 6:39 am
Contact:

Re: GetWeapon() or something similiar

Post by Raught19 »

Adil wrote:Well, you take that number and use it with the get_inventory() or something and in the end you get the desired items.

Though I don't understand what you're hoping to do after that. You can't just alter the attack parameters, nor there is accuracy parameter for machinegun and pistol.
Or actually, there's no accuracy checks for the bullets as they're instant.

Without runtime scripts, you can try altering ammunition prototypes to be real projectiles like shotgun pellets and cannon-projectile.
Then you could try specifying direction_deviation in weapon attack_parameters.

However, the prototypes are least documented element of the game, and I have only vague memory of making attempts of altering cannon turret accuracy. I don't remember or possess results on that but I believe that attack_parameters from gun override those of ammo, whenever they collide.
Also, they say such change of attack parameters might bork up gun turret ai as it relies on knowing the exact damage that will be dealt to enemy. (At least until 0.13 release.)
Thanks for the response :) I will try going through get_inventory()

Yeah basically I have the accuracy working by messing with attack parameters, but its okay because its for ammo that the turrets won't touch. Just doing some test projects for something bigger I had planned.

Post Reply

Return to “Modding help”