//When the quest gets given out it takes in the NPC it is being given to public void startQuest (NPC person, NPC person2) { inUse = true; questGiver = person; questGiver2 = person2; speechCounter = 0; }
/* FUNCTIONS */ // Use this for initialization void Start () { //declaring buttons and their values mapButton1 = GameObject.Find("buttonMap1"); mapButton1.GetComponent<buttonScript>().setTypeNum(2, 0); mapButton2 = GameObject.Find("buttonMap2"); mapButton2.GetComponent<buttonScript>().setTypeNum(2, 1); suspectButton1 = GameObject.Find("buttonSuspect1"); suspectButton1.GetComponent<buttonScript>().setTypeNum(0, 0); suspectButton2 = GameObject.Find("buttonSuspect2"); suspectButton2.GetComponent<buttonScript>().setTypeNum(0, 1); weaponButton1 = GameObject.Find("buttonWeapon1"); weaponButton1.GetComponent<buttonScript>().setTypeNum(1, 0); weaponButton2 = GameObject.Find("buttonWeapon2"); weaponButton2.GetComponent<buttonScript>().setTypeNum(1, 1); backButton = GameObject.Find("goBackButton"); backButton.GetComponent<buttonScript>().setTypeNum(3, 666); //alexiaChat = GameObject.Find("alexiaSays"); //original = alexiaChat.GetComponent<SpriteRenderer>().color; //alexiaChat.GetComponent<SpriteRenderer>().color = clear; //guiText.font.material.color = Color.black; answerSuspect = GameManager.guilty; answerWeapon = GameManager.weapon; answerRoom = GameManager.room; Debug.Log(GameManager.theCase); }
private void DecrementPassiveChatTimer(NPC npc) { currentTime = Time.timeSinceLevelLoad; timeToDecrement = Mathf.Abs(currentTime - previousTime); npc.timeTillPassiveChatAgain -= timeToDecrement; previousTime = currentTime; }
public void init(Transform newTarget) { target = newTarget; if (target.GetComponent<NPC>() != null) { isNPC = true; npc = target.GetComponent<NPC>(); } else { isNPC = false; player = target.GetComponent<Player>(); } if (isNPC) { name.text = npc.name; if (npc.isFriendly) { name.color = NamePlate.COLOR_SELECTED; } else { name.color = NamePlate.COLOR_ENEMY; } } else { name.text = player.name; if (player.isFriendly) { name.color = NamePlate.COLOR_SELECTED; } else { name.color = NamePlate.COLOR_ENEMY; } } InvokeRepeating("updateHealth", 1f, 1f); }
// Use this for initialization void Awake() { myTransform = transform; myRigidbody = rigidbody; myRigidbody.freezeRotation = true; startSpeed = moveSpeed; startNextFoot = nextFoot; runningSpeed = startSpeed + 2.0f; runningNextFoot = nextFoot - 0.25f; myState = NPC.Chasing; GameObject targetObject = GameObject.Find( "Player" ); if ( targetObject ) { target = targetObject.transform; lanternScript = target.GetComponentInChildren< Lantern >(); } else { Debug.Log( "no object named player was found" ); } }
public IEnumerator activate(NPC npc, int difficulty, string[] won, string[] lost) { if (npc.defeated) { StartCoroutine(GameEventManager.conversation.speak(new string[] { "You already defeated this challenge!" })); } else { while (GameEventManager.player.isTalking) { yield return null; } if (this.challenges.Length > 0) { Challenge challenge = this.challenges[Random.Range(0, this.challenges.Length)]; GameEventManager.player.inChallenge = true; StartCoroutine(GameEventManager.conversation.speak(challenge.explanation)); StartCoroutine(challenge.play(this, difficulty)); while (challenge.active()) { yield return null; } GameEventManager.player.inChallenge = false; if (challenge.won()) { if (won.Length > 0) { StartCoroutine(GameEventManager.conversation.speak(won)); } npc.defeated = true; } else { if (lost.Length > 0) { StartCoroutine(GameEventManager.conversation.speak(lost)); } } } } yield return 0; }
public InitialEmotionState(NPC toControl, string currentDialogue) : base(toControl, currentDialogue) { gaveRose = new Reaction(); gavePendant = new Reaction(); gaveSeashell = new Reaction(); randomMessage = new Reaction(); gaveRose.AddAction(new NPCCallbackAction(SetSeashell)); // DELETE gaveRose.AddAction(new NPCCallbackAction(SetPendant)); // DELETE gaveRose.AddAction(new NPCTakeItemAction(toControl)); gaveRose.AddAction(new NPCCallbackAction(SetRose)); //gaveRose.AddAction(new UpdateDefaultTextAction(toControl, "new default")); gaveRose.AddAction(new UpdateCurrentTextAction(toControl, "My bedroom window when I was little had this bed of peach colored roses, they made my room smell wonderful in the summers.")); _allItemReactions.Add(StringsItem.Apple, new DispositionDependentReaction(gaveRose)); // change item to rose gavePendant.AddAction(new NPCTakeItemAction(toControl)); gavePendant.AddAction(new NPCCallbackAction(SetPendant)); gavePendant.AddAction(new UpdateCurrentTextAction(toControl, "I know this seems just like a silly necklace but your father worked for weeks when we were young to buy this for me. It still makes me smile.")); _allItemReactions.Add("pendant", new DispositionDependentReaction(gaveRose)); gaveSeashell.AddAction(new NPCTakeItemAction(toControl)); gaveSeashell.AddAction(new NPCCallbackAction(SetSeashell)); gaveSeashell.AddAction(new UpdateCurrentTextAction(toControl, "Your father and I would spend afternoons looking for shells. He loved to find the shiniest ones he could for me.")); _allItemReactions.Add("seashell", new DispositionDependentReaction(gaveRose)); randomMessage.AddAction(new NPCCallbackAction(RandomMessage)); SetOnOpenInteractionReaction(new DispositionDependentReaction(randomMessage)); TempFarmerReturnReaction.AddAction(new UpdateCurrentTextAction(toControl, "Blah")); TempFarmerReturnReaction.AddAction(new NPCCallbackAction(TempResponse)); _allChoiceReactions.Add(TempFarmerReturnChoice,new DispositionDependentReaction(TempFarmerReturnReaction)); }
void MakeSomeDecisions() { float sqrDist = ( target.position - myTransform.position ).sqrMagnitude; if ( sqrDist > maximumRangeSqr ){ if ( isNpcChasing ){ myState = NPC.Chasing; } else{ myState = NPC.FreeRoam; } } else if ( sqrDist < minimumRangeSqr ){ if ( isNpcChasing ){ myState = NPC.Idle; } else{ myState = NPC.RunningAway; } } else{ if ( isNpcChasing ){ myState = NPC.Chasing; } else{ myState = NPC.RunningAway; } } }
// Use this for initialization void Start() { animator = this.gameObject.GetComponent<Animator> (); nodeQueue = new Queue<Vector3> (nodeList); prevNode = this.transform.position; npcScript = this.gameObject.GetComponent<NPC> (); }
public BubbleData generateBubble(NPC cha, string text, GameObject talker = null) { BubbleData bubble = new BubbleData (text, new Vector2 (40, 60), new Vector2 (40, 45)); Color textColor, textOutline, background, border; ColorUtility.TryParseHtmlString (cha.getTextFrontColor (), out textColor); ColorUtility.TryParseHtmlString (cha.getTextBorderColor (), out textOutline); ColorUtility.TryParseHtmlString (cha.getBubbleBkgColor (), out background); ColorUtility.TryParseHtmlString (cha.getBubbleBorderColor (), out border); bubble.TextColor = textColor; bubble.TextOutlineColor = textOutline; bubble.BaseColor = background; bubble.OutlineColor = border; if (talker != null) { Vector2 position = talker.transform.localPosition; position.y += talker.transform.localScale.y / 2; bubble.Destiny = position; bubble.Origin = new Vector2 (position.x, position.y - 10f); } else { bubble.Origin = new Vector2 (40, 60); bubble.Destiny = new Vector2 (40, 45); } return bubble; }
public PsychopathegeneQuest (GameObject questprefab) { this.questPrefab = questprefab; numPsycho = 0; inUse = false; waitPeriod = 0; speechCounter = 0; hints = new String[5]; hints [0] = "If you come close to a true" + "\n" + "psychopath they'll follow you" + "\n" + "around."; hints [1] = "True psychopaths don't look" + "\n" + "crazy like other psychopaths."; hints [2] = "If you see someone become" + "\n" + "psychotic then the person they were" + "\n" + "last near is a psychopath!"; hints [3] = "I hope my pig Wilbur is" + "\n" + "doing okay in the Wizard Realm."; hints [4] = "True pyschopaths will follow" + "\n" + "people close to them."; //Find psychos GameObject[] npcs = World.map.npcs.ToArray(); for (int count = 0; count < npcs.Length; count++) { NPC temp = npcs [count].GetComponent<NPC>(); if (temp.personality == Personality.psychotic && !temp.states.Contains (State.psychotic)) { if (numPsycho == 0) { numPsycho++; psycho1 = temp; } else { numPsycho++; psycho2 = temp; count = npcs.Length; } } } }
void Start() { var audios = gameObject.GetComponents<AudioSource>(); screamAudio = audios[1]; npcPrefab = Resources.Load<NPC>("Prefabs/NPC"); var basementPrefab = Resources.Load<Basement>("Prefabs/Basement"); npcBodiesPrefabList = new List<GameObject>(); for (int i = 0; i < 12; i++) { npcBodiesPrefabList.Add(Resources.Load<GameObject>("Prefabs/NPC/NPCBody_" + i)); } basement = Instantiate<Basement>(basementPrefab); var respawners = basement.transform.FindChild("Respawners"); npcs = new List<NPC>(); respawnPoints = new List<Transform>(); var allChildren = respawners.transform.Cast<Transform>().Select(t => t.gameObject).ToArray(); foreach (GameObject t in allChildren) { respawnPoints.Add(t.transform); } }
public AttackAction (Player p, NPC attacker, NPC target) { base.name = ATTACK; base.p = p; this.attacker = attacker; this.target = target; }
public void AddNPC(NPC npc) { if(!allNPCs.Contains(npc)) { allNPCs.Add(npc); } }
//add data from NPC.xml to NPC list public void addNpcToList(XDocument doc) { string name; int strength, weaponSkill, attack, speed, health, level; bool isHostile; var data = from item in doc.Descendants("NPC") select new { name = item.Element("name").Value, strength = item.Element("strength").Value, weaponSkill = item.Element("weaponSkill").Value, attack = item.Element("attack").Value, speed = item.Element("speed").Value, health = item.Element("health").Value, level = item.Element("level").Value, isHostile = item.Element("isHostile").Value }; foreach (var p in data) { name = p.name; strength = Convert.ToInt32(p.strength); weaponSkill = Convert.ToInt32(p.weaponSkill); attack = Convert.ToInt32(p.attack); speed = Convert.ToInt32(p.speed); health = Convert.ToInt32(p.health); level = Convert.ToInt32(p.level); isHostile = Convert.ToBoolean(p.isHostile); NPC n = new NPC(name, strength, weaponSkill, attack, speed, health, level, isHostile); npcList.Add(n); } }
protected void FlagToNPC(NPC npc, string text) { if (text == "castle"){ carpenterDate = false; } if (text == "carpenterSuccess" && farmersOnBoard){ initialState.PassStringToEmotionState("carpenterSuccess"); } if (text == "carpenterSuccess" && !farmersOnBoard){ initialState.PassStringToEmotionState("daughterOnBoard"); } if (text == "stoodUp" && farmersOnBoard){ initialState.PassStringToEmotionState("stoodUp"); disposition -= 20; } if (text == "farmerMotherOnBoard"){ farmersOnBoard = true; } if (text == "castleSuccess" && farmersOnBoard){ disposition = 0; FlagManager.instance.SetFlag(FlagStrings.FarmersBetrayed); } if (text == "daughterReady"){ initialState.PassStringToEmotionState(text); } }
public void ClearAndReplace(NPC npc, Schedule newSchedule) { _schedulesToDo.Clear(); current = null; Add(new DefaultSchedule(npc)); Add(newSchedule); }
public MoveAction (Player p, NPC npc, int position) { base.name = MOVE; base.p = p; this.position = position; this.npc = npc; }
public override void ApplyEffect() { if (isNPC==false) {//Apply to player if (GameWorldController.instance.playerUW==null) { GameWorldController.instance.playerUW= this.GetComponent<UWCharacter>(); } GameWorldController.instance.playerUW.Paralyzed=true; } else { if (npc==null) { npc=this.GetComponent<NPC>(); } this.GetComponent<NPC>().Frozen=true; state = this.GetComponent<NPC>().state; anim = this.GetComponent<NPC>().anim; if (anim!=null) { anim.enabled=false; } } base.ApplyEffect(); }
public Task(State stateToPerform, NPC toManage, float timeTillPassiveChat, string passiveTextToSay) { _stateToPerform = stateToPerform; _passiveTextToSay = passiveTextToSay; _toManage = toManage; _timeTillPassiveChat = timeTillPassiveChat; hasPassiveChat = true; }
void Start() { npcAttachedTo = this.gameObject.GetComponent<NPC>(); if (npcAttachedTo == null){ Debug.LogError("Error: No npc script attached to " + this.name); } base.InitEvent(); }
public NPCDef(NPC npc) { this.npc = npc; categories["Town"] = npc.townNPC; categories["Friendly"] = npc.friendly || (npc.damage <= 0 && npc.defDamage <= 0); categories["Hostile"] = !categories["Friendly"]; categories["Boss"] = npc.boss || (npc.type >= 13 && npc.type <= 15); }
// Use this for initialization void Start() { controlMovement = FindObjectOfType<ControlMovement>(); buttonSwitcher = FindObjectOfType<ButtonSwitcher>(); npc = this.transform.GetComponentInParent<NPC>(); //Debug.Log(npc.name); inventroy = FindObjectOfType<Inventory>(); }
//Start interaction with NPC public void InteractWithNPC() { Player.instance.talkToNPC = true; DisplayInteractionBubble(false); Sherlock.Instance.PlaySequenceInstructions(accept, null); interactingNPC.StartInteraction(); interactingNPC = null; }
//public GameObject toy; // Use this for initialization void Start() { // Get the associated NPC controller npc = this.gameObject.GetComponent<NPC>(); GameObject bedroomManagerGo = GameObject.Find ("BedroomManager").gameObject; manager = bedroomManagerGo.GetComponent<BedroomLevelManager>(); //toy.SetActive(false); }
protected void SpawnOwner() { if(npcPrototype == null || npcLocation == null) { Debug.Log("WARNING! " + gameObject.name + " Cannot spawn an npc because there is no start position or no npc prototype!"); return; } owner = (NPC)Instantiate(npcPrototype, npcLocation.position, Quaternion.identity); }
public ChatSchedule(NPC npcToChat, NPCChat chatToPerform) : base(npcToChat, priorityEnum.DoNow) { float timeToChat = chatToPerform.AddUpTimeToChat(); Debug.Log("Time to chat = " + timeToChat); canPassiveChat = false; GUIManager.Instance.AddNPCChat(chatToPerform); Add(new TimeTask(timeToChat, new InteractingWithPlayerState(npcToChat))); }
protected void MoveForMarriage(NPC npc, string text) { if (text == "castle"){ this.transform.position = new Vector3(0,0+LevelManager.levelYOffSetFromCenter*2, this.transform.position.z); } if (text == "carpenter"){ this.transform.position = new Vector3(0,0+LevelManager.levelYOffSetFromCenter*2, this.transform.position.z); } }
public InitialEmotionState(NPC toControl, string currentDialogue) : base(toControl, currentDialogue) { gaveRose = new Reaction(); gavePendant = new Reaction(); gaveRose.AddAction(new UpdateCurrentTextAction(toControl, "My bedroom window when I was little had this bed of peach colored roses, they made my room smell wonderful in the summers.")); _allItemReactions.Add("apple", new DispositionDependentReaction(gaveRose)); // change item to rose }
void Update(){ Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit, 3, (1<< LayerMask.NameToLayer("NPC")))){ if (hit.transform.tag.Equals("NPC")) { loot = hit.transform.gameObject.GetComponent<NPC>(); } else { loot = null; } if (loot != null) { if (talkingToNPC) { openText.transform.gameObject.SetActive(false); } else { openText.transform.gameObject.SetActive(true); } if (!talkingToNPC){ if (Input.GetKeyDown(KeyCode.E)) { talkingToNPC = true; if (!inventoryPanel.activeSelf) { inventoryPanel.SetActive(true); Time.timeScale = 0.0f; //Lock Cursor to Middle Cursor.visible = true; Cursor.lockState = CursorLockMode.None; openText.transform.gameObject.SetActive(false); playerInventory.activateMenu(true); } } else if (Input.GetKeyDown(KeyCode.F)) { Debug.Log("Quest annehmen"); int killCount = 1; GameConstants.getPlayerStats().questSystem.addNewQuest(NPC_Quest); } } else { if (Input.GetKeyDown(KeyCode.Q)) { inventoryPanel.SetActive(false); playerInventory.activateMenu(false); Time.timeScale = 1.0f; //Lock Cursor to Middle Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; openText.transform.gameObject.SetActive(true); } } } else{ DisableUIElements(false); } } else{ DisableUIElements(false); } }
public override void UpdateLifeRegen(NPC npc, ref int damage) { Player player = Main.player[Main.myPlayer]; FargoSoulsPlayer modPlayer = player.GetModPlayer <FargoSoulsPlayer>(); if (Rotting) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 100; if (damage < 5) { damage = 5; } } if (LeadPoison) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } int dot = npc.type == NPCID.EaterofWorldsBody ? 4 : 20; if (modPlayer.TerraForce || modPlayer.WizardEnchantActive) { dot *= 3; } npc.lifeRegen -= dot; } //50 dps if (SolarFlare) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 100; if (damage < 10) { damage = 10; } } //100 dps if (HellFire) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 200; if (damage < 20) { damage = 20; } } //20 dps if (OriPoison) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 40; if (damage < 4) { damage = 4; } } if (Infested) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= InfestedExtraDot(npc); if (damage < 8) { damage = 8; } } else { MaxInfestTime = 0; } if (Electrified) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 4; if (npc.velocity != Vector2.Zero) { npc.lifeRegen -= 16; } if (npc.wet) { npc.lifeRegen -= 16; } if (damage < 4) { damage = 4; } } if (CurseoftheMoon) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 24; if (damage < 6) { damage = 6; } } if (OceanicMaul) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 48; if (damage < 12) { damage = 12; } } if (Sadism) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 170 + 48 + 60 + 8 + 4 + 16; if (damage < 70) { damage = 70; } } if (MutantNibble) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } if (npc.lifeRegenCount > 0) { npc.lifeRegenCount = 0; } if (npc.life > 0 && LifePrevious > 0) //trying to prevent some wack despawn stuff { if (npc.life > LifePrevious) { npc.life = LifePrevious; } else { LifePrevious = npc.life; } } } else { LifePrevious = npc.life; } if (GodEater) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 4200; if (damage < 777) { damage = 777; } } if (Suffocation) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= (int)(40f * Math.Min(1f, 1f * SuffocationTimer / 480)); if (damage < 5) { damage = 5; } } if (FlamesoftheUniverse) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= (30 + 50 + 48 + 30) / 2; if (damage < 20) { damage = 20; } } if (Anticoagulation) { if (npc.lifeRegen > 0) { npc.lifeRegen = 0; } npc.lifeRegen -= 16; if (damage < 6) { damage = 6; } } if (modPlayer.OriEnchantActive && npc.lifeRegen < 0) { int multiplier = 3; if (modPlayer.EarthForce || modPlayer.WizardEnchantActive) { multiplier = 5; } npc.lifeRegen *= multiplier; damage *= multiplier; //half as effective if daybreak applied if (npc.daybreak) { npc.lifeRegen /= 2; damage /= 2; } } if (TimeFrozen && npc.life == 1) { if (npc.lifeRegen < 0) { npc.lifeRegen = 0; } } }
public override bool?CanHitNPC(NPC target) { return(false); }
public override void ModifyNPCLoot(NPC npc, NPCLoot npcLoot) { IItemDropRule BossDrop(int item) { return(new DropBasedOnEMode(ItemDropRule.Common(item, 3), ItemDropRule.Common(item, 10))); } switch (npc.type) { case NPCID.KingSlime: npcLoot.Add(BossDrop(ModContent.ItemType <SlimeKingsSlasher>())); break; case NPCID.EyeofCthulhu: npcLoot.Add(BossDrop(ModContent.ItemType <LeashOfCthulhu>())); break; case NPCID.EaterofWorldsHead: case NPCID.EaterofWorldsBody: case NPCID.EaterofWorldsTail: { LeadingConditionRule lastEater = new LeadingConditionRule(new Conditions.LegacyHack_IsABoss()); lastEater.OnSuccess(BossDrop(ModContent.ItemType <EaterStaff>())); npcLoot.Add(lastEater); } break; case NPCID.BrainofCthulhu: npcLoot.Add(BossDrop(ModContent.ItemType <BrainStaff>())); break; case NPCID.QueenBee: npcLoot.Add(BossDrop(ModContent.ItemType <TheSmallSting>())); break; case NPCID.SkeletronHead: npcLoot.Add(BossDrop(ModContent.ItemType <BoneZone>())); //npcLoot.Add(BossDrop(ModContent.ItemType<BrittleBone>(), 200)); break; case NPCID.WallofFlesh: npcLoot.Add(BossDrop(ModContent.ItemType <FleshHand>())); break; case NPCID.TheDestroyer: npcLoot.Add(BossDrop(ModContent.ItemType <DestroyerGun>())); break; case NPCID.SkeletronPrime: npcLoot.Add(BossDrop(ModContent.ItemType <RefractorBlaster>())); break; case NPCID.Retinazer: case NPCID.Spazmatism: { LeadingConditionRule noTwin = new LeadingConditionRule(new Conditions.MissingTwin()); noTwin.OnSuccess(BossDrop(ModContent.ItemType <TwinRangs>())); npcLoot.Add(noTwin); } break; case NPCID.Plantera: npcLoot.Add(BossDrop(ModContent.ItemType <Dicer>())); break; case NPCID.Golem: npcLoot.Add(BossDrop(ModContent.ItemType <RockSlide>())); break; case NPCID.DukeFishron: npcLoot.Add(BossDrop(ModContent.ItemType <FishStick>())); break; case NPCID.DD2Betsy: npcLoot.Add(BossDrop(ModContent.ItemType <DragonBreath>())); break; case NPCID.BigMimicJungle: npcLoot.Add(ItemDropRule.OneFromOptions(1, ModContent.ItemType <Vineslinger>(), ModContent.ItemType <Mahoguny>(), ModContent.ItemType <OvergrownKey>())); break; default: break; } //if (Fargowiltas.Instance.CalamityLoaded && Revengeance && FargoSoulsWorld.EternityMode && Main.bloodMoon && Main.moonPhase == 0 && Main.raining && Main.rand.NextBool(10)) //{ // Mod calamity = ModLoader.GetMod("CalamityMod"); // if (npc.type == calamity.NPCType("DevourerofGodsHeadS")) // { // Item.NewItem(npc.Hitbox, calamity.ItemType("CosmicPlushie")); // } //} }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.OnFire, 200); }
/// <summary> /// Allows you to create special effects when this NPC hits a friendly NPC. /// </summary> /// <param name="target"></param> /// <param name="damage"></param> /// <param name="knockback"></param> /// <param name="crit"></param> public virtual void OnHitNPC(NPC target, int damage, float knockback, bool crit) { }
public override void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit) { OnHitByEither(npc, player, damage, knockback, crit); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 6; }
static int RealAddBuff(NPC n, int type, int time, bool quiet = false) { if (n.buffImmune[type]) { return(-1); } if (!quiet) { if (Main.netMode == 1) { NetMessage.SendData(53, -1, -1, String.Empty, n.whoAmI, type, time); } else if (Main.netMode == 2) { NetMessage.SendData(54, -1, -1, String.Empty, n.whoAmI); } } for (int i = 0; i < 5; i++) { if (n.buffType[i] == type) { if (n.buffTime[i] < time) { n.buffTime[i] = time; } return(-1); } } int slot = -1; do { int buffSeek = -1; for (int j = 0; j < 5; j++) { if (!Main.debuff[n.buffType[j]]) { buffSeek = j; break; } } if (buffSeek == -1) { return(-1); } for (int k = buffSeek; k < 5; k++) { if (n.buffType[k] == 0) { slot = k; break; } } if (slot == -1) { n.DelBuff(buffSeek); } } while (slot == -1); n.buffType[slot] = type; n.buffTime[slot] = time; return(slot); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { base.OnHitNPC(target, damage, knockback, crit); target.immune[projectile.owner] = 9; }
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { // Add Onfire buff to the NPC for 1 second // 60 frames = 1 second target.AddBuff(BuffID.Frostburn, 400); }
public override void DoOutcome(ref NPC n) { GameObject.Find(WhatGameObject).GetComponent <InteractWithObject>().enabled = true; GameObject.Find(WhatGameObject).GetComponent <SphereCollider>().enabled = true; }
public override bool PreAI() { npc.TargetClosest(true); npc.velocity.X = npc.velocity.X * 0.93f; if (npc.velocity.X > -0.1F && npc.velocity.X < 0.1F) { npc.velocity.X = 0; } if (npc.ai[0] == 0) { npc.ai[0] = 500f; } if (npc.ai[2] != 0 && npc.ai[3] != 0) { // Teleport effects: away. Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8); for (int index1 = 0; index1 < 50; ++index1) { int newDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 44, 0.0f, 0.0f, 100, new Color(), 1.5f); Main.dust[newDust].velocity *= 3f; Main.dust[newDust].noGravity = true; } npc.position.X = (npc.ai[2] * 16 - (npc.width / 2) + 8); npc.position.Y = npc.ai[3] * 16f - npc.height; npc.velocity.X = 0.0f; npc.velocity.Y = 0.0f; npc.ai[2] = 0.0f; npc.ai[3] = 0.0f; // Teleport effects: arrived. Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8); for (int index1 = 0; index1 < 50; ++index1) { int newDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 44, 0.0f, 0.0f, 100, new Color(), 1.5f); Main.dust[newDust].velocity *= 3f; Main.dust[newDust].noGravity = true; } } ++npc.ai[0]; if (npc.ai[0] == 100 || npc.ai[0] == 200 || npc.ai[0] == 300) { npc.ai[1] = 30f; npc.netUpdate = true; } bool teleport = false; for (int i = 0; i < 255; ++i) { if (Main.player[i].active && !Main.player[i].dead && (npc.position - Main.player[i].position).Length() < 70) { teleport = true; break; } } // Teleport if (npc.ai[0] >= 500 && Main.netMode != 1) { teleport = true; } if (teleport) { Teleport(); } if (npc.ai[1] > 0) { --npc.ai[1]; if (npc.ai[1] == 15) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 8); if (Main.netMode != 1) { NPC.NewNPC((int)npc.position.X + npc.width / 2, (int)npc.Center.Y - 16, mod.NPCType("GrassBall"), 0, 0, 0, 0, 0, 255); } } } if (Main.rand.Next(3) == 0) { return(false); } Dust dust = Main.dust[Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 44, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, new Color(), 0.9f)]; dust.noGravity = true; dust.velocity.X = dust.velocity.X * 0.3f; dust.velocity.Y = (dust.velocity.Y * 0.2f) - 1; return(false); }
public override bool UseItem(Player player) { NPC.SpawnOnPlayer(player.whoAmI, ModLoader.GetMod("Fargowiltas").NPCType("Abominationn")); return(true); }
public override bool CanUseItem(Player player) { return(!NPC.AnyNPCs(ModLoader.GetMod("Fargowiltas").NPCType("Abominationn"))); }
public override void DrawEffects(NPC npc, ref Color drawColor) { if (LeadPoison) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.Lead, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.NextBool(4)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (OriPoison) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.PinkTorch, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, default(Color), 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.NextBool(4)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (HellFire) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.SolarFlare, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(56, Main.LocalPlayer); Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.NextBool(4)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } if (SBleed) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.Blood, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(56, Main.LocalPlayer); Dust expr_1CCF_cp_0 = Main.dust[dust]; expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; if (Main.rand.NextBool(4)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } } // /*if (Infested) // { // if (Main.rand.Next(4) < 3) // { // int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, 44, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100, Color.LimeGreen, InfestedDust); // Main.dust[dust].noGravity = true; // Main.dust[dust].velocity *= 1.8f; // Dust expr_1CCF_cp_0 = Main.dust[dust]; // expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; // if (Main.rand.NextBool(4)) // { // Main.dust[dust].noGravity = false; // Main.dust[dust].scale *= 0.5f; // } // } // Lighting.AddLight((int)(npc.position.X / 16f), (int)(npc.position.Y / 16f + 1f), 1f, 0.3f, 0.1f); // }*/ if (Suffocation) { drawColor = Colors.RarityPurple; } // if (Villain) // { // if (Main.rand.Next(4) < 3) // { // int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, DustID.AncientLight, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 100); // Main.dust[dust].noGravity = true; // Main.dust[dust].velocity *= 1.8f; // Dust expr_1CCF_cp_0 = Main.dust[dust]; // expr_1CCF_cp_0.velocity.Y = expr_1CCF_cp_0.velocity.Y - 0.5f; // if (Main.rand.NextBool(4)) // { // Main.dust[dust].noGravity = false; // Main.dust[dust].scale *= 0.5f; // } // } // Lighting.AddLight((int)(npc.position.X / 16f), (int)(npc.position.Y / 16f + 1f), 1f, 0.3f, 0.1f); // } if (Electrified) { if (Main.rand.Next(4) < 3) { int dust = Dust.NewDust(new Vector2(npc.position.X - 2f, npc.position.Y - 2f), npc.width + 4, npc.height + 4, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.8f; if (Main.rand.NextBool(3)) { Main.dust[dust].noGravity = false; Main.dust[dust].scale *= 0.5f; } } Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.3f, 0.8f, 1.1f); } if (CurseoftheMoon) { int d = Dust.NewDust(npc.Center, 0, 0, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 3f; Main.dust[d].scale += 0.5f; if (Main.rand.Next(4) < 3) { d = Dust.NewDust(npc.position, npc.width, npc.height, 229, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 1f; Main.dust[d].velocity *= 2f; } } if (Sadism) { if (Main.rand.NextBool(7)) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 156, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 0, Color.White, 4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 2f; } } if (GodEater) { if (Main.rand.NextBool(7)) { int dust = Dust.NewDust(npc.position - new Vector2(2f, 2f), npc.width + 4, npc.height + 4, 86, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 0, Color.White, 4f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 1.2f; Main.dust[dust].velocity.Y -= 0.15f; } Lighting.AddLight(npc.position, 0.15f, 0.03f, 0.09f); } if (Chilled) { int d = Dust.NewDust(npc.Center, 0, 0, 15, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 3f; Main.dust[d].scale += 0.5f; if (Main.rand.Next(4) < 3) { d = Dust.NewDust(npc.position, npc.width, npc.height, 15, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f); Main.dust[d].noGravity = true; Main.dust[d].velocity.Y -= 1f; Main.dust[d].velocity *= 2f; } } if (FlamesoftheUniverse) { if (!Main.rand.NextBool(3)) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 203, npc.velocity.X * 0.4f, npc.velocity.Y * 0.4f, 0, new Color(50 * Main.rand.Next(6) + 5, 50 * Main.rand.Next(6) + 5, 50 * Main.rand.Next(6) + 5, 0), 2.5f); Main.dust[d].velocity.Y -= 1; Main.dust[d].velocity *= 1.5f; Main.dust[d].noGravity = true; } } if (Smite) { if (!Main.rand.NextBool(4)) { Color color = Main.DiscoColor; int d = Dust.NewDust(npc.position, npc.width, npc.height, 91, 0.0f, 0.0f, 100, color, 2.5f); Main.dust[d].velocity *= 2f; Main.dust[d].noGravity = true; } } if (Anticoagulation) { if (!Main.rand.NextBool(4)) { int d = Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood); Main.dust[d].velocity *= 2f; Main.dust[d].scale += 1f; } } if (BloodDrinker) { if (!Main.rand.NextBool(3)) { int d = Dust.NewDust(npc.position, npc.width, npc.height, DustID.LifeDrain, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 0, Color.White, 2.5f); Main.dust[d].noGravity = true; } } }
public override void AI() { if (npc.localAI[3] == 0) //just spawned { npc.TargetClosest(false); Movement(Main.player[npc.target].Center, 0.8f, 32f); if (npc.Distance(Main.player[npc.target].Center) < 2000) { npc.localAI[3] = 1; } else { return; } if (Main.netMode != NetmodeID.MultiplayerClient) { if (FargoSoulsWorld.MasochistMode) { Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <LifeRitual>(), npc.damage / 2, 0f, Main.myPlayer, 0f, npc.whoAmI); } } } EModeGlobalNPC.championBoss = npc.whoAmI; Player player = Main.player[npc.target]; Vector2 targetPos; if (npc.HasValidTarget && npc.Distance(player.Center) < 2500) { npc.timeLeft = 600; } switch ((int)npc.ai[0]) { case -3: //final phase if (!Main.dayTime || !player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) { npc.timeLeft = 30; } npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; break; } npc.velocity = Vector2.Zero; npc.ai[1] -= (float)Math.PI * 2 / 447; npc.ai[3] += (float)Math.PI * 2 / 447; //spin deathrays both ways if (--npc.ai[2] < 0) { npc.localAI[1] = npc.localAI[1] == 0 ? 1 : 0; npc.ai[2] = npc.localAI[1] == 1 ? 90 : 30; if (npc.ai[1] < 360 && Main.netMode != NetmodeID.MultiplayerClient) { int type = npc.localAI[1] == 1 ? ModContent.ProjectileType <LifeDeathraySmall2>() : ModContent.ProjectileType <LifeDeathray2>(); int max = 3; for (int i = 0; i < max; i++) { float offset = (float)Math.PI * 2 / max * i; Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[3] + offset), type, npc.damage / 4, 0f, Main.myPlayer, (float)Math.PI * 2 / 447, npc.whoAmI); Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[1] + offset), type, npc.damage / 4, 0f, Main.myPlayer, -(float)Math.PI * 2 / 447, npc.whoAmI); } } } if (--npc.localAI[0] < 0) { npc.localAI[0] = 47; if (Main.netMode != NetmodeID.MultiplayerClient) { int max = 14; float rotation = Main.rand.NextFloat((float)Math.PI * 2); for (int i = 0; i < max; i++) { Projectile.NewProjectile(npc.Center, new Vector2(4f, 0).RotatedBy(rotation + Math.PI / max * 2 * i), ModContent.ProjectileType <ChampionBee>(), npc.damage / 4, 0f, Main.myPlayer); } } } break; case -2: //final phase transition npc.velocity *= 0.97f; if (npc.ai[1] > 180) { npc.localAI[0] = 0; npc.localAI[2] = 2; } if (++npc.ai[1] == 180) //heal up { Main.PlaySound(SoundID.Roar, npc.Center, 2); //arte scream int heal = npc.lifeMax / 3 - npc.life; npc.life += heal; CombatText.NewText(npc.Hitbox, CombatText.HealLife, heal); const int num226 = 80; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.UnitX * 40f; vector6 = vector6.RotatedBy(((num227 - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + npc.Center; Vector2 vector7 = vector6 - npc.Center; int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 174, 0f, 0f, 0, default(Color), 3f); Main.dust[num228].noGravity = true; Main.dust[num228].velocity = vector7; } } else if (npc.ai[1] > 240) { npc.ai[0] = -3; npc.ai[1] = npc.DirectionTo(player.Center).ToRotation(); npc.ai[2] = 0; npc.ai[3] = npc.DirectionTo(player.Center).ToRotation(); npc.netUpdate = true; } break; case -1: //heal npc.velocity *= 0.97f; if (npc.ai[1] > 180) { npc.localAI[2] = 1; } if (++npc.ai[1] == 180) //heal up { Main.PlaySound(SoundID.Roar, npc.Center, 2); //arte scream int heal = npc.lifeMax - npc.life; npc.life += heal; CombatText.NewText(npc.Hitbox, CombatText.HealLife, heal); const int num226 = 80; for (int num227 = 0; num227 < num226; num227++) { Vector2 vector6 = Vector2.UnitX * 40f; vector6 = vector6.RotatedBy(((num227 - (num226 / 2 - 1)) * 6.28318548f / num226), default(Vector2)) + npc.Center; Vector2 vector7 = vector6 - npc.Center; int num228 = Dust.NewDust(vector6 + vector7, 0, 0, 174, 0f, 0f, 0, default(Color), 3f); Main.dust[num228].noGravity = true; Main.dust[num228].velocity = vector7; } } else if (npc.ai[1] > 240) { npc.ai[0] = npc.ai[3]; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 0: //float over player if (!Main.dayTime || !player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) { npc.timeLeft = 30; } npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; break; } targetPos = player.Center; targetPos.Y -= 275; if (npc.Distance(targetPos) > 50) { Movement(targetPos, 0.18f, 24f, true); } if (npc.Distance(player.Center) < 200) //try to avoid contact damage { Movement(targetPos, 0.24f, 24f, true); } if (++npc.ai[1] > 150) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } if (npc.localAI[2] == 0 && npc.life < npc.lifeMax / 3) { float buffer = npc.ai[0]; npc.ai[0] = -1; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = buffer; npc.netUpdate = true; } if (npc.localAI[2] == 1 && npc.life < npc.lifeMax / 3 && FargoSoulsWorld.MasochistMode) { npc.ai[0] = -2; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 1: //boundary npc.velocity *= 0.95f; if (++npc.ai[1] > (npc.localAI[2] == 1 ? 2 : 3)) { Main.PlaySound(SoundID.Item12, npc.Center); npc.ai[1] = 0; npc.ai[2] -= (float)Math.PI / 4 / 457 * npc.ai[3]; if (npc.ai[2] < -(float)Math.PI) { npc.ai[2] += (float)Math.PI * 2; } if (Main.netMode != NetmodeID.MultiplayerClient) { int max = npc.localAI[2] == 1 ? 5 : 4; for (int i = 0; i < max; i++) { Projectile.NewProjectile(npc.Center, new Vector2(6f, 0).RotatedBy(npc.ai[2] + Math.PI / max * 2 * i), ModContent.ProjectileType <ChampionBee>(), npc.damage / 4, 0f, Main.myPlayer); } } } if (++npc.ai[3] > 300) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 2: if (npc.ai[3] == 0) { if (!player.active || player.dead || Vector2.Distance(npc.Center, player.Center) > 2500f) //despawn code { npc.TargetClosest(false); if (npc.timeLeft > 30) { npc.timeLeft = 30; } npc.noTileCollide = true; npc.noGravity = true; npc.velocity.Y -= 1f; return; } if (npc.ai[2] == 0) { npc.ai[2] = npc.Center.Y; //store arena height } if (npc.Center.Y > npc.ai[2] + 1000) //now below arena, track player { targetPos = new Vector2(player.Center.X, npc.ai[2] + 1100); Movement(targetPos, 1.2f, 24f); if (Math.Abs(player.Center.X - npc.Center.X) < npc.width / 2 && ++npc.ai[1] > (npc.localAI[2] == 1 ? 30 : 60)) //in position under player { Main.PlaySound(SoundID.Item92, npc.Center); npc.ai[3]++; npc.ai[1] = 0; npc.netUpdate = true; } } else //drop below arena { npc.velocity.X *= 0.95f; npc.velocity.Y += 0.6f; } } else { npc.velocity.X = 0; npc.velocity.Y = -36f; if (++npc.ai[1] > 1) //spawn pixies { npc.ai[1] = 0; npc.localAI[0] = npc.localAI[0] == 1 ? -1 : 1; //alternate sides if (Main.netMode != NetmodeID.MultiplayerClient) { int n = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <LesserFairy>(), npc.whoAmI, Target: npc.target); if (n != Main.maxNPCs) { Main.npc[n].velocity = 5f * Vector2.UnitX.RotatedBy(Math.PI * (Main.rand.NextDouble() - 0.5)); Main.npc[n].velocity.X *= npc.localAI[0]; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, n); } } } } if (npc.Center.Y < player.Center.Y - 600) //dash ended { npc.velocity.Y *= -0.25f; npc.localAI[0] = 0f; npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } } break; case 3: goto case 0; case 4: //beetle swarm npc.velocity *= 0.9f; if (npc.ai[3] == 0) { npc.ai[3] = npc.Center.X < player.Center.X ? -1 : 1; } if (++npc.ai[2] > (npc.localAI[2] == 1 ? 35 : 45)) { npc.ai[2] = 0; Main.PlaySound(SoundID.Item92, npc.Center); if (npc.localAI[0] > 0) { npc.localAI[0] = -1; } else { npc.localAI[0] = 1; } if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 projTarget = npc.Center; projTarget.X += 1200 * npc.ai[3]; projTarget.Y += 1200 * -npc.localAI[0]; for (int i = 0; i < 20; i++) { projTarget.Y += 250 * npc.localAI[0]; Vector2 speed = (projTarget - npc.Center) / 40; float ai0 = (npc.localAI[2] == 1 ? 9 : 6) * -npc.ai[3]; //x speed of beetles float ai1 = 6 * -npc.localAI[0]; //y speed of beetles Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <ChampionBeetle>(), npc.damage / 4, 0f, Main.myPlayer, ai0, ai1); } } } if (++npc.ai[1] > 360) { npc.localAI[0] = 0; npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 5: goto case 0; case 6: npc.velocity *= 0.98f; if (++npc.ai[2] > 60) { if (++npc.ai[3] > (npc.localAI[2] == 1 ? 4 : 7)) //spray fireballs that home down { npc.ai[3] = 0; if (Main.netMode != NetmodeID.MultiplayerClient) { //spawn anywhere above self Vector2 target = new Vector2(Main.rand.NextFloat(1000), 0).RotatedBy(Main.rand.NextDouble() * -Math.PI); Vector2 speed = 2 * target / 60; float acceleration = -speed.Length() / 60; Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <LifeFireball>(), npc.damage / 4, 0f, Main.myPlayer, 60f, acceleration); } } if (npc.ai[2] > (npc.localAI[2] == 1 ? 120 : 100)) { npc.netUpdate = true; npc.ai[2] = 0; } } if (++npc.ai[1] > 480) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 7: goto case 0; case 8: goto case 2; case 9: //deathray spin npc.velocity *= 0.95f; npc.ai[3] += (float)Math.PI * 2 / (npc.localAI[2] == 1 ? -300 : 360); if (--npc.ai[2] < 0) { npc.ai[2] = 60; npc.localAI[1] = npc.localAI[1] == 0 ? 1 : 0; if (npc.ai[1] < 360 && Main.netMode != NetmodeID.MultiplayerClient) { int type = npc.localAI[1] == 1 ? ModContent.ProjectileType <LifeDeathraySmall>() : ModContent.ProjectileType <LifeDeathray>(); int max = npc.localAI[2] == 1 ? 6 : 4; for (int i = 0; i < max; i++) { float offset = (float)Math.PI * 2 / max * i; Projectile.NewProjectile(npc.Center, Vector2.UnitX.RotatedBy(npc.ai[3] + offset), type, npc.damage / 4, 0f, Main.myPlayer, offset, npc.whoAmI); } } } if (++npc.ai[1] > 390) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.localAI[1] = 0; npc.netUpdate = true; } break; case 10: goto case 0; case 11: //cactus mines npc.velocity *= 0.98f; if (++npc.ai[2] > (npc.localAI[2] == 1 ? 75 : 100)) { if (++npc.ai[3] > 5) //spray mines that home down { npc.ai[3] = 0; Main.PlaySound(SoundID.Item12, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 target = player.Center - npc.Center; target.X += Main.rand.Next(-75, 76); target.Y += Main.rand.Next(-75, 76); Vector2 speed = 2 * target / 90; float acceleration = -speed.Length() / 90; Projectile.NewProjectile(npc.Center, speed, ModContent.ProjectileType <CactusMine>(), npc.damage / 4, 0f, Main.myPlayer, 0f, acceleration); } } if (npc.ai[2] > 130) { npc.netUpdate = true; npc.ai[2] = 0; } } if (++npc.ai[1] > 480) { npc.TargetClosest(); npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; default: npc.ai[0] = 0; goto case 0; } for (int i = 0; i < 3; i++) { int d = Dust.NewDust(npc.position, npc.width, npc.height, 87, 0f, 0f, 0, default(Color), 1.5f); Main.dust[d].noGravity = true; Main.dust[d].velocity *= 4f; } }
public override void OnHitByProjectile(NPC npc, Projectile projectile, int damage, float knockback, bool crit) { OnHitByEither(npc, Main.player[projectile.owner], damage, knockback, crit); }
public override string NormalMessage(Player player, TerraGuardian guardian) { List<string> Mes = new List<string>(); Mes.Add("Yay! I met more people!"); Mes.Add("Don't worry, I'll protect you from any danger."); Mes.Add("I'm sure you would like to meet " + AlexRecruitScripts.AlexOldPartner + ". Well, she was a bit closed off to other people, but she was my best pal. That's what matter, I guess?"); Mes.Add("I wonder if " + AlexRecruitScripts.AlexOldPartner + "'s tombstone is alright. Should I check it up later?"); Mes.Add("A number of Terrarians kept asking me how I managed to place "+AlexRecruitScripts.AlexOldPartner+"'s tombstone in so many weird places, so now I learned how to properly place them."); Mes.Add("Whaaaaaaaaaaat? You can't place tombstones on trees? Or plants? Or in the water?"); if(NPC.AnyNPCs(22)) Mes.Add("[gn:22] teached me how to properly place things on correct places, and now I can't place them on the wrong place."); if (Main.bloodMoon) { Mes.Add("Stay near me and you'll be safe."); Mes.Add("So many things to bite outside."); } if (Main.eclipse) { Mes.Add("I think I saw some of those guys in some movies I watched with " + AlexRecruitScripts.AlexOldPartner + "."); Mes.Add("I don't fear any of those monsters outside. The only thing I fear is the Legion, but It doesn't exist in this world."); } if (Main.dayTime) { if (!Main.eclipse) { if (!Main.raining) Mes.Add("This day seems good enough for playing outside!"); else Mes.Add("The rain would spoil all the fun if it weren't for the puddles."); Mes.Add("I still have two AA batteries to be depleted, so let's play a game!"); } } else { if (!Main.bloodMoon) { if (Main.moonPhase == 2) Mes.Add("This night reminds me of an adventure I had with " + AlexRecruitScripts.AlexOldPartner + ". That makes me miss her."); } } if (NpcMod.HasGuardianNPC(0)) { Mes.Add("When you are not around, I play some Hide and Seek with [gn:0]. He's really bad at hiding. His tail gives him away, but It's fun to always find him."); if (NPC.AnyNPCs(Terraria.ID.NPCID.Merchant)) Mes.Add("Do you know why [gn:0] eats [nn:" + Terraria.ID.NPCID.Merchant + "]'s trash? I'd join him but, " + AlexRecruitScripts.AlexOldPartner + " taught me that eating trash is bad."); } if (NpcMod.HasGuardianNPC(1)) { Mes.Add("I fertilized [gn:1]'s yard, and she thanked me by chasing me while swinging her broom at me. I guess we are besties now."); Mes.Add("[gn:1] looked very upset when I was playing with her red cloak. By the way, tell her that you didn't see me if she asks."); if (NpcMod.HasGuardianNPC(2)) Mes.Add("Why does [gn:1] watches [gn:2] and I play? Why don't she join us in the fun? That would be better than staring, right?"); } if (NpcMod.HasGuardianNPC(2)) { Mes.Add("[gn:2] called me to go on an adventure, I wonder if you will mind that."); } if (NpcMod.HasGuardianNPC(3)) { Mes.Add("I asked earlier if [gn:3] was using one of his bones. His answer was very rude."); if (NpcMod.HasGuardianNPC(1)) Mes.Add("Why do [gn:3] and [gn:1] look a bit sad when they meet each other? Aren't they dating?"); Mes.Add("I tried to cheer [gn:3] on. He threw a frizbee for me to catch, but when I returned, he wasn't there. Where did he go?"); } if (NpcMod.HasGuardianNPC(4)) { Mes.Add("What's with [gn:4]? He never shows up any kind of emotion when I talk to him. Even when we play."); Mes.Add("I don't really have any fun when playing with [gn:4], because he doesn't seems to be having fun."); } if (NpcMod.HasGuardianNPC(0) && NpcMod.HasGuardianNPC(2)) Mes.Add("I've got [gn:0] and [gn:2] to play with me. I guess my new dream will be for everyone in the village to play together."); if (NpcMod.HasGuardianNPC(7)) { Mes.Add("I think sometimes [gn:7] feels lonely, so I stay nearby to make her feel less lonely."); Mes.Add("I smell a variety of things inside of [gn:7]'s bag, including food. Can you persuade her to open her bag and show us what is inside?"); } if (NpcMod.HasGuardianNPC(8)) { Mes.Add("I love playing with [gn:8]. The other person that played as much with me was " + AlexRecruitScripts.AlexOldPartner + "."); Mes.Add("I'm up to playing some more. Do you know if [gn:8] is free?"); } if (NpcMod.HasGuardianNPC(Vladimir)) { Mes.Add("(He's watching the horizon. Maybe he's thinking about something?)"); Mes.Add("Have been talking with [gn:"+Vladimir+"] and... No... Forget it... Nevermind what I was saying."); Mes.Add("That [gn:" + Vladimir + "] is a real buddy. He accompanies me when I go visit " + AlexRecruitScripts.AlexOldPartner + "'s Tombstone. I don't feel alone when doing that anymore."); } if (NpcMod.HasGuardianNPC(GuardianBase.Michelle)) { Mes.Add("I've got a new friend, and the name is [gn:" + GuardianBase.Michelle + "]. What? I'm your buddy too.*"); } if (NpcMod.HasGuardianNPC(GuardianBase.Wrath)) { Mes.Add("*Whine~whine* [gn:" + Wrath + "] is a mean guy, I try playing with him, and he's really rude to me."); Mes.Add("I try making [gn:"+Wrath+"] feel better, but he aways yells at me."); } if (NpcMod.HasGuardianNPC(Fluffles)) { Mes.Add("I don't know why some people are scared of [gn:" + Fluffles + "], she's a good person. I like her."); Mes.Add("I love playing with [gn:" + Fluffles + "]. She always knows my favorite petting spot."); if (NpcMod.HasGuardianNPC(Rococo)) { Mes.Add("Sometimes [gn:"+Rococo+"] and [gn:"+Fluffles+"] play with me. It's like a dream came true. They could do that more often."); } } if (NpcMod.HasGuardianNPC(Miguel)) { Mes.Add("[nickname]... I'm working hard... With the help of [gn:" + Miguel + "]... To get stronger... and protect you..."); Mes.Add("I'm exausted... [gn:" + Miguel + "]'s exercises are hardcore... But I'm feeling stronger."); } if (NpcMod.HasGuardianNPC(Luna)) { Mes.Add("I like [gn:"+ Luna+ "], she always rub my belly when I ask."); } if (guardian.IsUsingToilet) { Mes.Add("I'm trying hard to aim at the hole."); Mes.Add("Is this how you humans use a toilet? It's very hard for me to use it."); } if (guardian.IsPlayerRoomMate(player)) { Mes.Add("You'll sleep in my bedroom? That's awesome! I will keep you protected while you sleep."); Mes.Add("You'll share your bed with me? This is the best day ever!"); } if (guardian.KnockedOut) { Mes.Clear(); Mes.Add("(He seems to be in pain.)"); Mes.Add("(His wounds aren't letting him rest.)"); Mes.Add("I have... To protec.t... " + player.name +"..."); } else if (guardian.IsSleeping) { Mes.Clear(); Mes.Add("(He's moving his paws while sleeping, maybe he's dreaming that he's running?)"); Mes.Add("No... Don't go... No... (He seems to be having a nightmare)"); Mes.Add("(You can hear his silent snores.)"); } if(FlufflesBase.IsHauntedByFluffles(player) && Main.rand.NextDouble() < 0.75) { Mes.Clear(); Mes.Add("Who's she? Is she friendly? Can she play with me?"); } /*if (FlufflesBase.IsCompanionHaunted(guardian) && Main.rand.Next(2) == 0) { Mes.Clear(); Mes.Add(""); }*/ return Mes[Main.rand.Next(Mes.Count)]; }
// public override void SetDefaults(NPC npc) // { // } public override bool PreAI(NPC npc) { if (npc.boss || npc.type == NPCID.EaterofWorldsHead) { boss = npc.whoAmI; } bool retval = base.PreAI(npc); if (TimeFrozen) { npc.position = npc.oldPosition; npc.frameCounter = 0; retval = false; } if (!FirstTick) { originalDefense = npc.defense; // switch (npc.type) // { // case NPCID.TheDestroyer: // case NPCID.TheDestroyerBody: // case NPCID.TheDestroyerTail: // npc.buffImmune[ModContent.BuffType<TimeFrozen>()] = false; // npc.buffImmune[ModContent.BuffType<Frozen>()] = false; // //npc.buffImmune[BuffID.Darkness] = false; // break; // /*case NPCID.WallofFlesh: // case NPCID.WallofFleshEye: // case NPCID.MoonLordCore: // case NPCID.MoonLordHand: // case NPCID.MoonLordHead: // case NPCID.MoonLordLeechBlob: // case NPCID.TargetDummy: // case NPCID.GolemFistLeft: // case NPCID.GolemFistRight: // case NPCID.GolemHead: // case NPCID.DungeonGuardian: // case NPCID.DukeFishron: // SpecialEnchantImmune = true; // break;*/ // case NPCID.Squirrel: // case NPCID.SquirrelRed: // if (!npc.SpawnedFromStatue) // { // int p = Player.FindClosest(npc.position, npc.width, npc.height); // if ((p == -1 || npc.Distance(Main.player[p].Center) > 800) && Main.rand.NextBool(5)) // npc.Transform(ModContent.NPCType<TophatSquirrelCritter>()); // } // break; // default: // break; // } // //critters // if (npc.damage == 0 && !npc.townNPC && npc.lifeMax == 5) // { // Player player = Main.player[Main.myPlayer]; // /*if ( npc.releaseOwner == player.whoAmI && player.GetModPlayer<FargoSoulsPlayer>().WoodEnchant) // { // switch (npc.type) // { // case NPCID.Bunny: // npc.active = false; // break; // } // ExplosiveCritter = true; // }*/ // } FirstTick = true; } if (Lethargic && ++LethargicCounter > 3) { LethargicCounter = 0; retval = false; } // if (ExplosiveCritter) // { // critterCounter--; // if (critterCounter <= 0) // { // Player player = Main.player[npc.releaseOwner]; // FargoSoulsPlayer modPlayer = player.GetModPlayer<FargoSoulsPlayer>(); // int damage = 25; // if (modPlayer.WoodForce || modPlayer.WizardEnchant) // { // damage *= 5; // } // Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType<ExplosionSmall>(), modPlayer.HighestDamageTypeScaling(damage), 4, npc.releaseOwner); // //gold critters make coin value go up of hit enemy, millions of other effects eeech // } // } if (SnowChilled) { SnowChilledTimer--; if (SnowChilledTimer <= 0) { SnowChilled = false; } if (SnowChilledTimer % 3 == 1) { npc.position = npc.oldPosition; retval = false; } } return(retval); }
/// <summary> /// 创建NPC /// </summary> /// <param name="id"></param> /// <param name="npc"></param> /// <param name="x"></param> /// <param name="y"></param> public void CreateNpc(int id, int npc, int x, int y) { NPC newNPC = Context.LibData.GetCharacter(2, npc) as NPC; newNPC.SetPosInMap(x, y); SceneNPCs[id] = newNPC; }
public override void Update(NPC npc, ref int buffIndex) { npc.defense = 0; npc.defDefense = 0; npc.GetGlobalNPC <NPCs.FargoSoulsGlobalNPC>().GodEater = true; }
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, (60 * Main.rand.Next(1, 4)), false); target.AddBuff(mod.BuffType("Frozen"), 60, false); }
public override bool UseItem(Player player) { NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, mod.NPCType("Floater1")); return true; }
public override bool?CanHitNPC(NPC target) { return(!target.friendly); }
/// <summary> /// Allows you to customize how this NPC is created when it naturally spawns (for example, its position or ai array). Return the return value of NPC.NewNPC. By default this method spawns this NPC on top of the tile at the given coordinates. /// </summary> /// <param name="tileX"></param> /// <param name="tileY"></param> /// <returns></returns> public virtual int SpawnNPC(int tileX, int tileY) { return(NPC.NewNPC(tileX * 16 + 8, tileY * 16, npc.type)); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[projectile.owner] = 5; target.AddBuff(mod.BuffType("BlightFlame"), 180, false); }
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Poisoned, 240, true); }
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { }
public override void AI() { NPC jotaro = null; if (NPCs.MarineBiologist.userIsAlive) { for (int k = 0; k < 200; k++) { NPC npc = Main.npc[k]; if (npc.type == mod.NPCType("MarineBiologist")) { jotaro = npc; } } } if (projectile.active) { SPActive = true; } if (!NPCs.MarineBiologist.userIsAlive) { projectile.Kill(); } if (projectile.spriteDirection == 1) { drawOffsetX = -10; } if (projectile.spriteDirection == -1) { drawOffsetX = -60; } if (jotaro != null) { Vector2 vector131 = jotaro.Center; vector131.X -= (float)((15 + jotaro.width / 2) * jotaro.direction); vector131.Y -= 15f; projectile.Center = Vector2.Lerp(projectile.Center, vector131, 0.2f); projectile.velocity *= 0.8f; projectile.direction = (projectile.spriteDirection = jotaro.direction); } if (projectile.timeLeft < 256) { projectile.alpha = -projectile.timeLeft + 255; } Vector2 targetPos = projectile.position; float targetDist = 98f; bool target = false; projectile.tileCollide = true; for (int k = 0; k < 200; k++) { NPC npc = Main.npc[k]; normalFrames = true; if (npc.CanBeChasedBy(this, false)) { float distance = Vector2.Distance(npc.Center, projectile.Center); if ((distance < targetDist || !target) && Collision.CanHitLine(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) { targetDist = distance; targetPos = npc.Center; target = true; projectile.timeLeft = 600; projectile.alpha = 0; } } } SelectFrame(); if (projectile.ai[1] > 0f) { projectile.ai[1] += 1f; if (Main.rand.Next(3) == 0) { projectile.ai[1] += 1f; } } if (projectile.ai[1] > shootCool) { projectile.ai[1] = 0f; projectile.netUpdate = true; } if (projectile.ai[0] == 0f) { if (target) { attackFrames = true; normalFrames = false; if ((targetPos - projectile.Center).X > 0f) { projectile.spriteDirection = (projectile.direction = 1); } else if ((targetPos - projectile.Center).X < 0f) { projectile.spriteDirection = (projectile.direction = -1); } if (projectile.ai[1] == 0f) { projectile.ai[1] = 1f; Vector2 shootVel = targetPos - projectile.Center; if (shootVel == Vector2.Zero) { shootVel = new Vector2(0f, 1f); } shootVel.Normalize(); shootVel *= shootSpeed; int proj = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, shootVel.X, shootVel.Y, mod.ProjectileType("NPCStandFists"), NPCs.MarineBiologist.attackPower, 1f, Main.myPlayer, 0, 0); Main.projectile[proj].npcProj = true; Main.projectile[proj].netUpdate = true; projectile.netUpdate = true; } } else { attackFrames = false; } } }
public static BroncoClass Find(NPC npc) { return(_instances.FirstOrDefault(b => b.Npc == npc)); }