From 2b82e1de44e62f9cd1ba3a680986e18e566581b6 Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Tue, 21 Jun 2016 21:46:32 +1000 Subject: [PATCH] Small quadrapeds/birds shouldn't be able to slip on things, nor should snakes. --- data.c | 3 +++ lf.c | 38 +++++++++++++++++++++++++++++++++----- lf.h | 1 + 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/data.c b/data.c index c6eb8c9..9be6ad6 100644 --- a/data.c +++ b/data.c @@ -17879,6 +17879,7 @@ void initrace(void) { addflag(lastrace->flags, F_NATURALFLIGHT, B_TRUE, NA, NA, ""); addflag(lastrace->flags, F_CANWILL, OT_A_FLY, NA, NA, NULL); addflag(lastrace->flags, F_SPELLCASTTEXT, OT_A_FLY, NA, NA, NULL); + addflag(lastrace->flags, F_STABILITY, B_TRUE, NA, NA, NULL); addflag(lastrace->flags, F_STARTSKILL, SK_FLIGHT, PR_BEGINNER, NA, NULL); addrace(R_SWARMRAT, "swarm of rats", 40, UNI_SWARM, C_BROWN, MT_FLESH, RC_ANIMAL, "A large swarm of vile rodents."); @@ -17899,6 +17900,7 @@ void initrace(void) { addflag(lastrace->flags, F_MAXATTACKS, 5, 5, NA, NULL); addflag(lastrace->flags, F_NOCORPSE, B_TRUE, NA, NA, NULL); addflag(lastrace->flags, F_SWARM, NA, NA, NA, NULL); + addflag(lastrace->flags, F_STABILITY, B_TRUE, NA, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_STR, AT_VLOW, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_IQ, IQ_ANIMAL, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_AGI, AT_GTAVERAGE, NA, NULL); @@ -17928,6 +17930,7 @@ void initrace(void) { addflag(lastrace->flags, F_MAXATTACKS, 7, 7, NA, NULL); addflag(lastrace->flags, F_NOCORPSE, B_TRUE, NA, NA, NULL); addflag(lastrace->flags, F_SWARM, NA, NA, NA, NULL); + addflag(lastrace->flags, F_STABILITY, B_TRUE, NA, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_STR, AT_VLOW, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_IQ, IQ_ANIMAL, NA, NULL); addflag(lastrace->flags, F_STARTATT, A_AGI, AT_HIGH, NA, NULL); diff --git a/lf.c b/lf.c index e7d15fd..8c0c04c 100644 --- a/lf.c +++ b/lf.c @@ -10837,13 +10837,15 @@ char *real_getlfnamea(lifeform_t *lf, char *buf, lifeform_t * usevis, int showal } enum LFSIZE getlfsize(lifeform_t *lf) { - flag_t *f; + flag_t *f = NULL; + enum LFSIZE size = SZ_HUMAN; f = hasflag(lf->flags, F_SIZE); - if (!f) f = hasflag(lf->race->flags, F_SIZE); - if (!f) { - return SZ_HUMAN; + if (f) { + size = f->val[0]; + } else { + size = getracesize(lf->race->id); } - return f->val[0]; + return size; } float getlfweight(lifeform_t *lf, int withobs) { @@ -11117,6 +11119,21 @@ int getracerarity(enum HABITAT hab, enum RACE rid, enum RARITY *rr) { return rarity; } +enum LFSIZE getracesize(enum RACE rid) { + race_t *r = NULL; + flag_t *f = NULL; + enum LFSIZE size = SZ_HUMAN; + r = findrace(rid); + if (r) { + f = hasflag(r->flags, F_SIZE); + if (f) { + size = f->val[0]; + } + } + return size; +} + + // if optional 'attacker' is provided, only select form armours which they // can reach. object_t *getrandomarmour(lifeform_t *lf, lifeform_t *attacker) { @@ -21757,6 +21774,9 @@ void setbodytype(race_t *r, enum BODYTYPE bt) { addbodypart(r, BP_LEGS, NULL); addbodypart(r, BP_FEET, "talons"); addbodypart(r, BP_WINGS, NULL); + if (getracesize(r->id) <= SZ_SMALL) { + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); + } break; case BT_HUMANOID: for (i = BP_WEAPON; i <= BP_LEFTFINGER; i++) { @@ -21770,6 +21790,7 @@ void setbodytype(race_t *r, enum BODYTYPE bt) { addbodypart(r, BP_LEGS, NULL); addbodypart(r, BP_WINGS, NULL); addflag(r->flags, F_SEEWITHOUTEYES, B_TRUE, NA, NA, NULL ); + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); break; case BT_QUADRAPED: addbodypart(r, BP_EYES, NULL); @@ -21780,25 +21801,32 @@ void setbodytype(race_t *r, enum BODYTYPE bt) { addbodypart(r, BP_BACKLEGS, "back legs"); addbodypart(r, BP_FRONTLEGS, "front legs"); addbodypart(r, BP_FEET, "paws"); + if (getracesize(r->id) <= SZ_SMALL) { + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); + } break; case BT_FISH: addbodypart(r, BP_EYES, NULL); addbodypart(r, BP_HEAD, NULL); addbodypart(r, BP_BODY, NULL); addbodypart(r, BP_TAIL, NULL); + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); break; case BT_SNAKE: addbodypart(r, BP_EYES, NULL); addbodypart(r, BP_HEAD, NULL); addbodypart(r, BP_TAIL, NULL); + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); break; case BT_SPIDER: addbodypart(r, BP_EYES, NULL); addbodypart(r, BP_HEAD, "cephalothorax"); addbodypart(r, BP_BODY, "abdomen"); addbodypart(r, BP_LEGS, NULL); + addflagifneeded(r->flags, F_STABILITY, B_TRUE, NA, NA, NULL); break; } + } int setfacing(lifeform_t *lf, int dir) { diff --git a/lf.h b/lf.h index cf35a59..85a1961 100644 --- a/lf.h +++ b/lf.h @@ -286,6 +286,7 @@ enum POISONSEVERITY getpoisonseverity(enum POISONTYPE ptype); */ enum RACECLASS getraceclass(lifeform_t *lf); int getracerarity(enum HABITAT hab, enum RACE rid, enum RARITY *rr); +enum LFSIZE getracesize(enum RACE rid); object_t *getrandomarmour(lifeform_t *lf, lifeform_t *attacker); enum BEHAVIOUR getrandombehaviour(void); enum BODYPART getrandomcorebp(lifeform_t *lf, lifeform_t *attacker);