Skip to content
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

JSONize gates #15945

Merged
merged 9 commits into from
Mar 27, 2016
Merged

JSONize gates #15945

merged 9 commits into from
Mar 27, 2016

Conversation

codemime
Copy link
Contributor

Follows #15927. Hard-coded gates no more. We can now modify/expand them freely. The gate code was placed to separate files to de-bloat the rest a tiny bit. Fix: closing gate damages contents of all involved tiles, not only the first damageable. Also, a gate can now be opened by both player's activity and completely by itself (the player witnessing). It would be useful e.g. for quests with restricted areas.

Edit: NPCs could now use gates as well (2D points are replaced with 3D ones according to @Coolthulhu 's suggestion).

The renaming was made, because I think the function really belongs to the 'game' class, but since it changes only one tile and doesn't know a thing about 'gates', the name should be more generic.
@Night-Pryanik
Copy link
Contributor

Great work!
Though ideally I'd prefer to remove "wall type - handle type" dependence and replace it with "gate type - handle type". In that case we wouldn't need to create different gate types for every type of wall and could use one usual mechanical handle for ordinary walls, concrete walls, brick walls etc to operate metal gate, for example.
Something like array of types of walls which we could use with some specific handle.

@codemime
Copy link
Contributor Author

Thanks. Good idea, makes sense to me. Since multiple levers/poles/ropes already exist to trigger the gates (in existing saved games as well), the handle field should become an array too. So that it will be many-to-many relationship. Usage of the neat generic_factory becomes trickier in that case. Though I think it allows insertion during loading so I can make as many copies as I need (or store pointers).

@Coolthulhu Coolthulhu self-assigned this Mar 27, 2016
const int wall_x = pos.x + dx[i];
const int wall_y = pos.y + dy[i];

if( g->m.ter( wall_x, wall_y ) != gate.get_wall() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better if it used the 3D (tripoint) map::ter rather than the compatibility 2D one. That way NPCs could be made to use it too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Good suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants