Skip to content

Commit af2d28c

Browse files
feat: is on combat condition (AscensionGameDev#2653)
* feat: is on combat condition * rename enum * rename strings
1 parent 50ad3d7 commit af2d28c

File tree

5 files changed

+62
-23
lines changed

5 files changed

+62
-23
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Intersect.Framework.Core.GameObjects.Conditions.ConditionMetadata;
2+
3+
public partial class CombatCondition : Condition
4+
{
5+
public override ConditionType Type { get; } = ConditionType.IsInCombat;
6+
}

Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ public enum ConditionType
3939
MapZoneTypeIs,
4040

4141
CheckEquipment,
42+
43+
IsInCombat,
4244
}

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_ConditionalBranch.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ ConditionalBranchCommand command
9696
var typeIndex = 0;
9797
foreach (var item in Strings.EventConditional.conditions)
9898
{
99-
if (item.Key == (int)Condition.Type)
99+
if (item.Key == Condition.Type)
100100
{
101101
cmbConditionType.SelectedIndex = typeIndex;
102102
break;
@@ -228,6 +228,9 @@ private void UpdateFormElements(ConditionType type)
228228
_variableControl.Show();
229229
break;
230230

231+
case ConditionType.IsInCombat:
232+
break;
233+
231234
default:
232235
throw new ArgumentOutOfRangeException();
233236
}
@@ -313,6 +316,9 @@ private void SetupFormValues(dynamic condition)
313316
_variableControl.SetupFormValues(variableIsCondition);
314317
break;
315318

319+
case CombatCondition _:
320+
break;
321+
316322
default:
317323
throw new ArgumentOutOfRangeException();
318324
}
@@ -398,6 +404,9 @@ private void SaveFormValues(dynamic condition)
398404
_variableControl.SaveFormValues(variableIsCondition);
399405
break;
400406

407+
case CombatCondition _:
408+
break;
409+
401410
default:
402411
throw new ArgumentOutOfRangeException();
403412
}
@@ -438,7 +447,7 @@ private void btnCancel_Click(object sender, EventArgs e)
438447
private void cmbConditionType_SelectedIndexChanged(object sender, EventArgs e)
439448
{
440449
var type = Strings.EventConditional.conditions.FirstOrDefault(x => x.Value == cmbConditionType.Text).Key;
441-
if (type < 4)
450+
if (type < ConditionType.HasItem)
442451
{
443452
type = 0;
444453
}
@@ -518,7 +527,6 @@ private void cmbConditionType_SelectedIndexChanged(object sender, EventArgs e)
518527
Condition = new SelfSwitchCondition();
519528
break;
520529

521-
522530
case ConditionType.VariableIs:
523531
Condition = new VariableIsCondition();
524532
SetupFormValues(Condition);
@@ -528,6 +536,10 @@ private void cmbConditionType_SelectedIndexChanged(object sender, EventArgs e)
528536
Condition = new TimeBetweenCondition();
529537
break;
530538

539+
case ConditionType.IsInCombat:
540+
Condition = new CombatCondition();
541+
break;
542+
531543
default:
532544
throw new ArgumentOutOfRangeException();
533545
}

Intersect.Editor/Localization/Strings.cs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using Intersect.Enums;
3+
using Intersect.Framework.Core.GameObjects.Conditions;
34
using Intersect.Framework.Core.GameObjects.Conditions.ConditionMetadata;
45
using Intersect.Framework.Core.GameObjects.Events;
56
using Intersect.Framework.Core.GameObjects.Items;
@@ -364,6 +365,11 @@ public static string GetEventConditionalDesc(CheckEquippedSlot condition)
364365
return EventConditionDesc.checkequippedslot.ToString(condition.Name);
365366
}
366367

368+
public static string GetEventConditionalDesc(CombatCondition condition)
369+
{
370+
return EventConditionDesc.Combat.ToString();
371+
}
372+
367373
public static string GetVariableComparisonString(VariableComparison comparison)
368374
{
369375
return "";
@@ -2461,27 +2467,28 @@ public partial struct EventConditional
24612467
{5, @"Does Not Equal"}
24622468
};
24632469

2464-
public static Dictionary<int, LocalizedString> conditions = new Dictionary<int, LocalizedString>
2470+
public static Dictionary<ConditionType, LocalizedString> conditions = new Dictionary<ConditionType, LocalizedString>
24652471
{
2466-
{0, @"Variable Is..."},
2467-
{4, @"Has item..."},
2468-
{5, @"Class is..."},
2469-
{6, @"Knows spell..."},
2470-
{7, @"Level or Stat is..."},
2471-
{8, @"Self Switch is..."},
2472-
{9, @"Power level is..."},
2473-
{10, @"Time is between..."},
2474-
{11, @"Can Start Quest..."},
2475-
{12, @"Quest In Progress..."},
2476-
{13, @"Quest Completed..."},
2477-
{14, @"No NPCs on Map..."},
2478-
{15, @"Gender is..."},
2479-
{16, @"Map is..."},
2480-
{17, @"Item Equipped is..."},
2481-
{18, @"Has X free Inventory slots..." },
2482-
{19, @"In Guild With At Least Rank..." },
2483-
{20, @"Map Zone Type is..." },
2484-
{21, @"Check Equipped Slot..." },
2472+
{ConditionType.VariableIs, @"Variable Is..."},
2473+
{ConditionType.HasItem, @"Has item..."},
2474+
{ConditionType.ClassIs, @"Class is..."},
2475+
{ConditionType.KnowsSpell, @"Knows spell..."},
2476+
{ConditionType.LevelOrStat, @"Level or Stat is..."},
2477+
{ConditionType.SelfSwitch, @"Self Switch is..."},
2478+
{ConditionType.AccessIs, @"Power level is..."},
2479+
{ConditionType.TimeBetween, @"Time is between..."},
2480+
{ConditionType.CanStartQuest, @"Can Start Quest..."},
2481+
{ConditionType.QuestInProgress, @"Quest In Progress..."},
2482+
{ConditionType.QuestCompleted, @"Quest Completed..."},
2483+
{ConditionType.NoNpcsOnMap, @"No NPCs on Map..."},
2484+
{ConditionType.GenderIs, @"Gender is..."},
2485+
{ConditionType.MapIs, @"Map is..."},
2486+
{ConditionType.IsItemEquipped, @"Item Equipped is..."},
2487+
{ConditionType.HasFreeInventorySlots, @"Has X free Inventory slots..." },
2488+
{ConditionType.InGuildWithRank, @"In Guild With At Least Rank..." },
2489+
{ConditionType.MapZoneTypeIs, @"Map Zone Type is..." },
2490+
{ConditionType.CheckEquipment, @"Check Equipped Slot..." },
2491+
{ConditionType.IsInCombat, @"Is in Combat" },
24852492
};
24862493

24872494
public static LocalizedString endrange = @"End Range:";
@@ -2660,6 +2667,8 @@ public partial struct EventConditionDesc
26602667

26612668
public static LocalizedString Class = @"Player's class is {00}";
26622669

2670+
public static LocalizedString Combat = @"Is in Combat";
2671+
26632672
public static LocalizedString contains = @"contains {00}";
26642673

26652674
public static LocalizedString equal = @"is equal to {00}";

Intersect.Server.Core/Entities/Events/Conditions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Intersect.Enums;
2+
using Intersect.Framework.Core;
23
using Intersect.Framework.Core.GameObjects.Conditions;
34
using Intersect.Framework.Core.GameObjects.Conditions.ConditionMetadata;
45
using Intersect.Framework.Core.GameObjects.Events;
@@ -511,6 +512,15 @@ public static bool MeetsCondition(
511512
return player.Map?.ZoneType == condition.ZoneType;
512513
}
513514

515+
public static bool MeetsCondition(
516+
CombatCondition condition,
517+
Player player,
518+
Event eventInstance,
519+
QuestDescriptor questDescriptor)
520+
{
521+
return player.CombatTimer > Timing.Global.Milliseconds;
522+
}
523+
514524
//Variable Comparison Processing
515525

516526
public static bool CheckVariableComparison(

0 commit comments

Comments
 (0)