/**
* @file mobile.c
* @ingroup mobile
*
* Mobile based code
*
* @author Geoff Davis <geoff@circlemudsquared.org>
* @author Greg Buxton <greg@circlemudsquared.org>
*
* @par Copyright:
* Copyright (C) 2006 Geoff Davis <geoff@circlemudsquared.org><br>
* Greg Buxton <greg@circlemudsquared.org>
*
* @par
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University<br>
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.
*
* @par
* All rights reserved. See license.doc for complete information.
*
* @package cs
* @version 1.0
*/
#define __MOBILE_C__
#include "sysdep.h"
#include "structs.h"
#include "utils.h"
#include "db.h"
#include "main.h"
#include "dao.h"
#include "character.h"
/*
* Here for now
*/
/* POS_x */
const char *position_types[] = {
"Dead",
"Mortally wounded",
"Incapacitated",
"Stunned",
"Sleeping",
"Resting",
"Sitting",
"Fighting",
"Standing",
"\n"
};
/*
* Local functions
*/
void mobileSpecialData_toDao(daoData_t *parentDao, struct mob_special_data *msData);
/*
* External variables
*/
extern const char *position_types[];
/**
* Convert a mobile prototype to its DAO representation.
*
* @param parentDao the container DAO to contain the item's DAO
* @param mob the mobile to be converted
* @return none
*/
void mobile_toDao(daoData_t *parentDao, struct char_data *mob) {
if (parentDao == NULL) {
log("mobile_toDao(): invalid 'parentDao' daoData_t.");
} else if (mob == NULL) {
log("mobile_toDao(): invalid 'mob' struct char_data.");
} else {
/* Declare some working DAO pointers */
daoData_t *mobDao = NULL, *subContainerDao = NULL;
mobDao = dao_newChild(parentDao, "%d", GET_MOB_VNUM(mob));
charPlayerData_toDao(mobDao, &(mob->player), FALSE);
/*
* Okay, we save the abilities for all mobiles. This is different
* from stock Circle which only saved the abilities for mob prototypes
* when they're the Circle 3 "Enhanced" mobs. Standard mobs (the majority)
*/
subContainerDao = dao_newChild(mobDao, "abilities");
charAbilities_toDao(subContainerDao, &(mob->real_abils));
subContainerDao = NULL;
subContainerDao = dao_newChild(mobDao, "points");
charPointData_toDao(subContainerDao, &(mob->points), FALSE);
subContainerDao = NULL;
subContainerDao = dao_newChild(mobDao, "savedCharSpecials");
savedCharSpecials_toDao(subContainerDao, &(mob->char_specials.saved), FALSE);
subContainerDao = NULL;
subContainerDao = dao_newChild(mobDao, "mobileSpecials");
mobileSpecialData_toDao(subContainerDao, &(mob->mob_specials));
subContainerDao = NULL;
/*
* Affects, equipment, and carrying are unused for mobiles
* at this time. This will likely be changed in the future
* as part of cleanup with the zone reset commands.
*/
}
}
/**
* Convert a mobileSpecialData_t to it's DAO representation
*
* @param parentDao the container DAO to contain the item's DAO
* @param msData the mobileSpecialData_t to be converted
* @return none
*/
void mobileSpecialData_toDao(daoData_t *parentDao, struct mob_special_data *msData) {
if (parentDao == NULL) {
log("mobileSpecialData_toDao(): invalid 'parentDao' daoData_t.");
} else if (msData == NULL) {
log("mobileSpecialData_toDao(): invalid 'msData' struct mob_special_data.");
} else {
dao_newScalar(parentDao, "attackType", "%d", msData->attack_type);
dao_newScalar(parentDao, "defaultPosition", "%s", position_types[msData->default_pos]);
dao_newScalar(parentDao, "damageDiceNumber", "%d", msData->damnodice);
dao_newScalar(parentDao, "damageDiceSize", "%d", msData->damsizedice);
}
}