static void FreeAim(bool down) { if (crosshair == null) { crosshair = new Sumpfkraut.GUI.GUCWorldSprite(10, 10); crosshair.SetBackTexture("crosshair.tga"); crosshair.ShowOutOfScreen = false; } var hero = NPCInst.Hero; string CamModFreeAim = "CAMMODRANGED_FREEAIM"; if (hero.ModelDef.Visual == "ORC.MDS" || hero.ModelDef.Visual == "DRACONIAN.MDS") { CamModFreeAim += "_ORC"; } if (down && hero != null && !hero.IsDead && hero.IsInFightMode && !hero.Environment.InAir && !hero.ModelInst.IsInAnimation()) { var drawnWeapon = hero.GetDrawnWeapon(); if (drawnWeapon != null && drawnWeapon.IsWepRanged) { if (!freeAim) { hero.SetMovement(NPCMovement.Stand); NPCInst.Requests.Aim(hero, true); // no auto-lock PlayerFocus.SetLockedTarget(null); // zoom in FOVTransition(60, TimeSpan.TicksPerSecond / 2); zCAICamera.CamModRanged.Set(CamModFreeAim); // replace so gothic sets it to this while in bow mode zCAICamera.CurrentCam.SetByScript(CamModFreeAim); // change camera freeAim = true; } return; } } if (freeAim) { NPCInst.Requests.Aim(hero, false); crosshair.Hide(); FOVTransition(90, TimeSpan.TicksPerSecond / 2); var cam = zCAICamera.CurrentCam; zCAICamera.CamModRanged.Set("CAMMODRANGED"); // reset if (cam.CurrentMode.ToString().Equals(CamModFreeAim, StringComparison.OrdinalIgnoreCase)) { cam.SetByScript("CAMMODRANGED"); // change camera } freeAim = false; } }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); pm = GetComponent <PlayerMovement>(); pf = GetComponent <PlayerFocus>(); ph = GetComponent <PlayerHealth>(); canTimeDash = false; }
static void RequestShootAuto(NPCInst hero) { Vec3f start; using (var matrix = Gothic.Types.zMat4.Create()) { var weapon = hero.GetDrawnWeapon(); var node = (weapon == null || weapon.ItemType == ItemTypes.WepBow) ? oCNpc.NPCNodes.RightHand : oCNpc.NPCNodes.LeftHand; hero.BaseInst.gVob.GetTrafoModelNodeToWorld(node, matrix); start = (Vec3f)matrix.Position; } const zCWorld.zTraceRay traceType = zCWorld.zTraceRay.Ignore_Alpha | zCWorld.zTraceRay.Ignore_Projectiles | zCWorld.zTraceRay.Ignore_Vob_No_Collision | zCWorld.zTraceRay.Ignore_NPC; NPCInst enemy = PlayerFocus.GetFocusNPC(); Vec3f dir = enemy == null ? (Vec3f)hero.BaseInst.gVob.Direction : (enemy.GetPosition() - start).Normalise(); Vec3f ray = 500000f * dir; Vec3f end; using (var zStart = start.CreateGVec()) using (var zRay = ray.CreateGVec()) { var gWorld = GothicGlobals.Game.GetWorld(); if (gWorld.TraceRayNearestHit(zStart, zRay, traceType)) { end = (Vec3f)gWorld.Raytrace_FoundIntersection; } else { end = start + ray; } } NPCInst.Requests.Shoot(hero, start, end); }
private void Start() { playerFocus = PlayerManager.instance.PlayerFocus; }
void Start() { camera = Camera.main; movement = GetComponent <PlayerMovement> (); playerFocus = GetComponent <PlayerFocus> (); }
void Start() { playerFocus = FindObjectOfType <PlayerFocus>(); }
partial void pAfterSetControl(NPCInst npc) { Menus.PlayerInventory.Menu.Close(); PlayerFocus.Activate(npc); }
void PlayerUpdate() { if (ArenaClient.DetectSchinken) { fwdTelHelper.Update(GameTime.Ticks); upTelHelper.Update(GameTime.Ticks); } NPCInst hero = ScriptClient.Client.Character; var gAI = hero.BaseInst.gAI; if (hero.IsDead || hero.IsUnconscious) { LookAround(hero); return; } zCAICamera.CurrentCam.BestAzimuth = 0; if (freeAim) { FreeAiming(hero); return; } DoTurning(hero); if (KeyBind.Action.IsPressed() && hero.IsInFightMode) { var enemy = PlayerFocus.GetFocusNPC(); if (enemy == null || !enemy.IsSpawned || enemy.IsDead) { PlayerFocus.SetLockedTarget(null); // updates for new target } PlayerFocus.SetLockedTarget(PlayerFocus.GetFocusNPC()); } else { PlayerFocus.SetLockedTarget(null); } NPCMovement state = NPCMovement.Stand; if (!KeyBind.Action.IsPressed() || hero.Movement != NPCMovement.Stand) { if (KeyBind.MoveForward.IsPressed()) // move forward { state = NPCMovement.Forward; } else if (KeyBind.MoveBack.IsPressed()) // move backward { var drawnWeapon = hero.GetDrawnWeapon(); if (hero.IsInFightMode && (drawnWeapon == null || drawnWeapon.IsWepMelee)) { if (dodgeLock.IsReady) // don't spam { if (IsWarmup()) { return; } NPCInst.Requests.Attack(hero, FightMoves.Dodge); } return; } else { state = NPCMovement.Backward; } } else if (KeyBind.MoveLeft.IsPressed()) // strafe left { state = NPCMovement.Left; } else if (KeyBind.MoveRight.IsPressed()) // strafe right { state = NPCMovement.Right; } else { state = NPCMovement.Stand; } } if (nextStrafeChange > GameTime.Ticks) { state = hero.Movement; } if (state == NPCMovement.Forward) { // FIXME: use only a better CheckEnoughSpaceMoveForward if (hero.Movement == NPCMovement.Stand && !gAI.CheckEnoughSpaceMoveForward(true)) { state = NPCMovement.Stand; } else { gAI.CalcForceModelHalt(); if ((gAI.Bitfield0 & zCAIPlayer.Flags.ForceModelHalt) != 0) { gAI.Bitfield0 &= ~zCAIPlayer.Flags.ForceModelHalt; state = NPCMovement.Stand; } } } else if (state == NPCMovement.Backward) { if (!gAI.CheckEnoughSpaceMoveBackward(true)) { state = NPCMovement.Stand; } } else if (state == NPCMovement.Left) { if (!gAI.CheckEnoughSpaceMoveLeft(true)) { state = NPCMovement.Stand; } } else if (state == NPCMovement.Right) { if (!gAI.CheckEnoughSpaceMoveRight(true)) { state = NPCMovement.Stand; } } if (state != NPCMovement.Stand && IsWarmup()) { state = NPCMovement.Stand; } if (state == NPCMovement.Left || state == NPCMovement.Right || (state == NPCMovement.Forward && hero.IsInFightMode)) { if (hero.Movement != state) { nextStrafeChange = GameTime.Ticks + StrafeInterval; } } else { nextStrafeChange = 0; } hero.SetMovement(state); }
public virtual void SetControl(NPCInst npc) { this.BaseClient.SetControl(npc.BaseInst); Menus.PlayerInventory.Menu.Close(); PlayerFocus.Activate(npc); }