Jump to content
Sign in to follow this  
six_ten

Keep your powder dry

Recommended Posts

Is there a way through script or otherwise to ruin a unit's ammunition if he swims? I'm giving my 18th c. soldiers black powder and it looks silly for them to emerge from the sea and load and fire their muskets as if nothing happened.

Share this post


Link to post
Share on other sites

while {true} do
{
//	hintSilent format ["position above sea level: %1", (getPosASL player) select 2];
_state = animationState player;
//	hintSilent _state;
};

At first I thought that you could check a player's position above sea level (at around -1 meter, a person's torso is submerged), then I thought you would have to make a custom event handler to reliably check that. BUT then I thought, wait there's already an event handler you can use which is "AnimChanged". So I think the best way to check this is to add an event handler and then check if the returned string is equal to the name for any of the swimming animations. Hopefully this will work (I'm still trying to learn event handler's, myself):

this addEventHandler ["AnimChanged",
{
if (_this select 1 == "abswpercmstpsnonwnondnon") then
{
	//replace some ammo with destroyed ammo or whatever
};
}];

That is just the animation name for when a unit is floating still in the water. If you uncomment the second "hintSilent", and put it in an active script, you can see all of the animations for yourself (note: they are super long). Hopefully that gets you pointed in the right direction/direction you were looking for.

Share this post


Link to post
Share on other sites

Nice one DreadedEntity.

I use eyepos to determine whether a units head is submerged for a night vision mod of mine.

The following script will check if any unit's head is submerged:

while {true} do
{
{
_unit = _x;
if ((eyepos _unit) select 2 < 0) then 
	{
	//Insert water damage code here
	};
} foreach allunits;
sleep 10;	
};

Share this post


Link to post
Share on other sites

Thanks guys, I'll try these right now and report back.

---------- Post added at 01:54 ---------- Previous post was at 01:49 ----------

I know this is a basic question but I'm really just starting to learn how to script: how do I code removal of the normal musket ammo and replace it with ruined? For a test I could just replace it with .556 or whatever as it won't work, and later create special ruined cartridges.

Share this post


Link to post
Share on other sites

You need to know the classname for the ammo before you can do anything with it with BIS's functions, if you do know that then:

player removeMagazine "musketAmmo";
player addMagazine "ruinedMusketAmmo";

The way you're wording your posts and your "MAKE ARMA NOT WAR CONTESTANT" profile badge makes me think you're doing some kind of full conversion mod so you probably do know the classname already. That code is pretty self-explanatory, it just removes one magazine of "TYPE" and adds another one of "TYPE", you can change the object from "player" to anything you like.

Although, if I remember my history correctly most weapons in the 18th century were muzzle-loaded and shooters stored their powder inside a bull horn bored out to be a container (these were supposedly waterproof but, hell, I wasn't alive in the 18th century). So I think to fit with history, when a player loads their musket, it would require some powder too. I'm sure that's more than a bit complicated to script in, but I'm all for realism and it would create a cool element where players won't be able to fire despite having ammo. For ease of display, you could even create the powder as a grenade type so it would be displayed right underneath the musket's actual ammo. Also, you wouldn't have to create a "ruined powder" item because powder would simply dissolve and disperse when submerged. Just a few thoughts.

Share this post


Link to post
Share on other sites
"... most weapons in the 18th century were muzzle-loaded ..."

True.

"... and shooters stored their powder inside a bull horn bored out to be a container..."

Some did, though all regular soldiers and many if not most militia used pre-formed cartridges made of paper, with a powder charge and ball tied into it, carrying about 20 in a wood block inside a leather pouch.

A surviving cartridge

Cartridge Pouch

If someone can help me figure out how to post pictures I will show you the models I have for these.

"For ease of display, you could even create the powder as a grenade type so it would be displayed right underneath the musket's actual ammo."

I don't understand this.

"... So I think to fit with history, when a player loads their musket, it would require some powder too. I'm sure that's more than a bit complicated to script in, but I'm all for realism and it would create a cool element where players won't be able to fire despite having ammo. ... Also, you wouldn't have to create a "ruined powder" item because powder would simply dissolve and disperse when submerged."

Good idea, I like that. Maybe I'll just replace the functional cartridge with a plain bullet. I'm thinking of setting it up so you can get balls, powder and paper separately and craft cartridges for faster firing. This way you keep the bullets but have to replace the powder and make new cartridges.

Share this post


Link to post
Share on other sites
I don't understand this.

What I meant was when you make a new item for the powder, you should make it as a grenade so it will be displayed underneath the weapon ammo so you can quickly and easily see how much you have left, because they are grenades and they will go into the grenade counter that is below the normal weapon ammunition count. Then in a script you can make it so some of the powder is used when you reload.

It sounds pretty interesting, I think I'd like to play it when you finish

Share this post


Link to post
Share on other sites

Edit the last line above "Maybe I'll just replace the functional cartridge with a plain bullet" to read "when it gets wet".

One more thing about the event handler as I'm about to start: can I add that to the ammo config itself rather than the player, so that only the ammunition cares whether it is wet or not?

---------- Post added at 03:17 ---------- Previous post was at 03:15 ----------

What I meant was when you make a new item for the powder, you should make it as a grenade so it will be displayed underneath the weapon ammo so you can quickly and easily see how much you have left, because they are grenades and they will go into the grenade counter that is below the normal weapon ammunition count. Then in a script you can make it so some of the powder is used when you reload.

Oh, that sounds good.

Share this post


Link to post
Share on other sites

I've never added items/models to the game so I don't know the process, but it sounds like if you did that the ammo would only think it's wet if you dropped it so it turns it into an item on the ground. Checking whether the player is wet or not and if he has powder is likely the easier, and most reliable way.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×