Merge pull request #8 from NeonKnightOA/skills

Easier handling of skill levels by using defines instead of numbers
This commit is contained in:
Yamagi 2020-01-30 18:36:21 +01:00 committed by GitHub
commit 8236760dfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 76 additions and 69 deletions

View file

@ -653,7 +653,7 @@ qboolean M_CheckAttack (edict_t *self)
if (enemy_range == RANGE_MELEE)
{
// don't always melee in easy mode
if (skill->value == 0 && (rand()&3) )
if (skill->value == SKILL_EASY && (rand()&3) )
return false;
if (self->monsterinfo.melee)
self->monsterinfo.attack_state = AS_MELEE;
@ -693,9 +693,9 @@ qboolean M_CheckAttack (edict_t *self)
return false;
}
if (skill->value == 0)
if (skill->value == SKILL_EASY)
chance *= 0.5;
else if (skill->value >= 2)
else if (skill->value >= SKILL_HARD)
chance *= 2;
if (random () < chance)

View file

@ -404,7 +404,7 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
meansOfDeath = mod;
// easy mode takes half damage
if (skill->value == 0 && deathmatch->value == 0 && targ->client)
if (skill->value == SKILL_EASY && deathmatch->value == 0 && targ->client)
{
damage *= 0.5;
if (!damage)
@ -541,7 +541,7 @@ void T_Damage (edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir,
{
targ->pain (targ, attacker, knockback, take);
// nightmare mode monsters don't go into pain frames often
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
targ->pain_debounce_time = level.time + 5;
}
}

View file

@ -170,7 +170,7 @@ qboolean Pickup_Powerup (edict_t *ent, edict_t *other)
int quantity;
quantity = other->client->pers.inventory[ITEM_INDEX(ent->item)];
if ((skill->value == 1 && quantity >= 2) || (skill->value >= 2 && quantity >= 1))
if ((skill->value == SKILL_MEDIUM && quantity >= 2) || (skill->value >= SKILL_HARD && quantity >= 1))
return false;
if ((coop->value) && (ent->item->flags & IT_STAY_COOP) && (quantity > 0))

View file

@ -647,9 +647,9 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
(ent->spawnflags & SPAWNFLAG_NOT_MEDIUM) &&
(ent->spawnflags & SPAWNFLAG_NOT_HARD)))
{
if (((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD)))
if (((skill->value == SKILL_EASY) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == SKILL_MEDIUM) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == SKILL_HARD) || (skill->value == SKILL_HARDPLUS)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD)))
{
G_FreeEdict(ent);
inhibit++;
@ -662,9 +662,9 @@ void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint)
{
if (((!coop->value) && (ent->spawnflags2 & SPAWNFLAG2_NOT_SINGLE)) ||
((coop->value) && (ent->spawnflags2 & SPAWNFLAG2_NOT_COOP)) ||
((skill->value == 0) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == 1) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == 2) || (skill->value == 3)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD))
((skill->value == SKILL_EASY) && (ent->spawnflags & SPAWNFLAG_NOT_EASY)) ||
((skill->value == SKILL_MEDIUM) && (ent->spawnflags & SPAWNFLAG_NOT_MEDIUM)) ||
(((skill->value == SKILL_HARD) || (skill->value == SKILL_HARDPLUS)) && (ent->spawnflags & SPAWNFLAG_NOT_HARD))
)
{
G_FreeEdict (ent);

View file

@ -18,7 +18,7 @@ void check_dodge (edict_t *self, vec3_t start, vec3_t dir, int speed)
float eta;
// easy mode only ducks one quarter the time
if (skill->value == 0)
if (skill->value == SKILL_EASY)
{
if (random() > 0.25)
return;
@ -41,7 +41,7 @@ void check_dodge (edict_t *self, vec3_t start, vec3_t dir, int speed)
tr.ent->monsterinfo.dodgetimeout = 0;
}
if(skill->value > 3)
if(skill->value > SKILL_HARDPLUS)
{
skilllevel = 3;
}

View file

@ -555,6 +555,13 @@ extern int body_armor_index;
#define MOD_GL_POLYBLEND 40
#define MOD_FRIENDLY_FIRE 0x8000000
/* Easier handling of AI skill levels */
#define SKILL_EASY 0
#define SKILL_MEDIUM 1
#define SKILL_HARD 2
#define SKILL_HARDPLUS 3
extern int meansOfDeath;

View file

@ -255,7 +255,7 @@ void berserk_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if ((damage < 20) || (random() < 0.5))

View file

@ -441,7 +441,7 @@ void zboss_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 5;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if(self->laser)
@ -1061,11 +1061,11 @@ void FireCannon(edict_t *self)
distance = 700;
}
if(skill->value < 2)
if(skill->value < SKILL_HARD)
{
fire_plasmaCannon (self, start, dir, 90, 700, 2.5, 90+40, distance);
}
else if(skill->value < 3)
else if(skill->value < SKILL_HARDPLUS)
{
fire_plasmaCannon (self, start, dir, 90, (int)(distance * 1.2), 2.5, 90+40, distance);
}
@ -1659,15 +1659,15 @@ void SP_monster_zboss (edict_t *self)
self->monsterinfo.aiflags = AI_MONREDUCEDDAMAGE;
self->monsterinfo.reducedDamageAmount = 0.25;
if(skill->value == 0)
if(skill->value == SKILL_EASY)
{
self->health = 3000;
}
else if(skill->value == 1)
else if(skill->value == SKILL_MEDIUM)
{
self->health = 4500;
}
else if(skill->value == 2)
else if(skill->value == SKILL_HARD)
{
self->health = 6000;
}

View file

@ -430,7 +430,7 @@ void jorg_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 50)

View file

@ -554,7 +554,7 @@ void makron_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare

View file

@ -385,7 +385,7 @@ void brain_tentacle_attack (edict_t *self)
vec3_t aim;
VectorSet (aim, MELEE_DISTANCE, 0, 8);
if (fire_hit (self, aim, (10 + (rand() %5)), -600) && skill->value > 0)
if (fire_hit (self, aim, (10 + (rand() %5)), -600) && skill->value > SKILL_EASY)
self->spawnflags |= 65536;
gi.sound (self, CHAN_WEAPON, sound_tentacles_retract, 1, ATTN_NORM, 0);
}
@ -472,7 +472,7 @@ void brain_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
r = random();

View file

@ -264,7 +264,7 @@ void chick_pain (edict_t *self, edict_t *other, float kick, int damage)
else
gi.sound (self, CHAN_VOICE, sound_pain3, 1, ATTN_NORM, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 10)

View file

@ -213,7 +213,7 @@ void flipper_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
n = (rand() + 1) % 2;

View file

@ -553,7 +553,7 @@ void floater_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
n = (rand() + 1) % 3;

View file

@ -512,7 +512,7 @@ void flyer_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
n = rand() % 3;

View file

@ -238,7 +238,7 @@ void gladiator_pain (edict_t *self, edict_t *other, float kick, int damage)
else
gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (self->velocity[2] > 100)

View file

@ -276,7 +276,7 @@ void gunner_pain (edict_t *self, edict_t *other, float kick, int damage)
else
gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 10)
@ -346,7 +346,7 @@ void gunner_duck_down (edict_t *self)
if (self->monsterinfo.aiflags & AI_DUCKED)
return;
self->monsterinfo.aiflags |= AI_DUCKED;
if (skill->value >= 2)
if (skill->value >= SKILL_HARD)
{
if (random() > 0.5)
GunnerGrenade (self);

View file

@ -204,7 +204,7 @@ void hound_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (random() < 0.5)

View file

@ -475,7 +475,7 @@ void hover_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 25)

View file

@ -205,7 +205,7 @@ void infantry_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
n = rand() % 2;

View file

@ -475,7 +475,7 @@ void insane_pain (edict_t *self, edict_t *other, float kick, int damage)
l = 100;
gi.sound (self, CHAN_VOICE, gi.soundindex (va("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
// Don't go into pain frames if crucified.

View file

@ -305,7 +305,7 @@ void medic_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (random() < 0.5)

View file

@ -260,7 +260,7 @@ void mutant_check_refire (edict_t *self)
if (!self->enemy || !self->enemy->inuse || self->enemy->health <= 0)
return;
if ( ((skill->value == 3) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
if ( ((skill->value == SKILL_HARDPLUS) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
self->monsterinfo.nextframe = FRAME_attack09;
}
@ -486,7 +486,7 @@ void mutant_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
r = random();

View file

@ -263,7 +263,7 @@ void parasite_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (random() < 0.5)

View file

@ -469,11 +469,11 @@ void sentien_post_blast_attack(edict_t *self)
if (visible(self, self->enemy) &&
infront(self, self->enemy))
{
if(skill->value == 1)
if(skill->value == SKILL_MEDIUM)
refire = 0.40;
else if(skill->value == 2)
else if(skill->value == SKILL_HARD)
refire = 0.60;
else if(skill->value >= 3)
else if(skill->value >= SKILL_HARDPLUS)
refire = 0.75;
if (random() > refire)
@ -772,12 +772,12 @@ void sentien_fend (edict_t *self, edict_t *attacker, float eta)
self->monsterinfo.currentmove == &sentien_move_blast_attack)
return;
if (skill->value == 0)
if (skill->value == SKILL_EASY)
{
if (random() > 0.45)
return;
}
else if(skill->value == 1)
else if(skill->value == SKILL_MEDIUM)
{
if (random() > 0.60)
return;
@ -881,14 +881,14 @@ void sentien_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
}
if (skill->value >= 1)
if (skill->value >= SKILL_MEDIUM)
{
// don't flinch if attacking
if(self->monsterinfo.currentmove == &sentien_move_laser_attack ||
self->monsterinfo.currentmove == &sentien_move_blast_attack)
return;
}
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
target_laser_off(self->laser);
@ -1132,12 +1132,12 @@ void SP_monster_sentien(edict_t *self)
create_sentien_laser(self);
if(skill->value == 2)
if(skill->value == SKILL_HARD)
{
self->laser->dmg *= 1.5;
self->yaw_speed *= 1.5;
}
else if(skill->value >= 3)
else if(skill->value >= SKILL_HARDPLUS)
{
self->laser->dmg *= 2.5;
self->yaw_speed *= 2;

View file

@ -355,7 +355,7 @@ void soldier_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
}
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
r = random();
@ -456,7 +456,7 @@ void soldier_attack1_refire1 (edict_t *self)
if (self->enemy->health <= 0)
return;
if ( ((skill->value == 3) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
if ( ((skill->value == SKILL_HARDPLUS) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
self->monsterinfo.nextframe = FRAME_attak102;
else
self->monsterinfo.nextframe = FRAME_attak110;
@ -470,7 +470,7 @@ void soldier_attack1_refire2 (edict_t *self)
if (self->enemy->health <= 0)
return;
if ( ((skill->value == 3) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
if ( ((skill->value == SKILL_HARDPLUS) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
self->monsterinfo.nextframe = FRAME_attak102;
}
@ -506,7 +506,7 @@ void soldier_attack2_refire1 (edict_t *self)
if (self->enemy->health <= 0)
return;
if ( ((skill->value == 3) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
if ( ((skill->value == SKILL_HARDPLUS) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
self->monsterinfo.nextframe = FRAME_attak204;
else
self->monsterinfo.nextframe = FRAME_attak216;
@ -520,7 +520,7 @@ void soldier_attack2_refire2 (edict_t *self)
if (self->enemy->health <= 0)
return;
if ( ((skill->value == 3) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
if ( ((skill->value == SKILL_HARDPLUS) && (random() < 0.5)) || (range(self, self->enemy) == RANGE_MELEE) )
self->monsterinfo.nextframe = FRAME_attak204;
}
@ -627,7 +627,7 @@ void soldier_attack6_refire (edict_t *self)
if (range(self, self->enemy) < RANGE_MID)
return;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
self->monsterinfo.nextframe = FRAME_runs03;
}
@ -677,7 +677,7 @@ void soldier_sight(edict_t *self, edict_t *other)
else
gi.sound (self, CHAN_VOICE, sound_sight2, 1, ATTN_NORM, 0);
if ((skill->value > 0) && (range(self, self->enemy) >= RANGE_MID))
if ((skill->value > SKILL_EASY) && (range(self, self->enemy) >= RANGE_MID))
{
if (random() > 0.5)
self->monsterinfo.currentmove = &soldier_move_attack6;
@ -717,7 +717,7 @@ void soldier_dodge (edict_t *self, edict_t *attacker, float eta)
if (!self->enemy)
self->enemy = attacker;
if (skill->value == 0)
if (skill->value == SKILL_EASY)
{
self->monsterinfo.currentmove = &soldier_move_duck;
return;
@ -726,7 +726,7 @@ void soldier_dodge (edict_t *self, edict_t *attacker, float eta)
self->monsterinfo.pausetime = level.time + eta + 0.3;
r = random();
if (skill->value == 1)
if (skill->value == SKILL_MEDIUM)
{
if (r > 0.33)
self->monsterinfo.currentmove = &soldier_move_duck;
@ -735,7 +735,7 @@ void soldier_dodge (edict_t *self, edict_t *attacker, float eta)
return;
}
if (skill->value >= 2)
if (skill->value >= SKILL_HARD)
{
if (r > 0.66)
self->monsterinfo.currentmove = &soldier_move_duck;

View file

@ -445,13 +445,13 @@ void supertank_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
// Don't go into pain if he's firing his rockets
if (skill->value >= 2)
if (skill->value >= SKILL_HARD)
if ( (self->s.frame >= FRAME_attak2_1) && (self->s.frame <= FRAME_attak2_14) )
return;
self->pain_debounce_time = level.time + 3;
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 10)

View file

@ -282,7 +282,7 @@ void tank_pain (edict_t *self, edict_t *other, float kick, int damage)
return;
// If hard or nightmare, don't go into pain while attacking
if ( skill->value >= 2)
if ( skill->value >= SKILL_HARD)
{
if ( (self->s.frame >= FRAME_attak301) && (self->s.frame <= FRAME_attak330) )
return;
@ -293,7 +293,7 @@ void tank_pain (edict_t *self, edict_t *other, float kick, int damage)
self->pain_debounce_time = level.time + 3;
gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
if (skill->value == 3)
if (skill->value == SKILL_HARDPLUS)
return; // no pain anims in nightmare
if (damage <= 30)
@ -453,7 +453,7 @@ mmove_t tank_move_attack_post_blast = {FRAME_attak117, FRAME_attak122, tank_fram
void tank_reattack_blaster (edict_t *self)
{
if (skill->value >= 2)
if (skill->value >= SKILL_HARD)
if (visible (self, self->enemy))
if (self->enemy->health > 0)
if (random() <= 0.6)
@ -623,7 +623,7 @@ mmove_t tank_move_attack_chain = {FRAME_attak401, FRAME_attak429, tank_frames_at
void tank_refire_rocket (edict_t *self)
{
// Only on hard or nightmare
if ( skill->value >= 2 )
if ( skill->value >= SKILL_HARD )
if (self->enemy->health > 0)
if (visible(self, self->enemy) )
if (random() <= 0.4)

View file

@ -288,11 +288,11 @@ void HelpComputer (edict_t *ent)
char string[1024];
char *sk;
if (skill->value == 0)
if (skill->value == SKILL_EASY)
sk = "easy";
else if (skill->value == 1)
else if (skill->value == SKILL_MEDIUM)
sk = "medium";
else if (skill->value == 2)
else if (skill->value == SKILL_HARD)
sk = "hard";
else
sk = "hard+";

View file

@ -792,7 +792,7 @@ void SP_monster_autocannon(edict_t *self)
self->style = 1;
// if we're on hard or nightmare, use fast lasers
if (skill->value >= 2 && self->style == 4)
if (skill->value >= SKILL_HARD && self->style == 4)
self->style = 3;
// precache some sounds and models