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

Projects
None yet
4 participants
@Coolthulhu
Copy link
Contributor

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>

This comment has been minimized.

Copy link
@codemime

codemime Dec 9, 2016

Member

Why do you need this include?


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

This comment has been minimized.

Copy link
@codemime

codemime Dec 9, 2016

Member

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 )

This comment has been minimized.

Copy link
@codemime

codemime Dec 9, 2016

Member

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

This comment has been minimized.

Copy link
@Coolthulhu

Coolthulhu Dec 10, 2016

Author Contributor

How to get it without generic factory?

This comment has been minimized.

Copy link
@codemime

codemime Dec 10, 2016

Member

optional() doesn't depend on it.

@DangerNoodle

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2016

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

@DangerNoodle

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2016

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

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

This comment has been minimized.

Copy link
@codemime

codemime Dec 19, 2016

Member

mtype is a struct.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Jan 22, 2017

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 referenced this pull request Jan 23, 2017

Closed

JSON API changes #19376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.