Commit graph

629 commits

Author SHA1 Message Date
Anders Jenbo
bf706f2fbb 🐛 Fix Phasing not working in Lazarus' camber
Previously an improper check was being done to see if the player was
located on the 3 teleporting pads in the level. Even if fixng this the
spell would not work correctly if the layer was standing on the pads
when casting the spell.

Simply use TARGET_BOTH to indicate that it should not be random and send
the player to the given destination
2021-08-28 03:43:59 +02:00
Anders Jenbo
4fd2e2dc97 🐛 Fix Phasing teleporting to invalid locations
Phasing could end up attempting to teleport to hunreds of random
location and still fail to find a valid target and send the player in to
a wall or outside the map.

This is fixed by first finding all valid locations within range and then
picking one of them at random.

Valid targets is a 13x13 area around the player minus the inner 7x7

In total there can be no more then 120 valid tiles and on average there
should be 75 avalible.
2021-08-28 03:43:59 +02:00
Robin
62a33c61d9
objects: deduplicate logic in OperateShrineGloomy using ForEachItem function 2021-08-27 11:41:45 +02:00
BC Ko
4df798808e
2435 refactor global variable Items part 2 (#2673) 2021-08-26 08:06:48 +02:00
Anders Jenbo
96b19ca8d5 Set _micaster type to mienemy_type
Rino never made use of the player id, so no reason to abuse _micaster
2021-08-23 10:51:06 +02:00
Anders Jenbo
3df8af0e9d Apply missile_id to _mitype 2021-08-21 09:10:53 +02:00
BC Ko
40c804c0ba Replace QuestStatus() with IsAvailable() in QuestStruct 2021-08-19 02:12:20 +02:00
ephphatha
96e3ce6ea4 ensure std::min call uses correct types, cast result explicitly
No idea why template deduction was failing on 3ds builds only... It was using the context of the return type to deduce what the template arguments should be? Hopefully specifying the template explicitly works.
2021-08-12 13:38:05 +02:00
ephphatha
8f2e94ae4d Use unsigned types for player experience and related values 2021-08-12 13:38:05 +02:00
ephphatha
0575716eac Rename UiFlags members to group related options 2021-07-31 20:22:40 +02:00
ephphatha
4ad53232a0 Convert the UiFlags enum to a scoped enum type
Replace operator&& with named function
2021-07-31 20:22:40 +02:00
Anders Jenbo
ab8afa7cd7
Fix edge cases in mouse action tracking code (#2452)
Fixes #2431

Also:
- Track spell targets
- Merge repeat walk in to the new repeat action code
- Avoid time based repeats (use action frame instead)
2021-07-25 03:57:42 +00:00
Anders Jenbo
9c4e34f988 Player by reference 2021-07-20 01:35:56 +02:00
Anders Jenbo
f0a7a5c989 🎨 Apply code style 2021-07-19 05:44:20 +02:00
Anders Jenbo
069249f318 🚚 Move local function to anonymous namespace i-p 2021-07-19 05:44:20 +02:00
Anders Jenbo
0889780923 Remove more usage of miniwin types 2021-07-18 02:11:58 +02:00
Anders Jenbo
b591824182 💚 Fix NOSOUND build 2021-07-17 16:44:32 +02:00
Anders Jenbo
9264ad4b89 Use IsTileNotSolid() in place of !nSolidTable[dPiece[][]] 2021-07-17 03:57:26 +02:00
FluffyQuack
ba60907853
Hold mouse button to keep attacking (Diablo 2-style) (#2349) 2021-07-16 15:01:01 +01:00
Anders Jenbo
4cdcff90db 🐛 Fix Zhar state not being set when triggered
Instead the first players golem was reset
2021-07-15 19:48:55 +02:00
Anders Jenbo
77b72da276 ♻️Use monster by reference when possible 2021-07-14 20:22:35 -07:00
ephphatha
a842d07dab Combine duplicated initialisation logic for quest book objects 2021-07-11 05:09:13 -07:00
ephphatha
cc3572af81 Update BookLever related functions to use Rectangle.
This is mainly to help isolate functionality in the hopes of adding a specialised object class for this type of object as suggested by @julealgon in https://github.com/diasurgical/devilutionX/pull/2344#discussion_r667415019

For example, AddSCambBook performs almost the same logic but uses var6 instead of var8 for the trigger condition/identifier.
2021-07-11 05:09:13 -07:00
ephphatha
e25d287ba9 Move SetObjMapRange to a member function
Due to the way this function is used it was easiest to also change ObjIndex to return a reference to the object instead of the index. Also added an explicit conversion from Size to Displacement to make one of the uses slightly cleaner to express.
2021-07-10 19:11:30 -07:00
ephphatha
ea63eecd17 Break out crux search logic from BreakCrux/SyncCrux
Really blanking on a good name for that function. Might not even be necessary given I think the BreakCrux use is effectively dead code, it could be rolled back into SyncCrux.
2021-07-10 16:40:12 -07:00
ephphatha
a1d4bdc98d Object by reference for BreakCrux
Some common code that searches for the crux object in the active objects list, can extract that into a dedicated function.
2021-07-10 16:40:12 -07:00
Andrew James
af60158274
Object by reference in SyncObjectAnimation functions (#2344) 2021-07-10 14:03:44 +02:00
Anders Jenbo
730c0750e7 Apply clang-tidy to code 2021-07-09 16:54:01 -07:00
ephphatha
74584bb02a Remove doorSetDirection temporary
Instead calling the function directly makes it easier to see common code patterns

DoorSet really only cares if the door opens to the left or the right

Can take a bool instead of the object type.
2021-07-10 01:03:24 +02:00
ephphatha
da4ae52886 Move objects_set_door_piece next to DoorSet
these two functions are always called together, can probably be combined or have a wrapper introduced

Move SyncL1Doors to near declarations of other SyncDoors functions
2021-07-10 01:03:24 +02:00
ephphatha
b0023be41e Remove unnecessary temporaries from SyncL3Doors
Simplify checks in SyncL3Doors

The function is only called with objects of type L3LDOOR or L3RDOOR so there's no real need to check again.

Take door by reference in SyncL3Doors

Removes one use of the Objects global.

Door by reference 2, SyncL2Doors

Simplify logic in SyncL2Doors to match L3Doors

Almost the same code, can probably be combined to a single function with appropriate parameters.

Use Point in DoorSet params

Use switch in DoorSet

Instead of a whole bunch of if statements where only one can be true

Replace object index with type in DoorSet

This function doesn't need any other object property. Still references the dPiece global unfortunately.

SyncL1Doors door by reference

Replace code that mutates a copy of door position with Direction

Inline if/else statement for L1LDOOR

Only difference is the value of the second parameter
2021-07-10 01:03:24 +02:00
ephphatha
36ff5578fd Refactor LoadMapObjects/LoadMapObjs to take Point instead of int x/y 2021-07-09 18:00:08 +02:00
ephphatha
3a517048f7 Refactor ObjIndex to take Point instead of int x/y
Also updated declaration of temporary/local variables to match
convention. This includes inlining int oi in LoadMapObjects as this
matches the way SetOBjMapRange is called in other areas.
2021-07-09 17:59:07 +02:00
ephphatha
19ae61811f Refactor AddObject to take Point instead of int x/y 2021-07-09 17:58:34 +02:00
ephphatha
e4b434b2ef Refactor SetupObject to use Point 2021-07-09 17:57:45 +02:00
ephphatha
288d691678 Refactor OperateShrineTown to use Point
Also added documentation about what the function does.
2021-07-09 17:57:01 +02:00
ephphatha
c2cf2f8b59 Refactor OperateShrineSparkling to use Point
Also added documentation about what the function does.
2021-07-09 17:56:27 +02:00
ephphatha
61a2cf9ac8 Refactor OperateShrineOily to use Point
Also added documentation about what the function does.
2021-07-09 17:55:57 +02:00
ephphatha
bc386a4701 Refactor OperateShrineDivine to use Point
Also added documentation about what the function does.
2021-07-09 17:55:20 +02:00
ephphatha
73cf62179c Refactor ObjSetMini to use Point 2021-07-09 18:52:51 +10:00
ephphatha
e668d215f2 Refactor objects_set_door_piece to use a Point param 2021-07-09 18:52:51 +10:00
ephphatha
cbe542c52e Refactor Add*Door functions to use more descriptive parameters 2021-07-09 18:52:50 +10:00
ephphatha
a3d155f552 Remove unnecessary temporaries from Obj_Light
This function can use Point member functions to perform the logic that determines when to show lights.
2021-07-09 18:52:50 +10:00
ephphatha
6f40f0dd88 Refactor ObjSetMicro to take a Point parameter 2021-07-09 18:52:50 +10:00
Anders Jenbo
903d4bd2e1 Scope all for loops
This caused 7 of the loops to be rewriteen using range by clang-tidy
2021-07-08 08:14:03 -07:00
Anders Jenbo
467b74dc06 Rename object globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
9b8bf92575 Rename quest globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
96bf75b502 Rename player globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
c8870dbd1f Rename item globals 2021-07-08 02:01:14 -07:00