Skip to content

Unification of spell casts #3333

@Svjatovit

Description

@Svjatovit

Implement a success_roll section for spells similar to potency_roll in lib\cfg\spells.xml. This section is located at the same level in the spell description as potency_roll, and the parameters are identical. Use ESpell::kChillTouch as a model spell for parsing and storing power roll parameters.

Move the calculation of success_roll and potency_roll to the function int CallMagic(CharData *caster, CharData *cvict, ObjData *ovict, RoomData *rvict, ESpell spell_id, int level) from src/gameplay/magic/magic_utils.cpp. Optimize the calculation placement; there's no point in calculating rolls if the spell won't be cast at all. Declare a struct CastRollResult structure. It includes the spell_id, the caster level passed to CallMagic, and the results of both rolls.

Change the function signatures in src/gameplay/magic/magic.cpp:
int CallMagicToArea(CharData *ch, CharData *victim, RoomData room, ESpell spell_id, int level)
int CallMagicToGroup(int level, CharData ch, ESpell spell_id)
int CallMagicToRoom(int/
level
/, CharData *ch, RoomData *room, ESpell spell_id)
int CastToSingleTarget(int level, CharData *caster, CharData *cvict, ObjData *ovict, ESpell spell_id)
so that instead of level and spell_id, they all accept the CastRollResult result. In all cases, the result should be the last parameter to ensure consistent signatures.

For CallMagicToArea, it will likely be necessary to implement an additional wrapper that calculates the roll results so that it can be called in
void HandleRoomAffect(RoomData *room, CharData *ch, const Affect::shared_ptr &aff) from src/gameplay/magic/magic_rooms.cpp, without putting the roll calculation in HandleRoomAffect. Alternatively, move the CastRollResult calculation to a separate function and call it within HandleRoomAffect.

The purpose of the changes is to unify the checks for the basic success/failure roll of a spell and its power, and collect them in one place. From now on, only interpret the roll results in the context of a specific spell.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions