Home   Help Search Login Register  

Author Topic: Chaos Studios Body remover script  (Read 3039 times)

0 Members and 1 Guest are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Chaos Studios Body remover script
« on: 10 Sep 2006, 17:55:46 »
Type of resource: Script
Applicability: OFP
Title of resource: Body remover script
Author/Submitted by: Author ChSbrs / Submitted by hoz
Version: 1.0
Description: The script cleans fallen units in an elegant way and takes the work away from the hardware. very useful concerning huge fights and MP games. It only needs to be started once for every group.


Xbox Rocks

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Chaos Studios Body remover script
« Reply #1 on: 12 Sep 2006, 23:52:13 »
Couple things wrong with this script:
1) The first loop that is supposed to 'sink' the first body dead does not work. What I see instead is the body flickering as it is setPos'd below ground level and then pops up again, creating a strange flickering affect.
2) It is not MP friendly.  The script deleteVehicle's bodies based on the distance to the player, which will be different on each client. The result of this will be bodies disappearing as soon as one player in an MP game gets far enough away.  While this is not the end of the world, the script is not behaving as stated.
3) Most of the 542kb comes from images, and the fact that a pbo and a folder version of the demo mission are inside. The pbo should be removed and the two larger ChSBRS publicity images should be removed.
« Last Edit: 14 Sep 2006, 19:07:59 by Mr.Peanut »
urp!

Offline Chaos

  • Contributing Member
  • **
  • The best Missions are realistic Missions !
    • Operation Flashpoint Database
Re: Chaos Studios Body remover script
« Reply #2 on: 21 Sep 2006, 23:15:58 »
Hello!

Sorry about the late answer. And first - sorry for my english. Its not soo good, so i canÂ't explain this themes detailed.

1.) I donÂ't find the animation problem - i think what you see is the clipping issue. The animation will ever ends and the body will be deleted. Maybe this problem will comes when the body is lying on a steeply underground ? On a flat underground this phase works ever correctly.

2.) I am not really sure about the mp functionality. But i think the script will ask about the nearest player charakter. I donÂ't make my scripts in first line for MP but i thought this script will works in MP. Are you 100% sure about this issue ? Can anybody help me with this problem ? The asking for range from player must be - so the script can start his works or delete the body immediately afer phase one if the players distance is big enough.
« Last Edit: 22 Sep 2006, 00:27:36 by Chaos »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Chaos Studios Body remover script
« Reply #3 on: 22 Sep 2006, 20:44:14 »
Hello Chaos, and welcome back.

1) I was testing on a flat surface. Using the ECP debugger I also tried setPosing a man half below ground. Dead or alive it did not work for me, he pops back up to ground level.  I have OFP/R 1.96.  It would help if someone else would test to verify this.

2) The problem is this. Player A is close to the body but player B is not.  The script with continue on for Player B, but for Player A the script still loop because the body is too close.   Player A will see everything happen. The body sinking and being deleted. The camCreate command will only run on player B's machine so only B will see the bodybag and then the grave.

3) A third problem might be lag if this script is run on too many enemy units at once. For each enemy unit there is a @!alive _t. If run for 50-100 enemy this is the same as adding 50-100 triggers to a map.

Your script will work in MP, but it will not work as you want it to. The only fix is to place all players in an array and then check that the distance is great enough for all players. This is still not 100% but it is better.
In the init.sqs
Code: [Select]
playerArray = [p1,p2,p3,p4...]
Then in your script something like this for all distance checks:
Code: [Select]
? _deR == 1 && ({(_t distance _x)  < _e} count playerArray) == 0) : goTo "deleting"Will make sure no players are near the body. Then your script should work properly.


The best way to do this for MP without lag is as follows.   Remove the first part of your script that loops through all units in an enemy group and put it in another script.  Make it so the new script adds a killed eventhandler to each unit of an enemy group.  Have the eventhandler call your body removal script for that unit.  Eventhandlers do not take as much cpu as triggers and the @ command. When the enemy unit is killed, the eventhandler will fire on the server only, and your body removal script will execute on the server only.  In your body removal script check distance to all players as I show above and replace the camCreate command with the createVehicle command.  createVehicle will make all players see the graves.

Doing it this way will make it 100% MP compatible.  If you do not want to do all this then say in your readme that it is for SP only.
urp!

Offline Chaos

  • Contributing Member
  • **
  • The best Missions are realistic Missions !
    • Operation Flashpoint Database
Re: Chaos Studios Body remover script
« Reply #4 on: 23 Sep 2006, 16:38:14 »
do you have a idea to use eventhandler with more than one parameter ?

Usually is:
Code: [Select]
_this addEventHandler ["hit",{_this exec "script.sqs"}]

But i need it so:
Code: [Select]
unit addEventHandler ["hit",{[unit,option1,option2,option3] exec "script.sqs"}]


and this version doesnÂ't works. the parameters will not give to the script.

A little note: this script is called "Body remove script" - not "remover". And it is "ChaosStudios" - not "Chaos Studios"  :angel:
« Last Edit: 23 Sep 2006, 21:40:21 by Chaos »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Chaos Studios Body remover script
« Reply #5 on: 24 Sep 2006, 00:32:59 »
Code: [Select]
_unit addEventHandler ["killed",{[_this select 0,option1,option2,option3] exec "script.sqs"}]
Option1, option2, option3 must be global variables.
« Last Edit: 24 Sep 2006, 01:07:41 by Mr.Peanut »
urp!

Offline Chaos

  • Contributing Member
  • **
  • The best Missions are realistic Missions !
    • Operation Flashpoint Database
Re: Chaos Studios Body remover script
« Reply #6 on: 24 Sep 2006, 03:25:51 »
Yes, i know what you mean. I must set global array and fill it with global variables. But it is not possible when i will use these options for many, many groups of AIs. And here is the problem - without this possibilities is this script not really flexible and useful.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Chaos Studios Body remover script
« Reply #7 on: 25 Sep 2006, 19:04:51 »
Here's one way to implement most of the features in multiplayer. I was too lazy to implement the last option. @Chaos: you were right about the clipping problem causing all the flickering.

I also realised that you could keep your script as you originally posted if you insert the lines of code I added to check all players are far enough away.  Implemented this way, it would also be MP friendly, and require almost no changes.  You just have to make sure you define the chs_brs_parray, perhaps in the init.sqs.
« Last Edit: 27 Sep 2006, 00:18:39 by Mr.Peanut »
urp!

Offline Chaos

  • Contributing Member
  • **
  • The best Missions are realistic Missions !
    • Operation Flashpoint Database
Re: Chaos Studios Body remover script
« Reply #8 on: 28 Sep 2006, 19:52:18 »
hi, i checked your version. Yes its possible but what is when you have 2 (or more - maybe 20?) groups on the map - all with different settings ? So the "chs_brs_l" and "chs_brs_d" global Variables become rewrited with the next. I see it so: only solution for this would be to create "dynamic, global Names" for these options.

To read and analyse your answers here i need a translation help and more time. So stand by please because my english is not good enough.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Chaos Studios Body remover script
« Reply #9 on: 29 Sep 2006, 02:54:16 »
Okay, I have made the most simple changes possible to make it more MP compatible.  The distance checks are done for all players.

There was also one serious bug in your code:
Code: [Select]
? (count _this > 2) : _e = _this select 3; _deR = 1should be:
Code: [Select]
? (count _this > 3) : _e = _this select 3; _deR = 1
I have attached the working version below.

« Last Edit: 30 Sep 2006, 05:03:08 by Mr.Peanut »
urp!