Skip to content

Commit

Permalink
Fixed abilityuser index out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
XenEmpireAdmin committed Jun 4, 2017
1 parent 5440b07 commit 292abd2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 80 deletions.
Binary file modified Assemblies/AbilityUser.dll
Binary file not shown.
Binary file modified Source/.vs/JecsTools/v15/.suo
Binary file not shown.
170 changes: 91 additions & 79 deletions Source/AllModdingComponents/CompAbilityUser/CompAbilityUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,96 +276,108 @@ public void UpdateAbilities()
public IEnumerable<Command_PawnAbility> GetPawnAbilityVerbs()
{
//Log.ErrorOnce("GetPawnAbilityVerbs Called", 912912);
List<Verb_UseAbility> temp = new List<Verb_UseAbility>();
temp.AddRange(this.AbilityVerbs);
for (int i = 0; i < this.AllPowers.Count; i++)
//Log.ErrorOnce("GetPawnAbilityVerbs Called", 912912);
if (this.AbilityVerbs != null && this.AbilityVerbs.Count > 0)
{
int j = i;
Verb_UseAbility newVerb = temp[j];
VerbProperties_Ability newVerbProps = newVerb.UseAbilityProps;
newVerb.caster = this.AbilityUser;
newVerb.verbProps = temp[j].verbProps;

Command_PawnAbility command_CastPower = new Command_PawnAbility(this, this.AllPowers[i])
{
verb = newVerb,
defaultLabel = this.AllPowers[j].powerdef.LabelCap
};


//GetDesc
StringBuilder s = new StringBuilder();
s.AppendLine(this.AllPowers[j].powerdef.GetDescription());
s.AppendLine(PostAbilityVerbCompDesc(newVerb.UseAbilityProps));
command_CastPower.defaultDesc = s.ToString();
s = null;


command_CastPower.targetingParams = this.AllPowers[j].powerdef.MainVerb.targetParams;
//command_CastPower.targetingParams = TargetingParameters.ForAttackAny();

//if (newVerb.useAbilityProps.AbilityTargetCategory == AbilityTargetCategory.TargetSelf)
//{
// command_CastPower.targetingParams = TargetingParameters.ForSelf(this.abilityUser);
//}
//else
//{
// command_CastPower.targetingParams = TargetingParameters.
//}
command_CastPower.icon = this.AllPowers[j].powerdef.uiIcon;
//string str;
//if (FloatMenuUtility.GetAttackAction(this.abilityUser, LocalTargetInfo.Invalid, out str) == null)
//{
// command_CastPower.Disable(str.CapitalizeFirst() + ".");
//}
command_CastPower.action = delegate (Thing target)
{
Action attackAction = CompAbilityUser.TryCastAbility(this.AbilityUser, target, this, newVerb, this.AllPowers[j].powerdef as AbilityDef);
if (attackAction != null)
{
if (CanOverpowerTarget(this.AbilityUser, target, this.AllPowers[j].powerdef as AbilityDef)) attackAction();
}
};
if (newVerb.caster.Faction != Faction.OfPlayer)
List<Verb_UseAbility> temp = new List<Verb_UseAbility>();
temp.AddRange(this.AbilityVerbs);
if (this.allPowers != null && this.allPowers.Count > 0)
{
command_CastPower.Disable("CannotOrderNonControlled".Translate());
}
string reason = "";
if (newVerb.CasterIsPawn)
{
if (newVerb.CasterPawn.story.WorkTagIsDisabled(WorkTags.Violent) && this.AllPowers[j].powerdef.MainVerb.isViolent)
for (int i = 0; i < this.allPowers.Count; i++)
{
command_CastPower.Disable("IsIncapableOfViolence".Translate(new object[]
int j = i;
Verb_UseAbility newVerb = temp[j];
VerbProperties_Ability newVerbProps = newVerb.UseAbilityProps;
newVerb.caster = this.AbilityUser;
newVerb.verbProps = temp[j].verbProps;

Command_PawnAbility command_CastPower = new Command_PawnAbility(this, this.AllPowers[i])
{
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.CasterPawn.drafter.Drafted)
{
command_CastPower.Disable("IsNotDrafted".Translate(new object[]
verb = newVerb,
defaultLabel = this.AllPowers[j].powerdef.LabelCap
};


//GetDesc
StringBuilder s = new StringBuilder();
s.AppendLine(this.AllPowers[j].powerdef.GetDescription());
s.AppendLine(PostAbilityVerbCompDesc(newVerb.UseAbilityProps));
command_CastPower.defaultDesc = s.ToString();
s = null;


command_CastPower.targetingParams = this.AllPowers[j].powerdef.MainVerb.targetParams;
//command_CastPower.targetingParams = TargetingParameters.ForAttackAny();

//if (newVerb.useAbilityProps.AbilityTargetCategory == AbilityTargetCategory.TargetSelf)
//{
// command_CastPower.targetingParams = TargetingParameters.ForSelf(this.abilityUser);
//}
//else
//{
// command_CastPower.targetingParams = TargetingParameters.
//}
command_CastPower.icon = this.AllPowers[j].powerdef.uiIcon;
//string str;
//if (FloatMenuUtility.GetAttackAction(this.abilityUser, LocalTargetInfo.Invalid, out str) == null)
//{
// command_CastPower.Disable(str.CapitalizeFirst() + ".");
//}
command_CastPower.action = delegate(Thing target)
{
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.ability.CanFire)
{
command_CastPower.Disable("AU_PawnAbilityRecharging".Translate(new object[]
Action attackAction = CompAbilityUser.TryCastAbility(this.AbilityUser, target, this,
newVerb,
this.AllPowers[j].powerdef as AbilityDef);
if (attackAction != null)
{
newVerb.CasterPawn.NameStringShort
}));
}
//This is a hook for modders.
else if (!CanCastPowerCheck(newVerb, out reason))
{
command_CastPower.Disable(reason.Translate(new object[]
if (CanOverpowerTarget(this.AbilityUser, target,
this.AllPowers[j].powerdef as AbilityDef)) attackAction();
}
};
if (newVerb.caster.Faction != Faction.OfPlayer)
{
newVerb.CasterPawn.NameStringShort
}));
command_CastPower.Disable("CannotOrderNonControlled".Translate());
}
string reason = "";
if (newVerb.CasterIsPawn)
{
if (newVerb.CasterPawn.story.WorkTagIsDisabled(WorkTags.Violent) &&
this.AllPowers[j].powerdef.MainVerb.isViolent)
{
command_CastPower.Disable("IsIncapableOfViolence".Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.CasterPawn.drafter.Drafted)
{
command_CastPower.Disable("IsNotDrafted".Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
else if (!newVerb.ability.CanFire)
{
command_CastPower.Disable("AU_PawnAbilityRecharging".Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
//This is a hook for modders.
else if (!CanCastPowerCheck(newVerb, out reason))
{
command_CastPower.Disable(reason.Translate(new object[]
{
newVerb.CasterPawn.NameStringShort
}));
}
}
yield return command_CastPower;
}
}
yield return command_CastPower;
temp = null;
}
temp = null;
yield break;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7f494f8fbd8caaa123541373d2094a7dc15ff438
73a1343a1e53c14aa2de2bbadb67a06fc09baf37
Binary file not shown.

0 comments on commit 292abd2

Please sign in to comment.