Home   Help Search Login Register  

Author Topic: Check_deadgunner.sqs  (Read 1210 times)

0 Members and 1 Guest are viewing this topic.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Check_deadgunner.sqs
« on: 12 Jan 2008, 18:16:00 »
Ok guys i made this script today for my hummers with m2 to be used in the BHD MOD.
basically the function of this script is to check whatever the gunner is dead or not, then replace it with another soldier of the same group that is in cargo position.
I also added a part in which I've defined what sounds should randomly be played when gunner has been killed

now the strange thing I get is:
A soldier is effectively randomly chosen from the crew of the hummer, and he says effectively a randomly chosen sound, but when speaking of moving to gunner position, nothing happens, he doesn't do the job...
whyyy????:weeping:

here is the script that is called via

[nameofvehicle, (gunner nameofvehicle)] exec "check_deadgunner.sqs"
Code: [Select]
;check_deadGunner.sqs

_veh = _this select 0
_gunner = _this select 1
_grp = (group (driver _veh))
_count = count units _grp
_num_count = (random _count)
_leader = leader _gunner
;------------------------------------------
;Start of the script
;------------------------------------------
#START

;------------------------------------------
_arr_sounds = ["UScry1","UScry3","UScry4","UScry5","UScry6","UScry7","UScry8","UScry9","UScry10","UScry11","UScry12","UScry13"]
_count_arr = count _arr_sounds
;random count sounds to play
_items = random _count_arr
_number_items = _items - (_items mod 1)

;------------------------------------------
?!(alive _gunner) : goto "Deadgunner"

~1

goto "START"

#Deadgunner

_number_soldiers = _num_count - (_num_count mod 1)

_selected_soldier = ((units _grp) select _number_soldiers)
_selected_soldier say (_arr_sounds select _number_items)
;if (_leader == _gunner) then {((units _grp) select _number_soldiers) say (_arr_sounds select _number_items)} else {_leader say (_arr_sounds select _number_items)}
;[_gunner] join grPnull
_selected_soldier moveInGunner _veh

exit

as I said, the script work till it reaches the last line, _selected_soldier moveInGunner _veh


help help help help help help
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)

Offline Loyalguard

  • Former Staff
  • ****
Re: Check_deadgunner.sqs
« Reply #1 on: 12 Jan 2008, 19:59:15 »
I will look into it more, but the first things that came to mind are:

1) Maybe _selected_soldier cannot get into the gunner position while the dead body is there (or from his current cargo "seat").  So maybe try deleteVehicle _gunner to remove the dead gunner before using moveInGunner with _selected_soldier.  I know moveINGunner is an immediate switch (no animation) so maybe all the conditions have to be correct before he can move in.

2) As an alternative, use AssignAsGunner to assign selected_soldier to the gunner position and then use orderGetIn to move him into the gunner position.

If neither of those work we can diagnose deeper.

Good luck!
« Last Edit: 12 Jan 2008, 20:01:05 by Loyalguard »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Check_deadgunner.sqs
« Reply #2 on: 12 Jan 2008, 21:58:11 »
AFAIK, once a unit is inside a vehicle, you cannot use moveIn commands to change its position.

Offline Linker Split

  • Members
  • *
  • BHD MOD leader
    • BHD MOD site
Re: Check_deadgunner.sqs
« Reply #3 on: 13 Jan 2008, 00:27:08 »
Ok now it works!

I changed the last part, from the label Deadgunner to the end:
Code: [Select]
#Deadgunner

_number_soldiers = _num_count - (_num_count mod 1)

[_gunner] join grpNull
_selected_soldier = (_grp select _number_soldiers)
_selected_soldier say (_arr_sounds select _number_items)
~2.3
unAssignVehicle _gunner
unAssignVehicle _selected_soldier
_selected_soldier action ["EJECT",_veh]
deleteVehicle _gunner
_selected_soldier assignAsGunner _veh
_selected_soldier moveInGunner _veh
ArmA: Black Hawk Down MOD website
Only the dead have seen the end of war (Plato)