Home   Help Search Login Register  

Author Topic: Destroy Flak  (Read 1486 times)

0 Members and 1 Guest are viewing this topic.

Offline guziczek101

  • Members
  • *
Destroy Flak
« on: 25 Nov 2011, 17:31:17 »
I wrote a script and (if you watch Band of brothers in 2nd period is a scene of destroying of the guns ) i have a problem I'm at work and don't really have time to describe it, but prepared a demo of the problem (do not need anything besides the original OFP) http://www.gamefront.com/files/21024045/test.intro.zip

Offline guziczek101

  • Members
  • *
Re: Destroy Flak
« Reply #1 on: 09 Dec 2011, 16:59:37 »
Mission Test

I improved this simple script and he add Action if you have two conditions you must be closer than X meters (u can change distance) and u must have at least one grenade in your inventory

Check.sqs
[Target,Distance] exec "Check.sqs"

Code: [Select]
_gun = _this select 0
_dis = _this select 1
_checkarray = []


#loop

@(({_x == "handgrenade"} count magazines Player)>=1)

?(player distance _gun) < _dis && !(_gun in _checkarray): destroy = _gun addaction ["Place Charge","stickyBomb.sqs"]; _checkarray = _checkarray + [_gun]

?(player distance _gun) > _dis : _gun removeaction destroy; _checkarray = _checkarray - [_gun]
?!(alive player): exit

~0.5
goto "loop"

and the stickybomb.sqs isn't mine i found it on Ofpec

stickybomb.sqs
Code: [Select]
;myTank addAction ["Attach Sticky Bomb","scripts\stickyBomb.sqs"]


;stickyBomb.sqs

;Tank that the action is attached to.
_tank = _this select 0
;Action number to remove
_indexNumber = _this select 2

player RemoveMagazine "handgrenade"

;Give the player 10 seconds to run away.
~10

;Get the position of the tank
_tankPos = getPos _tank
_tankX = _tankPos select 0
_tankY = _tankPos select 1

;Create a large explosion at the tank.
_stickyBomb = "Shell73" camCreate [_tankX,_tankY,1]
;Make sure he's dead :)
if (alive _tank) then {_tank setDammage 1}

;Remove the now redundant action
_tank removeAction _indexNumber

;exit script
exit

Walter_E_Kurtz

  • Guest
Re: Destroy Flak
« Reply #2 on: 09 Dec 2011, 19:23:26 »
As you have it, Check.sqs is acting like a trigger; effectively you addAction when the trigger is Activated and then removeAction when it is deactivated. As the script loops, so the trigger is Repeating.

I'm attaching a small test mission based on your original. I didn't do any more work on it after your question was answered over at the BI Forums.

I didn't bother with checking the distance between player and the AA. Since you attach the action to the AA, the player can only make use of it when close enough in the first place. It's also worth noting that units under the player's command can be order to perform the action themselves eg. F2 - 6 - 1.

The distance command measures between the centres of vehicles (to be strictly accurate, the zamerny point in the Memory LOD) - NOT between their surfaces. Hence the number to be checked against has to be high enough; something like 5 metres for tanks and the like.

Offline guziczek101

  • Members
  • *
Re: Destroy Flak
« Reply #3 on: 09 Jan 2012, 15:32:07 »
I worked a little with this system and I reached the conclusion:
1. does not have to check if player has grenade's/satchels because inventory of player is a little too small (need to have grenades at the expense of ammunition)
2. Tank does not have to be destroyed, enough to be immobilized
3. Crew can die from the overloading of explosion strength even if tank is not destroyed
4. Time is displayed for an explosion (in upper right corner)*
I a little worked on this system and i present this:

Check.sqs
Code: [Select]
; *****************************************************
; ** Check.sqs this script will check distance player and object to blow up
; ** Written by guziczek101 for Operation "Neptune" mission
; ** [object,distance,true/false] exec "Skrypty\Efekty\Check.sqs"
; *****************************************************
_gun = _this select 0
_dis = _this select 1
_random = _this select 2
_checkarray = []

#loop
?(player distance _gun) < _dis && !(_gun in _checkarray): destroy = _gun addaction ["Place Charge","stickybomb.sqs"]; _checkarray = _checkarray + [_gun]

?(player distance _gun) > _dis : _gun removeaction destroy; _checkarray = _checkarray - [_gun]
?(!(alive player) || !(alive _gun)) : exit

~0.5
goto "loop"

Stickybomb.sqs
Code: [Select]
; *****************************************************
; ** Stickybomb.sqs this script will blow up the object
; ** Written by guziczek101 for Operation "Neptune" mission
; ** Script is called from Check.sqs
; *****************************************************
_gun = _this select 0
?(!(alive _gun)) : exit

TimeisUp = FALSE

_dam = Getdammage _gun
player switchmove "CombatToMedic"
~5
player say "Eng29"
player sidechat "Lookout"
player switchmove "MedicToCombat"
[] exec "CountD.sqs"
~10
?TimeIsUp : goto "RDamage";

#RDamage
_nrand = random(10)
?_nrand >= 7: goto "KILL2"
?_nrand >= 3: goto "KILL3"
?_nrand >= -10: goto "KILL1"

#kill1
_gun setdammage (_dam + 0.5)
playsound "Explo"
goto "fire"
exit

#kill2
_gun setdammage (_dam + 1)
playsound "Explo"
goto "fire"
exit

#kill3
_gun setdammage (_dam + 0.7)
playsound "Explo"
goto "fire"
exit

#fire
_smoke= "SmokeShell" CamCreate [0,0,0]
_smoke setpos getpos _gun
_color2 = [0.009,  0.00,0,0.99]
_whitereal = [0,0,0,0]
_shell = "Shell105" CamCreate [0, 0, 0]
_shell setpos getpos _gun
drop ["cl_basic", "", "Billboard", 1, 5, [0,3,0], [0,0,0], 0, 1.1, 1, 0.5, [Random 7, 9, 15],[_color2,  _color2, _color2, _whitereal],[0],0.2,0.6,"","",_shell]
~3
deletevehicle _smoke
goto "Randomkill"

#Randomkill
_random = true
_maxkills = 3
?count _this == 2: _random = _this select 2; _maxkills = 4
?count _this == 3: _random = _this select 2; _maxkills = _this select 3
; now the randomkills
_crew = crew _gun
_c = count _crew
_i = 0
_kills = 0

#crew
_unit = _crew select _i
?random 1 > 0.8 && _unit != player : _unit setdammage (random 1)
?random 1 > 0.8 && _unit != player && _kills < _maxkills : _unit setdammage 1; _kills = _kills + 1
_i = _i + 1
?_i < _c : goto "crew"

exit

CountD.sqs
Code: [Select]
; *****************************************************
; ** CountD.sqs
; *****************************************************

Counting=true
_timeRSC = 10

#COUNTDOWN
?_timeRSC >= 100 : TitleRSC [format ["%1",_timeRSC],"PLAIN"]
?_timeRSC < 100 && _timeRSC >= 10 : TitleRSC [format ["0%1",_timeRSC],"PLAIN"]
?_timeRSC < 10 : TitleRSC [format ["00%1",_timeRSC],"PLAIN"]

_timeRSC = _timeRSC - 1
?_timeRSC == 010 : _timeRSC = 000
?_timeRSC == -1 : TimeIsUp = True; Exit
~1
?alive player and Counting : Goto "COUNTDOWN"


Exit

Demo Mission

* The countdown script is not mine it's from the CSLA 2 mission Poison Island (I hope this is not offended anyone, but really wanted to have the counter to keep the climate,yet it is not what I wanted, watch such as in Call of Duty 2 / Medal of Honor )