-
1 Attachment(s)
Fire direction/angles
Hello,
Spent a few hours on this, no success, and haven't found anything in the forum.
I'm still adjusting an AC-130 script, and I need to fire 7 bullets in different angles:
Attachment 774
Right now I'm not even making the bullet trace, only thing I'm doing is the damage on target origin:
This is called on each player for every bullet:
Code:
players[p] thread [[level.callbackPlayerDamage]](players[p], self, 200, 0, "MOD_RIFLE_BULLET", "gunship_25mm_mp", players[p].origin, (0,0,0), "none",0);
Any ideas?
-
PHP Code:
init()
{
level.effects = [];
level.effects["large_bark"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["large_brick"]=loadfx("fx/impacts/large_brick.efx");
level.effects["large_carpet"]=loadfx("fx/impacts/default_hit.efx");
level.effects["large_cloth"]=loadfx("fx/impacts/cloth_hit.efx");
level.effects["large_concrete"]=loadfx("fx/impacts/large_plaster.efx");
level.effects["large_dirt"]=loadfx("fx/impacts/large_dirt.efx");
level.effects["large_flesh"]=loadfx("fx/impacts/flesh_hit.efx");
level.effects["large_foliage"]=loadfx("fx/impacts/small_foliage.efx");
level.effects["large_glass"]=loadfx("fx/impacts/large_glass.efx");
level.effects["large_grass"]=loadfx("fx/impacts/small_grass.efx");
level.effects["large_gravel"]=loadfx("fx/impacts/large_gravel.efx");
level.effects["large_ice"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["large_metal"]=loadfx("fx/impacts/large_metalhit.efx");
level.effects["large_mud"]=loadfx("fx/impacts/large_mud.efx");
level.effects["large_paper"]=loadfx("fx/impacts/default_hit.efx");
level.effects["large_plaster"]=loadfx("fx/impacts/large_plaster.efx");
level.effects["large_rock"]=loadfx("fx/impacts/large_rock.efx");
level.effects["large_sand"]=loadfx("fx/impacts/large_dirt.efx");
level.effects["large_snow"]=loadfx("fx/impacts/small_snowhit.efx");
level.effects["large_water"]=loadfx("fx/impacts/large_waterhit.efx");
level.effects["large_wood"]=loadfx("fx/impacts/large_woodhit.efx");
level.effects["large_asphalt"]=loadfx("fx/impacts/large_rock.efx");
level.effects["large_default"]=loadfx("fx/impacts/default_hit.efx");
}
firebullets(bullets, spread, damage)
{
for(i = 0; i < bullets; i++)
{
spreadangles = spreadangles(spread, self getplayerangles);
smallforward = anglestoforward(spreadangles);
forward = maps\mp\_utility::vectorscale(smallforward, 10000);
point = self geteyepos();
trace = bullettrace(point, point + forward, true, self);
if(isdefined(trace["entity"]) && isplayer(trace["entity"]))
{
iDflags = 0;
sMeansofDeath = "MOD_RIFLE_BULLET"
vDir = vectornormalize(trace["position"] - self.origin);
if(distancesquared(trace["entity"] geteye() + (0, 0, 16), trace["position"]) < 64)
{
damage = int(damage * 2);
sHitloc = "head";
}
else
sHitloc = "none";
trace["entity"] maps\mp\gametypes\_callbacksetup::CodeCallback_PlayerDamage(self, self, damage, iDFlags, sMeansOfDeath, weap, trace["position"], vDir, sHitLoc, 0);
}
else if(trace["fraction"] < 1 && isdefined(trace["surfacetype"]) && trace["surfacetype"] != "default")
placebullethole(trace, self.origin);
}
}
placebullethole(trace, startpoint)
{
fx="large_";
fx += trace["surfacetype"];
if(isdefined(level.effects[fx]))
effect = level.effects[fx];
else
effect = level.effects["large_default"];
normal = vectornormalize(startpoint - trace["position"]);
if(normal != (0,0,0))
{
normal2 = trace["normal"];
if(distance(normal, normal2)> 2 * sin(22.5))
normal = normal2;
playfx(effect, trace["position"], normal);
}
}
spreadangles(spread, oldangles)
{
minx = 1 - randomint(2) * 2;
miny = 1 - randominit(2) * 2;
spready = randomfloat(spread);
oldangles = (oldangles[0] + minx * randomfloat(spread), oldangles[1] + miny * spready, oldangles[2]);
if(oldangles[1] > 180)
oldangles = (oldangles[0], oldangles[1] - 360, oldangles[2]);
if(oldangles[1] < -180)
oldangles = (oldangles[0], oldangles[1] + 360, oldangles[2]);
if(oldangles[0] > 90 && oldangles[1] > 180)
oldangles = (oldangles[0] - spready * 2, oldangles[1] - 180, oldangles[2]);
else if(oldangles[0] > 90)
oldangles = (oldangles[0] - spready * 2, oldangles[1] + 180, oldangles[2]);
if(oldangles[0] < -90 && oldangles[1] > 180)
oldangles = (oldangles[0] + spready * 2, oldangles[1] - 180, oldangles[2]);
else if(oldangles[0] < -90)
oldangles = (oldangles[0] + spready * 2, oldangles[1] + 180, oldangles[2]);
return oldangles;
}
Just a little addition: if you want to fire 7 bullets each frame, this would result in 140 bullets per second or 8400 bullets per minute. Just for reference, the biggest flying gun does only 3900 rpm (source: http://en.wikipedia.org/wiki/Fairchi...Thunderbolt_II )
-
I did my AC130 with 3 real weapons (modified rocket launcher, simply make them faster/ slower + no recoil etc) since u already use 3(?) custom weapon files for your killicon.
So you dont need to precache effects nor use bullettraces and a script at all on this.
You can even use the reticle and dont have to precache and use your huds etc. Just monitor the weapon the player currently has.
-
2 Attachment(s)
@iznogod
It's only 1 shot for each one of the hud marks (there are seven, like in the image). The user can fire a set of 7 bullets every 0.875 seconds (0.125s delay between each bullet).
By the way, I got the code I'm editting from pastebin, and it was entitled "to IzNoGod" - do you remember who created it? I need to credit this person.
@serthy
The killicons for the ac130 (and also the airstrike) are working now.
This is a demo video I just made:
http://classic.xfire.com/video/62cd41/
As you can see, I'm firing 7 shots right at the center of my screen with 1 mouse click. What I want is - to fire 7 shots, but 1 shot in each of the hud marks (is this how the ac130 works? I'm gonna look for it now, actually....):
Attachment 776
This is the code I'm using to fire the 25mm gun right now.
PHP Code:
if(self attackbuttonpressed() && isalive(self) && self._ac_gun1_ammo>0)
{
self playsound("gunship_25mm_fire");
earthquake(0.3,0.5, self.origin, 80);
vec=anglestoforward(self getplayerangles());
trace=bullettrace(self geteye()+(0,0,18),self geteye()+(20000*vec[0],20000*vec[1],20000*vec[2]+18),true,self);
for(i = 1; i < 8; i++)
{
if(isDefined(self.acsound))
self.acsound delete();
self.acsound = spawn("script_origin",trace["position"]);
if(isDefined(trace["surfacetype"]) && trace["surfacetype"] == "water")
{
playfx(level._effect["water_small"],trace["position"]);
self.acsound playsound("bullet_small_water");
}
else
{
playfx(level._effect["ac25mm"],trace["position"]);
}
self._ac_gun1_ammo--;
players=getentarray("player","classname");
for(p=0;p<players.size;p++)
{
if(players[p].pers["team"]!=self.pers["team"] && isAlive(players[p]))
{
if(distance(trace["position"],players[p].origin)<80)
{
earthquake(0.5,1, trace["position"], 80);
players[p] thread [[level.callbackPlayerDamage]](players[p], self, 200, 0, "MOD_RIFLE_BULLET", "gunship_25mm_mp", players[p].origin, (0,0,0), "none",0);
}
}
}
if(isdefined(self.hud_currentammo))
self.hud_currentammo setValue(self._ac_gun1_ammo);
wait 0.125;
}
}
Editted:
I'm now guessing it's something to do with this
Code:
trace=bullettrace(self geteye()+(0,0,18),self geteye()+(20000*vec[0],20000*vec[1],20000*vec[2]+18),true,self);
But I've been trying to identify the player angles (by moving and printing it), and I don't know what to change there.
-
oh I didn't actually read it all.
I'm gonna try to make some changes based on your code, thank you.
-
What do you want? An AC130 like in the modern CoD titles?
They are done like I said, by using projectile weapons.
You can download the gamescripts from MW2, MW3 and BO1 to see how its done.
Otherwise you can just add a delay of 0.1 between your 7 bullettraces
-
Sorry it took so long for me to answer, but what I want is exactly what the code from iznogod is doing.
I set the weapon to 20 rounds/second. Seems to be working fine.
Although I'm trying to add the flash effect. It should start at the shooter's origin and end at the target - but it's starting in variable locations, which depend on the surface angle of the target.
I'm placing this
playfx(level._effect["ac25mm_tracer_flash"], trace["position"], normal);
after this
playfx(effect, trace["position"], normal);
and here, a few corrections and the base code should run:
1
Code:
spreadangles = spreadangles(spread, self getplayerangles);
should be
Code:
spreadangles = spreadangles(spread, self getplayerangles());
2
Code:
point = self geteyepos();
should be
Code:
point = self geteye();
3
Code:
sMeansofDeath = "MOD_RIFLE_BULLET"
should be
Code:
sMeansofDeath = "MOD_RIFLE_BULLET";
4
Code:
miny = 1 - randominit(2) * 2;
should be
Code:
miny = 1 - randomint(2) * 2;
-
For your tracer effect: I had an issue with the fx playing on the impact if the angle between the fx and the surface was too high: this would cause the bullethole to become invisible, thus i had to hack in the normal of the surface if the angle exceeded this value. You should always use the normal in placebullethole(), not normal2. Try to playfx() your fx before this check. (aka right before the normal2 = line, but inside that if)
-
worked perfectly.
Editted: is there an easy way to zoom the shooter's view? I know I could use the overlay from weapon_mp, but I'm not using it at the moment, and still, the player would need to aim to zoom it. Any way to automatically zoom it depending on the hud?
-
you could look in the extreme mod to see how they did their sniper zoom (by setting the client var cg_fov or something like that)