1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mobile spawns helper but the helper dies

Discussion in 'Script Support' started by RedBeard, Feb 5, 2017.

  1. RedBeard
    Offline

    RedBeard Active Member

    Joined:
    May 19, 2013
    Messages:
    365
    Likes Received:
    72
    When the Solen Queen lays egg sac if not destroyed it spawns a helper. This all works well except the helper's life slowly drains til it dies as well as the queen after the egg hatches, what causes this and how can I control that effect or negate it?


    This is the section with helper:
    The entire file:
    Code (C#):
    1.  
    2. using System;
    3.  
    4. using System.Collections;
    5.  
    6. using Server.Items;
    7.  
    8. using Server.Network;
    9.  
    10. namespace Server.Mobiles
    11.  
    12. {
    13.  
    14. [CorpseName("a solen queen corpse")]
    15.  
    16. public class BlackSolenQueen : BaseCreature
    17.  
    18. {
    19.  
    20. private bool m_BurstSac;
    21.  
    22. [Constructable]
    23.  
    24. public BlackSolenQueen()
    25.  
    26. : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
    27.  
    28. {
    29.  
    30. this.Name = "a black solen queen";
    31.  
    32. this.Body = 807;
    33.  
    34. this.BaseSoundID = 959;
    35.  
    36. this.Hue = 0x453;
    37.  
    38. this.SetStr(296, 320);
    39.  
    40. this.SetDex(121, 145);
    41.  
    42. this.SetInt(76, 100);
    43.  
    44. this.SetHits(151, 162);
    45.  
    46. this.SetDamage(10, 15);
    47.  
    48. this.SetDamageType(ResistanceType.Physical, 70);
    49.  
    50. this.SetDamageType(ResistanceType.Poison, 30);
    51.  
    52. this.SetResistance(ResistanceType.Physical, 30, 40);
    53.  
    54. this.SetResistance(ResistanceType.Fire, 30, 35);
    55.  
    56. this.SetResistance(ResistanceType.Cold, 25, 35);
    57.  
    58. this.SetResistance(ResistanceType.Poison, 35, 40);
    59.  
    60. this.SetResistance(ResistanceType.Energy, 25, 30);
    61.  
    62. this.SetSkill(SkillName.MagicResist, 70.0);
    63.  
    64. this.SetSkill(SkillName.Tactics, 90.0);
    65.  
    66. this.SetSkill(SkillName.Wrestling, 90.0);
    67.  
    68. this.Fame = 4500;
    69.  
    70. this.Karma = -4500;
    71.  
    72. this.VirtualArmor = 45;
    73.  
    74. SolenHelper.PackPicnicBasket(this);
    75.  
    76. this.PackItem(new ZoogiFungus((Utility.RandomDouble() > 0.05) ? 5 : 25));
    77.  
    78. if (Utility.RandomDouble() < 0.05)
    79.  
    80. this.PackItem(new BallOfSummoning());
    81.  
    82. }
    83.  
    84. public BlackSolenQueen(Serial serial)
    85.  
    86. : base(serial)
    87.  
    88. {
    89.  
    90. }
    91.  
    92. public bool BurstSac
    93.  
    94. {
    95.  
    96. get
    97.  
    98. {
    99.  
    100. return this.m_BurstSac;
    101.  
    102. }
    103.  
    104. }
    105.  
    106. public override int GetAngerSound()
    107.  
    108. {
    109.  
    110. return 0x259;
    111.  
    112. }
    113.  
    114. public override int GetIdleSound()
    115.  
    116. {
    117.  
    118. return 0x259;
    119.  
    120. }
    121.  
    122. public override int GetAttackSound()
    123.  
    124. {
    125.  
    126. return 0x195;
    127.  
    128. }
    129.  
    130. public override int GetHurtSound()
    131.  
    132. {
    133.  
    134. return 0x250;
    135.  
    136. }
    137.  
    138. public override int GetDeathSound()
    139.  
    140. {
    141.  
    142. return 0x25B;
    143.  
    144. }
    145.  
    146. public override void GenerateLoot()
    147.  
    148. {
    149.  
    150. this.AddLoot(LootPack.Rich);
    151.  
    152. }
    153.  
    154. //Edit 1 of 2
    155.  
    156. public override void OnGotMeleeAttack(Mobile attacker)
    157.  
    158. {
    159.  
    160. if (attacker.Weapon is BaseRanged)
    161.  
    162. BeginAcidBreath();
    163.  
    164. else if (this.Map != null && attacker != this && 0.25 > Utility.RandomDouble())
    165.  
    166. {
    167.  
    168. BSQEggSac sac = new BSQEggSac();
    169.  
    170. sac.MoveToWorld(this.Location, this.Map);
    171.  
    172. PlaySound(0x582);
    173.  
    174. Say(1114445); // * * The solen queen summons her workers to her aid! * *
    175.  
    176. }
    177.  
    178. base.OnGotMeleeAttack(attacker);
    179.  
    180. }
    181.  
    182. public override void OnDamagedBySpell(Mobile attacker)
    183.  
    184. {
    185.  
    186. base.OnDamagedBySpell(attacker);
    187.  
    188. BeginAcidBreath();
    189.  
    190. }
    191.  
    192. #region Acid Breath
    193.  
    194. private DateTime m_NextAcidBreath;
    195.  
    196. public void BeginAcidBreath()
    197.  
    198. {
    199.  
    200. PlayerMobile m = Combatant as PlayerMobile;
    201.  
    202. if (m == null || m.Deleted || !m.Alive || !Alive || m_NextAcidBreath > DateTime.Now || !CanBeHarmful(m))
    203.  
    204. return;
    205.  
    206. PlaySound(0x118);
    207.  
    208. MovingEffect(m, 0x36D4, 1, 0, false, false, 0x3F, 0);
    209.  
    210. TimeSpan delay = TimeSpan.FromSeconds(GetDistanceToSqrt(m) / 5.0);
    211.  
    212. Timer.DelayCall<Mobile>(delay, new TimerStateCallback<Mobile>(EndAcidBreath), m);
    213.  
    214. m_NextAcidBreath = DateTime.Now + TimeSpan.FromSeconds(5);
    215.  
    216. }
    217.  
    218. public void EndAcidBreath(Mobile m)
    219.  
    220. {
    221.  
    222. if (m == null || m.Deleted || !m.Alive || !Alive)
    223.  
    224. return;
    225.  
    226. if (0.2 >= Utility.RandomDouble())
    227.  
    228. m.ApplyPoison(this, Poison.Greater);
    229.  
    230. AOS.Damage(m, Utility.RandomMinMax(100, 120), 0, 0, 0, 100, 0);
    231.  
    232. }
    233.  
    234. #endregion
    235.  
    236. //End Edit
    237.  
    238. public override bool IsEnemy(Mobile m)
    239.  
    240. {
    241.  
    242. if (SolenHelper.CheckBlackFriendship(m))
    243.  
    244. return false;
    245.  
    246. else
    247.  
    248. return base.IsEnemy(m);
    249.  
    250. }
    251.  
    252. public override void OnDamage(int amount, Mobile from, bool willKill)
    253.  
    254. {
    255.  
    256. SolenHelper.OnBlackDamage(from);
    257.  
    258. if (!willKill)
    259.  
    260. {
    261.  
    262. if (!this.BurstSac)
    263.  
    264. {
    265.  
    266. if (this.Hits < 50)
    267.  
    268. {
    269.  
    270. this.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "* The solen's acid sac is burst open! *");
    271.  
    272. this.m_BurstSac = true;
    273.  
    274. }
    275.  
    276. }
    277.  
    278. else if (from != null && from != this && this.InRange(from, 1))
    279.  
    280. {
    281.  
    282. this.SpillAcid(from, 1);
    283.  
    284. }
    285.  
    286. }
    287.  
    288. base.OnDamage(amount, from, willKill);
    289.  
    290. }
    291.  
    292. public override bool OnBeforeDeath()
    293.  
    294. {
    295.  
    296. this.SpillAcid(4);
    297.  
    298. return base.OnBeforeDeath();
    299.  
    300. }
    301.  
    302. public override void Serialize(GenericWriter writer)
    303.  
    304. {
    305.  
    306. base.Serialize(writer);
    307.  
    308. writer.Write((int)1);
    309.  
    310. writer.Write(this.m_BurstSac);
    311.  
    312. }
    313.  
    314. public override void Deserialize(GenericReader reader)
    315.  
    316. {
    317.  
    318. base.Deserialize(reader);
    319.  
    320. int version = reader.ReadInt();
    321.  
    322.  
    323.  
    324. switch( version )
    325.  
    326. {
    327.  
    328. case 1:
    329.  
    330. {
    331.  
    332. this.m_BurstSac = reader.ReadBool();
    333.  
    334. break;
    335.  
    336. }
    337.  
    338. }
    339.  
    340. }
    341.  
    342. }
    343.  
    344. //Edit 2 of 2
    345.  
    346. public class BSQEggSac : Item, ICarvable
    347.  
    348. {
    349.  
    350. private SpawnTimer m_Timer;
    351.  
    352. public override string DefaultName
    353.  
    354. {
    355.  
    356. get { return "egg sac"; }
    357.  
    358. }
    359.  
    360. [Constructable]
    361.  
    362. public BSQEggSac()
    363.  
    364. : base(4316)
    365.  
    366. {
    367.  
    368. Movable = false;
    369.  
    370. Hue = 350;
    371.  
    372. m_Timer = new SpawnTimer(this);
    373.  
    374. m_Timer.Start();
    375.  
    376. }
    377.  
    378. public void Carve(Mobile from, Item item)
    379.  
    380. {
    381.  
    382. Effects.PlaySound(GetWorldLocation(), Map, 0x027);
    383.  
    384. Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10, 10, 0, 0);
    385.  
    386. from.SendMessage("You destroy the egg sac.");
    387.  
    388. Delete();
    389.  
    390. m_Timer.Stop();
    391.  
    392. }
    393.  
    394. public BSQEggSac(Serial serial)
    395.  
    396. : base(serial)
    397.  
    398. {
    399.  
    400. }
    401.  
    402. public override void Serialize(GenericWriter writer)
    403.  
    404. {
    405.  
    406. base.Serialize(writer);
    407.  
    408. writer.Write((int)0); // version
    409.  
    410. }
    411.  
    412. public override void Deserialize(GenericReader reader)
    413.  
    414. {
    415.  
    416. base.Deserialize(reader);
    417.  
    418. int version = reader.ReadInt();
    419.  
    420. m_Timer = new SpawnTimer(this);
    421.  
    422. m_Timer.Start();
    423.  
    424. }
    425.  
    426. private class SpawnTimer : Timer
    427.  
    428. {
    429.  
    430. private Item m_Item;
    431.  
    432. public SpawnTimer(Item item)
    433.  
    434. : base(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10)))
    435.  
    436. {
    437.  
    438. Priority = TimerPriority.FiftyMS;
    439.  
    440. m_Item = item;
    441.  
    442. }
    443.  
    444. protected override void OnTick()
    445.  
    446. {
    447.  
    448. if (m_Item.Deleted)
    449.  
    450. return;
    451.  
    452. Mobile spawn;
    453.  
    454. switch (Utility.Random(2))
    455.  
    456. {
    457.  
    458. case 0:
    459.  
    460. spawn = new BlackSolenWarrior();
    461.  
    462. spawn.MoveToWorld(m_Item.Location, m_Item.Map);
    463.  
    464. m_Item.Delete();
    465.  
    466. break;
    467.  
    468. case 1:
    469.  
    470. spawn = new BlackSolenWorker();
    471.  
    472. spawn.MoveToWorld(m_Item.Location, m_Item.Map);
    473.  
    474. m_Item.Delete();
    475.  
    476. break;
    477.  
    478. }
    479.  
    480. }
    481.  
    482. }
    483.  
    484. } //End Edit
    485.  
    486. }
    487.  
    488.  
     
    #1 RedBeard, Feb 5, 2017
    Last edited: Feb 5, 2017
  2. PyrO
    Offline

    PyrO Active Member

    Joined:
    Jan 27, 2015
    Messages:
    768
    Likes Received:
    38
    I think your issue is that you poison it? m.ApplyPoison(this, Poison.Greater);
     
  3. RedBeard
    Offline

    RedBeard Active Member

    Joined:
    May 19, 2013
    Messages:
    365
    Likes Received:
    72
    that is poison spit has chance to poison the player. Im referring to the spawning egg sac mobile, as well as the queen both start to lose hitpoints once the egg appears/hatches
     
  4. PyrO
    Offline

    PyrO Active Member

    Joined:
    Jan 27, 2015
    Messages:
    768
    Likes Received:
    38
    Tested the script and it works fine? I thought the ApplyPoison would be the other way around so that was my mistake ;)

    But yea they spawn fine and do not get damage over time.

    Also maybe a delay between each egg? :p spawned like 10 at once since high dex and a lot of hits
     
  5. RedBeard
    Offline

    RedBeard Active Member

    Joined:
    May 19, 2013
    Messages:
    365
    Likes Received:
    72
    I just retested it and it seems to be fine now. Must been something else. Thanx for your input, Ill see about a delay timer that might be needed, back at it, let's see what I come up with next :)
     
Similar Threads: Mobile spawns
Forum Title Date
Script Support Messing around on a T2A shard. How do I force mobiles to show their newer body values Nov 23, 2017
Script Support Using PlayerMobile instead of BaseCreature for NPC Oct 31, 2017
Script Support Bad Mobiles Oct 31, 2017
Script Support How to make a item execute a method that is made for a mobile? Oct 15, 2017
ServUO Tutorials Converting IDamageable to Mobile Oct 13, 2017
Script Support Need help with PlayerMobile Oct 8, 2017
Archived Bug Reports Crash Report Shadow Guard Mobile Sep 27, 2017