-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ai: add configurable item drop behaviour #1012
Conversation
This replaces all hardcoded enemy item drops with a flexible system using the gameflow. Specific enemies can carry pickup items, which spawn on death and are remembered between saves. Dropped guns can also optionally be converted to ammo if Lara has the gun already. Support is also included for Pierre, Cowboy, Skaterboy and Kold to handle their items accordingly when using legacy save files. Resolves LostArtefacts#967.
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, let's add more comments in the functions what's their purpose.
src/game/carrier.c
Outdated
#include <stdbool.h> | ||
#include <stddef.h> | ||
|
||
#define AMMO_OFFSET 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do without this const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps an explicit switch statement to convert gun to ammo would be better, or a map even.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's exactly what I had on my mind.
ITEM_INFO *item = &g_Items[item_num]; | ||
if (Carrier_IsObjectType(item->object_number, m_PlaceholderObjects)) { | ||
int16_t child_item_num = *(int16_t *)item->data; | ||
item = &g_Items[child_item_num]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's amazing that you thought of this even.
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the int16_t
throughout this file become GAME_OBJECT_ID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be much neater I think.
Converted int16_t to GAME_OBJECT_ID in the carrier module; changed the approach for gun-to-ammo conversion and legacy enemy testing; changed invalid drop object ID handling - these will no longer invalidate the entire array for that enemy. Added comments to carrier functions for clarity. Part of LostArtefacts#967.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice!
Resolves #967.
Checklist
Description
This follows on from #1000, and allows all but a few enemies to carry and drop items for Lara to collect. The hardcoded drops have been removed and the gameflow is now responsible for the setup. The default gameflow is configured in line with OG behaviour/requirements.
convert_dropped_guns
in the gameflow controls whether guns are converted to ammo when dropped and Lara already has that gun. This isfalse
by default to avoid extra ammo pickups when killing Pierre, Cowboy and Kold in the original levels.Enemies that are not capable of carrying and dropping are:
O_CROCODILE
O_ALLIGATOR
O_RAT
O_VOLE
- having items spawn in the water would be difficult to track with changing water levels I feel, and having floating pickups would not be in-keeping with normal experience.O_WARRIOR1
O_WARRIOR2
O_WARRIOR3
- these explode in mid-air and don't follow the standardCreature_Animate
routine on death. We could manually spawn the items in each object's control, and work out the floor height, but the item would appear out of nowhere if the creature were high above land when killed, so again it feels non-standard.Pods and centaur statues can be referenced as carriers in the gameflow; the system will give the items to the enemies that actually spawn, provided those are suitable carriers (empty pods are excluded).
The statistics take into account carried items. I have added a function here for common behaviour when testing triggered killable items.
In terms of saving and loading, items will respawn accordingly if Lara hasn't picked them up yet and equally they will not if she has done so. For testing, I used legacy ATI saves, V3 of the TR1X save format (2.16) and the current V4. In each case, I tested Pierre, Cowboy, Skaterboy and Kold in six scenarios - the following with
convert_dropped_guns
set tofalse
and then again with it set totrue
.I also used a test level to ensure items allocated to every potential carrier type spawn as expected, and that items allocated to non-carriers are ignored.
I will follow-up this PR with a document update to create a gameflow MD file, so that builders have a go-to reference for this feature in detail, as well as other gameflow aspects.