-
Notifications
You must be signed in to change notification settings - Fork 177
Adds Props as a new object type #6836
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
base: master
Are you sure you want to change the base?
Conversation
41df668 to
9119837
Compare
560ef58 to
56e68c4
Compare
56e68c4 to
6d47939
Compare
db0b6a8 to
8b802ba
Compare
7e3bbbc to
3d00c18
Compare
3cea937 to
d331d00
Compare
f27e2f0 to
2050d6d
Compare
4dbc80a to
5053b91
Compare
5053b91 to
1027a9f
Compare
ef81fc3 to
4ed7f50
Compare
4ed7f50 to
92fecb8
Compare
BMagnu
left a comment
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.
Great work.
A few small things, otherwise this is pretty much there.
Just as a list of ToDo you mentioned in the code and that I can think of that should be done in future PRs, as a reference here:
Modelanimation support
Multithreaded collision support
Possibly support as a permanent particle host (think something like a Volcano spewing smoke)
92fecb8 to
27a65e3
Compare
And full QtFRED support which I'll get to once I finish rewriting sexp tree to be shared between FRED and QtFRED. |
2a0a78a to
e4e745c
Compare
BMagnu
left a comment
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.
Wanted to comment on SEXP ergonomics when I saw the model_instance thing, so I'm giving this a short look-over again. Should all be fairly simple, but better to root out anything now than after it's merged
| } else if (obj->type == OBJ_RAW_POF) { | ||
| model_num_a = Pof_objects[obj->instance].model_num; | ||
| } else if (obj->type == OBJ_PROP) { | ||
| model_num_a = prop_id_lookup(obj->instance)->model_instance_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.
Wait a minute, should this not be model_num rather than model_instance_num here?
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.
This is prop object, which doesn't have model_num. model_instance_num looks to be equivalent.
| } else if (other.obj->type == OBJ_RAW_POF) { | ||
| model_num_b = Pof_objects[other.obj->instance].model_num; | ||
| } else if (other.obj->type == OBJ_PROP) { | ||
| model_num_b = prop_id_lookup(other.obj->instance)->model_instance_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.
Same here
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.
See above
| { "add-to-collision-group-prop", OP_ADD_TO_COLGROUP_PROP, 2, INT_MAX, SEXP_ACTION_OPERATOR, }, // MjnMixael | ||
| { "remove-from-collision-group-prop", OP_REMOVE_FROM_COLGROUP_PROP, 2, INT_MAX, SEXP_ACTION_OPERATOR, }, // MjnMixael | ||
| { "get-collision-group-prop", OP_GET_COLGROUP_ID_PROP, 1, 1, SEXP_ACTION_OPERATOR, }, // MjnMixael |
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.
Playing around with this, as a slight ergonomic improvement, is it not possible to make the original collision group sexps just accept ships and props?
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.
Iirc the original sexps are tuned pretty specifically for ships and it would require a new sexp_tree type (ship or prop) I think. Honestly this PR has been sitting so long I don't really remember how it works under the hood anymore.
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.
Ok, yes I looked at this. This requires significant overhead just for the one combined sexp to work. You'd need a new Sexp Tree type, OPF_SHIP_PROP, and all the extra code that requires. You'd need to do that for both FRED and QtFRED. Then you'd need to change the ship versions of these sexps to accept OFP_SHIP_PROP instead if just OPF_SHIP and adjust the sexp code to have two paths. This also requires adjusting all the error checking for these sexps to be able to return a new "invalid ship or prop" error type.
This would be a user-facing improvement for sure but I, quite honestly, don't want to do all that work just for these barely used sexps. If there were other more common sexps that could benefit from OPF_SHIP_PROP then it might be more justified.
code/parse/sexp.h
Outdated
| @@ -1479,6 +1488,7 @@ struct wing; | |||
| // Goober5000 - stuff with caching | |||
| // (included in the header file because Lua uses the first three) | |||
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.
This comment should probably be updated to 4
code/parse/sexp/LuaSEXP.cpp
Outdated
| auto ship_entry = eval_prop(node); | ||
|
|
||
| // if this is a shipname type, we want the name of a valid ship but not the ship itself | ||
| // (if the ship is not valid, return an empty string) | ||
| if (argtype.first == "propname") { | ||
| return LuaValue::createValue(_action.getLuaState(), ship_entry ? ship_entry->prop_name : ""); | ||
| } | ||
|
|
||
| if (!ship_entry || (ship_entry->objnum >= 0)) { | ||
| // Name is invalid | ||
| return LuaValue::createValue(_action.getLuaState(), l_Prop.Set(object_h())); | ||
| } | ||
|
|
||
| auto objp = &Objects[ship_entry->objnum]; |
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.
Lots of this is called ship, but should probably be called prop, both in comments and variable names
| SCP_string get_prop_table_text(const prop_info* pip) | ||
| { | ||
| char line[256], line2[256], file_text[82]; | ||
| int i, j, n, found = 0, comment = 0, num_files = 0; |
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.
If we're already doing a round 2 here:
Is it possible to consolidate this with the function above, as they basically do the same thing?
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.
Depends on where you want to draw the line. Right now, iirc, this matches the code structure that ships do. If I update this are you going to want me to update ships also?
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.
Looking at this, I'd rather not for now. This whole file could use consolidation and cleanup. However, this Props PR does a ton of changes already. I'd rather keep the change here as additive and later on someone can consolidate get_weapon_table_text, get_ship_table_text, get_asteroid_table_text, and get_prop_table_text as much as makes sense.
e4e745c to
1ae73c7
Compare
This PR adds Props as a distinct new object type. Props work very similarly to ships in most cases but there are some key assumptions that make them unique:
Props are meant to be scenery, set pieces, decoration, or even objects rendered by Lua in the UI only. Props do not take up ship slots and are not limited. Props are created in FRED using the new second dropdown with ctrl-shift-click instead of just ctrl-click

Props have a basic set of flags to start:
Props have a basic set of sexps to start:
Props have basic Lua support including collision hooks and table indexing with a standard set of members and methods. Props are also a valid type for Lua SEXPs. Props are viewable in the F3 Lab as well. Props have stubbed in support for @BMagnu animation system and glowpoints but both are inactive for now.
Props.tbl is modular with -prp.tbm. It supports both
+nocreateand+remove. Props can be categorized with colors for easy browsing in FRED. A sample table looks like this:Many thanks to @BMagnu and @Baezon for the assistance in various places of this PR, especially with collisions.
Fixes #4727