OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: MakkaraTheMan on 09 May 2007, 20:07:44
-
Hello yall :) Uh sorry moderators, I caused problems for you guys all ready... :-[ Thanks for moving this topic to the right place.
Ok. i´ll try to keep this short:
So what i need is, that the trigger-launched artillery script (BarrageArea.sqs), to use the shrapnell script (track.sqs+ the others).
NOTE!! The downloadable example mission is really worth a few minutes trying/watching, at least once. I give you my word, OK??
And here i try to explain the whole thing:
1. The original idea with the (shrapnells/explosion firing lethal fragments) script, was to make explosions more realistic, and dangerous. To me it just didn´t make sense, that a whole squad could run trough a mortar barrage, standing up all the way, or near eny explosion for that matter. Thas why i started this whole thing, and john smith helped me out, and created the foudation for this script.
This john smiths script is pretty cool, and very realistic!!! Maby some of you could get some new ideas, from it? Well, any way:
The script is lauched by a trigger that covers the whole map. All grenades, fired by any unit or vehicle under the trigger, are automatically firing real(bullet) shrapnells, when exploding. But It´s basic problem is the lagging, specially when there are meny nades exploding at the same time, and hundreds of bullets are shot around from each nade (360degrees).
The script laucher code is call handleri and goes trough this script first init.sqs
;Type of resource: Script / function
;Applicability: OFP, i´m not shure if this works w. ARMA too?
;Title of resource: Real (bullet)explosion fragments for different size grenades
;Version: 1.2
;Author/submitted by: The creator of this script is john smith[FIN]
;The original idea, testing and small modifications by: MakkaraTheMan[FIN]
;
;Description:
;This script is tested, and it works with all units and vehicles under the trigger area,
;that are using ammo, listed in the init.sqs -file
;--------------------------------------------------------------------------------
;Make a trigger covering the whole map size, activated by anybody (present)
;copy (ctrl + c) the script launch code on the triggers activation field:
;
;{_x addEventhandler ["fired", {_this call handleri}]} forEach thisList
;
;Copy all 5 separate script files into your user mission folder:
;b.sqf
;grad.sqf
;init.sqs
;track.sqs
;--------------------------------------------------------------------------------
;This file/code is still unfinnished, but as you can see it´s possible to make every single
;nade to make its own individual shrapnell group for different explosions.
;I must study more command references and ammolists for different addons and mods.
;Eny way, if you want to add or change something, you can easily do it your self.
;-------------------------------------------------------------------------------
smallshelltypes=["GrenadeHand", "GrenadeHand_e", "GrenadeHand_r", "FDF_handgrenade_ammo", "Grenade", "FDF_rk95Mortar", "FDF_rk95Mortar2", "FDF_agsGrenade", "FDF_stickGrenade", "MortarShell", "BISGrenadeCamel", "Cannon25HE", "Cannon30AP", "Cannon30HE", "FDF_BMP30HE", "FDF_BMP30AP", "Heat73", "Shell73", "FDF_73mm", "FDF_Zsu57Cannon", "FDF_55s55LauncherMag"]
mediumshelltypes=["FDF_mortar81", "FDF_mortar81_E", "FDF_Musti95Okr", "FDF_MustiHeat", "FDF_MustiHE"]
bigshelltypes=["Shell105", "Shell120", "Shell125", "Shell155", "FDF_mk81_6", "FDF_kasapanos", "AT Mine", "LaserGuidedBomb", "Mine", "PipeBomb", "MineE", "TimeBomb", "Heat105", "Heat120", "Heat125", "Heat155", "FDF_leo2Sabot", "FDF_leo2heat", "FDF_T55MHVAPDS", "FDF_T55MHeat", "FDF_T55MHE", "FDF_T55MAP", "FDF_t72m1Sabot", "FDF_t72m1Heat", "FDF_t72m1HE"]
rockettypes=["CarlGustav", "Maverick", "LAW", "RPG", "Rocket57","AT3","AT4", "AT6", "Hellfire", "HellfireApach", "Rocket57x192", "Rocket57x64", "Rocket57x40Kamov", "FDF_apilasLauncherMag", "FDF_66kes75LauncherMag", "FDF_66kes88LauncherMag", "FDF_Rocket57x96", "FDF_Rocket57x32""9K32", "FDF_at3StaticLauncher", "FDF_PstOhj82mLauncher_e_v", "FDF_rocket135mm", "FDF_PstOhj82mLauncher", "Ch29T", "Zuni", "AA"]
handleri = preprocessfile "h.sqf"
grad = preprocessfile "grad.sqf"
paukku = preprocessfile "b.sqf"
;-----------------------------------------------------------------------------------------------
;This ammolist below, is still not working well enough, because the track.sqs is not fast enough.
;For example, the shells fired from a tank (T72) are so fast, that the shrapnell burst is
;left behind from the impact point, up to 30-50m. That looks odd and can cause irritation
;among players. If somebody would come up with more accurate script to track the grenades,
;Please send that script to e-mail adress: sami.heino@lifeline.fi
;bigshelltypes= "Heat105", "Heat120", "Heat125", "Heat155", "FDF_leo2Sabot", "FDF_leo2heat", "FDF_T55MHVAPDS", "FDF_T55MHeat", "FDF_T55MHE", "FDF_T55MAP", "FDF_t72m1Sabot", "FDF_t72m1Heat", "FDF_t72m1HE",
Then it goes to h.sqf
if ((_this select 4) in smallshelltypes) then {[nearestObject [_this select 0,_this select 4], 20, 200, "Bullet7_6W"] exec "track.sqs"};
if ((_this select 4) in mediumshelltypes) then {[nearestObject [_this select 0,_this select 4], 40, 400, "Bullet12_7"] exec "track.sqs"};
if ((_this select 4) in bigshelltypes) then {[nearestObject [_this select 0,_this select 4], 50, 500, "Cannon30AP"] exec "track.sqs"};
if ((_this select 4) in rockettypes) then {[nearestObject [_this select 0,_this select 4], 30, 200, "Bullet12_7"] exec "track.sqs"};
;"FDF_itkk"
NOTE! If you dont have a power PC, and If you don´t like the lagging, that the shrapnell script is causing, you should first lower the shrapnells amount/value in the h.sqf-file. If you reduce the amount/value of the shrapnells too low, the risk of getting hit by a shrapnell is very low, and then the whole script will loose it´s main point, but still it should be usefull at least making the AI-units to go down, and not just run straight in the middle of a barrage. Secondly thinking about MP-missions even a few shrapnelss makes the grenades moore dangerous, realistic and even human players must take the shrapnells seriously. At least it should give the game a bit more realistic "bite" :)
And here is the actual script that finds the nade track.sqs
;Type of resource: Script / function
;Applicability: OFP, i´m not shure if this works w. ARMA too?
;Title of resource: Real (bullet)explosion fragments for different size grenades
;Version: 1.2
;Author/submitted by: The creator of this script is john smith[FIN]
;The original idea, testing and small modifications by: MakkaraTheMan[FIN]
;
;Description:
;This script is tested, and it works with all units and vehicles under the trigger area,
;that are using ammo, listed in the init.sqs -file
;Suites in MP-missions too, but the script must be run on the servers battlefield,,, i think...
;--------------------------------------------------------------------------------
;Make a trigger covering the whole map size, activated by anybody (present)
;copy (ctrl + c) the script launch code on the triggers activation field:
;
;{_x addEventhandler ["fired", {_this call handleri}]} forEach thisList
;
;Copy all 5 separate script files into your user mission folder:
;b.sqf
;grad.sqf
;init.sqs
;track.sqs
;--------------------------------------------------------------------------------
goto "alku"
#fragloop
_j=_lkm
if (_lkm>5) then {_j=5}
while {_j>0} do {call paukku; _j=_j-1}
_lkm=_lkm-5
? (_lkm>0) : goto "fragloop"
exit
#alku
_nade=_this select 0
_pos=getpos _nade
_i=0
_u=_this select 1
;shrap speed
_lkm=_this select 2
;shrap numbers
_fragtype=_this select 3
_o1=0
_o2=0
_o3=0.1
#check
if ((isnull _nade)) then {goto "boom"} else {_pos=getpos _nade}
@true
goto "check"
#boom
@(isnull _nade)
_height=_pos select 2
_min=-_u*(_height+_o3)/4
? (_min<-_u) : _min=-_u
_max=3*9.81/2
;if (_height>=4) then {_min=-1e12; _max=0}
;if (_height>=4) then {_max=0}
? (_max>_u) : _max=_u
_extent=_max-_min
? (_extent<=0) : exit
_lkm=_lkm*(_extent)/(2*_u)
_grad=_pos call grad
_norm=sqrt ((_grad select 0)^2+(_grad select 1)^2)
? (_norm==0) : _r11=1;_r12=0;_r13=0;_r21=0;_r22=1;_r23=0;_r31=0;_r32=0;_r33=1; goto "fragloop"
_x=-(_grad select 1)/_norm
_y=(_grad select 0)/_norm
_t=atan _norm
_sin=sin _t;
_cos1=1-(cos _t);
_r11=(1-_cos1)+_x^2*_cos1;
_r12=_x*_y*_cos1
_r13=_y*_sin
_r21=_x*_y*_cos1;
_r22=(1-_cos1)+_y^2*_cos1;
_r23=-_x*_sin
_r31=-_y*_sin
_r32=_x*_sin
_r33=(1-_cos1)
_o1=_o3*_r31
_o2=_o3*_r32
_o3=_o3*_r33
goto "fragloop"
The track.sqs is using two additional scripts for calculation: b.sqf
_v3=(random _extent)+_min;
_cosu=sqrt (_u^2-_v3^2);
_b=random 360;
_v1=_cosu*(sin _b);
_v2=_cosu*(cos _b);
_u1=_v1*_r11+_v2*_r21+_v3*_r31;
_u2=_v1*_r12+_v2*_r22+_v3*_r32;
_u3=_v1*_r13+_v2*_r23+_v3*_r33;
_frag=_fragtype camcreate [(_pos select 0)+_o1, (_pos select 1)+_o2, (_pos select 2)+_o3];
_frag setvelocity [_u1,_u2,_u3];
And grad.sqf
private ["_s","_x","_y","_h","_zl","_zr","_dx","_dy"];
_s="emptydetector" camcreate [0,0,0];
_x=_this select 0;
_y=_this select 1;
_h=0.2;
_s setpos [_x+_h,_y,0];
_zr=(getpos _s) select 2;
_s setpos [_x-_h,_y,0];
_zl=(getpos _s) select 2;
_dx=(_zl-_zr)/(2*_h);
_s setpos [_x,_y+_h,0];
_zr=(getpos _s) select 2;
_s setpos [_x,_y-_h,0];
_zl=(getpos _s) select 2;
_dy=(_zl-_zr)/(2*_h);
deletevehicle _s;
[_dx,_dy]
2. The artillery script BarrageArea.sqs
;Type of resource: Artillery script
;Applicability: OFP, i´m not shure if this works w. ARMA too?
;Title of resource: Artillery, Triggers, Scripts
;Version: 1.1
;Author/submitted by: The original creator of this script is unknown to me.
;Modifications/ideas MakkaraTheMan[FIN] and somebody who cracks that question below, in the #loop.
;Description:
;can be used in MP-missions too, but the script must be run on the servers battlefield.
;This can be usefull, making areas "more dangerous", cut scene effects, no go zones, and so on...
;--------------------------------------------------
;Make/name a mission folder with your mission editor
;Copy the BarrageAreaWshrapnells.sqs -file in to that same user mission file
;
;Make a west or east activated trigger
;NOTE! The triggers covering area (axis y, and axis b) defines only the triggers activation area.
;The barrage area is defined with the values in the scripts Xrange and Yrange.
;Remember to name the trigger!
;Write this script on the triggers activation, or deactivation field, for example:
;
;[ArtilleryBarrage,"shell73",300,100,100,100,.5,.7] exec "BarrageArea.sqs";
;
;[triggername,shelltype,howmanyrounds,Xrange,Yrange,starting height,minimum time, variable time] exec "nameofthe.sqs";
;
;-------------------------------------------------
_tag = _this select 0
_objtype = _this select 1
_amount = _this select 2
_randomX = _this select 3
_randomY = _this select 4
_height = _this select 5
_timemin = _this select 6
_timev = _this select 7
_offsetX = _randomX / 2
_offsetY = _randomY / 2
_height = _this select 4
_tX = getpos _tag select 0
_tY = getpos _tag select 1
_tZ = getpos _tag select 2
#Loop
? (_amount < 1 ) : exit
;PlaySound "igw_incoming_arty"
_this = _objtype CamCreate[((_tX+Random _randomX)-_offsetX),((_tY+Random _randomY)-_offsetY),_tZ+_height]
_amount = _amount - 1
~(_timemin+(random _timev))
;HOW CAN THIS CAMCREATED OBJECT(_objtype) USE the shrapnell script files/call handleri????????????
;The command/code "handleri" launches the preprocessfile "h.sqf", at least if it was a unit
;that should happen, but it doesnt seem to work with objects.
;I tryed the command; _this call handleri
;but it doesn´t work... nothing works... im desperate....
goto "Loop"
#End
Exit
So here it is again. What i need is, that the trigger-launched artillery script (BarrageArea.sqs), to use the shrapnell script (track.sqs+ the others).
I´m pretty shure that this is a very simple thing for you super scripters, but please help me out here. The main problem is to make these two scripts to work to getter. They both work fine individually, but my crappy scripting skills(stupid brains) can´t put them together. I´m shure the original author could easily crack all the problems in a second, but sense I´ve been away for a few months, I cant find mr. john smith anywhere any more. He has probably changed his nick name, or just moved on to doing something else. Donno what or where :(
Thats why i need your help, badly. Otherwise this fine script will be unfinished forever. :dunno:
PS. Thaks to the OFPEC -team, for the new OFPEC-site. It´s really working fine, and looks good too :clap:
PSS. This is my first time i´m loading attachments in to the topic, so if i screw it up, forgive me... and my crappy enlish too :whistle:
I downloaded/tested the zip-file my self, it seems to work fine :good:
-
Ok. there are a couple of downloads there but no replys. I modyfied my original post a bit, and put all scripts for you to see. I hope this will help to star even a small converstaion?
:good:
-
Each unit that uses the shrapnel script has a "FIRED" event handler. That is how the script "catches" the nades and shells when they are fired. You do not need the nearestObject command for the barrage created shells. For them use hj.sqf
if (_this in smallshelltypes) then {[_this, 20, 200, "Bullet7_6W"] exec "track.sqs"};
if (_this in mediumshelltypes) then {[_this, 40, 400, "Bullet12_7"] exec "track.sqs"};
if (_this in bigshelltypes) then {[_this, 50, 500, "Cannon30AP"] exec "track.sqs"};
if (_this in rockettypes) then {[_this, 30, 200, "Bullet12_7"] exec "track.sqs" };
Now in the barrage script add the following line:
_this call handlerj
and in your init.sqs
handlerj = preProcessFile "hj.sqf"
Give that a try and let me know if it works.... :shhh:
-
Thanks fo your reply Mr.Peanut :clap: :good: :yes:
I thought that nobody cares for this s..t eny moore. :P
If there was a lovesmiley, I´d put it next here :clap: :cool2: Thank you sir for you interrest :good:.
Ok. I tryed your suggestions, and ..."¤%#&¤ darned bloody thing still didn´t work. But hey, there wasn´t eny error messages. So when I made litle adjustments to the trigger artillery script, it started to send errors messages to the upper line of the editor interface.
So I think that you are on the right track, but there is something to add/remove...? donno what? :weeping:
Did you watch the example mission? What do u think obout this whole thing?
-
I didn't try the demo mission because I was at "work" when I wrote my message. I'll find time to try it again but it may be a 3-5 days before I manage to do that. In the meantime could you let me know what you tweaked and what error message you saw? I will help you with this but you'll have to be a little patient.
Edit: I think I see my error.
Change the hj.sqf to:
private ["_obj","_objtype"];
_obj = _this select 0;
_objtype = _this select 1;
if (_objtype in smallshelltypes) then {[_obj, 20, 200, "Bullet7_6W"] exec "track.sqs"};
if (_objtype in mediumshelltypes) then {[_obj, 40, 400, "Bullet12_7"] exec "track.sqs"};
if (_objtype in bigshelltypes) then {[_obj, 50, 500, "Cannon30AP"] exec "track.sqs"};
if (_objtype in rockettypes) then {[_obj, 30, 200, "Bullet12_7"] exec "track.sqs" };
And change the calling line to:
[_this, _objtype] call handlerj
???
-
Ok Mr.Peanut, there is no problem for me to wait a few days for your answers. I´ve been banging my head against the wall for several moths with this one, so take your time at ease. My patiense is wery good :good:
here is the error for the:
BarrageArea loop:[_this, _objtype] call handlerjif ((isnull _nade)) then /#/ {goto "boom"} else {_pos=getpos _nade}; Error isnull: Type Array, expected Object,Group
I think that means that the "track.sqs" doesn´t cope with the call code ???
other tryouts:
BarrageArea loop:_objtype call handlerj_obj=_this select0/#/
"hj.sqf" didn´t like that one.
BarrageArea loop:_this call handlerjnothing... no errors and no explosion fragments?
If i try fex the original "h.sqf" with BarrageArea loop:_this call handlerinothing there either.
hmm... i feel quite useless here :-[ :dunno:
-
Your call in barrage is in the wrong place. Change to:
#Loop
? (_amount < 1 ) : exit
;PlaySound "igw_incoming_arty"
_this = _objtype CamCreate[((_tX+Random _randomX)-_offsetX),((_tY+Random _randomY)-_offsetY),_tZ+_height]
;[_this, _objtype] call handlerj
_amount = _amount - 1
~(_timemin+(random _timev))
goto "Loop"
You had it after the pause which means the camCreated shell may have already disappeared.
Edit: You should also get rid of the _tz and just have _height in your camCreate command. This will ensure the shell is created at the height specified above the ground. You do not need the trigger's height. In fact, using it will cause the shells to be created lower than you expect them to be.