Mam kolejny problem ze śmigłowcem ale dotyczy troszkę czegoś innego. Nie wiem jaki skrypt zastosować do sprawdzenia czy konkretna cześć śmigłowca jest uszkodzona w określonym stopniu.
Large rotor damage: _heli setHit ["velka vrtule", 1];
Small rotor damage: _heli setHit ["mala vrtule", 1];
Engine damage: _heli setHit ["motor", 1];
Te 3 linijki odpowiadają określonemu typowi uszkodzenia: górny wirnik, tyny i silnik główny. (jeśli ktoś zna ich więcej to też bardzo bym prosił). Chodzi mi o to, że jeśli np. silnik zostanie zniszczony albo tylny rotor, to okreslone zadanie bedzie =true. Próbowałem (i pewnie jak zwykle skompromituję się tym co zobaczycie) zrobić coś takiego:
if (heli setHit ["velka vrtule", 1]) then {zdechl=true. }; Niestety nie działa...
Bardzo proszę o pomoc.
Problem z uszkodzeniem elementów śmigłowca
Moderatorzy: kondor, Inkwizytor
Re: Problem z uszkodzeniem elementów śmigłowca
setHit, jak sama nazwa ("ustaw trafienie") mówi, potrafi co najwyżej zniszczyć - dlatego instrukcja if-then nigdy nie zadziała (zobacz tu: http://community.bistudio.com/wiki/setHit, że "return value" jest "Nothing").
Spróbuj komend: http://community.bistudio.com/wiki/getDammage lub http://community.bistudio.com/wiki/canMove
Spróbuj komend: http://community.bistudio.com/wiki/getDammage lub http://community.bistudio.com/wiki/canMove
Re: Problem z uszkodzeniem elementów śmigłowca
Przeszukałem kilka stron, fora i nie znalazłem możliwości zastosowania getdammage do uzyskania zamierzonego celu. Nie ma więc takiej możliwości? A jakbym chciał np dodać dżwięk w momencie, gdy jakaś określona część ulegnie uszkodzeniu np. w 50%? Musi być przecież na to jakiś sposób?! Proszę pomóżcie.
Re: Problem z uszkodzeniem elementów śmigłowca
Chyba nie ma (jeszcze) takiej komendy (któraby zwracała wartość zniszczenia dla konkretnej części).
Re: Problem z uszkodzeniem elementów śmigłowca
Znalazłem coś takiego. Pogrubiłem informację o częciach śmigłowca. Może da się jakiś skrypt zastosować, który wyciągnąłby informację o danej części. Może komuś coś przyjdzie do głowy... Bardzo będę wdzięczny.
class CfgModels
{
class Default
{
sectionsInherit="";
sections[] = {};
skeletonName = "";
};
class Vehicle: Default
{
sections[] =
{
"cislo",
"grupa",
"side",
"sektor",
"clan",
"clan_sign",
"podsvit pristroju",
"poskozeni",
"L svetlo",
"P svetlo",
"zasleh"
};
};
class Helicopter: Vehicle
{
sectionsInherit="Vehicle";
sections[]=
{
"sklo predni p",
"sklo predni l",
"velka vrtule staticka",
"velka vrtule blur",
"mala vrtule staticka",
"mala vrtule blur",
"trup",
"motor",
"elektronika",
"mala vrtule",
"velka vrtule",
"munice",
"zbran",
"vez"
};
skeletonName="Helicopter";
class Animations
{
class damageHide
{
type="hide";
source="damage";
selection="damageHide";
};
class IndicatorAltRadar: Rotation
(...)
class CfgModels
{
class Default
{
sectionsInherit="";
sections[] = {};
skeletonName = "";
};
class Vehicle: Default
{
sections[] =
{
"cislo",
"grupa",
"side",
"sektor",
"clan",
"clan_sign",
"podsvit pristroju",
"poskozeni",
"L svetlo",
"P svetlo",
"zasleh"
};
};
class Helicopter: Vehicle
{
sectionsInherit="Vehicle";
sections[]=
{
"sklo predni p",
"sklo predni l",
"velka vrtule staticka",
"velka vrtule blur",
"mala vrtule staticka",
"mala vrtule blur",
"trup",
"motor",
"elektronika",
"mala vrtule",
"velka vrtule",
"munice",
"zbran",
"vez"
};
skeletonName="Helicopter";
class Animations
{
class damageHide
{
type="hide";
source="damage";
selection="damageHide";
};
class IndicatorAltRadar: Rotation
(...)
Re: Problem z uszkodzeniem elementów śmigłowca
Witam ponownie. Znów szukałem, szukałem i znalazłem coś takiego. Przepraszam, że po angielsku i że tak tego dużo ale może to komuś pomoże. opis dotyczy uszkodzeń ciała. Może da się to przekształcić na uszkodzenia części pojazdu...
The passed array
_this select 0: Unit the EH is assigned to
_this select 1: Selection (=body part) that was hit
_this select 2: Damage to the above selection (sum of dealt and prior damage)
_this select 3: Source of damage (returns the unit if no source)
_this select 4: Ammo classname of the projectile that dealt the damage (returns "" if no projectile)
Infantry selections
"": The overall damage that determines the damage value of the unit. Unit dies at damage over 0.9.
"head_hit": Unit dies at damage over 0.9.
"body": Unit dies at damage over 0.9.
"hands": Unit doesn't die with damage to this part.
"legs": Unit doesn't die with damage to this part.
The "" part is the reason why consecutive leg hits are fatal. Whenever the unit is hit, "" gets damage based on the power of the hit with no other modifiers. Wherever you hit the unit, it will die when this overall damage quota is up. You will notice that when shooting at a unit's feet (with e.g. a Makarov) it will almost always die after the same amount of rounds.
How the EH fires
The event handler fires multiple times at the same time when the unit is damaged, once for each selection. The sequence is always the same, the sequence for infantry being the same as in the selection list above. Only the current selection and its damage are remembered during each activation unless you assign variables to them. If a selection is not damaged at all and there are no damaged selections after it in the sequence (e.g. a shot in the head without damage to legs), the EH doesn't fire for that selection.
Manipulating damage
The last value given in the EH's code is the damage that it receives for the current selection. For example, this addEventHandler ["HandleDamage",{_this select 2}] will have a unit receive damage as if it didn't have the event handler at all. Changing _this select 2 to 1 will make the unit die however minor the original damage was. You can allow damage to only specific selections by passing a damage value only if the selection is of a certain type: this addEventHandler ["HandleDamage",{if (_this select 1 in ["head_hit","legs"]) then {_this select 2}}] will pass only the damage that the head and legs were dealt. If the code is too complex to be written into the EH itself, only callable scripts should be used for the purpose of determining damage because the damage has to be given in the EH's code.
Poor man's getHit
Until BIS is kind enough to give us a command to return the damage of individual selections, HandleDamage is the best workaround. This EH will assign the "gethit" variable to a unit, and returning a selection's damage is a matter of _unit getVariable "gethit" select <sequence index of selection>.
Add this to a unit:
this setVariable ["gethit",[0,0,0,0,0],false];this addEventHandler ["HandleDamage",{_unit=_this select 0;_selection=_this select 1;_damage=_this select 2;_gethit=_unit getVariable "gethit";switch (_selection) do {case "": {_gethit set [0,_damage];_unit setVariable ["gethit",_gethit,false]};case "head_hit": {_gethit set [1,_damage];_unit setVariable ["gethit",_gethit,false]};case "body": {_gethit set [2,_damage];_unit setVariable ["gethit",_gethit,false]};case "hands": {_gethit set [3,_damage];_unit setVariable ["gethit",_gethit,false]};case "legs": {_gethit set [4,_damage];_unit setVariable ["gethit",_gethit,false]}};_damage}]
A simpler version for a single selection:
this setVariable ["gethitlegs",0,false];this addEventHandler ["HandleDamage",{if (_this select 1=="legs") then {_this select 0 setVariable ["gethitlegs",_this select 2,false]};_this select 2}]
Remember that event handlers will carry on to respawned units as do setVariables, so the setVariable should be made [0,0,0,0,0] again. Of course, vehicles will need a code with their own selections, but you can work it out from here.
przepraszam za podwójny post. Coś przekombinowałem.
The passed array
_this select 0: Unit the EH is assigned to
_this select 1: Selection (=body part) that was hit
_this select 2: Damage to the above selection (sum of dealt and prior damage)
_this select 3: Source of damage (returns the unit if no source)
_this select 4: Ammo classname of the projectile that dealt the damage (returns "" if no projectile)
Infantry selections
"": The overall damage that determines the damage value of the unit. Unit dies at damage over 0.9.
"head_hit": Unit dies at damage over 0.9.
"body": Unit dies at damage over 0.9.
"hands": Unit doesn't die with damage to this part.
"legs": Unit doesn't die with damage to this part.
The "" part is the reason why consecutive leg hits are fatal. Whenever the unit is hit, "" gets damage based on the power of the hit with no other modifiers. Wherever you hit the unit, it will die when this overall damage quota is up. You will notice that when shooting at a unit's feet (with e.g. a Makarov) it will almost always die after the same amount of rounds.
How the EH fires
The event handler fires multiple times at the same time when the unit is damaged, once for each selection. The sequence is always the same, the sequence for infantry being the same as in the selection list above. Only the current selection and its damage are remembered during each activation unless you assign variables to them. If a selection is not damaged at all and there are no damaged selections after it in the sequence (e.g. a shot in the head without damage to legs), the EH doesn't fire for that selection.
Manipulating damage
The last value given in the EH's code is the damage that it receives for the current selection. For example, this addEventHandler ["HandleDamage",{_this select 2}] will have a unit receive damage as if it didn't have the event handler at all. Changing _this select 2 to 1 will make the unit die however minor the original damage was. You can allow damage to only specific selections by passing a damage value only if the selection is of a certain type: this addEventHandler ["HandleDamage",{if (_this select 1 in ["head_hit","legs"]) then {_this select 2}}] will pass only the damage that the head and legs were dealt. If the code is too complex to be written into the EH itself, only callable scripts should be used for the purpose of determining damage because the damage has to be given in the EH's code.
Poor man's getHit
Until BIS is kind enough to give us a command to return the damage of individual selections, HandleDamage is the best workaround. This EH will assign the "gethit" variable to a unit, and returning a selection's damage is a matter of _unit getVariable "gethit" select <sequence index of selection>.
Add this to a unit:
this setVariable ["gethit",[0,0,0,0,0],false];this addEventHandler ["HandleDamage",{_unit=_this select 0;_selection=_this select 1;_damage=_this select 2;_gethit=_unit getVariable "gethit";switch (_selection) do {case "": {_gethit set [0,_damage];_unit setVariable ["gethit",_gethit,false]};case "head_hit": {_gethit set [1,_damage];_unit setVariable ["gethit",_gethit,false]};case "body": {_gethit set [2,_damage];_unit setVariable ["gethit",_gethit,false]};case "hands": {_gethit set [3,_damage];_unit setVariable ["gethit",_gethit,false]};case "legs": {_gethit set [4,_damage];_unit setVariable ["gethit",_gethit,false]}};_damage}]
A simpler version for a single selection:
this setVariable ["gethitlegs",0,false];this addEventHandler ["HandleDamage",{if (_this select 1=="legs") then {_this select 0 setVariable ["gethitlegs",_this select 2,false]};_this select 2}]
Remember that event handlers will carry on to respawned units as do setVariables, so the setVariable should be made [0,0,0,0,0] again. Of course, vehicles will need a code with their own selections, but you can work it out from here.
przepraszam za podwójny post. Coś przekombinowałem.