Skip to content
Permalink
Browse files

Add variable type melee attack damage

  • Loading branch information...
Coolthulhu committed Feb 1, 2016
1 parent 5c1adc3 commit 155519aa6a1b269629f2cf21ea277204c7c1069c
@@ -5667,9 +5667,12 @@
"morale":100,
"speed":90,
"melee_skill":10,
"melee_dice":8,
"melee_dice_sides":7,
"melee_dice":7,
"melee_dice_sides":5,
"melee_cut":6,
"melee_damage" : [
{"damage_type" : "acid", "amount" : 20}
],
"dodge":0,
"armor_bash":10,
"armor_cut":30,
@@ -722,7 +722,6 @@ classes = {
{ name = "craft_has_charges", rval = "bool", args = { } },
{ name = "cut_resist", rval = "int", args = { } },
{ name = "damage_bash", rval = "int", args = { } },
{ name = "damage_cut", rval = "int", args = { } },
{ name = "deactivate_charger_gun", rval = "bool", args = { } },
{ name = "deserialize", rval = nil, args = { "string" } },
{ name = "destroyed_at_zero_charges", rval = "bool", args = { } },
@@ -1512,7 +1511,6 @@ classes = {
hp = { type = "int", writable = true },
id = { type = "mtype_id" },
luminance = { type = "float", writable = true },
melee_cut = { type = "int", writable = true },
melee_dice = { type = "int", writable = true },
melee_sides = { type = "int", writable = true },
melee_skill = { type = "int", writable = true },
@@ -7,6 +7,8 @@
#include "messages.h"
#include "addiction.h"

#include <algorithm>

const efftype_id effect_foodpoison( "foodpoison" );
const efftype_id effect_poison( "poison" );

@@ -1,7 +1,6 @@
#ifndef CREATURE_H
#define CREATURE_H

#include "damage.h"
#include "pldata.h"
#include "json.h"
#include "effect.h"
@@ -16,9 +15,15 @@
class game;
class JsonObject;
class JsonOut;
class projectile;
class damage_instance;
class dealt_damage_instance;
class damage_unit;
class dealt_projectile_attack;
struct trap;
enum m_flag : int;
enum field_id : int;
enum damage_type : int;

enum m_size : int {
MS_TINY = 0, // Squirrel
@@ -11,6 +11,7 @@
#include <string>
#include <cassert>
#include <vector>
#include <algorithm>

#include "debug.h"
#include "json.h"
@@ -11,6 +11,7 @@

#include <deque>
#include <iterator>
#include <algorithm>

// sidebar messages flow direction
extern bool log_from_top;
@@ -24,6 +24,7 @@
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>

const skill_id skill_dodge( "dodge" );
const skill_id skill_gun( "gun" );
@@ -2,6 +2,8 @@
#include "translations.h"
#include "rng.h"

#include <algorithm>

std::vector<mission_type> mission_type::types;

void mission_type::initialize()
@@ -914,15 +914,9 @@ void monster::melee_attack(Creature &target, bool, const matec_id&) {
body_part bp_hit;
//int highest_hit = 0;

damage_instance damage;
if(!is_hallucination()) {
if (type->melee_dice > 0) {
damage.add_damage(DT_BASH,
dice(type->melee_dice,type->melee_sides));
}
if (type->melee_cut > 0) {
damage.add_damage(DT_CUT, type->melee_cut);
}
damage_instance damage = !is_hallucination() ? type->melee_damage : damage_instance();
if( !is_hallucination() && type->melee_dice > 0 ) {
damage.add_damage( DT_BASH, dice( type->melee_dice,type->melee_sides ) );
}

dealt_damage_instance dealt_dam;
@@ -1034,15 +1028,9 @@ void monster::hit_monster(monster &other)
return;
}

damage_instance damage;
if( !is_hallucination() ) {
if( type->melee_dice > 0 ) {
damage.add_damage( DT_BASH, dice( type->melee_dice, type->melee_sides ) );
}

if( type->melee_cut > 0 ) {
damage.add_damage( DT_CUT, type->melee_cut );
}
damage_instance damage = !is_hallucination() ? type->melee_damage : damage_instance();
if( !is_hallucination() && type->melee_dice > 0 ) {
damage.add_damage( DT_BASH, dice( type->melee_dice,type->melee_sides ) );
}

dealt_damage_instance dealt_dam;
@@ -17,6 +17,8 @@
#include "rng.h"
#include "translations.h"

#include <algorithm>

const mtype_id mon_generator( "mon_generator" );
const mtype_id mon_zombie_dog( "mon_zombie_dog" );
const mtype_id mon_fungaloid( "mon_fungaloid" );
@@ -462,7 +464,6 @@ void mtype::load( JsonObject &jo )
optional( jo, was_loaded, "melee_skill", melee_skill, 0 );
optional( jo, was_loaded, "melee_dice", melee_dice, 0 );
optional( jo, was_loaded, "melee_dice_sides", melee_sides, 0 );
optional( jo, was_loaded, "melee_cut", melee_cut, 0 );
optional( jo, was_loaded, "dodge", sk_dodge, 0 );
optional( jo, was_loaded, "armor_bash", armor_bash, 0 );
optional( jo, was_loaded, "armor_cut", armor_cut, 0 );
@@ -476,6 +477,19 @@ void mtype::load( JsonObject &jo )
optional( jo, was_loaded, "vision_night", vision_night, 1 );
optional( jo, was_loaded, "armor_stab", armor_stab, 0.8f * armor_cut );

// TODO: make this work with `was_loaded`
if( jo.has_array( "melee_damage" ) ) {
JsonArray arr = jo.get_array( "melee_damage" );
melee_damage = load_damage_instance( arr );
} else if( jo.has_object( "melee_damage" ) ) {
melee_damage = load_damage_instance( jo );
}

if( jo.has_int( "melee_cut" ) ) {
int bonus_cut = jo.get_int( "melee_cut" );
melee_damage.add_damage( DT_CUT, bonus_cut );
}

// TODO: allow adding/removing specific entries if `was_loaded` is true
if( jo.has_array( "attack_effs" ) ) {
JsonArray jsarr = jo.get_array( "attack_effs" );
@@ -28,7 +28,6 @@ mtype::mtype()
melee_skill = 0;
melee_dice = 0;
melee_sides = 0;
melee_cut = 0;
sk_dodge = 0;
armor_bash = 0;
armor_cut = 0;
@@ -7,6 +7,7 @@
#include "color.h"
#include "int_id.h"
#include "string_id.h"
#include "damage.h"

#include <bitset>
#include <string>
@@ -264,10 +265,10 @@ struct mtype {
int speed; // Speed; human = 100
// Number of moves per regular attack.
int attack_cost;
damage_instance melee_damage; // Basic melee attack damage
unsigned char melee_skill; // Melee hit skill, 20 is superhuman hitting abilities.
unsigned char melee_dice; // Number of dice on melee hit
unsigned char melee_dice; // Number of dice of bonus bashing damage on melee hit
unsigned char melee_sides; // Number of sides those dice have
unsigned char melee_cut; // Bonus cutting damage
unsigned char sk_dodge; // Dodge skill; should be 0 to 5
unsigned char armor_bash; // Natural armor vs. bash
unsigned char armor_cut; // Natural armor vs. cut
@@ -24,6 +24,7 @@
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>

const skill_id skill_speech( "speech" );
const skill_id skill_barter( "barter" );
@@ -11,6 +11,7 @@
#include <sstream>
#include "calendar.h"
#include <cmath>
#include <algorithm>

quality::quality_map quality::qualities;

@@ -1,6 +1,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>

#include "scenario.h"

0 comments on commit 155519a

Please sign in to comment.
You can’t perform that action at this time.