Raised This Month: $ Target: $400
 0% 

[?]Origin/Vector/Velocity - Help!?!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heliumdream
Senior Member
Join Date: Aug 2006
Old 11-13-2006 , 16:25   [?]Origin/Vector/Velocity - Help!?!
Reply With Quote #1

I thought this would be rather easy, but I'm having some trouble. I've muffed with the code for about an hour and I know am I having trouble with the syntax I believe.

All I want to do, is make a projectile shoot with an added value to its axis'.

Instead of you pointing forward and shooting forward, I want to point forward and have the object shoot up.

Here is my code brick I am trying to edit
Code:
//make_rocket(userindex,commandtype,missilespeed,antimissleid)
make_rocket(id,icmd,iarg1,antimissile)
{

    new args[16]
    new Float:vOrigin[3]
    new Float:vAngles[3]
    Entvars_Get_Vector(id, EV_VEC_origin, vOrigin)
    Entvars_Get_Vector(id, EV_VEC_v_angle, vAngles)
    new notFloat_vOrigin[3]
    notFloat_vOrigin[0] = floatround(vOrigin[0])
    notFloat_vOrigin[1] = floatround(vOrigin[1])
    notFloat_vOrigin[2] = floatround(vOrigin[2])
    gBazookaSelected[id]=gHasBazookaPowers[id]
    new accessLevel[10]
    get_cvar_string("bazooka_adminflag", accessLevel, 9)

    if(icmd == 5){
        new aimvec[3]
        get_user_origin(id,aimvec,3)
        new dist = get_distance(notFloat_vOrigin,aimvec)
        new found
        new dist1 = 20000

        new players[32], inum
        get_players(players,inum,"a")
        for(new i = 0 ;i < inum ;++i){
            if(players[i] == id) continue

            new soutput[8],output
            get_user_info(players[i],"JP",soutput,7)
            output = str_to_num(soutput)

            if(output == 1){
                new temp[3]
                get_user_origin(players[i],temp)
                dist1 = get_distance(temp,aimvec)
                if(dist1 < dist){
                    dist = dist1
                    found = 1
                    args[6] = players[i]
                }
            }
        }
        if(!found){
            client_print(id,print_chat,"[SH](Bazooka) Cannot fire Heat-Seeking Missile, no running JetPacks in view.")

            if(get_cvar_num("bazooka_buy") == 1){
                new umoney = get_user_money(id)
                new m_cost = get_cvar_num("bazooka_cost5")
                if ((get_user_flags(id)&read_flags(accessLevel)) ) {
                    set_user_money(id,umoney+(m_cost/100),1)
                }
                else {
                    set_user_money(id,umoney+m_cost,1)
                }
            }
            else {
                missile_inv[id][5] += 1
                show_missile_inv(id)
            }
            if(using_menu[id])
                show_main_menu(id)

            return PLUGIN_HANDLED
        }
    }
    else if(icmd == 6){
        new aimvec[3]
        get_user_origin(id,aimvec,3)
        new dist = get_distance(notFloat_vOrigin,aimvec)
        new found
        new dist1 = 20000
        new players[32], inum
        get_players(players,inum,"a")
        for(new i = 0 ;i < inum ;++i){
            if(players[i] == id) continue

            new soutput[8],output
            get_user_info(players[i],"ROPE",soutput,7)
            output = str_to_num(soutput)
            if(output == 1){
                new temp[3]
                get_user_origin(players[i],temp)
                dist1 = get_distance(temp,aimvec)
                if(dist1 < dist){
                    dist = dist1
                    found = 1
                    args[6] = players[i]
                }
            }
        }
        if(!found){
            client_print(id,print_chat,"[SH](Bazooka) Cannot fire Rope-Seeking Missile, no Ropes in view.")

            if(get_cvar_num("bazooka_buy") == 1){
                new umoney = get_user_money(id)
                new m_cost = get_cvar_num("bazooka_cost6")
                if ((get_user_flags(id)&read_flags(accessLevel)) ) {
                    set_user_money(id,umoney+(m_cost/100),1)
                }
                else {
                    set_user_money(id,umoney+m_cost,1)
                }
            }
            else {
                missile_inv[id][6] += 1
                show_missile_inv(id)
            }
            if(using_menu[id])
                show_main_menu(id)

            return PLUGIN_HANDLED
        }
    }
    using_menu[id] = 0

    new NewEnt
    NewEnt = CreateEntity("info_target")
    if(NewEnt == 0) {
        client_print(id,print_chat,"[SH](Bazooka) Rocket Failure")
        return PLUGIN_HANDLED
    }
    has_rocket[id] = NewEnt
    missile_inv[id][0] = 0

    Entvars_Set_String(NewEnt, EV_SZ_classname, "bazooka_missile_ent")
    ENT_SetModel(NewEnt, "models/rpgrocket.mdl")

    new Float:fl_vecminsx[3] = {-1.0, -1.0, -1.0}
    new Float:fl_vecmaxsx[3] = {1.0, 1.0, 1.0}

    Entvars_Set_Vector(NewEnt, EV_VEC_mins,fl_vecminsx)
    Entvars_Set_Vector(NewEnt, EV_VEC_maxs,fl_vecmaxsx)

    ENT_SetOrigin(NewEnt, vOrigin)
    Entvars_Set_Vector(NewEnt, EV_VEC_angles, vAngles)
    Entvars_Set_Int(NewEnt, EV_INT_effects, 64)
    Entvars_Set_Int(NewEnt, EV_INT_solid, 2)

    if(get_cvar_num("bazooka_obeygravity")) {
        Entvars_Set_Int(NewEnt, EV_INT_movetype, 6)
    }
    else {
        Entvars_Set_Int(NewEnt, EV_INT_movetype, 5)
    }

    Entvars_Set_Edict(NewEnt, EV_ENT_owner, id)
    Entvars_Set_Float(NewEnt, EV_FL_health, 10000.0)
    Entvars_Set_Float(NewEnt, EV_FL_takedamage, 100.0)
    Entvars_Set_Float(NewEnt, EV_FL_dmg_take, 100.0)

    new Float:fl_iNewVelocity[3]
    new iNewVelocity[3]
    VelocityByAim(id, iarg1, fl_iNewVelocity)
    Entvars_Set_Vector(NewEnt, EV_VEC_velocity, fl_iNewVelocity)
    iNewVelocity[0] = floatround(fl_iNewVelocity[0])
    iNewVelocity[1] = floatround(fl_iNewVelocity[1])
    iNewVelocity[2] = floatround(fl_iNewVelocity[2])

    emit_sound(NewEnt, CHAN_WEAPON, "weapons/rocketfire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
    emit_sound(NewEnt, CHAN_VOICE, "weapons/rocket1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

    args[0] = id
    args[1] = NewEnt
    args[2] = iarg1
    args[3] = iNewVelocity[0]
    args[4] = iNewVelocity[1]
    args[5] = iNewVelocity[2]
    args[8] = notFloat_vOrigin[0]
    args[9] = notFloat_vOrigin[1]
    args[10] = notFloat_vOrigin[2]

    switch(icmd){
        case 1: {
            make_trail(NewEnt,icmd)
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            set_task(0.1,"guide_rocket_comm",NewEnt,args,16,"b")
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 2: {
            make_trail(NewEnt,icmd)
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            set_task(0.1,"guide_rocket_las",NewEnt,args,16)
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 3: {
            make_trail(NewEnt,icmd)
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            Entvars_Set_Int(NewEnt, EV_INT_rendermode,1)
            AttachView(id, NewEnt)
            args[11] = 1
            set_task(0.1,"guide_rocket_dir",NewEnt,args,16,"b")
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 4: {
            make_trail(NewEnt,icmd)
            args[6] = antimissile
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            set_task(0.1,"guide_rocket_anti",NewEnt,args,16)
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 5: {
            is_heat_rocket[id] = 1
            make_trail(NewEnt,icmd)
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            set_task(0.1,"guide_rocket_het",NewEnt,args,16)
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 6: {
            make_trail(NewEnt,icmd)
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.25)
            set_task(0.1,"guide_rocket_rope",NewEnt,args,16)
            set_task(get_cvar_float("bazooka_fuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
        case 7: {
            Entvars_Set_Float(NewEnt, EV_FL_gravity, 0.000001)
            SD_CircleRockets(NewEnt)
            set_task(0.1,"guide_rocket_swirl",NewEnt,args,16)
            set_task(get_cvar_float("bazooka_sdfuel"),"rocket_fuel_timer",NewEnt,args,16)
        }
    }
    return PLUGIN_HANDLED
}
Yeah this is a complex chunk of code I'm aware, its part of the 7 variety bazooka plugin. I simply want my baz shot 1 to shoot staight up, instead of straight out.

This is where I got confused..from what I gather from reading the function wiki I should change the values of my x or y or z before passing them back to these statements.
Code:
ENT_SetOrigin(NewEnt, vOrigin)
Entvars_Set_Vector(NewEnt, EV_VEC_angles, vAngles)
I tried using someone like vAngles[0] = vAngles[0] + 90
and yeah, got no result - no change of any kind =(.

Help my noob self out, please? - Thanks in advance,
-helium
heliumdream is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-15-2006 , 21:09   Re: [?]Origin/Vector/Velocity - Help!?!
Reply With Quote #2

before you do
Code:
Entvars_Set_Vector(NewEnt, EV_VEC_velocity, fl_iNewVelocity)
you can do this
Code:
 fl_iNewVelocity[2] = 500.0
that should give it a velocity of 500 upwards.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
heliumdream
Senior Member
Join Date: Aug 2006
Old 11-16-2006 , 12:48   Re: [?]Origin/Vector/Velocity - Help!?!
Reply With Quote #3

My hero! <3. This is good, but I guess I was confused, I was asking the wrong question!

So I used your idea and it does work, only its still not my desired effect. If I set the third velocity to say 2500, it will go straight up, only with the velocity so high that it hits the cieling and never falls back down accordingly. If the velocity is 500, it gets a slights hop upward, but its vector really never changes to straight up. Also messing with these velocities fucks up the timing of the missile, they don't fly high enough, etc.

So I guess really I should be asking, can I change the vector at which I want to aim? I reckon when you shoot straight forward, the game captures your vector and sets it to where your aimer is pointing. Well can I change the vector after its been captured? Cause thats really what I'm trying to do, I'm not wanting to change velocity I'm wanting to change the aim vector.

Also, in this case I wanted to shoot straight forward, only have the missle go straight up. Well what if I wanted it to shoot backward instead of forward? How would I change my aim vector to shoot back? ^_^

Thanks again Emp - you are the shit.
-helium
heliumdream is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-16-2006 , 19:56   Re: [?]Origin/Vector/Velocity - Help!?!
Reply With Quote #4

pretty much same thing. velocity determines where it goes.

if you want it to go straight up (and not forward or anything)
Code:
velocity[0] = 0.0
velocity[1] = 0.0
velocity[2] = 500.0
but if you want it to make like an arch path, then you can just set the cvar "bazooka_obeygravity" because it's already in the code
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
heliumdream
Senior Member
Join Date: Aug 2006
Old 11-17-2006 , 13:33   Re: [?]Origin/Vector/Velocity - Help!?!
Reply With Quote #5

I am going to continue playing with this, I'm trying to created some 'fireworks' heroes. Basically mega attacks, on par with an alpha strike or something. I will post my creatings and screen shots whenever I get it working the way I want. ^_^ Thanks again!
heliumdream is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:58.


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