Talk:Overloaded

From Caves of Qud Wiki
Jump to navigation Jump to search

Notes from decompilation

[1]

if (IsPowerLoadSensitive && E.Subject == ParentObject && E.BaseDamage != "0")
			{
				int num = MyPowerLoadBonus(); // +=300 if overloaded, =100 by default {{Code Reference|class=IActivePart.cs|method=MyPowerLoadBonus}}
				if (num != 0)
				{
					E.GetDamageRoll()?.AdjustResult(num);
				}
			}
			return base.HandleEvent(E); load min value baseline 100 divisor 150 

IsPowerLoadSensitive is true by default, the only ones that are specified to be false is hypertractor, ganglionic teleprojector, and the overloaded laser pistol (presumably because it is already overloaded). i dont understand AdjustResult, but it always seems to add a +2 to the original damage.

[2]

int @for = GetOverloadChargeEvent.GetFor(Object, Amount);
			if (@for > 0)
			{
				GameObject gameObject = Object.Equipped ?? Object.Implantee ?? Object.InInventory;
				Object.TemperatureChange(1 + @for / 100, gameObject);
				gameObject?.TemperatureChange(1 + @for / 100, gameObject);
				if ((1 + @for / 10).in10000() && Object.ApplyEffect(new Broken(FromDamage: false, FromExamine: false, FromOverload: true)))
				{
					Messaging.XDidY(Object, "overheat", null, "!", null, null, null, UseFullNames: false, IndefiniteSubject: false, gameObject, null, DescribeSubjectDirection: false, DescribeSubjectDirectionLate: false, AlwaysVisible: false, FromDialog: false, UsePopup: false, gameObject);
				}
			}

I have no idea what number the event here is returning X_X if i learn what @for is here, I would be able to get everything. Teamtoto (talk) 02:19, 2 August 2021 (UTC)

  • The name of the variable you're decompiling as @for is just charge. It's the amount of charge to use for heat/breakage calculations. GetOverloadChargeEvent allows that to be modified; it's unused at the moment and just passes back the actual amount of charge consumed.
  • IsPowerLoadSensitive is a field on IActivePart and only controls applicability of ModOverloaded to IActivePart inheritors; the actual control is IsOverloadableEvent, which IActivePart responds to in a fashion defined by IsPowerLoadSensitive but can also be responded to independently, and two parts do so, Teleprojector and GeomagneticDisk. (So the indication in the page that ganglionic teleprojectors can't be overloaded is incorrect, and it's not that IsPowerLoadSensitive is set to false for it, it's that that field doesn't even exist in Teleprojector because Teleprojector is not an IActivePart.)
  • FWIW I don't think becoming tech scannable or EMPable is worth highlighting; it's not clear to me that there's a case where ModOverloaded could be applied where those weren't already the case.
  • Also FWIW, the original line for that message is Messaging.XDidY(Object, "overheat", terminalPunctuation: "!", SubjectPossessedBy: who, UseVisibilityOf: who);. What the decompiler is doing to it is pretty hideous. --Chaos (talk) 03:30, 2 August 2021 (UTC)
  • Heating the player

    If I read the above correctly, it looks as though overloaded device raises the temperature of the wearer/wielder/carrier as well as itself. Is that correct? Wondering if this effect could be useful in a cold environment... Alephander (talk) 00:09, 1 March 2024 (UTC)

    More Notes

    Looking at the decompilation, it seems like the only material effect of Overloaded is adding 300 to the power load level of the object:

    public override bool HandleEvent(GetPowerLoadLevelEvent E)
        {
          E.Level += 300;
          return base.HandleEvent(E);
        }
    

    GameObject has a method GetPowerLoadLevel(), which just calls GetPowerLoadLevelEvent.GetFor with Level empty, as seen below:

     public static int GetFor(GameObject Object, int Level = 100)
        {
          bool flag = true;
          if (flag && GameObject.validate(ref Object) && Object.HasRegisteredEvent("GetPowerLoadLevel"))
          {
            Event E = Event.New("GetPowerLoadLevel");
            E.SetParameter(nameof (Object), (object) Object);
            E.SetParameter(nameof (Level), Level);
            flag = Object.FireEvent(E);
            Level = E.GetIntParameter(nameof (Level));
          }
          if (flag && GameObject.validate(ref Object) && Object.WantEvent(GetPowerLoadLevelEvent.ID, MinEvent.CascadeLevel))
          {
            GetPowerLoadLevelEvent E = GetPowerLoadLevelEvent.FromPool();
            E.Object = Object;
            E.Level = Level;
            Object.HandleEvent<GetPowerLoadLevelEvent>(E);
            Level = E.Level;
          }
          return Level;
        }
      }
    

    So the default power load level is 100, meaning Overloaded multiplies it by 4 (I can't find anything that calls GetFor with anything other than the default Level). This mostly just multiplies charge usage by 4 (though I haven't verified this in general, it's the case everywhere I've checked). It seems like most things that use it go through XRL.World.IComponent's MyPowerLoadBonus(), which gives a bonus of (Load - Baseline)/Divisor, with Baseline being default 100 and Divisor being default 150. So the default for a power load level of 400 gives a bonus of 2. The bonus seems to be usually additive (added to radius of light sources, strength of reality stabilization, and I cannot for the life of me decipher the missile weapon damage adjustment code but it looks like it adds to that as well, and empirically it seems to add 2 to the damage roll). It gets more complicated for stuff like gas generation (seems to add 30% to density?) and so on.

    Illuminatiswag (talk) 04:14, 17 September 2021 (UTC)

    1. XRL.World.Parts.EnergyAmmoLoader.cs
    2. XRL.World.ChargeUsedEvent.cs