public override void Update(GuidedVob vob, long now) { if (Target == null) { return; } if (!Cast.Try(vob.ScriptObject, out NPCInst npc)) { throw new Exception("Vob used with GoToVobCommand is no NPC!"); } if (npc.IsDead) { return; } var gNpc = npc.BaseInst.gVob; gNpc.RbtTimer = 500; gNpc.RbtTargetVob = Target.BaseInst.gVob; Target.GetPosition().SetGVec(gNpc.RbtTargetPos); gNpc.RbtMaxTargetDist = Distance * Distance; gNpc.RbtGotoFollowPosition(); }
void GameClient.IScriptClient.ReadScriptRequestMessage(PacketReader stream, GuidedVob vob) { RequestMessageIDs id = (RequestMessageIDs)stream.ReadByte(); if (id > RequestMessageIDs.MaxGuidedMessages && vob != ControlledNpc.BaseInst) { return; // client sent a request for a bot which is only allowed for players } if (id < RequestMessageIDs.MaxNPCRequests) { if (vob is NPC) { NpcInst.Requests.ReadRequest(id, stream, (NpcInst)vob.ScriptObject); } } }
public override void Update(GuidedVob vob, long now) { if (Target == null) { return; } if (!Cast.Try(vob.ScriptObject, out NPCInst npc)) { throw new Exception("Vob used with GoToVobLookAtCommand is no NPC!"); } if (npc.IsDead) { return; } var gNpc = npc.BaseInst.gVob; gNpc.RbtTimer = 500; gNpc.RbtTargetVob = Target.BaseInst.gVob; gNpc.RbtBitfield = gNpc.RbtBitfield | (1 << 4); // stand when reached Target.GetPosition().SetGVec(gNpc.RbtTargetPos); gNpc.RbtMaxTargetDist = Distance * Distance; gNpc.RbtGotoFollowPosition(); Vec3f npcPos = npc.GetPosition(); Vec3f targetPos = Target.GetPosition(); if (npcPos.GetDistance(targetPos) <= Distance) { const float maxTurnFightSpeed = 0.08f; float bestYaw = Angles.GetYawFromAtVector(targetPos - npcPos); Angles curAngles = npc.GetAngles(); float yawDiff = Angles.Difference(bestYaw, curAngles.Yaw); curAngles.Yaw += Alg.Clamp(-maxTurnFightSpeed, yawDiff, maxTurnFightSpeed); npc.SetAngles(curAngles); } }
public override void Update(GuidedVob vob, long now) { if (!Cast.Try(vob.ScriptObject, out NPCInst npc)) { throw new Exception("Vob used with GoToPos is no NPC!"); } if (npc.IsDead) { return; } var gNpc = npc.BaseInst.gVob; gNpc.RbtTimer = 500; gNpc.RbtTargetVob = zCVob.NullVob; gNpc.RbtBitfield = gNpc.RbtBitfield | (1 << 4); // stand when reached this.Destination.SetGVec(gNpc.RbtTargetPos); gNpc.RbtMaxTargetDist = 100 * 100; gNpc.RobustTrace(); }
public override void Start(GuidedVob vob) { }
public override void Stop(GuidedVob vob) { }