Author |
Topic: Welcome + Flak88 AA mod |
messi995 |
General Member Since: May 8, 2011 Posts: 27 Last: Aug 22, 2012 [view latest posts] |
|
|
Category: CoD+UO General Posted: Sunday, May. 8, 2011 12:39 pm |
|
Hello. I am new to here and I'd like to say hello everyone!
I know basics in C scripting language. I am stuck with one problem... I think you could help me.
So, I want to make Flak88 mod so its shells explode on exact distance since its fired from gun, like real AA gun; middle-air detonation. I've joined couple of scripts and I came up with this:
Code: shot_fx()
{
flak = getentarray ("flak88_mp","vehicletype");
level._effect["flak_air_exp"] = loadfx ("fx/map_bomber/flak_single_400_pushed.efx");
if(!isdefined(level._effect["flak_air_exp"]))
{
println("^1level._effect['flak_air_exp'] is not defined!!!");
return;
}
tag_origin = flak gettagorigin("tag_flash");
tag_angles = flak gettagangles("tag_flash");
vec = anglesToForward(tag_angles);
fx_origin = tag_origin + maps\mp\_util_mp_gmi::vectorScale(vec, flak.flak_fx_dist);
trace_result = bulletTrace(tag_origin, fx_origin, false, flak);
dist = distance(trace_result["position"],tag_origin);
if(trace_result["surfacetype"] == "default")
{
dist = distance(fx_origin,tag_origin);
the_origin = fx_origin;
}
else if(dist < 512)
{
return;
}
else if(dist < flak.flak_fx_dist)
{
the_origin = trace_result["position"];
}
else
{
dist = distance(fx_origin,tag_origin);
the_origin = fx_origin;
}
println("Surfacetype: ", trace_result["surfacetype"]);
wait (dist * .00005);
playfx(level._effect["flak_air_exp"], the_origin);
wait randomfloat(0.25);
playfx(level._effect["flak_air_exp"], (the_origin + ((-256 + randomint(512)), (-256 + randomint(512)), (-256 + randomint(512)))) );
}
Of course, I got script compile error for this line:
tag_origin = flak gettagorigin("tag_flash");
tag_angles = flak gettagangles("tag_flash");
The problem is can't find substitute for gettagorigin(); and gettagangles();, as it only works in Singleplayer. As far as I've understood, this line:
tag_origin = flak gettagorigin("tag_flash");
tag_angles = flak gettagangles("tag_flash");
actually makes game find the Flak88 tag called "tag_flash" so it can actually find where from it is going to fire vectors (with specified length), which later will be some kind of path of where shell's gonna explode. It gives me "Unknown (BULTIN) command" error message. If you have (in some case) seen _flakvierling.gsc SP script, you may've notice that I have really modified that script.
Thank you for reading this, I hope someone can help :) |
|
|
|
zeroy |
|
General Member Since: Nov 26, 2007 Posts: 1060 Last: Mar 12, 2014 [view latest posts] |
|
|
|
messi995 |
General Member Since: May 8, 2011 Posts: 27 Last: Aug 22, 2012 [view latest posts] |
|
|
Category: CoD+UO General Posted: Sunday, May. 8, 2011 12:55 pm |
|
Thanks for quick response.
I've tried that, but it didn't work as suspected. Maybe you could write it the right way? I've tried this:
tag_origin = flak.origin(); (no possible arguments, I'd put the "tag_flash inside the bracket if there were)
tag_angles = flak.angles(); (same)
Also, you can't use Flak88 origin itself, because Flak88 fires shell from "tag_flash", not "tag_origin".
If someone does not understand what is point of this mod, here's the picture from kharkov_2 SP mission:
|
|
|
|
BraX |
|
General Member Since: Apr 29, 2008 Posts: 413 Last: May 26, 2012 [view latest posts] |
|
|
|
Category: CoD+UO General Posted: Sunday, May. 8, 2011 05:29 pm |
|
messi995 writes...Quote: tag_origin = flak.origin(); (no possible arguments, I'd put the "tag_flash inside the bracket if there were)
tag_angles = flak.angles(); (same)
2 mistakes.. Grab this corrected code:
Code: tag_origin = flak.origin;
tag_angles = flak.angles; |
|
|
|
messi995 |
General Member Since: May 8, 2011 Posts: 27 Last: Aug 22, 2012 [view latest posts] |
|
|
Category: CoD+UO General Posted: Sunday, May. 8, 2011 05:36 pm |
|
OK. I have no more error messages. For some reason, I can't see explosion.
So my file structure is following (inside maps\mp\):
* _aa_flak.gsc
* _flak_gmi.gsc
* _util_mp_gmi.gsc
*_aa_flak.gsc contains code written above which now works correctly.
*_flak_gmi.gsc contains code of Flak88, and also I added part that after you shoot the gun, _aa_flak.gsc is automatically threaded.
...
self FireTurret();
thread maps\mp\_aa_flak::main();
...
*_util_mp_gmi.gsc contains vector stuff thats needed. I wrote some of it myself.
Code: vectorScale (vec, scale)
{
vec = (vec[0] * scale, vec[1] * scale, vec[2] * scale);
return vec;
}
I reckon that the problem is in * _aa_flak.gsc script. I would appreciate quick help because I need it for my clan mod.
Thanks
|
|
|
|
Spik3d |
|
General Member Since: Jan 30, 2008 Posts: 130 Last: Feb 19, 2015 [view latest posts] |
|
|
|
messi995 |
General Member Since: May 8, 2011 Posts: 27 Last: Aug 22, 2012 [view latest posts] |
|
|
Category: CoD+UO General Posted: Sunday, May. 8, 2011 08:22 pm |
|
Spik3d writes...Quote: Is there an effect precached or in the map's map_fx file that sounds like it'd be for that?
I'm guessing it has nothing to do with effect. It is precached in line 2 as you may see in my first post:
level._effect["flak_air_exp"] = loadfx ("fx/map_bomber/flak_single_400_pushed.efx");
I'm worried about that distance, but I dont know. Is there someone willing to fix up this script a bit? Thanks.
|
|
|
|
GomerPyle |
General Member Since: Oct 1, 2006 Posts: 357 Last: Jul 14, 2011 [view latest posts] |
|
|
|
|
messi995 |
General Member Since: May 8, 2011 Posts: 27 Last: Aug 22, 2012 [view latest posts] |
|
|
Category: CoD+UO General Posted: Monday, May. 9, 2011 01:10 pm |
|
Thank you very much!
Thats really a good way but I'm searching something... that I won't have to change map skybox limit everytime... but just change few lines in script.
So this would be algorhitm, but for now (as I know basics in C languages) isn't really easy for me, I gotta get really known with this modified version of C++.
Algorithm for Flak88 AA Mod:
1.) Load _aa_flak.gsc the very same moment it's gun is being fired.
2.) Spawn script_origin and attach it to Flak88 tag ("tag_flash") with same angle and origin of that tag.
3.) Move script origin for some vector size.
4.) Once it reached that distance, play effect on script origin's position.
Now, I tried to do this by this algorithm, but it probably has billion mistakes :)
Lines which are commented I obviously didn't know =)
*_flak_gmi.gsc
Code: ...
FireTurret();
level thread maps\mp\_aa_flak.gsc::flak_effect_by_distance();
...
*_aa_flak.gsc
Code: flak_effect_by_distance()
{
fx_origin = spawn ("script_origin",flak,"tag_flash")); //tag flash obviously isn't good as none of arguments for this command accept tags
fx_origin.angles = flak.angles;
//Move for distance of 512
//Precache distance as length from gun barrel to origin thats e.g. 512 far away from barrel.
if (distance = 512)
{
playfx(level._effect["someeffect"], fx_origin.origin);
}
}
I'd like if it was possible to really get that algorhitm to script, I would really appreciate it :)
|
|
|
|
GomerPyle |
General Member Since: Oct 1, 2006 Posts: 357 Last: Jul 14, 2011 [view latest posts] |
|
|
|
Category: CoD+UO General Posted: Monday, May. 9, 2011 01:27 pm |
|
Sorry, I guess I was thinking that you were trying to make it more like the real ones that explode at a certain altitude.
I've seen posts on here that some used in sniper maps that returned a distance of the shot they take. Perhaps that's the direction you should look. Also the awe mod uses a distance function to determine maps playable size, perhaps that may help you.
Anyone else? |
|
|
|