AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing an entity's position and eye view. (https://forums.alliedmods.net/showthread.php?t=293315)

Infractem 01-29-2017 03:54

Changing an entity's position and eye view.
 
Okay I just spent like 2 days trying to do this and is seriously crippling me off now.

I had asked around this forum a few days ago about the "random enemy player" in which Bugsy helped me(thanks btw) and have come upon this bit of a problem on the entity's(a missile) position and eye position(or view or whatever it's called)which spawns overhead of that random enemy player. The script uses an "attach_view" line in which the player's model is moved into that entity, creating the simulation of the Predator Missile from the MW2 series.

So here's the problem. The missile spawning overhead of the player is positioned horizontally and of course, when my view is attached, the view is horizontal as well.

Yes, this needed a bit of model editing in which I have already tried, but sadly learned that eye position cannot be changed via model editing so that the view would be pointing downwards.

Now I have gone over this forum on how to change the view itself but everything was in vain.

To give you an idea on what I am talking about, here's a screenshot(and a bit of picture editing on what I want to achieve). EDIT: I forgot to mention in the picture that I need the eye position should be pointing downwards as well.

http://i.imgur.com/gMZ5qZX.jpg.

And here's the snippet of the code:
Code:

public CreatePredator2(id)
{
        new num, players[32];
        get_players(players, num, "gh");
        for(new a = 0; a < num; a++)
        {
                new i = players[a];
                if(get_user_team(id) != get_user_team(i))
                        client_cmd(i, "spk sound/mw/predator_enemy.wav");
                else
                        client_cmd(i, "spk sound/mw/predator_friend.wav");
        }

        set_task(5.0, "target_lock", id)
       
        predator[id] = false;
        cd_active = id;
        set_task(8.0, "cooldownover")
}
//thanks to bugsy
enum Teams
{
    Team_Unassigned,
    Team_T,
    Team_CT,
    Team_Spectator
}


predator_target(id)
{
        new iPlayers[32], iPnum
        get_players(iPlayers, iPnum, "ae", Teams:get_user_team( id ) == Team_T ? "CT" : "TERRORIST")

        return iPnum ? iPlayers[random(iPnum)] : 0;
}


public target_lock(id)
{
        new iPlayer = predator_target(id)
        new PlayerCoords[3], ent;
        if(is_user_alive(iPlayer))
        {
                get_user_origin(iPlayer, PlayerCoords);
                PlayerCoords[2] += 300
               
                new Float:LocVec[3], Float:fAngles[3];
                IVecFVec(PlayerCoords, LocVec);
               
                create_ent(id, "predator", "models/cod_predator.mdl", 2, 10, LocVec, ent);
                message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
                write_byte(TE_BEAMFOLLOW);
                write_short(ent);
                write_short(cache_trail);
                write_byte(10);
                write_byte(5);
                write_byte(205);
                write_byte(237);
                write_byte(163);
                write_byte(200);
                message_end();
               
               
                emit_sound(iPlayer, CHAN_ITEM, "mw/predator_sound.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);
                attach_view(id, ent);
        }
}

stock create_ent(id, szName[], szModel[], iSolid, iMovetype, Float:fOrigin[3], &ent=-1)
{
        new ent1 = create_entity("info_target");
        entity_set_string(ent1, EV_SZ_classname, szName);
        entity_set_model(ent1, szModel);
        entity_set_int(ent1, EV_INT_solid, iSolid);
        entity_set_int(ent1, EV_INT_movetype, iMovetype);
        entity_set_edict(ent1, EV_ENT_owner, id);
        entity_set_origin(ent1, fOrigin);
       
        if(ent != -1)
                ent = ent1;
}



All times are GMT -4. The time now is 20:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.