public static void standAnim(this NPCProto proto) { if (proto.WeaponMode == 1) { proto.playAnimation("S_FISTRUN"); } else { proto.playAnimation("S_RUN"); } }
public static bool gotoPosition(this NPCProto proto, Vec3f position, float minDistance) { if (proto is NPC) { NPC p = (NPC)proto; if (p.NPCController == null)//set the position! { if (proto.getAI().lastPosUpdate == 0) { proto.getAI().lastPosUpdate = DateTime.Now.Ticks; } else { long now = DateTime.Now.Ticks; long time = now - proto.getAI().lastPosUpdate; float speed = (5 * 100) * (int)(time / 1000.0); Vec3f direction = position - proto.Position; if (direction.Length < speed) { proto.Position = position; } else { direction = direction.normalise(); direction *= speed; proto.Position = proto.Position + direction; } proto.getAI().lastPosUpdate = now; } } else { proto.getAI().lastPosUpdate = 0; } } if (proto.Position.getDistance(position) < minDistance) { return(true); } else { Vec3f p = position - proto.Position; p.Y = 0; proto.setDirection(p); proto.playAnimation(proto.getRunAnimation()); return(false); } }
public static void OnDamage(NPCProto npc, NPCProto victim, NPCProto attacker, int damage, bool dropUnconscious, bool dropDead) { NPCAI ai = victim.getAI(); if (victim.HP == 0) { victim.standAnim(); victim.playAnimation("S_DEADB"); return; } if (attacker == null) { return; } ai.addEnemy(attacker); }