Home   Help Search Login Register  

Author Topic: RUG_BodyArmor v.1.1 (ACCEPTED)  (Read 16812 times)

0 Members and 1 Guest are viewing this topic.

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #45 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.
« Last Edit: 22 Oct 2009, 21:22:33 by ZachHox »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #46 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.

"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #47 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,
« Last Edit: 25 Oct 2009, 13:09:00 by ZachHox »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #48 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.



"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #49 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.
« Last Edit: 28 Oct 2009, 15:12:33 by ZachHox »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #50 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.
"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #51 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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #52 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). 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.
"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #53 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

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #54 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.
"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #55 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
« Last Edit: 08 Nov 2009, 06:27:02 by ZachHox »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #56 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.
"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #57 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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #58 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.
"When 900 years YOU reach, look as good you will not!"

Offline ZachHox

  • Members
  • *
Re: RUG_BodyArmor v.1.1 (ACCEPTED)
« Reply #59 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.