Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

1 year ago

June 19, 2018, 04:37:49 pm
  • Projectiles/Missiles 5 1
Currently:  

Author Topic: Projectiles/Missiles  (Read 6709 times)

Trix

  • Developer
  • Full Member
  • *****
  • Posts: 216
    • View Profile
Projectiles/Missiles
« on: March 29, 2014, 04:34:44 pm »
So I guess a lot of people have been after this since we posted the 0.1.4 trailer showing missiles and SAM sites.



I will be expanding on the API when time permits, and will obviously accept pull requests from anyone wishing to contribute their own projectiles.

At the time of writing, the API supports the ability to fire 'dumb' missiles in a single direction, a moving location, as well as an entity. The latter two are controlled via fields right now, which is a little strange. This will be changed as the code develops and time permits.

Interested in hearing any and all improvements/suggestions.

Note: This does not contain the proof-of-concept lock-on indicators that were present in the 0.1.4 video, however those are trivial HUD elements that can utilize this API.

The Lua can be downloaded from Github.
« Last Edit: March 29, 2014, 04:41:41 pm by Trix »

misterff1

  • Donator
  • Hero Member
  • *****
  • Posts: 582
    • View Profile
Re: Projectiles/Missiles
« Reply #1 on: March 29, 2014, 04:38:02 pm »
THANK YOU! :) glad you released this Trix.

hashman80

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Projectiles/Missiles
« Reply #2 on: March 29, 2014, 07:16:18 pm »



THANK YOU! :)

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: Projectiles/Missiles
« Reply #3 on: March 29, 2014, 10:07:50 pm »
Thank you very much, Trix. I look forward to experimenting with this.

Darwood37

  • Donator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: Projectiles/Missiles
« Reply #4 on: March 30, 2014, 12:48:53 am »
Cheers, my wish came true.

Stabulous

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: Projectiles/Missiles
« Reply #5 on: April 04, 2014, 05:46:31 am »
So, is anyone having any luck playing around with this? I can't get the thing to so much as load for a second without crashing. I've gone as far as to unload all other modules, and this still crashes as soon as I activate RightFire for the firetest. It seems like it isn't initializing any of the classes at all, as every error is "attempted to index variable [class]: a nil value". Any advice? Did your copies work out-of-the-box or are modifications necessary?

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: Projectiles/Missiles
« Reply #6 on: April 04, 2014, 06:45:19 am »
So, is anyone having any luck playing around with this? I can't get the thing to so much as load for a second without crashing. I've gone as far as to unload all other modules, and this still crashes as soon as I activate RightFire for the firetest. It seems like it isn't initializing any of the classes at all, as every error is "attempted to index variable [class]: a nil value". Any advice? Did your copies work out-of-the-box or are modifications necessary?
Much luck, actually. It's a bit tricky to get the hang of but fairly easy once you do. Anyone is welcome to come to my server to see SAMs in action.

And yes, mine worked out of the box. Not the SAM part, but a HL2 style rocket did.

Redownload and load without touching the files. Either a file was corrupt or you changed something, that's the only explanation.

Schwarzen_Neger

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Projectiles/Missiles
« Reply #7 on: April 04, 2014, 02:15:54 pm »
Code: [Select]
for k, v in ipairs(EntityManager.entities) do
if class_info(v).name == 'Missile' then
v.target_position = Physics:Raycast(Camera:GetPosition(), Camera:GetAngle() * Vector3.Forward, 0, 2000).position
end
end

This is just a workaround right? Doesn't look optimal.

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: Projectiles/Missiles
« Reply #8 on: April 04, 2014, 06:53:19 pm »
Code: [Select]
for k, v in ipairs(EntityManager.entities) do
if class_info(v).name == 'Missile' then
v.target_position = Physics:Raycast(Camera:GetPosition(), Camera:GetAngle() * Vector3.Forward, 0, 2000).position
end
end

This is just a workaround right? Doesn't look optimal.

I can't even find that code in mine anymore. I think I removed it. If I remember correctly that bit is in the input section of FireTests? It is what makes the missiles follow the player's aim position. Good for HL2 style rockets, but you must change it and have the target sent to missile file if you want tracking.

Trix

  • Developer
  • Full Member
  • *****
  • Posts: 216
    • View Profile
Re: Projectiles/Missiles
« Reply #9 on: April 04, 2014, 07:41:46 pm »
Code: [Select]
for k, v in ipairs(EntityManager.entities) do
if class_info(v).name == 'Missile' then
v.target_position = Physics:Raycast(Camera:GetPosition(), Camera:GetAngle() * Vector3.Forward, 0, 2000).position
end
end

This is just a workaround right? Doesn't look optimal.

It is an example for how one might write a HL2 style rocket launcher, it should not be taken as production worthy code.

Apples292

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Projectiles/Missiles
« Reply #10 on: April 21, 2014, 11:45:54 am »
I've succeeded in creating missiles that home in on the nearest player and can be seen by everyone on the server, how can I implement the SAM's (for example where are the models etc) now I have the working sync system?

Thanks
Apples292
« Last Edit: April 21, 2014, 11:49:52 am by Apples292 »

JasonMRC

  • Donator
  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Re: Projectiles/Missiles
« Reply #11 on: April 21, 2014, 07:05:22 pm »
I've succeeded in creating missiles that home in on the nearest player and can be seen by everyone on the server, how can I implement the SAM's (for example where are the models etc) now I have the working sync system?

Thanks
Apples292
Code: [Select]
model, colision
Mount: "general.blz/wea31-a.lod", "wea31_lod1-a_col.pfx"
Chasis: "general.blz/wea31-b.lod", "wea31_lod1-b_col.pfx"
Radar: "general.blz/wea31-e.lod", "wea31_lod1-e_col.pfx"
Barrel: "general.blz/wea31-c.lod", "wea31_lod1-c_col.pfx"

Some Notes: There is only one barrel, it is used for both the left and right barrel. Also, the barrels can only rotate 180 degrees pitch, they don't seem to be coded to rotate a full 360. This is alright though because in Single Player they do not rotate 360 pitch either.

You'll have to build the SAM yourself, there is no one piece unit.

You can check out my server to see some of what is possible by learning from Trix's script.

Apples292

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Projectiles/Missiles
« Reply #12 on: April 21, 2014, 07:40:40 pm »
Awesome, thanks Jason ;D

Thanks
Apples292

Edit: I don't mind if you tell me to go around discovering them for myself but is there a list of the positions of all the SAM sites in the world publicly available to save me having to find all of them?
« Last Edit: April 23, 2014, 09:26:22 pm by Apples292 »

DaAlpha

  • Donator
  • Jr. Member
  • *****
  • Posts: 52
    • View Profile
Re: Projectiles/Missiles
« Reply #13 on: November 07, 2016, 12:49:03 am »
*digs out dead thread*

Just found a bug that does not seem to have been reported yet.

In the entities/missile.lua file, line 127, it calculates the slerped angle and stores it in new_angle but in line 129, it passes the final target angle dir_to_target on. This obviously results in missiles instantly rotating to the final direction and ignoring the max_turn_angle setting.

Thought you might want to know. Jason actually seems to have found this as well, the bug is fixed in his SAM missiles.

Trix

  • Developer
  • Full Member
  • *****
  • Posts: 216
    • View Profile
Re: Projectiles/Missiles
« Reply #14 on: November 07, 2016, 06:57:34 pm »
*digs out dead thread*

Just found a bug that does not seem to have been reported yet.

In the entities/missile.lua file, line 127, it calculates the slerped angle and stores it in new_angle but in line 129, it passes the final target angle dir_to_target on. This obviously results in missiles instantly rotating to the final direction and ignoring the max_turn_angle setting.

Thought you might want to know. Jason actually seems to have found this as well, the bug is fixed in his SAM missiles.

Nice find, should be fixed on master. Thanks!