Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33

Thread: Fire direction/angles

  1. #1
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts

    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:

    Click image for larger version. 

Name:	aim_angles.png 
Views:	125 
Size:	51.2 KB 
ID:	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?

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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(bulletsspreaddamage)
    {
        for(
    0bulletsi++)
        {
            
    spreadangles spreadangles(spreadself getplayerangles);
            
    smallforward anglestoforward(spreadangles);
            
    forward maps\mp\_utility::vectorscale(smallforward10000);
            
    point self geteyepos();
            
    trace bullettrace(pointpoint forwardtrueself);
            if(
    isdefined(trace["entity"]) && isplayer(trace["entity"]))
            {
                
    iDflags 0;
                
    sMeansofDeath "MOD_RIFLE_BULLET"
                
    vDir vectornormalize(trace["position"] - self.origin);
                if(
    distancesquared(trace["entity"geteye() + (0016), trace["position"]) < 64)
                {
                    
    damage int(damage 2);
                    
    sHitloc "head";
                }
                else
                    
    sHitloc "none";
                
    trace["entity"maps\mp\gametypes\_callbacksetup::CodeCallback_PlayerDamage(selfselfdamageiDFlagssMeansOfDeathweaptrace["position"], vDirsHitLoc0);
            }
            else if(
    trace["fraction"] < && isdefined(trace["surfacetype"]) && trace["surfacetype"] != "default")
                
    placebullethole(traceself.origin);
        }
    }

    placebullethole(tracestartpoint)
    {
        
    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(normalnormal2)> sin(22.5))
                
    normal normal2;
            
    playfx(effecttrace["position"], normal);
        }
    }


    spreadangles(spreadoldangles)
    {
        
    minx randomint(2) * 2;
        
    miny randominit(2) * 2;
        
    spready randomfloat(spread);
        
    oldangles = (oldangles[0] + minx randomfloat(spread), oldangles[1] + miny spreadyoldangles[2]);
        if(
    oldangles[1] > 180)
            
    oldangles = (oldangles[0], oldangles[1] - 360oldangles[2]);
        if(
    oldangles[1] < -180)
            
    oldangles = (oldangles[0], oldangles[1] + 360oldangles[2]);
        if(
    oldangles[0] > 90 && oldangles[1] > 180)
            
    oldangles = (oldangles[0] - spready 2oldangles[1] - 180oldangles[2]);
        else if(
    oldangles[0] > 90)
            
    oldangles = (oldangles[0] - spready 2oldangles[1] + 180oldangles[2]);
        if(
    oldangles[0] < -90 && oldangles[1] > 180)
            
    oldangles = (oldangles[0] + spready 2oldangles[1] - 180oldangles[2]);
        else if(
    oldangles[0] < -90)
            
    oldangles = (oldangles[0] + spready 2oldangles[1] + 180oldangles[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 )
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (22nd September 2014)

  4. #3
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    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.
    Last edited by serthy; 22nd September 2014 at 16:07.

  5. The Following User Says Thank You to serthy For This Useful Post:

    guiismiti (22nd September 2014)

  6. #4
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    @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....):
    Click image for larger version. 

Name:	aim_angles2.png 
Views:	125 
Size:	50.1 KB 
ID:	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.5self.origin80);
        
    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(
    18i++)
        {
            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,1trace["position"], 80);
                        
    players[pthread [[level.callbackPlayerDamage]](players[p], self2000"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.
    Attached Thumbnails Attached Thumbnails aim_angles2.png  
    Last edited by guiismiti; 22nd September 2014 at 18:16.

  7. #5
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    oh I didn't actually read it all.
    I'm gonna try to make some changes based on your code, thank you.

  8. #6
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    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

  9. #7
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    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;
    Last edited by guiismiti; 24th September 2014 at 17:22.

  10. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  11. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (24th September 2014)

  12. #9
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    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?
    Last edited by guiismiti; 24th September 2014 at 20:00.

  13. #10
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    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)

  14. The Following User Says Thank You to serthy For This Useful Post:

    guiismiti (24th September 2014)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •