OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Wolfrug on 27 Jan 2008, 18:38:49

Title: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 27 Jan 2008, 18:38:49
Hey all!

Edit: Version 1.1 is out now, should be ready for review/upload. Check it out if you can find any bugs :)
I -might- yet in the future create a version which adds the possibility for proper anims upon death (currently a rather ugly switchmove) using Mando Unit Position to see if they're crouching or standing etc, and maybe incorporate some kind of POW-taking ability on enemies/yourself. But those can be done by mission makers as well, and might require external scripts.

This isn't really much : just a tiny self-sufficient script that simulates a -very- crude "body armor" which might increase the survivablity of at least your own soldiers. It is not suggested to use these on enemies - it's no fun scoring a straight headshot and getting nothing for your pain. :) Also, 1.09beta is recommended, since I'm using a whole bunch of globals and the like, hopefully making things a bit faster.

Script call: [UnitName, Mode, Init] execVM "RUG_BodyArmor.sqf" (can also be used with for instance foreach to give body armor to each member of your squad).

Unitname : name of the unit, quite simply. Can be this if called from init.

Mode : Currently supports four modes : 0, 1, 2 and 3. In 0, once the unit's body armor has been depleted and the unit has been knocked down, it will never return and the unit will be as defenceless as a standard ArmA dude. In 1, the body armor is fully regenerated between knock downs, which means there are only really two good ways to kill these people: high caliber weapons, or shoot 'em when they're down. 2 is the "Medevac" mode; the unit will regain full body armor once it has been fully healed, for instance by a medic or a medic tent. 3 is essential invulnerability: the unit is knocked unconscious, but can be revived, and is invulnerable during all these stages.
 
Init: this number should be less than 0, which tells the script it's initializing. The number also determines the total amount of body armor the unit should have in a relative way: the total body armor is directly derived from their config "armor" entry (for normal soldiers it's 3); this is then multiplied with the positive equivalent of the Init value. Make it -1 to give the units 3 body armor, -2 to give them 6, 0.5 to give them 1.5 and so on.

How the "body armor" works: It uses the little-known fact that you can set negative values to a unit's Damage using setDamage: however these negative values aren't persistent, and disappear with the first "hit". By having a "hit" eventhandler however which constantly resets the negative value, you can have invulnerable units. This has been used in various missions before, such as in Surdus Priest's. What my script does is stores the amount of damage done in each hit (which the "hit" eventhandler picks up), and once it surpasses the total body armor value, the unit is knocked "unconscious".

Being unconscious: Once the total body armor has been surpassed, you're unconscious (well, the units are switchmoved into a prone position and setCaptived, nothing else). This either lasts a random period (presently set to about 2 minutes), until a medic gets to you (your damage levels decrease) or someone uses the "first aid" action that's added to you. After that, depending on your "mode", your body armor is entirely regenerated, or you're left without it. Note that although units that are unconscious can call an AI medic to help them, it doesn't always work (depends on at what angle the medic approaches if the knocked down AI can use the medic action or not).

As of v.1.0, a knocked-out player or AI will automatically "call for help" within a 50 meter radius, prompting any friendly AI unit nearby to move to the knocked out unit's location and perform first aid. Note that the AI will smartly first check if any known enemies are closer than 100 meters: if that is the case, the fighting is still too intense to perform healing actions. Note that as team leader, you can still order the AI to heal someone (for instance you) via the action menu, regardless of the proximity of enemies.

Caveats: Since this uses a simple "hit" eventhandler with setdamage, the body armor does not take into account WHERE you are hit; headshots, legshots, they're all the same. Also, certain large caliber weapons such as the .50 cal, rockets, etc. will still kill you immediately (unless using mode 3). And finally, I have no idea if this works on a larger scale or not, or how it takes to streaming and such.  :)

This is more or less finished now, although I sort of wrote it pretty quickly over the weekend, so it's no master piece of coding. But it's kind of nifty, I think. Attached example mission (sorry about the size) and script. Note both the mission and the script still has a bunch of hints and such in it to track the progress of stuff. Enjoy!  :good:

Version history:
0.1 BETA
-Initial release
1.0 RC
- Added ability for AI to independently administer first aid
- Added modes 2 and 3.
- Minor changes to demo mission (can choose mode at start, random weather/time just for fun, player = team leader...)
1.1 RC
- Fixed some minor bug with the helpers
- Other slight fixes and tweaks
- Minimized size of demo mission
- Added an explanation to the script itself on how to call it

Wolfrug out.

RUG_Bodyarmor v1.1 (http://www.ofpec.com/ed_depot/index.php?action=details&id=540&game=ArmA&type=sc&cat=ug)
Title: Re: RUG_BodyArmor
Post by: LeeHunt on 28 Jan 2008, 01:26:07
hi Wolfrug,

Gave this demo a try, i like the idea.  The body armor "unconscious" hit appeared to work- my player was knocked down prone and unable to move but also appeared to be "setcaptive true" as you mentioned.  My teammates however had the notorious Scalar Bool Array error come up when they were hit.  Not sure what's going on.  It is a cool idea though and I like it, just initial test thoughts here...
Title: Re: RUG_BodyArmor
Post by: Wolfrug on 28 Jan 2008, 07:45:41
The scalar bool error in the hints (if that's what you're referring to) comes from me renaming a variable in the last moment, which I forgot to rename in the actual hint. :D In this case it's just the second value in the array passed to the script by the "hit" eventhandler, namely causedBy; which I don't use at all. :) So it shouldn't be a problem.

Also I tested the script as a team leader yesterday evening: telling them to use the action via the action menu will actually have the AI soldier move all the way over to your "unconscious" body and begin the heal action :O Maybe it's an ArmA novelty, but at least back in OFP telling them to do stuff like that would just make them magically activate the action from wherever they were - be it hundreds of klicks away.

Knowing this, I'll script in some kind of algorithm that checks for nearby friendlies, and if said friendlies are capable of helping, they will. :) Should make stuff a bit better.

Another thing: as you've noticed, the transition to unconscious happens through a pretty ugly switchmove to "DeadState". I could use some other animation as well, but at least DeadState looks very particular when you're...dead. If you use playMove with "DeadState", then the unit plays the appropriate death animation, depending on its stance etc. However, for some weirdo reason, you can't get out of the playmove -_- No matter what you try, the unit will always go back to playing the "I die now" animation, which is really fricken annoying. If anyone knows how to break out of a "dead" playmove, do tell.

Anyway: this script is mostly meant as a small enhancement to your own squad or your allies' groups; just something that makes them a -little- less likely to die en-masse the first time they smell an enemy. It's no true body armor, since it doesn't care about headshots or legshots or anything else, but for those quick firefights where you're not really looking where the enemy's shots are landing, I think it's pretty cool.  :good:

By the way: for a mission maker to manually reset the body armor, simply use: UnitName setVariable ["RUG_BodyArmor", 0]; <- will put the total damage of the body armor back to 0. To manually set (or check) the maximum damage sustainable, use: UnitName setVariable ["RUG_BA_MaxD", #]; With # representing the number. You can also change the "mode" on the fly using, surprise surprise; UnitName setVariable ["RUG_BA_Mode", #]; So far, there are only the two modes mentioned above. :)

Any more suggestions on features and the like, feel free to tell!

Wolfrug out.
Title: Re: RUG_BodyArmor
Post by: Mandoble on 28 Jan 2008, 11:33:54
You might try to consider the following just for MP:
The unit locality for a group will change depending on the locality of the leader, and hit EH is local to the unit that receives the impact. Lets suppose the following:
group A: leader is player A, second in rank is player B. Player A dies definitively or leaves the game, now the units of the group should be local to player B.  But, the internal variables you are using are local too, so these values set by Hit EH when units were local to A doesnt exist for client B. This might generate a problem for this script.
Title: Re: RUG_BodyArmor
Post by: Wolfrug on 28 Jan 2008, 14:14:17
Hey there!

As I've stated elsewhere, online locality is still more or less a complete mystery to me, but I'm sure I can add those things if you walk it through with me step by step :D

Hypothetical MP scenario:

Group A, led by Player A has the script initiated on each member of the group. For all intents and purposes, the group is now "protected" on everybody's computer, even if Group B, led by Player B, is on the opposite side shooting at them?

Now, Player A disconnects ; does that mean all variables set with setVariable in Player A;s group are effectively nulled? I.e., the script can no longer update the state of the bodyarmor since the variables don't exist (which I think would lead to everyone in the group automatically getting knocked unconscious...either that or they'd have constant invulnerability O.o)?

What if player A isn't the leader, but just a group member. Is the group -still- local to Player A then?

In any which case, this could be fixed by having a check that checks if a player is in the group or not, and then rerun the script as necessary. But what happens if Player C joins the game and takes control over/enters Group A? Will the variables be nulled again/will the script not work on Player C's character/what? And what happens if Player A reconnects?

 :blink: Multiplayer. What about the 1.09b command addPublicVariableEventHandler? Could that maybe be used...somehow? Although that would make the script rely on 1.09beta.  :dry:

Phoie.

I'm planning on adding the following to the script:
More modes:
Mode 2: The unit will have no body armor after revival until it has been -entirely- healed by a medic or a medic tent (or script), thus necessating a sort of "medivac" after performing first aid on units.
Mode 3: The unit is invincible (can't be killed by high caliber weapons nor by shooting when down), but can be knocked out and revived as many times as is necessary. For "quest NPCs" and the like. ;)
Maybe more?
Mode 4: Specific-class only mode? Only medics/SF/anyone you want can revive? Maybe, we'll see.

More AI features:
AI ability to find unconscious teammates and attempt a revival, depending on how safe they deem the situation. Unsure if this should work outside the group or not, I'm thinking yes - not sure how yet though.
AI ability to drag their teammates to safety using animations....yeah right.  :D I'll leave that to Solus and his SLX, since there is just no way to make that look any good without a proper addon.

Wolfrug out.
Title: Re: RUG_BodyArmor
Post by: Mandoble on 28 Jan 2008, 14:51:47
To make the story shorter. I understand you are basing your script in Hit Event Handler. Hit EH code is executed only in the client (or server) where the unit is local (well, this is what BIKI claims  ;) ). So, if the locality of that unit changes, then the next time the unit is hit, the code associated with the EH will be executed in a different client or server.

Now the second rule, a unit is local to where the leader of its group is local. A vehicle is local to where the driver of the vehicle is local. So, if leadership of a group changes, the locality of the remaining AI units might change. For example, with player B becoming the leader. As you are using local vehicle internal variables and globals which are local to the client executing that script, then a change in the locality of the unit receiving the hit will generate a problem, as these variables are not published and the new computer (client) executing the code of the Hit EH might have different values for these variables for the very same unit.

So, might be you should have a "monitoring" script running in every client and the server attending to units (local or not) based on info published by code executed by local Hit EHs. This script might set locally the values of these internal vehicle variables. So, lets say this is named script S1, running in every machine. Script S2 (code based on hit EH) is executed in client A, and publish a flag and a value that is catched by every client running script S1. This script puts the value in local variables for the specified unit, so every client has the very same value for that internal variable of that unit.

Well, probably my explanation is not the best one, but at least a base to start designing a viable fix for the potential problem.
Title: Re: RUG_BodyArmor v.1.0
Post by: Wolfrug on 28 Jan 2008, 23:22:45
Mandoble, I still honestly have no idea how to do that or what you're talking about :D

And anyway, there are things like Norrin's Revive script for MP enthusiasts - this thing was mostly meant for SP anyway. The code is faaar too unoptimized for proper large-scale MP usage, I'd dare say. :no: And I have no idea how it'd work with respawning etc...a regular nightmare. Maybe? If someone -does- want to take a look at the code and try to turn it into MP, feel entirely 100% free to do so!

Report any bugs and such, and enjoy.  :good:

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.0
Post by: Mandoble on 01 Feb 2008, 15:59:37
Should we consider this final and ready for submission?
Title: Re: RUG_BodyArmor v.1.0
Post by: Wolfrug on 01 Feb 2008, 16:31:27
If it works for you, and it works for me, sure.  :good: The demo mission is slightly unnecessarily large though, since it's just a copy-paste of the default "Clean Sweep" mission into Rahmadi (= it has pictures and briefings and sound files), but aside from that it should be all good. :) If you want to create an alternative demo mission which removes all the extra files, you can do that too.

I might update it in the future if there's need (adding more modes and the like, or, god forbid, allowing MP compatibility), but that's for the future!

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.0
Post by: Mandoble on 01 Feb 2008, 17:13:18
If you want to create an alternative demo mission which removes all the extra files, you can do that too.

The author is who determines which demo he wants the users to download. If the current one is good for you, we'll proceed with it.
Title: Re: RUG_BodyArmor v.1.0
Post by: Wolfrug on 02 Feb 2008, 00:08:42
Actually hold it off a moment longer - I playtested this some more, and at least in 1.09beta, empty vehicles are also caught in the radius-of-help around people  :dry: And yes, I'll cut down on the demo mission's size a bit and fart out a v.1.1 soonish, which can then be submitted :)

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.0
Post by: Rommel92 on 30 Mar 2008, 03:17:17
fart out a v.1.1 soonish

Now that gave me the giggles.

Great idea, and although I won't use it, its definetly given me an idea for a script thats a bit different, same knockdown concept, but you come back to conciousness yourself, might check what ammo the opponent is firing aswell, because if the shooters firing a 50cal round or tank shell, somehow unconciousness doesn't quite fit the bell.

Excellent work, and i'll be putting credits.  :yes:
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Wolfrug on 30 Mar 2008, 11:36:27
Well, you DO come back to consciousness yourself as well in this script, only it takes a while (something like a couple of minutes) to bounce back without help. It's this part of the RUG_BA_Down script that determines the amount of time before you get up:

Code: [Select]
_timer = [] spawn {sleep (120 + (random 15))};
Just increase or decrease that as you see fit!

Also, a couple of lines above that are these lines:

Code: [Select]
_id = _unit addAction [_text, "RUG_BodyArmor.sqf", _id, 9.8, true, true];
[_unit, _id] spawn RUG_BA_AIAction;

Removing or commenting out those lines will remove the "first aid" option.

And finally, regarding the different ammo types and such : if I had found some foolproof and simple way of determining a) where you were hit and b) what type of ammo was used, I could've added a much more complex "getting hit and going down" simulation. But I ran into some problems - maybe you'll be able to fix them, in which case you've definitely created a superior "bodyarmor" simulation!

1) Using the dammaged eventhandler, it's possible to gauge where a unit's been hit (head, arms, legs). However, the dammaged eventhandler simply isn't -fast- enough for the setdamage -5 to kick in! Try it yourself : place down one unit with this init field:

Code: [Select]
this addeventhandler ["dammaged", {_this select 0 setDamage -5}];
And one unit with this in his init field:

Code: [Select]
this addeventhandler ["hit", {_this select 0 setdamage -5}];
The latter one will survive your barrage of bullets, whereas the former won't. Although I suppose a dammaged eventhandler -might- work for very far away, low-damage shots, where you can still say stuff like a headshot is immediately lethal, whereas a bodyshot would not be. However, here's the problem: say you're simulating no bodyarmor on the legs. Your unit gets hit in the leg, and goes down to 0.5 health. What now? Using setDamage 0 or setDamage 0.5 or somesuch in a dammaged or hit eventhandler isn't going to prevent death, meaning your 'bodyarmor' just got pretty much useless because someone got hit in the legs. This is sadly due to the hitpoint system in ArmA, and I can't really see any immediate solution for it right now. :-/

2) How were you planning on doing this? And anyway, there already is a system like this of sorts in place. Have you tried opening up with a .50 cal on one of the default (not mode = 3) units with bodyarmor? The -5 setdamage won't be able to stop that, meaning the damage goes over the pain threshold, meaning the unit dies before the script has time to kick in. This is the only basic difference between mode = 3 (invincibility) and the other modes : in mode 3, the unit receives a whopping -500 damage instead, meaning not even dropping a GBU or shooting a D-30 shell into his face is going to make any difference.
However, if you feel the units are -still- a bit too hardy, simply change the -5 to something less like -3 or -2 or somesuch : the risk of them getting two consecutive shots of something high-caliber that knocks them out is considerably greater. I didn't add a simple system for changing the minus-modifier in the whole script, stupid me, so you'll just have to go around switching all the cases of -5 to whatever minus you want.

Anyway, good luck with your effort as well! :) The knockdown effect is really the main reason I made this script, not for the somewhat hokey 'bodyarmor' effect - too bad dammaged is such a crappy eventhandler, and too bad Hit doesn't return the -actual- total damage done (i.e., a hit to the head and a hit to the legs register the same damage, even though one is lethal and the other is not).

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Rommel92 on 31 Mar 2008, 03:45:51
Does the hit event handler not return: [unit, causedBy, damage].
In which case you could check the object or causedBy for the ammo type? Shame it doesnt have a "FiredBy" if it is indeed a bullet, but none the less.

For the damaged event handler:
Code: [Select]
_hitselection = _this select 1;

? (_hitselection == "body") etc
Thats worked for me in the past?

Quote
the unit receives a whopping -500 damage instead, meaning not even dropping a GBU or shooting a D-30 shell into his face is going to make any difference.
haha, guess you called it invincible for a reason.

Sorry if my reply seemed smug, it was in no way meant to offend you.
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Wolfrug on 31 Mar 2008, 16:52:54
Yes :) causedBy = the unit who damaged you. Now, you -could- use this information to figure out the potential weapon used to harm your character, by checking what weapons the unit dishing out the damage is wielding at the time. But what about tanks or helicopters or vehicles with more than one weapon? AFAIK, there's no way to tell which weapon was selected at the time of the shooting. Same thing with personal weapons, really, since a unit might have shot at you with his primaryWeapon, his secondary, or his launcher (yes : there are some scripts that are capable of checking the weaponInHand thing, but between shooting at you and you getting hit the person might've switched weapons). Besides, as mentioned : setdammage -5 isn't enough to stop .50 cal bullets at close range anyway, not to mention rockets and other things that go big-boom, so I figured I might as well let it be.

And the damaged eventhandler does return bodyparts, but, as I already explained, it's not as fast as the hit eventhandler. I don't know why, but that's the way it is. Also, you can't use both a dammaged and a hit eventhandler together, since the dammaged never runs if you immediately set the damage back to -5 on a hit. So I'm guessing there's some kind of internal order in which eventhandlers are run as well.  :dunno: Although I'm sure the dammaged eventhandler could work on long-distance shots that aren't immediately lethal. But here's the thing: you want to make a real bodyarmor that covers only the torso, not the legs or the arms or the head. So, you create a script that, say, heals you back to whatever your current health was before getting hit whenever you're hit in the torso instead of any other body part. Even then, there're other problems:1) setdamage evens out damage across the whole body, meaning if you couldn't shoot properly/walk before getting your torso hit, you probably can now! 2) If you're already hurt, your bodyarmor will probably be useless, since a single shot to the torso will kill you anyway before the setdamage has time to kick in. That's why I use setdamage -5 instead of 0 : if I used 0, the unit would die half the times. 3) the aforementioned slowness of the dammaged eventhandler.

But good luck nonetheless!  :D If you manage to solve some of these problems, you'll definitely make a much better bodyarmor script than me.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Rommel92 on 03 Apr 2008, 04:36:51
Hey Wolfrug, I been thinking bout what you said, perhaps if you triggered the Hit first (which made sure you have a handshit in there to make sure its a proper hit), initiate the knockdown from the concussion, and seeing as the damaged runs after it as you said, check if the wound is lethal or not (bodyarmour hit or not), and if it is lethal perhaps kill them while they're knockeddown, and if its not lethal, its a win win situation.

Reckon that would work? I'm going to start on it now, but maybe it could help you? :scratch:
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Ironman on 09 Apr 2008, 09:09:14
good luck with this.... I just did a quick read up on it. Is anyone working on this for Small scale MP missions?
Title: Re: RUG_BodyArmor v.1.1 (review please?)
Post by: Wolfrug on 09 Apr 2008, 13:28:07
Ahhh, the plague of MP once again :D

Anyway : since vehicle variables are local by default, these scripts won't be easy to implement in a large-scale, JIP-supported type of mission. However, since all AI soldiers are local to a player squad leader, as long as the player squadleader doesn't JIP, disconnect or otherwise confuse things, it should be possible to have the script working for singular PC-led squads. I guess. :)

Once again : MP is not SP. In MP, you hopefully have a squad of REAL people under your command/in your squad, and these people should have no problem staying in cover, advancing tactically and generally kicking a lot more ass than the AI. This script is mostly meant for SP, to enhance your squad's chance of survival, and even if someone does go down you have a shot at "saving" them. Say for instance a campaign game where you have a squad of mercenaries under your command, and every time one of the AI bumbles over a hill or stands up into the gunfire it doesn't mean automatic retry/restart :)

Or hey - if it's too unrealistic for you, add some visual effects, remove the "knocked down" bit, and call it an energy shield!  :good:

Arrrh, MP...  :no:

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (READY)
Post by: snafu on 20 Apr 2008, 18:49:01
I am wanting to add this into my mission but I couldn't get my head around all that code.

How do I implement it for the players group?
Title: Re: RUG_BodyArmor v.1.1 (READY)
Post by: Wolfrug on 20 Apr 2008, 19:15:08
There should be a description in the script header...one moment.

Quote
//RUG_BodyArmor by Wolfrug (www.ofpec.com)
//
//Calling: [UnitName, Mode, MaxDam] execVM "RUG_BodyArmor.sqf"
//UnitName : Name of unit, can be 'this' in the init field, or _x if used with foreach
//Mode : 0, 1, 2 or 3.
//0 = Once armor is depleted, it can never be recharged (except by calling the script again).
//1 = Armor returns fully after each revival
//2 = Armor returns fully once unit has been fully healed after revival
//3 = Armor is never depleted: unit can be knocked down but not killed (except by scripting)
//MaxDam : Must be a number less than 0: determines total body armor. -1 = 3 total, -2 = 6 total etc.
//Note : due to the usage of eventhandlers, you should avoid calling this script more than once on any unit!
//Enjoy! - Wolfrug

For the "medevac" mode (=has to be fully healed to recharge bodyarmor) which is my favourite, you'd do this on the player's group (just add the code to the player for instance, or any group member) Remember to have the rug_bodyarmor.sqf file in your main mission folder!

Code: [Select]
{[_x, 2, -1] execvm "rug_bodyarmor.sqf"} forEach units group this;

The _x is the unit in the foreach loop, the 2 is the mode, the 1 is the relative amount of bodyarmor.

Hope that helps, and I'm looking forward to seeing it in action in your mission!  :clap:

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: snafu on 11 May 2008, 23:00:57
Wolfrug. I have just put up the new version of my mission (in the mission beta area) that contains this script of yours. It really is an awesome script that added a new aspect of the mission. It made up for the lack of numbers in my squad and it was fun dashing around giving first aid to all my knocked out squad members.

Nice work.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 12 May 2008, 05:29:51
Sweet! I'd love to check it out but, alas, I'm nowhere close to an ArmA-capable computer and won't be for some time! But I'll be sure to check it out when I get back :)

Oh, and as a note for posterity: the syntax above has a slight error in it : it should be -1, not 1 (if you make it >0, the unit will start knocked out and remain unhealable!). I will modify my post above to fix it.  :whistle:

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: USM-CPT.Dyson on 28 Jun 2008, 19:38:58
I sort of skimmed this and I was wondering... I want all unit to fall down and become unconscious after 1 round for between 30-120 seconds. I would also like the body armor to only cover the chest area (and part of the head, 9mm rounds would knock the player out for a long time, anything bigger would kill). Currently, in your demo mission, after 2 shots to the face the unit is still alive.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 29 Jun 2008, 11:59:48
@USM-CPT.Dyson

If you'd read through the thread, you'd find you're not the first to wish for a proper, localized body armor. However as the thread will reveal, that's not practicable due to limitations to the ArmA "dammaged" eventhandler, as well as due to the way ArmA in general handles "being dead" (irreversible, basically). So the whole "headshot" thing is not too likely to happen, sadly. If someone figures out a work-around, that'd be great! As I said in this thread, this script is not really meant for your enemies, since, well, shooting them in the head is supposed to kill them! But for your own teammates or people one in general does not want to bloody die. :D

However it is possible to make something like what you want (people falling over unconscious after one round). Either you make the body armor in the current script very little: (instead of -1, make it something like -0.025) and they will be sure to be falling unconscious every round - although they can still be revived, of course, and depending on mode, the armor would or would not be regenerated. You can change the amount of time spent sleeping in the little sub-script (caller _timer, I believe) which determines how long the knockout lasts. Either that or you simply create your own script based on your own parameters, since in my version you could still be revived ahead of time by your mates. :)

Good luck!

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: USM-CPT.Dyson on 29 Jun 2008, 17:02:20
Yeah sorry I had been reading so many posts yesterday I could only stand to skim things.  :D Well that's too bad, and I can't script to save my life.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: hank_officer on 30 Jun 2008, 08:39:27
is there a invincible mode without knocking down and it can be disable after a time  ???
I need it for my mission :P

thank you!
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 30 Jun 2008, 17:42:16
If you just want your unit to be invincible, simply add this to its init field:

Code: [Select]
this setdamage -500; this addeventhandler["hit", {_this select 0 setDamage -500}];
And then when you want him to stop being invincible, simply do something like:

Code: [Select]
unitName removeeventhandler ["fired", 0];
(unitName being the name of the unit - this also assumes this fired eventhandler is the first one attached to the unit in question)

Good luck!

Wolfrug out.

Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: hank_officer on 04 Jul 2008, 16:41:46
Thank you :clap:
Now my mission may avoids spawnkill :D
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Luke on 23 Aug 2008, 00:26:58

Code: [Select]
this addeventhandler ["dammaged", {_this select 0 setDamage -5}];
And one unit with this in his init field:

Code: [Select]
this addeventhandler ["hit", {_this select 0 setdamage -5}];
The latter one will survive your barrage of bullets, whereas the former won't.

I know this thread is older than Yoda, (that's 900 years + a long time ago!  :P)
and I did not see a solution to the headshot bug,

so...

here's my two bits (:flips_a_quarter:)

Anyway when the script init-s, in addition to the hit event handler, you add a dammaged one as well so that,
when hit in the head you could have:
Code: [Select]
this addeventhandler["Dammaged", {(_this ) exec "headcheck.sqs"]
headcheck.sqs:
Code: [Select]
? _this select 1=="hlava":(_this select 0) setdammage 1or alternatively:
Code: [Select]
? _this select 1=="hlava":_hlava_head_shot=true;
exit

where in the body armour script, if (_hlava_head_shot) then {removebodyarmour;unit setdammage 1}
or something like that.

that way if they don't get headshotted then they still have their armour, but if they do they die despite it.

Luke

P.S. if this problem has been solved, then
a) Hi!  :P
b) Thanx for letting me exercise my fingertips/get my typing practice in.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 23 Aug 2008, 01:17:14
The "hit" eventhandler does not return body parts (like the "dammaged" eventhandler does). Also, if you try to have both a dammaged and a hit eventhandler working at the same time (i.e., one to check for location, one to reset damage), the dammaged will never fire as the hit always works before it -> thus healing any damage and making the dammaged eventhandler think nothing has happened. Adding for instance a delay to the hit eventhandler means insta-kills will start happening again, which is not something we want. :)

Believe me, I tested and tried all possible ways of making this more "realistic" to no avail. Apparently ArmA II will have built-in revives though, which should be fun (and should make the creation of a body-armor script that much easier).

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Luke on 23 Aug 2008, 01:21:40
Understood, however if you have the setdammage at -5, wouldn't there be enough of a delay to get the info of dammaged before doing setdammage -5 again?

Luke
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 23 Aug 2008, 11:08:35
As I said: the dammaged eventhandler DOES NOT FIRE if the damage of the player is set to -5. Try this:

Have a unit, name him, say, unit1. We'll make a global variable that should update with each eventhandler and then displayed in a hint. So, define a global variable named EH_Hint = []; someplace, say in the init field of a unit. First, add only this eventhandler:

unit1 addeventhandler ["dammaged", {EH_Hint = EH_Hint + [_this]; hint str (EH_Hint)}];

Now shoot unit1, and you'll probably (unless you killed him) get a hint with all the contents of the dammaged eventhandler (unit hit, area hit, total damage to area etc.).

Now, add a second eventhandler:

unit1 addeventhandler ["hit", {EH_Hint = EH_Hint + [_this]; hint str (EH_Hint)}];

And shoot unit1: see which hint displays last (i.e., you should first get the "hit" information and then the "dammaged" information). So far so good, eh?

Now, change the "hit" eventhandler:

unit1 addeventhandler ["hit", {unit1 setdamage -5;EH_Hint = EH_Hint + [_this]; hint str (EH_Hint)}];

Also, change the init of the unit to include the line : this setdamage -5 (will keep the first shot from being an insta-kill). Leave the dammaged eventhandler as it is.

And...whatever happened? :O The dammaged eventhandler NEVER FIRES anymore! This is because, as mentioned, it never has time to fire, since the hit eventhandler always resets damage to -5. However, the unit is happily invulnerable.

Now, as a final test, try adding a tiny sleep to the hit eventhandler, to allow the dammaged to fire:

unit1 addeventhandler ["hit", {sleep 0.02;unit1 setdamage -5;EH_Hint = EH_Hint + [_this]; hint str (EH_Hint)}];

And try to kill unit1 -> you will find you can kill him again, which defeats the purpose of the whole body armor script.

Thank you for your suggestions, but I -have- tried some stuff before making it. ;) If you -do- come up with a fully working alternative "head shot allowing" version, please do give me an example script or example mission where it works! I'm sure I haven't tested -everything- yet. :)

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: johnnyboy on 23 Aug 2008, 17:20:06
Hey Wolf,  I just read this entire thread (but I'm an old dude, and retention aint that good), and I didn't hear mention of the idea of replacing a downed unit with a cloned unit.

Maybe using damage event handler alone, if dead, you could replace him with a newly created identical unit (loading him with exact equipment from dead guy, setdir, setpos, same animation, etc.).   This might open up the option of using hit locality better.

Just a thought.   Great script BTW.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Luke on 24 Aug 2008, 23:22:46
If you have setdammage -60, and you get hit, is the getdammage command at 0, or some negative value?

Luke
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: hoz on 25 Aug 2008, 02:42:16
getdammage (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=g#146)

Value is from 0 - 1
Damage 0 means fully functional, damage 1 means completely destroyed / dead
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Luke on 25 Aug 2008, 04:57:59
Yes, granted and established under normal conditions.

but within the functionality of the script it sets damage to Negative numbers.

What I am wondering is after being struck by a bullet will it still yield a negative value,
(if the 0 threshold is not crossed) or is the damage automatically set back to 0?

Luke
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: bedges on 25 Aug 2008, 08:59:20
A unit with damage set to a negative value will have damage set to a positive value when hit. It's pretty simple to test this in the editor.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 25 Aug 2008, 10:44:56
Hey Wolf,  I just read this entire thread (but I'm an old dude, and retention aint that good), and I didn't hear mention of the idea of replacing a downed unit with a cloned unit.

Maybe using damage event handler alone, if dead, you could replace him with a newly created identical unit (loading him with exact equipment from dead guy, setdir, setpos, same animation, etc.).   This might open up the option of using hit locality better.

Just a thought.   Great script BTW.

In theory possible, but in practice complicated. 1) The equipment would NOT be the same, since there's no way to copy the exact number of bullets in the gun, in the magazines etc. Even if you could look past that, we've got 2) There's no real way of listing custom eventhandlers, addactions and vehicle variables added to each unit, and since these are attached to one particular unit, replacing that unit with another (even if it has the same name) will cause all of this data to disappear. And finally, 3) Would be hard to get to work with the Player unit, although in principle lightning-fast teamswitching might do the trick, but 1 and 2 would be rather glaringly obvious to the player, even if overlookable in AI.

@Luke

bedges is correct: there's no way to find out if the damage is set to negatives either, since the getdamage command does not return the "correct" negative number when queried if the number IS negstive. And yes, one shot = back to 0.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Luke on 26 Aug 2008, 01:13:09
With dammage at 0 and you get shot in the head, but with the hit event handler setting dammage back to -5,
would you 'zombify' (that is, still stand there with the player dead screen)?

Luke
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: samsamps on 15 Sep 2008, 18:24:13
I've been testing your body armor mod for use in a MP map and i've been encountering some strange things. I cant seem to get it to work right; what happens is  when someone goes down from losing all their armor when they get up they look as if they are still on the ground and they move at normal speed, just prone. Also other mp players dont seem to have the first aid option in their action menu to revive their fallen comrades.

Is there something I need to do to make it mp friendly?
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 16 Sep 2008, 11:11:33
Hi there samsamps

I'm sorry to say I never designed the body armor script for MP. The bugs you describe all seem to be tied to the phenomenon of locality, something which continually escapes me. :D

In short, I believe the problems to be as follows: apparently switchMove is local: it switchmoves you down ("DeadState") but the switchmove back to normal (can't remember the exact name, but it's one of the prone animations) doesn't seem to register. Maybe changing the switchmove to just "" would fix it, but then the unit would jump up from prone to standing in an instant.

Same thing with the addaction: this is an entirely local happening, the actions aren't broadcasted to the other players at all.

And finally, I'd assume that the actual VEHICLE VARIABLES are also local - see, there's a vehicle variable (added with setVariable) on each unit that has the bodyarmor script running which checks how much bodyarmor it still has, what mode it's in, what it's maximum armor is and so on. I don't actually know if these even need to be made global, but as of this moment at least they're as local as they come.

So. To make it work I'd assume you'd need to make each of these three things global somehow. As to how : no idea! I'd like to make my scripts MP-compatible, but sadly I haven't got the machine power to run any tests by myself, nor do I have a clan/server/bunch of people who can do the testing for me - especially since I'm such a noob at MP scripting it'd probably be rather tedious to test stuff with me ;)

Anyone else have any ideas?

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Spooner on 16 Sep 2008, 13:46:53
You are right! All those things you are talking about are local to the machine and would need to be communicated across the network to affect everyone in an MP game. Unfortunately, making this all happy in MP would require quite a bit of rewriting (sorry, bit much for me at the moment).

Additionally, you would also have to broadcast the stuff to tell the AI to come and help you as well, since unless you are their direct leader, they will be local to the server, not your machine, and so will ignore the commands. I'd suggest that in MP games (missionName != "") you ensure that you only attempt to call in your own AI followers to ensure that this still works (without needing to mess around a great deal with MP scripting).
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: samsamps on 17 Sep 2008, 19:54:30
:(

Ah well, I guess I wont  put in armored enemy in my maps. Apparently Having the unit affected with the crawling bug get into a vehicle seems to fix it but I dont know how useful that will be in terms of making it mroe MP-friendly.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 19 Oct 2009, 14:35:33
So to run in this evolution or warfare I would have to put this "[UnitName, Mode, Init] execVM "RUG_BodyArmor.sqf"" in my init.sqf file right?

And furthermore just copy:
injuries.sqs
M05.paa
Outro.sqs
Outro2.sqs
RUG_BodyArmor.sqf
Add whatever it says in stringtable.csv into the same file in my directory
And last copy the sound folder into the same directory

And I want it for all West so can I put that at UnitName and that would just work for my entire west team/squad soldiers?

And how can I get to 4 bullet hits per kill? Like -1.3 at Init?

Just asking to be sure. :D


Thanks.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 20 Oct 2009, 10:54:45
Hi there!

Actually, you only need to copy RUG_Bodyarmor.sqf, the rest are parts of the demo mission. Sorry for that being unclear :) And yes, putting that line in the init.sqf should do the trick (with the appropriate numbers and entries, e.g. [Player, 2, -1].

The amount of bullets depends on range, bullet type, where it hits and so on, so...experiment!

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 20 Oct 2009, 20:19:56
Thanks for your reply.

Btw at Player can I just put West and that will be for the entire West team, versus having to put 30 players :D. And does it refer to the classname of the unit or the name that he has/is giving, like for example in a the missoins.sqm "text="Player"" etc?

And in general, is 1 hit more 5.56 ammunition or AK bullets? :D
I wanna make meself some Dragon Fly armor. Has to be comfortable and AK bullet proof. :P :D


Thx.


EDIT: I think I found a bug. After I get killed once and respawn back at HQ and all and go back to fight they don't shoot at me anymore, its like I'm invisible to them. But I did hear one radio to his troops that there is an enemy at 12oclock right in front of him :) so that is working, except that they stopped shooting at me. I don't know why. I can just walk by them and shoot them one by one without being seen or shot at or anything.

And how can I get rid of the part where he lies down? Even though I can respawn a moment later. What I really want is just for the soldier to respawn when killed and if shot get his full armor back after being healed. Just the simple mode. But 1 doesn't really cut it. And I am using mode 2 btw.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 23 Oct 2009, 21:18:46
Heya! Sorry for missing this, been a little busy.

Anyway, the bodyarmor was never designed for MP: if it works in multiplayer, that's great, but I never intended it for any kind of MP play (never did figure out the problems of locality etc). What you describe though sounds like a setCaptive left over: I don't know how exactly to stop that from happening (once again, not designed for MP), but maybe you could try adding a setCaptive false to all units that respawn, or somesuch? As to how to do that: no idea once again.

To add the script to more unit than one without having to add it in the init line, simply use forEach:

Code: [Select]
{[_x, 2, -1] execvm "RUG_Bodyarmor.sqf"} foreach [unit1, unit2, unit3, unit4....]
With the unit... list containing all the units you want to have the body armor (using the same mode and the same maxdamage). You could also put down a trigger, activated by West Present that covers all the units you want the BA added to, and then put something like this in the On Activation field of the trigger:

Code: [Select]
{[_x, 2, -1] execvm "RUG_Bodyarmor.sqf"} foreach thisList
thisList refers to the trigger's "list", which is all the units that have activated it, e.g. all the West units Present inside it.

As to your very final request: you mean that you don't want the unit to be knocked down/unconscious, but rather just "have" body armor until it's finished, and then be hurt normally? Well, I've thought of that too, and it should be very possible with some minor modifications to the script, but honestly I figured that kind of took away from the original "point". Right now I haven't got access to ArmA either, so I couldn't bug-beta-test out a working version of it even if I wanted to. :) But if you go into the script and try to edit it (be sure to save a working version ;)) maybe you could learn a thing or two while you're at it! (e.g., feel free to edit the script to suit your needs).

Wolfrug out.

Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 24 Oct 2009, 11:58:12
Thanks for your reply and PM reply. :)

Well I tried it, I removed the second SetCaptive and it worked, they shoot at me again :P ^^. But now its like I lose it after I die once, which is very unfortunately because it is very nice. :D

Well what I actually wanted is just the "Simple Version", extra armor so like you can take a few hits, if you die than you're just dead and respawn, and after you get hit a few times, you get your armor back when you healed yourself, a medic or tent for example and you just go on your way again.
But with the sense of having body armor it gives you the survivability you need, confidence and A LOT better gaming experience and A LOT more fun. You know evo, its like you have to drive, walk and move miles of distance and than you finally arrived and a blind shot kills you out of nowhere, and the ai cheats anyway wiht their "GetPostion" ^^ :D so you know thats crap.
I finally got the ai right and perfect, good enough, tactical enough, accurate enough and engage over long distances and as gameplay wise and combat wise its finally "fair play". But one shot one kill sucks if its you, especially a blind shot which they usually are. :D

So to recap, Simple Version, body armor, get killed respawn, if damaged heal somewhere/how and get your armor back obvious and just happy and fun gaming man :D


I like it very much and am very happy with it. :) And I bet other players would most definitely appreciate it and alot more fun for everyone.

:good:


EDIT:
I looked at it again and I basically wanna get rid of the "RUG_BA_Action = {" , "RUG_BA_AIAction = {", "RUG_BA_Down = {" which is indeed almost the whole script :D. And after that I kinda wanna put 1 and 2 together into one. Although it doesn't really work out so far. And as I said before after I die once or spawn it still don't get my armor back and the debug mode stopped as well, I think this is because it is set to only after revival which is different from spawn because of teh medic and all.
So like _unit Spawn --> get full armor back.
And after healing, anyway either medic, self or tent -->get fulll armor back.
And I wanna get rid of the as well:
Quote
         _unit switchMove "AmovPpneMstpSrasWrflDnon";
         _unit setcaptive false;
         };
I'm not sure what I can just delete or "//", I only want the simple version. :P

Thx


EDIT2:
I found another error, after I die once my armor doesn't return and gives an error both 1 and 2.
It says "Current/Maxscalar/<null>" in the debug screen,
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 27 Oct 2009, 16:17:35
You can manually give the unit whatever armor values (max, current, etc) you want by using setVariable, however I think that after spawning the script probably isn't running any longer (it stops running when the unit dies): so the easiest way to reset the armor upon spawn is to simply re-run the script on that unit (same way you setcaptive false the unit, although I'm not sure why THAT sticks if the script doesn't)!

You can try resetting the armor by using:

Code: [Select]
unitName setVariable ["RUG_BodyArmor", 0];
That should reset the bodyarmor to "0", e.g. full armor. Try putting that in together with the setcaptive false, see if it works.

As to the rest: maybe if you simply exchange all of RUG_BA_DOWN with:

Code: [Select]
RUG_BA_Down =
{
private ["_unit", "_dam", "_EH", "_mode", "_id", "_text"];
_unit = _this select 0;
_dam = _this select 1;
_EH = _unit getVariable "RUG_BA_EH";
_mode = _unit getVariable "RUG_BA_Mode";

if (_mode != 3) then {_unit removeEventhandler ["hit", _EH]};
if (_mode != 3) then {_unit setdamage _dam};

waitUntil {damage _this == 0};
_this setdamage -5;
_EH = _this addEventHandler ["hit", {_this call RUG_BA}];
_this setvariable ["RUG_BA_EH", _EH];
_this setVariable ["RUG_BodyArmor", 0];
};


Then all the animations, actions and so on should be gone, and it should simply wait until your damage is back to 0 (e.g., fully healed). You can also remove all of RUG_BA_AIAction, since it won't be run at all in this version of the script. Also, the other modes won't work (since they don't make any sense any more without the "knockdown" effect).

Can't test it, sorry, but it should work?

Try it and tell me!

Wolfrug out.



Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 28 Oct 2009, 15:09:48
I am confident it will work. :D I am highly motivated ;).

Im not sure though where to put this:
Code: [Select]
unitName setVariable ["RUG_BodyArmor", 0];I changed the RUG_BA_DOWN with what it says and deleted the ai action.
But do I put this in the mission.sqm file under the unit with a like "init="etc etc";" or at the captive which I set to false, although it would than look weird or in the init.sqf file instead of this:
Code: [Select]
{[_x, 1, -1.3] execVM "RUG_BodyArmor.sqf";} foreach [Player1, Player2, Player3, Player4]
Although that doesn't look exactly right either :D.
And if so could I still use the "_x to replace unitName + foreach [Player1, Player2, Player3, Player4]" like you wrote earlier?
And btw, I only changed the second setCaptive which was under the modes if I remember correct to false:
Code: [Select]
_unit switchMove "AmovPpneMstpSrasWrflDnon";
_unit setcaptive false;

And since we're using mode 3 I think and the new thing you put the armor restores after healing too right, not just spawn? It waits till heal/damage reaches 0 again right? Just so I understood correctly. :D

Quote
You can manually give the unit whatever armor values (max, current, etc) you want by using setVariable
Is the 0 like the init, which multiples by 3 etc etc alike the -1 or -2 = 6? Because you said I can set it to anything, you mean like when it restores it restores it to what I would put as init from the original script? I use -1.2 or -1.3.


Thanks.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 29 Oct 2009, 11:37:14
Code: [Select]
And if so could I still use the "_x to replace unitName + foreach [Player1, Player2, Player3, Player4]" like you wrote earlier?
Yes, that's fine. The code you quoted above will work just fine. Don't use mode 3 though, use 1 or 2. The code that I changed basically removes the different modes, except mode 3 still works slightly differently from time to time (namely it sets the damage to -500 instead of -5, which means not even a nuclear explosion will kill you with a single hit). Essentially, what the code does now is:

Protect you until the max damage has been achieved, and then stop protecting you, until someone comes along and heals you back to full health, upon which the armor will return to max. You will not be knocked down and there will be no first aid option etc.

As to the rest: as I've said many times, the scripts aren't meant for MP play, so I really don't know how it'd work in MP. For instance: do eventhandlers stick past death/respawn? Do vehicle variables (i.e. setvariable) stick past death/respawn? If they do, then you only need to run the script once and that's that. If they don't, you need to re-run the script whenever someone respawns. I'm not sure how to do this, but I'm sure you can find an answer to "on spawn" scripting someplace in the MP forums. :)

As to the "RUG_BodyArmor" variable: this is a number that tracks the current damage to the armor. 0 means full armor. It goes all the way up to RUG_BA_MaxDam (or somesuch) which is another vehicle variable and which is determined by the negative number you entered in the beginning. The reason it's a negative number is basically because the script is being reused, and when it notes a non-negative number in the third spot it runs a different course than when it notices a negative one. But you don't need to worry about that. Essentially you can make the maxdam on an individual unit whatever you want, whenever you want, by using setvariable on that. But that's more advanced stuff already.

Do try it and tell me where it goes wrong. Hopefully it should work now as you want. As mentioned, I can't try or do anything about respawning and MP play - if it works, that's great, if it doesn't, I'm a bit stumped.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 29 Oct 2009, 16:42:38
Ok I tried it out and got some error messages:

Quote
_x setVariable ["RUG_BodyArmor", 0]; foreach [Player1, Player2, Player3, Player4]
_x setVariable ["RUG_BodyArmor.sqf", 0]; foreach [Player1, Player2, Player3, Player4]

{[_x, 1, -1.3] execVM "RUG_BodyArmor.sqf";} foreach [Player1, Player2, Player3, Player4]
Error _unit setVariable ["RUG_BodyArmor", 0];
And in the script itself it says line 111, which only has "};" and this line above it "_unit setVariable ["RUG_BodyArmor", 0];".

_x foreach [Player1, Player2, Player3, Player4] --> doesn't do anything.

And it hasn't worked yet :).

Btw, I wasn't clear on what exactly to put in the Init.sqf so I tried a few variations.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 29 Oct 2009, 22:28:31
Um.

To run the script, just use this code:

Code: [Select]
{[_x, 1, -1.3] execVM "RUG_BodyArmor.sqf";} foreach [Player1, Player2, Player3, Player4];
Which you've got there quite nicely. You can read up on how to properly use foreach in the COMREF (forEach (http://www.ofpec.com/COMREF/index.php?action=details&id=140&game=All)). You don't need to set the armor manually using setvariable, so just remove that (no point setting it BEFORE the script starts either).

As to the missing {, this might be due to you deleting too much or too little of the scripts that you did delete. Be very careful with that! Basically you need to count every { and make sure it has a } to end it. Best bet might be to go back to the original script, and then be very careful with what you delete: you don't HAVE to delete the BA_AiAction script, since it won't be run either way.

Also, I think there's a little error in the script I provided you for a replacement BA_Down: wherever it says _this, it should say _unit, so you might want to replace this little code snippet with the below:

Code: [Select]
waitUntil {damage _unit == 0};
_unit setdamage -5;
_EH = _unit addEventHandler ["hit", {_this call RUG_BA}];
_unit setvariable ["RUG_BA_EH", _EH];
_unit setVariable ["RUG_BodyArmor", 0];

Yeah, um. As mentioned, I simply can't test this now, so I apologize for any errors and such.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 30 Oct 2009, 19:21:09
Well after trying it a few times and got the "{" errors out it seems to start without errors, however laying down that is how I start instead of standing up :).
After about dying once though or it seems my armor is totally blasted away, alike a test today I got shot at with a cannon :D, it says on the next rerun and getting shot still the same thing "Current/Maxscalar/null" and it doesn't work anymore unfortunately.
But I got the errors out ^^ :D.

I traced that debug line down:
Code: [Select]
if (RUG_BA_Debug) then {hint format ["Unit:%1\nDamage:%2\nCurrent/Max:%3/%4", _unit, _dam, _curDam, _maxdam]};


if (_curDam > _maxdam) then
{

[_unit, _dam] spawn RUG_BA_Down; if (_mode == 3) then {_unit setdamage -500};

}

else {_unit setdamage -5; if (_mode == 3) then {_unit setDamage -500}};
But it seems fine, I think. if current damage is more than max damage, you're dead and spawn. And if max damage is greater than reset as well basically. Correct?

Don't worry, I'll test it out :D, I'm overly happy with the help. Its one of the best script I've ever found in arma. And I've searched through alot. :D
I was surprised there was no standard body armor in arma alike pretty much every other game, every other shooting ever to have been actually. :)
It feels like this is a "Do It Yourself" game anyway, I found that even for the smallest thing you need a script, mod, edit, addon or pretty much do it yourself someway. Its like crazy man. :P

Anyway, we'll figure it out. :D
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 07 Nov 2009, 22:31:02
Hm. Okay. As mentioned, I can't test these things because, as always, I have no access to a computer capable of ArmA right now. However, since it seems there's no easy solution to this, and since it seems you WANT a pretty easy script (quite unlike the bodyarmor script I wrote originally), how about simply making a new one?

Code: [Select]
//Init code, creates separate script, adds eventhandler

_unit = _this select 0;
_maxdam = _this select 1;

_unit setdamage -5;
_unit setvariable ["RUG_BA_MaxDam", _maxdam];
_unit setvariable ["RUG_BA_CurDam", 0];

RUG_BA_Script =
{
_unit = _this select 0;
_dam = _this select 2;
_curdam = _unit getvariable "RUG_BA_Curdam";
_maxdam = _unit getvariable "RUG_BA_MaxDam";

_curdam = _curdam + _dam;
_unit setvariable ["RUG_BA_CurDam", _curdam];

if (_curDam > _maxdam) then {} else {_unit setdamage -5};
};

_unit addeventhandler ["hit", {_this call RUG_BA_Script}];

Copy the above script into notepad, save as something like for instance "RUG_BodyArmorSimple.sqf", and then run it on each unit using something like: [unit1, 3] execvm "RUG_BodyArmorSimple.sqf". The number is the maximum damage the unit can take, unit1 is the name of the unit. This should basically do what you want: no knock down effects, no first aid, no AI, no nothing. Just an "armor" that lasts for a couple of shots, and then doesn't work anymore.

You'll probably have to re-run the script on each respawn, I think.

I haven't tested this, so if you find any errors, do tell me.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 08 Nov 2009, 00:48:48
Well it runs without errors :D.

This is the code I use to run it in the init.sqf.
Code: [Select]
{[_x] execVM "RUG_BodyArmor.sqf";} foreach [Player1, Player2, Player3, Player4];
I do like the -1.3 from earlier though but I don't know how or where to implement it. I don't know how well it works, with armor and bullets but it seems to work so that is nice :D.

I do think it needs to be rerun after death though. And don't worry about the testing, I will do that. :D
But I suppose you had the re-run idea or code ready anyway :P.

But overall thanks very much.

I guess only the -1.3 and re-run and its fine, "accepted version" ;).

So thanks again. :)

PS btw, the clean scripts come from my HTML days, extremely clean, Perfection Clean. :D
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 08 Nov 2009, 11:34:51
Code: [Select]
{[_x, 4] execVM "RUG_BodyArmor.sqf";} foreach [Player1, Player2, Player3, Player4];
Is the appropriate way to run it, I'd say, otherwise I couldn't imagine how it could work  :dunno: The number there can be whatever you want. The -1.3 of the previous script is probably something around 4-6, so experiment.

If you want to, you can paste in a debug code as well (comment it out using // when you're sure it works). E.g., right before the }; on the line after if (_curDam > _maxdam) then {} else {_unit setdamage -5};

Code: [Select]
hint format ["Unit: %1, Dam: %2/%3", _unit, _curdam, _maxdam];
That should tell you which unit is hit and how much current damage out of maximum damage it has: when it goes over that level, the unit should take damage normally.

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 09 Nov 2009, 08:53:34
Alright, it works without error. :)

Only thing is with the debug after I get killed once it stays stuck at Dam: Max/null or Scalar/null, but I will leave it.

It works, even after respawn, I clearly notice I still have my body armor and it resets/respawns too so it works.

Btw, does it reset my armor too after healing, mash, medic or whatever?


Anyway, it works. :P

Thank you very much.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: Wolfrug on 09 Nov 2009, 23:03:38
Hmm, strange that it works if it doesn't say it does.  :dunno: Then again, MP scripting just makes me confused as I've said before.

And nope, that version doesn't do that: the reason being that keeping an eventhandler script waiting would be a little stupid since every time you'd be hit thereafter (even if not lethally) it'd have another version of the script waiting. And such. Hmm. But if you don't mind the potential lag, you can maybe do something like this, subsituting the appropriate line:

Code: [Select]
if (_curDam > _maxdam) then {_unit setdamage _dam; waituntil {damage _unit == 0}; _unit setvariable ["RUG_BA_CurDam", 0]; _unit setdamage -5} else {_unit setdamage -5};
Then, at least theorethically, it should wait until the unit is back to zero damage, and then reset the curdam of the unit to 0 and the script can continue as it were.

But, again, I don't understand how it can work if the local variables aren't "showing" properly. :-/ But if you're happy with it, then by all means!

Wolfrug out.
Title: Re: RUG_BodyArmor v.1.1 (ACCEPTED)
Post by: ZachHox on 10 Nov 2009, 21:21:56
Well, I thought it was only a debuging problem, that is why I just left it.

Kinda strange though, sometimes it seems to work, sometimes it doesn't.


But it really won't work, I'll just leave it.


Thanks.