Home   Help Search Login Register  

Author Topic: Move Logic to explosion position of shell?  (Read 2064 times)

0 Members and 1 Guest are viewing this topic.

Offline Odin

  • Members
  • *
Move Logic to explosion position of shell?
« on: 13 Oct 2008, 23:43:18 »
G'day I am trying to get a logic to be created at the point where a fired shell impacts so I can add effects.

I am using a fired event handler to catch the shell and this code.
Code: [Select]
? isServer and (isNull player)) : exit

GasDrop = "logic" createvehicle getpos gasclick
_shella = nearestobject [_this select 0,_this select 4];
_shellpos = getpos _shella;

hint (if (format ["%1", getpos _shella] != "scalar bool array string 0xfcffffef") then {_shellpos = getpos _shella,vehicle gasclick setpos _shellpos});
~ 0.0001
hint "fire";
~1
;?!(local Server): exit

_Dropzone = GasDrop
#start
_array1 = []
_cnt = 0
_deg = deg (100.5)

_obj = "LOGIC" createVehicle position _Dropzone;


PARTICLE & DAMMAGE EFFECTS START HERE!

This works error free but my effects allways appear at the initial logic position.
Could anyone be so kind to steer me in the right direction on how to do this. I am not sure if my if statment is written correctly?

Cheers
Odin

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Move Logic to explosion position of shell?
« Reply #1 on: 13 Oct 2008, 23:56:44 »
_shella is the object captured as soon as it is fired, so _shellpos is more or less the firing position, not the impact position.
You need a tight loop getting the position of the shell as long as the shell is not null.

Code: [Select]
? isServer and (isNull player)) : exit
GasDrop = "logic" createvehicle getpos gasclick
_shella = nearestobject [_this select 0,_this select 4];
? isNull _shella: hint "NO SHELL CAPTURED";exit
#check_pos
~0.01
?!isNull _shella: _shellpos = getpos _shella;goto "check_pos"
;Now in _shellpos you have the last known position of the shell, that might be over ground so
_shellpos set [2, 0];

;Now you should have a more or less decent effects position in _shellpos

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Move Logic to explosion position of shell?
« Reply #2 on: 14 Oct 2008, 03:20:30 »
Odin, you can check out my arty

Take apart the shellmon.sqf and add your arguments line at the very bottom.

Use _pos as the last position of the shell.

The arty.sqf uses a spawned projectile, so your going (sand have my permission) to dissect and reassemble it to your needs.

All you need is the basic arguments, which I don't have at the moment (not by my arma computer),

and execvm shellmon.sqf from your script.

The effects line is commented because I need help with the Switch:case commands,
but I can put in a single custom warhead into my arty script.

If you would like, I'll try and see if I can get that for you.

If not, I'll see if I can get a custom version for you.

And remember: it is a work in progress.  :P

Luke
Pesky Human!!
Wort Wort Wort.

Offline Odin

  • Members
  • *
Re: Move Logic to explosion position of shell?
« Reply #3 on: 14 Oct 2008, 22:42:01 »
Thanx Mando, it appears my shell is not getting captured  :dunno: as it returns the hint, so now I am at a complete loss as to what is wrong, any ideas?

Thanx Luke for your offer, I will have a look at your script on the weekend RL permitting, goto run Early start at work today.


Cheers
Odin

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Move Logic to explosion position of shell?
« Reply #4 on: 14 Oct 2008, 23:55:25 »
Might be you are not setting correctly the event handler:
Code: [Select]
EH = this addEventHandler ["Fired", {_this exec "firingweapon.sqs"}]For the init field of your unit and assuming your script name is firingweapon.sqs

Offline Odin

  • Members
  • *
Re: Move Logic to explosion position of shell?
« Reply #5 on: 15 Oct 2008, 09:40:36 »
Just checked the EH settings in the init, they were basically the same but changed to match yours and still no luck. Could it be the way I am trying to catch a shell with nearestObject ?
Would using; typeOf "myshelltype" work?
Sorry I am a bit green still, but I love messing with bombs!

Thanx
Odin

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Move Logic to explosion position of shell?
« Reply #6 on: 15 Oct 2008, 11:26:11 »
You may try the nearObjects command. Might be nearestObject is not able to catch your round class.

Offline Odin

  • Members
  • *
Re: Move Logic to explosion position of shell?
« Reply #7 on: 15 Oct 2008, 23:36:24 »
G'day, I have been trying to catch the shell ["Sh_105_HE"] with the other two near# commands, still no shell is captured.
Will I have to make my own shell class? or is it possible to attach effects to BIS classes?

Thanx for your help so far

Odin

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Move Logic to explosion position of shell?
« Reply #8 on: 16 Oct 2008, 00:41:59 »
This is a fragment of my SADARM arty script, try it and then rename the global vars there if this works for you:
Code: [Select]
// Mando_arty_sadarm.sqf
_gun = _this select 0;
if (!local _gun) exitWith {};

if (isNil "mando_arty_sadarm") then
{
   if (isNil "mando_sadarm_shell_types") then
   {
      mando_sadarm_shell_types = ["Sh_122_HE", "Sh_105_HE", "Sh_125_HE", "Sh_120_HE"];
   };

   mando_arty_sadarm =
   {
      private ["_shell"];
      if ((_this select 4) in mando_sadarm_shell_types) then
      {
         _shell = nearestObject [(_this select 0), (_this select 4)];
         waitUntil {(isNull _shell) || ((getPos _shell select 2) > 150)};
         if (!isNull _shell) then
         {
            hint "SHELL CAPTURED";
         };
      };
   };
};
_gun addEventHandler ["Fired", {_this spawn mando_arty_sadarm}];


To execute:
Code: [Select]
[your_gun]execVM"Mando_arty_sadarm.sqf";

Note that mando_arty_sadarm global var, is the script that handles what happens with the shell when fired.

Offline Odin

  • Members
  • *
Re: Move Logic to explosion position of shell?
« Reply #9 on: 16 Oct 2008, 23:03:08 »
Thanx again Mandoble, I am gonna give it a whirl tonight after work, two questions about this but
where do I execute the script from.
Code: [Select]
[your_gun]execVM"Mando_arty_sadarm.sqf"; the init or gun itself?

With the Global Var, is that what I would include in my effects script as a pointer to the shell pos, eg;
Code: [Select]
GasDrop = "logic" createvehicle getpos "mando_arty_sadarm"? sorry for this I am not familiar with the use of Global's

Thanx heaps

Odin

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Move Logic to explosion position of shell?
« Reply #10 on: 16 Oct 2008, 23:28:08 »
This is the global var:
mando_arty_sadarm = { blah blah blah
it is a code variable (its content is a block of code that later will be spawned by the event).

Offline Odin

  • Members
  • *
Re: Move Logic to explosion position of shell?
« Reply #11 on: 17 Oct 2008, 23:44:24 »
Ahh now I see, DOH! thanx mate I think I have got it sorted now  :D

Cheers
Odin