| razermamba |
05-21-2013 12:34 |
Zombie NPC
Hi all, I want to make my own zombie NPC stuff. I have read about vectors, velocity, origings etc. and I made my own code but it doesn't work good. First I just want to make my zombie move during IDLE state. Thx for reply. Code shuts down server :(
PHP Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> #include <engine>
// new const DeathSounds[][] ={ // "dragonus/death1.wav", // "dragonus/death2.wav", // "dragonus/death3.wav" // }; // // new const PainSounds[][] ={ // "dragonus/pain1.wav", // "dragonus/pain2.wav", // "dragonus/pain3.wav" // }; // // new const AttackSounds[][] ={ // "dragonus/attack1.wav", // "dragonus/attack2.wav", // "dragonus/attack3.wav" // };
new const ZombieModel[] = "models/zombie.mdl";
public plugin_precache(){ // new i; // for(i = 0; i < sizeof(DeathSounds); ++i) // precache_sound(DeathSounds[i]); // for(i = 0; i < sizeof(PainSounds); ++i) // precache_sound(PainSounds[i]); // for(i = 0; i < sizeof(AttackSounds); ++i) // precache_sound(AttackSounds[i]); }
public plugin_init(){ register_plugin("Dragonus NPC", "1.0", "Dragonus"); register_think("zombie_npc", "ZombieThink"); register_clcmd("say /spawn", "spawn_zombie"); }
public ZombieThink(ent){ zombie_walk(ent); entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.01); } public spawn_zombie(id){ new entity = create_entity("info_target"); entity_set_string(entity, EV_SZ_classname, "zombie_npc"); entity_set_model(entity, ZombieModel); new Float: Vectors[3]; entity_get_vector(id, EV_VEC_origin, Vectors); Vectors[2] += 80.0; entity_set_origin(entity, Vectors); new Float: Mins[3] = {16.0, 16.0, 36.0}; new Float: Maxs[3] = {-16.0, -16.0, -36.0}; entity_set_size(entity, Mins, Maxs); entity_set_float(entity, EV_FL_maxspeed, 220.0); entity_set_int(entity, EV_INT_solid, 2); entity_set_float(entity, EV_FL_takedamage, 1.0); entity_set_float(entity, EV_FL_health, 250.0); play_animation(entity, 1); entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.01); drop_to_floor(entity); }
stock play_animation(id, sequence) { entity_set_float(id, EV_FL_animtime, get_gametime()); entity_set_float(id, EV_FL_framerate, 1.0); entity_set_int(id, EV_INT_sequence, sequence); }
public zombie_walk(ent) { new Float: Origins[3]; new Float: Velocity[3]; new Float: Angles[3]; pev(ent, pev_origin, Origins); pev(ent, pev_velocity, Velocity); play_animation(ent, 3); Velocity[1] += 300.0; set_pev(ent, pev_velocity, Velocity); pev(ent, pev_angles, Angles); Angles[1] += 180.0; set_pev(ent, pev_angles, Angles); pev(ent, pev_velocity, Velocity); Velocity[1] += 300.0; set_pev(ent, pev_velocity, Velocity); zombie_walk(ent); }
|