magic
This will probably need to be split into a bunch of dub-issues for each type of magic
I've been tinkering around having a look at what would be required for this, thought I'd share some findings so far. Turns out all magic and bows (#46) generate a "missile" which can include many animations and even complicated things like golem/guardian. Even stuff like town portal is considered a "missile". There are tables for spells, missiles and missile animations which can be extracted from exe, but that's far from everything needed.
Framework changes:
- Direction:
Currently freeablo only handles 8 compass directions.
Arrows and some other "missile" graphics have 16 directions for animations AND can be fired at any angle.
This means we'll probably need to convert
Directionto a class (based on a FixedPoint angle) that has conversions for 8 and 16 point compass bearings. I've toyed around with this and it's not too hard to change: e.g.
// direction.h
Direction(FixedPoint degrees);
Direction(Direction8 dir);
Direction(Direction16 dir);
Direction8 getDirection8() const;
Direction16 getDirection16() const;
Also means we need proper trig functions (atan2 and sin or cos).
-
FixedPoint: For trig functions I've tested with floating point, should try find a decent fixed point approximation at some point. There's also a bunch of bugs with negative numbers that need tidying up..
-
Position: Currently
Positiononly works for actor positions, it should be usable for "missile" position as well. It currently has sub-tile position in 1/100 increments, although the direction of this can only point toward one of the 8 surrounding tiles, this will need to be updated as well as the corresponding rendering code. I've been playing around with this but haven't quite got the conversion right.. Also needs a speed parameter rather than fixed250. Note from Jarulf's Guide:
Any missile in the game (be it an arrow or a spell) will use true trigonometrical calculations for its movement, both for location and speed. Thus, it takes a missile longer to move through a location diagonally than straight along a side (roughly 40% longer) as opposed to character and monster movement which takes the same time regardless of it being diagonally or not.
Other minor updates required: Passing right click and spell hotkeys through to game for testing. Extract tables from exe.
Structure of spells/missiles
- Naming:
Spells/Magic (which?) will be a seperate layer from "missiles". Since we're including things like bows, town portals, manashields etc I don't like "missiles". My thoughts are it's basically every non-melee action a player/monster can make, so...
NonMeleeAction:/ ahh any other ideas... - Missile ownership: I think "missiles" should be owned by the level, when an actor casts a spell etc they should pass ownership to the level. This means "missiles" will need to keep track of who created them. Can "missiles" be generated from opening barrels/sarcophaguses etc?
- Player interaction: "Missiles" ask each of their associated animations for their position, then check which players are near them and do the appropriate action. "Missiles" may also need a count of how many times each associated animation has interacted with each player (as some can hit multiple times etc).
- Missile classes: "Missiles" can do an awful lot of different things. We could try put it in a big table but it'd probably be difficult to maintain. Maybe just a base class that has helpers for each type of movement etc and a subclass (with activator ID for saving) for each spell.
There's probably a bunch of other stuff I can't think of right now too. Thoughts on any/all of the above would be helpful