Witam, mam dość nietypowy problem, dotyczy on poruszania się entity.
Za pomocą pluginu tworzę enta, ustawiam mu odpowiednie movetype i solid (TOSS i SLIDEBOX), jednak próba zrobienia sterowania nie wychodzi mi najlepiej Ktoś ma jakieś pomysły ? Mój obecny kod
public UpgradePosition(ent) { new id = 0; for(new i=0;i<33;i++) if(ent == entskrz[i]) { id = i break; } if(id == 0) return FMRES_IGNORED; if(!is_user_alive(id)) { entity[id] = 0 remove_entity(ent) if(is_user_connected(id)) { set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255); attach_view( id, id ); } przemieniony[id] = false; return FMRES_IGNORED; } new buttons = get_user_button(id) if(buttons & IN_USE) { if(!nieruszalny[id] && licznik[id] == -1) licznik[id] = 10; else if(!nieruszalny[id] && licznik[id] > 0) licznik[id]-- else if(!nieruszalny[id] && licznik[id] == 0) nieruszalny[id] = true; else nieruszalny[id] = false; } if(nieruszalny[id]) { entity_set_float(ent, EV_FL_nextthink, get_gametime()); return FMRES_IGNORED; } new Float:Angles[3] pev(id, pev_angles, Angles) Angles[0] = 0.0 Angles[2] = 0.0 set_pev(ent, pev_angles, Angles) set_user_health(id, pev(ent, pev_health)) new Float:velocity[3]; pev(ent, pev_velocity, velocity) new Float:old2vel = velocity[2] new Float:fector[4][3]; new bool:old = false; if((buttons & IN_FORWARD) || (buttons & IN_BACK) || (buttons & IN_RIGHT) || (buttons & IN_LEFT)) { new count = 0; new bool:zm_p[4] if(buttons & IN_BACK && !(buttons & IN_FORWARD)) { angle_vector (Angles, ANGLEVECTOR_FORWARD, fector[0]) count++ zm_p[0] = true; } if(buttons & IN_FORWARD && !(buttons & IN_BACK)) { angle_vector (Angles, ANGLEVECTOR_FORWARD, fector[0]) xs_vec_neg(fector[0],fector[1]) count++ zm_p[1] = true; } if(buttons & IN_LEFT && !(buttons & IN_RIGHT)) { angle_vector (Angles, ANGLEVECTOR_RIGHT,fector[2]) count++ zm_p[2] = true; } if(buttons & IN_RIGHT && !(buttons & IN_LEFT)) { angle_vector (Angles, ANGLEVECTOR_RIGHT,fector[2]) xs_vec_neg(fector[2],fector[3]) count++ zm_p[3] = true; } new Float:speed = 250.0 / count if(count == 0) old = true; else if(count == 1){ new ktoraz = -1 for(new i=0;i<4;i++) { if(zm_p[i]) { xs_vec_mul_scalar( fector[i] , speed , fector[i] ); ktoraz = i break; } } for(new i=0;i<3;i++) velocity[i] = fector[ktoraz][i] } else if(count == 2){ new bool:ilosczm = false; new bool:ktoraz[2] for(new i=0;i<4;i++) { if(zm_p[i]) { xs_vec_mul_scalar( fector[i] , speed , fector[i] ); ktoraz[i > 1 ? 1 : 0] = i%2 == 1 ? true : false if(ilosczm) break; else ilosczm = true; } } for(new i=0;i<3;i++) velocity[i] = floatdiv(floatadd(fector[ktoraz[0] ? 1 : 0][i], fector[ktoraz[0] ? 3 : 2][i]), 2.0) } } if(old) { entity_set_float(ent, EV_FL_nextthink, get_gametime()); return FMRES_IGNORED; } velocity[2] = old2vel + 0.05 if(!(get_user_oldbutton(id) & IN_JUMP) && buttons & IN_JUMP && pev(ent, pev_flags) & FL_ONGROUND) velocity[2] = random_float(25.0, 26.0) if(!(buttons & IN_BACK) && !(buttons & IN_FORWARD) && !(buttons & IN_RIGHT) && !(buttons & IN_LEFT)) { entity_set_float(ent, EV_FL_nextthink, get_gametime()); return FMRES_IGNORED; } set_pev(ent,pev_velocity,velocity) entity_set_float(ent, EV_FL_nextthink, get_gametime()); return FMRES_IGNORED; }
// EDIT po to żeby przestawić new buttons = get_user_button(id) z warunkiem czy gracz jest żywy
sprawia że entity po wciśnięciu w, a, s lub d po prostu staje w miejscu, nic nie da się z nią zrobić (z samym thinkiem wszystko w porządku, bo obraca bytem co mogę zaobserwować)
Czy możliwe jest że funkcja jest zbudowana źle i po prostu entity "klinuje się" w ziemi ?
Dziękuje.
Użytkownik NoLiFeR edytował ten post 26.02.2016 22:37