Commit graph

2997 commits

Author SHA1 Message Date
Kamron Batman
f2ce860c18
feat: Adds Map.GetXByDistance (for tracking skill). Fixes negative range checks. (#2252)
### Summary

Adds `XInRangeByDistance` and `XInBoundsByDistance` methods to `Map.cs`:

**Item Distance Enumeration:**
```cs
ItemDistanceEnumerable<Item> GetItemsInRangeByDistance(Point3D p);
ItemDistanceEnumerable<Item> GetItemsInRangeByDistance(Point3D p, int range);
ItemDistanceEnumerable<T> GetItemsInRangeByDistance<T>(Point3D p) where T : Item;
ItemDistanceEnumerable<T> GetItemsInRangeByDistance<T>(Point3D p, int range) where T : Item;
ItemDistanceEnumerable<Item> GetItemsInRangeByDistance(Point2D p);
ItemDistanceEnumerable<Item> GetItemsInRangeByDistance(Point2D p, int range);
ItemDistanceEnumerable<T> GetItemsInRangeByDistance<T>(Point2D p) where T : Item;
ItemDistanceEnumerable<T> GetItemsInRangeByDistance<T>(Point2D p, int range) where T : Item;
ItemDistanceEnumerable<Item> GetItemsInRangeByDistance(int x, int y, int range);
ItemDistanceEnumerable<T> GetItemsInRangeByDistance<T>(int x, int y, int range) where T : Item;
ItemDistanceEnumerable<Item> GetItemsInBoundsByDistance(Rectangle2D bounds, , bool makeBoundsInclusive = false);
ItemDistanceEnumerable<T> GetItemsInBoundsByDistance<T>(Rectangle2D bounds, bool makeBoundsInclusive = false) where T : Item;
```

**Mobile Distance Enumeration:**
```cs
MobileDistanceEnumerable<Mobile> GetMobilesInRangeByDistance(Point3D p);
MobileDistanceEnumerable<Mobile> GetMobilesInRangeByDistance(Point3D p, int range);
MobileDistanceEnumerable<T> GetMobilesInRangeByDistance<T>(Point3D p) where T : Mobile;
MobileDistanceEnumerable<T> GetMobilesInRangeByDistance<T>(Point3D p, int range) where T : Mobile;
MobileDistanceEnumerable<Mobile> GetMobilesInRangeByDistance(Point2D p);
MobileDistanceEnumerable<Mobile> GetMobilesInRangeByDistance(Point2D p, int range);
MobileDistanceEnumerable<T> GetMobilesInRangeByDistance<T>(Point2D p) where T : Mobile;
MobileDistanceEnumerable<T> GetMobilesInRangeByDistance<T>(Point2D p, int range) where T : Mobile;
MobileDistanceEnumerable<Mobile> GetMobilesInRangeByDistance(int x, int y, int range);
MobileDistanceEnumerable<T> GetMobilesInRangeByDistance<T>(int x, int y, int range) where T : Mobile;
MobileDistanceEnumerable<Mobile> GetMobilesInBoundsByDistance(Rectangle2D bounds, bool makeBoundsInclusive = false);
MobileDistanceEnumerable<T> GetMobilesInBoundsByDistance<T>(Rectangle2D bounds, bool makeBoundsInclusive = false) where T : Mobile;
```

**Client Distance Enumeration:**
```cs
ClientDistanceEnumerable GetClientsInRangeByDistance(Point3D p);
ClientDistanceEnumerable GetClientsInRangeByDistance(Point3D p, int range);
ClientDistanceEnumerable GetClientsInRangeByDistance(Point2D p);
ClientDistanceEnumerable GetClientsInRangeByDistance(Point2D p, int range);
ClientDistanceEnumerable GetClientsInRangeByDistance(int x, int y, int range);
ClientDistanceEnumerable GetClientsInBoundsByDistance(Rectangle2D bounds, bool makeBoundsInclusive = false);
```

**Example Usage:**

How to use `minDistance` to terminate early when all subsequent mobiles in the iteration will be at an increasing min distance.

```csharp
var playerLocation = player.Location;
const int maxRange = 100;
const int maxMobiles = 12;

var closestMobiles = new SortedSet<Mobile>(Comparer<Mobile>.Create((x, y) =>
{
    var distX = x.GetDistanceToSqrt(playerLocation);
    var distY = y.GetDistanceToSqrt(playerLocation);

    int result = distX.CompareTo(distY);
    if (result == 0)
    {
        result = (x?.Serial ?? Serial.MinusOne).CompareTo(y?.Serial ?? Serial.MinusOne);
    }
    return result;
}));

int lastMinDistance = 0;

foreach (var (mobile, minDistance) in map.GetMobilesInRangeByDistance(playerLocation, maxRange))
{
    // Stop if we have enough and distance starts increasing
    if (closestMobiles.Count >= maxMobiles && minDistance > lastMinDistance)
    {
        break;
    }

    closestMobiles.Add(mobile);
    lastMinDistance = minDistance;
}

// Results are already ordered by proximity
foreach (var mobile in closestMobiles)
{
    var actualDistance = mobile.GetDistanceToSqrt(playerLocation);
    Console.WriteLine($"{mobile.Name}: ActualDist={actualDistance:F2}");
}
```
2025-11-28 10:57:54 -08:00
Kamron Batman
d3fdb180b3
fix: Fixes searching multis/clients. Adds missing map enumeration tests (#2278)
> [!IMPORTANT]
> **Dev Note:** This is an **important** patch as the bug could lead to major issues like:
> * Multis/Players disappearing from view or not being counted during game logic.
> * World processes (e.g., area checks, targeting) failing to detect entities correctly.
> * General stability and correctness concerns for core map functionality.
>
> **Important Breaking Change**: Multis now properly use the map link list. This means modifying a multi while iterating will cause the server to crash. The crash _is expected_. Please modify/fix code accordingly to create a list using `PooledRefQueue` or `PooledRefList` instead of moving/deleting multis while inside the foreach.

### Summary

* Fixes a bug where deleting/moving a multi (boat/house) in some circumstances can use undefined behavior due to unsafe changes to List<BaseMulti>
* Fixes a bug where Multis may not be considered while searching due to a bug causing the sector search to end early.
2025-11-27 11:59:47 -08:00
Kamron Batman
5aed018232
chore: Update README with logo link and image sources 2025-11-25 20:05:05 -08:00
Kamron Batman
c5bbe0bc90
chore: Updates README.md to use stable CDN links for images. 2025-11-25 17:35:22 -08:00
Kamron Batman
7bd5a853a3
feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257)
> [!IMPORTANT]
> **Developer Note**
> THIS IS A BREAKING CHANGE TO THE NEW API GUMP.
> Please give us feedback in [discord ](https://muo.gg/discord) if you have issues, need help, or have ideas for a better API change!

### Summary

* Adds support for size/style to dynamic/static builder.
* Drastically simplifies the dynamic/static builder api for AddHtml.
* Cleans up some legacy gump files.
2025-11-23 11:35:31 -08:00
Kamron Batman
ea86d5b2a6
chore: Adds Debian 13 to CI/CD (#2277) 2025-11-23 10:09:42 -08:00
Bohica
dfb83cda13
fix: Fixes priced healer resurrection when not choosing the correct option (#2276) 2025-11-23 09:58:33 -08:00
Kamron Batman
4836bff5eb
fix: Eliminates List allocations in various places. (#2158) 2025-11-16 18:33:53 -08:00
Kamron Batman
6f64cddd0b
feat: Optimizes HTML Escape (#2273)
### Summary

Optimizes HTML escaping by using a vectorized search.
2025-11-16 10:32:29 -08:00
Bohica
ee1a40bb51
fix: Fixes movement pathing while in combat (#2271) 2025-11-16 10:14:06 -08:00
Bohica
051f22ff93
fix: Fixes vendor look spam (#2269) 2025-11-16 10:12:12 -08:00
Bohica
5e65f9f0b2
fix: Fixes descending comparer in admin gump (#2272) 2025-11-16 10:09:44 -08:00
Bohica
6cabac5a4f
fix: Fixes pets from attacking themselves (Again) (#2267) 2025-11-15 14:21:18 -08:00
Bohica
5667017874
fix: Fixes pets from attacking themselves (#2265)
### Summary

Stops pets from attacking themselves.
2025-11-15 10:15:10 -08:00
Kamron Batman
6f5b7f7a6b
fix: Fixes SpanWriter/SpanReader tests (#2263) 2025-11-13 00:00:19 -08:00
Kamron Batman
68caaab92c
fix: Makes SpanWriter/SpanReader exceptions clearer (#2262) 2025-11-12 23:34:13 -08:00
Kamron Batman
5d920a25b1
chore: Updates .NET reference material to 10 (#2261) 2025-11-12 23:03:14 -08:00
Bohica
c308a3baad
fix: Fixes timer leak in BaseCamp (#2259) 2025-11-12 09:49:35 -08:00
Kamron Batman
3a3f5ee518
feat: Adds .NET 10 / C# 14 support. (#2258)
### Summary
* Adds .NET 10 support
* Bumps to C# 14
2025-11-11 11:26:34 -08:00
Copilot
fbf8497c59
fix: Fix PlantSystem serialization of LeftSeeds and LeftResources at zero (#2255)
* Initial plan

* Add SerializableFieldDefault attributes for LeftSeeds and LeftResources

This fixes the serialization bug where _leftSeeds and _leftResources were initialized to 8 in the constructor but didn't serialize when their value was 0. Upon deserialization, the constructor would run again and reset these values back to 8.

The SerializableFieldDefault attributes tell the serialization system that the default value is 8, so it will properly serialize 0 values and maintain the correct state across server restarts.

Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com>

* Update ShouldSerialize methods to check against default value

Changed ShouldSerializeLeftSeeds() and ShouldSerializeLeftResources() to check if the value is != 8 (the default) instead of != 0. This ensures that only non-default values are serialized, following the same pattern used in BaseWeapon.cs and other classes with SerializableFieldDefault attributes.

Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com>
2025-10-31 00:53:47 -07:00
Kamron Batman
df171926bb
fix: Fixes potential notoriety caching issue in Mobile.cs (#2251)
Replaces the 2D packet cache with a simpler one outlining the packet flag changes
2025-09-11 06:32:48 -07:00
Kamron Batman
641a3eb1f8
fix: Updates BOB/BOD gumps to the new API (#2250)
### Summary

* Moves BOBGump to DynamicGump.
* BOBGump no longer creates a whole new gump context object on every send.
* Moves BODBuyGump to StaticGump.
2025-09-07 12:50:20 -07:00
Kamron Batman
340acafcb3
fix: Fixes mining/lumberjacking multi-harvest (#2249) 2025-08-20 15:30:04 -07:00
Kamron Batman
bbb7dc2294
fix: Fixes dropping a stack of scrolls on a spellbook (#2248) 2025-08-09 20:55:36 -07:00
Kamron Batman
52e309ef95
chore: Updates readme files (#2247) 2025-07-27 11:04:32 -07:00
Bohica
d6bb8316d0
feat: Refactors A* Movement to use PriorityQueue (#2244)
### Summary

* Replaces the node chain with a PriorityQueue.
* Performance difference is up to 3x faster.

### Benchmarks
```cs
| Method              | Mean     | Error     | StdDev    | Gen0   | Allocated |
|-------------------- |---------:|----------:|----------:|-------:|----------:|
| FastAStar_PQueue    | 2.112 us | 0.0186 us | 0.0165 us | 0.0038 |      64 B |
| FastAStar_NodeChain | 6.430 us | 0.0800 us | 0.1807 us |      - |      64 B |
```

### Video

https://github.com/user-attachments/assets/3edd2524-5146-4775-be45-3516f0b01c27
2025-07-26 15:53:06 -07:00
Bohica
6938735113
fix: fixes movement jitter for non-AOS (#2245) 2025-07-26 10:21:36 -07:00
Bohica
f59605190c
fix: fixes mobiles pathing home after combat (#2246) 2025-07-26 10:11:31 -07:00
Kamron Batman
fa0b67ec29
fix: Optimizes items to use default weights. (Part 4) (#2243) 2025-07-24 23:29:29 -07:00
Kamron Batman
40ba85d7b8
fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
Kamron Batman
2c5441731e
fix: Optimizes items to use default weights. (Part 2) (#2241) 2025-07-24 15:41:44 -07:00
Kamron Batman
2eba2868a6
fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
Kamron Batman
c2e44a58f6
fix: Moves container enumerables to Item. (#2238) 2025-07-24 14:26:35 -07:00
Kamron Batman
1e2f4b1171
fix: Fixes tentacles not getting removed from harrower's list (#2239) 2025-07-24 14:18:16 -07:00
Kamron Batman
2df62fba5a
chore: Bumps various dependencies (#2237) 2025-07-22 16:04:04 -07:00
Bohica
173037ae77
fix: Prevents recursion in BaseCreature.DoHarmful() (#2202) 2025-07-22 16:01:56 -07:00
Kamron Batman
8a118170e7
fix: Fixes treasure map chest crash from null guardians (#2236) 2025-07-22 16:01:27 -07:00
Kamron Batman
aab731ed96
feat: Overhauls AI (Speech/Movement) (#2232)
### Summary

* Refactors AI so it is easier to read and maintain
* Fixes NPC speed issues
* Fixes pet sector AI issue that was causing stuttering
* Fixes direction snapping for Melee/Mage AI
* Refactors pet orders
* Refactors speech commands
* Removes scale speed by dex for HS+ (it was a stupid feature anyways)
2025-07-18 22:39:57 -07:00
Kamron Batman
f89150735e
fix: Consolidates debug check messages for AI and adds debounce (#2235) 2025-07-18 18:08:03 -07:00
Kamron Batman
8f88de68a7
fix: Standardizes the variables for AI (#2234) 2025-07-18 17:50:32 -07:00
Kamron Batman
416e1be735
fix: Adds GetDistanceToSqrt for Point3D and centralizes all the calls (#2233) 2025-07-18 09:24:41 -07:00
Bohica
2086e9b292
fix: Fixes direction snapping when pathing to combatant for MeleeAI (#2187)
* fix: Fixes direction snapping when pathing to combatant

* Fixes speed when exiting out of flee action
2025-07-16 21:55:47 -07:00
Bohica
c1af2ade83
fix: Fixes pet validation for resurrection spell (#2197) 2025-07-16 21:34:43 -07:00
Bohica
5f0561b7fc
feat: New Jail System (#2215)
New Jail System for MUO
----------------------------

Commands:
[jail [player] [reason] - Jail with time escalation per offense (5 to 120 minutes, GM only)
[unjail [player] - Manual release from jail regardless of time (GM only)
[jailinfo [player] - Check jail status and history (GM only)
[jailrecord - Checks their own jail record stats (player access)

Jail/Unjail can be found in the client view of a player in Admin Gump
![Screenshot 2025-06-12 030226](https://github.com/user-attachments/assets/a9f1a736-0316-464c-8958-c589ea0a1dcb)

Jail record gump, invoked with [jailrecord (30 second cooldown)
![Screenshot 2025-06-12 030320](https://github.com/user-attachments/assets/c19b3e76-3042-48ae-a00d-c70ef564bc84)
2025-07-16 20:41:21 -07:00
Bohica
c2c486c06e
fix: Adds body parts to headless one loot (#2225) 2025-07-07 18:54:18 -07:00
Felipe Maya Muniz
4209f7ea16
fix: Add properties for crafting ranged weapons with colored logs (#2222) 2025-07-07 18:51:08 -07:00
Kamron Batman
55d653d752
fix: Fixes skill cooldown for some target skills (#2231)
### Summary

Stealing, Detect Hidden, and Begging will now give credit for the time it took the player to use the targeter against the total skill cooldown. So if the player takes longer than 10s to target, then they can use a skill again immediately.

> [!NOTE]
> This does not change the requirement that players can no longer stack target these skills.
2025-07-06 22:50:40 -07:00
Felipe Maya Muniz
c0948fd0e2
feat: Adds ClearXY command (#2229) 2025-07-06 20:15:50 -07:00
Kamron Batman
edf16effa0
fix: Fixes container not properly consuming in some cases (#2230) 2025-07-06 10:23:37 -07:00
Bohica
8997130e57
fix: fixes death explosion trigger on death (#2228) 2025-07-03 09:47:52 -07:00