Zap traps not damaging player

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
pango
Posts: 2164
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Zap traps not damaging player

Post by pango » Wed Mar 11, 2020 11:03 pm

Dungeons can cast spells at the player, like some mausoleum entrances.
While a flash can be seen and a zap can be heard (the shock missile is harder to see, but it can be observed in the editor), I don't remember having my health damaged by one such trap.

I'm not entirely sure why; I suspect that sometimes the player capsule is not on the trajectory of the missile, or already collides with the spawned missile, but even when the colliders are correctly aligned, they get thru one another.
zaptrap overlap.jpg
zaptrap overlap.jpg (117.83 KiB) Viewed 159 times
I suspect the issue is that such "environmental" missiles use the player as the caster, so the player is excluded from collisions, but I've yet to verify this hypothesis (what caster can be used?)
PS I just proved the hypothesis by removing the two lines that exclude collisions with the player if (s)he is the caster. Still don't know what caster to use however.
Attachments
SAVE563.zip
(225.11 KiB) Downloaded 2 times
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
pango
Posts: 2164
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Zap traps not damaging player

Post by pango » Thu Mar 12, 2020 11:10 pm

pango wrote:
Wed Mar 11, 2020 11:03 pm
Still don't know what caster to use however.
I assume the goal was to cast environment spells of the same "level" as the player; However using the player as the caster here is incorrect in several ways (beside above problem, I assume the player could get damage say from his own spell reflection).
I was thinking about a fix that would involve create a "clone" of the player, delegating its properties to the player object but discarding all mutations (like a read only clone of the player); That way it's a different object from the player, and it prevents spell reflection bug.
I'm not sure how many properties of DaggerfallEntityBehavior and DaggerfallEntity need to be delegated though. It may also feel like an overengineered solution...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 5183
Joined: Sun Mar 22, 2015 1:51 am

Re: Zap traps not damaging player

Post by Interkarma » Thu Mar 12, 2020 11:42 pm

Most of the effect system was engineered to work without a caster. I've not done that for the missile class, which seems to be a mistake on my part.

Only a small number of changes are required to support caster-less missiles, and it doesn't really affect anything more than spell being cast at magnitude of level 1. Oh, and area around caster can't work, but trap spells don't use those in any case.

I'll push some changes now for you to review. :)

User avatar
pango
Posts: 2164
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Zap traps not damaging player

Post by pango » Fri Mar 13, 2020 3:26 am

Checks like if (!caster) return in Update() convinced me that a caster was needed, but seems not (with the few adjustments you made).
Anyway, zap trap seems to work as it should now, I'm happy :D
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
King of Worms
Posts: 3035
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Zap traps not damaging player

Post by King of Worms » Fri Mar 13, 2020 10:55 am

Nice job finding this bug and dealing with it, Ive never noticed it

User avatar
Baler
Posts: 82
Joined: Thu May 23, 2019 1:39 am
Location: Earth

Re: Zap traps not damaging player

Post by Baler » Fri Mar 13, 2020 11:41 am

Awww I've been exploiting this bug for a long time to farm certain crypts/dungeons
well I guess it's better that it get's fixed..

User avatar
pango
Posts: 2164
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Zap traps not damaging player

Post by pango » Fri Mar 13, 2020 11:55 am

Well, it's not impossible to avoid getting zapped, it's just its own minigame :D
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Post Reply