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

Generic monster attacks, take 2: "Library of Attacks" #19702

Merged
merged 11 commits into from
Jan 22, 2017

Conversation

Coolthulhu
Copy link
Contributor

@Coolthulhu Coolthulhu commented Dec 9, 2016

This got pretty giant. Recreating PR instead of reopening #17679 because it got some giant updates.

Contains the generic melee attacks as in #17679 but also a "library of monster attacks" which works as follows:

  • Monster attacks specified in base context (ie. not in a monster) with type "monster_attack" are written down into MonsterGenerator::attack_map
  • In monster context, a monster can either request one of the base types ("leap", "bite" etc.) or "monster_attack", which covers library ones
  • A monster can request a library type and make inline modifications to it, in case something tiny needs to be changes - for example cooldown
  • Due to the limitations of current implementation, nested library types are NOT supported at the moment
  • Hardcoded mattacks are wrapped into a structure similar to that of iuse functions
  • Monster attack "type" renamed to "attack_type", as "type" is a reserved keyword for init functions
  • Old definitions are supported for now, but will cause warnings in test_mode (--check-mods)

For example:

{
    "type": "monster_attack",
    "attack_type": "bite",
    "id": "nibble",
    "move_cost": 10
}
...
{
    "type": "monster",
    "id": "nibblerung"
    ...
    "special_attacks": [ { "id": "nibble" } ]
}

It is also possible to use the array definition ("special_attacks": [ [ "nibble", 2 ] ]).

EDIT: Added a doc: https://github.com/CleverRaven/Cataclysm-DDA/wiki/Monster-special-attacks

@@ -10,6 +10,7 @@
#include "sounds.h"
#include "npc.h"
#include "debug.h"
#include <algorithm>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this include?


void mattack_actor::load( JsonObject &jo, const std::string &src )
{
bool strict = src == "core";
Copy link
Contributor

Choose a reason for hiding this comment

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

This check doesn't work anymore. The core mod is "dda".

{
damage_max_instance = damage_instance::physical( 9, 0, 0, 0 );
min_mul = 0.5f;
max_mul = 1.0f;
move_cost = 100;
}

void bite_actor::load( JsonObject &obj )
void load_if_available( std::string &to, JsonObject &obj, const std::string &id,
const std::string &def )
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a reinvented optional( ..., translated_string_reader ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How to get it without generic factory?

Copy link
Contributor

Choose a reason for hiding this comment

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

optional() doesn't depend on it.

@DangerNoodle
Copy link
Contributor

DangerNoodle commented Dec 9, 2016

I assume this will warrant reporting on #19376 when it is merged, if it changes monster files. @pisskop and @chaosvolt would need to update their mods.

@Coolthulhu Coolthulhu changed the title [WiP][CR]Generic monster attacks, take 2: "Library of Attacks" Generic monster attacks, take 2: "Library of Attacks" Dec 10, 2016
@chaosvolt
Copy link
Contributor

Eh? Sure, I guess. Wait, JSON API? :V

@DangerNoodle
Copy link
Contributor

See issue mentioned by me above, reporting major JSON changes.

struct mtype_special_attack {
protected:
// @todo Remove friend
friend class mtype;
Copy link
Contributor

Choose a reason for hiding this comment

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

mtype is a struct.

@Coolthulhu
Copy link
Contributor Author

Should be working now.

@codemime codemime self-assigned this Jan 22, 2017
@codemime codemime merged commit ac528f6 into CleverRaven:master Jan 22, 2017
@Coolthulhu Coolthulhu mentioned this pull request Jan 23, 2017
@Coolthulhu Coolthulhu deleted the generic-melee branch June 15, 2020 17:41
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.

4 participants