anarch/constants.h

583 lines
16 KiB
C
Raw Normal View History

2019-10-03 18:04:14 -04:00
/**
@file constants.h
This file contains definitions of game constants that are not considered
part of game settings and whose change can ffect the game balance and
playability, e.g. physics constants.
by Miloslav Ciz (drummyfish), 2019
Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
plus a waiver of all other intellectual property. The goal of this work is
be and remain completely in the public domain forever, available for any use
whatsoever.
*/
2019-09-25 09:51:19 -04:00
#ifndef _SFG_CONSTANTS_H
#define _SFG_CONSTANTS_H
/**
How quickly player moves, in squares per second.
*/
2020-02-23 05:45:32 -05:00
#define SFG_PLAYER_MOVE_SPEED 7
2019-10-01 14:25:21 -04:00
/**
Gravity acceleration in squares / (second^2).
*/
#define SFG_GRAVITY_ACCELERATION 30
2019-09-25 09:51:19 -04:00
2019-10-03 14:09:00 -04:00
/**
Initial upwards speed of player's jump, in squares per second.
*/
2020-03-28 12:34:09 -04:00
#define SFG_PLAYER_JUMP_SPEED 5
2019-10-03 14:09:00 -04:00
2020-01-02 13:40:00 -05:00
/**
Melee and close-up attack range, in RCL_Units.
*/
2020-01-07 15:26:38 -05:00
#define SFG_MELEE_RANGE 1600
2020-01-02 13:40:00 -05:00
2020-02-10 06:55:15 -05:00
/**
When a projectile is shot, it'll be offset by this distance (in RCL_Units)
from the shooter.
*/
#define SFG_PROJECTILE_SPAWN_OFFSET 256
2020-01-02 13:40:00 -05:00
/**
Player's melee hit range, in RCL_Units (RCL_UNITS_PER_SQUARE means full angle,
180 degrees to both sides).
*/
#define SFG_PLAYER_MELEE_ANGLE 512
2019-09-26 21:34:49 -04:00
/**
How quickly elevators and squeezers move, in RCL_Unit per second.
*/
#define SFG_MOVING_WALL_SPEED 1024
2019-10-04 15:09:10 -04:00
/**
How quickly doors open and close, in RCL_Unit per second.
*/
#define SFG_DOOR_OPEN_SPEED 2048
2020-09-19 13:35:26 -04:00
/**
Helper special state value.
*/
#define SFG_CANT_SAVE 255
2019-10-06 10:47:47 -04:00
/**
2020-01-11 12:05:27 -05:00
Says the distance in RCL_Units at which level elements (items, monsters etc.)
are active.
2019-10-06 10:47:47 -04:00
*/
2020-01-11 12:05:27 -05:00
#define SFG_LEVEL_ELEMENT_ACTIVE_DISTANCE (12 * 1024)
2019-10-06 10:47:47 -04:00
2019-10-17 17:58:19 -04:00
/**
2019-10-18 10:34:51 -04:00
Rate at which AI will be updated, which also affects how fast enemies will
appear.
2019-10-17 17:58:19 -04:00
*/
2019-10-22 10:48:27 -04:00
#define SFG_AI_FPS 4
2019-10-18 11:26:13 -04:00
/**
Says a probability (0 - 255) of the AI changing its state during one update
step.
*/
2019-10-22 10:48:27 -04:00
#define SFG_AI_RANDOM_CHANGE_PROBABILITY 40
2019-10-17 17:58:19 -04:00
2019-10-21 17:50:19 -04:00
/**
Distance at which level elements (sprites) collide, in RCL_Unit (1024 per
square).
*/
2020-10-12 09:47:20 -04:00
#define SFG_ELEMENT_COLLISION_RADIUS 1800
2019-10-21 19:34:40 -04:00
2019-10-22 08:27:56 -04:00
/**
Height, in RCL_Units, at which collisions happen with level elements
(sprites).
*/
#define SFG_ELEMENT_COLLISION_HEIGHT 1024
2019-10-21 19:34:40 -04:00
/**
2020-10-12 09:47:20 -04:00
Distance at which explosion does damage and throws away the player, in
RCL_Units. Should be higher than SFG_ELEMENT_COLLISION_RADIUS so that
exploded rockets also hurt the target.
2019-10-21 19:34:40 -04:00
*/
2020-10-12 09:47:20 -04:00
#define SFG_EXPLOSION_RADIUS 2000
2019-10-21 17:50:19 -04:00
2020-03-08 10:04:02 -04:00
/**
2020-10-12 09:47:20 -04:00
Distance in RCL_Units which the player is pushed away by an explosion. Watch
out, a slightly higher value can make player go through walls. Rather keep
this under RCL_UNITS_PER_SQUARE;
2020-03-08 10:04:02 -04:00
*/
2020-10-12 09:47:20 -04:00
#define SFG_EXPLOSION_PUSH_AWAY_DISTANCE 1023
2020-03-08 10:04:02 -04:00
2020-01-11 13:22:14 -05:00
/**
How much damage triggers a barrel explosion.
*/
2020-09-12 06:58:53 -04:00
#define SFG_BARREL_EXPLOSION_DAMAGE_THRESHOLD 3
2020-01-11 13:22:14 -05:00
2019-10-23 18:09:46 -04:00
/**
Maximum player health.
*/
2020-09-14 10:40:26 -04:00
#define SFG_PLAYER_MAX_HEALTH 125
2020-03-22 06:31:02 -04:00
/**
Start health of player.
*/
#define SFG_PLAYER_START_HEALTH 100
2019-10-23 18:09:46 -04:00
2019-10-24 17:20:35 -04:00
/**
At which value health indicator shows a warning (red color).
*/
#define SFG_PLAYER_HEALTH_WARNING_LEVEL 20
2019-10-25 18:50:22 -04:00
/**
Amount of health that is increased by taking a health kit.
*/
#define SFG_HEALTH_KIT_VALUE 20
2020-01-02 11:22:00 -05:00
/**
How much randomness (positive and negative) will be added to damage
2020-01-11 13:22:14 -05:00
(e.g. by weapons, explosions, ...). This constant is is 0 to 255, 255 meaning
2020-01-02 11:22:00 -05:00
100% of the base value.
*/
#define SFG_DAMAGE_RANDOMNESS 64
2020-08-04 15:49:53 -04:00
/**
Height of monster collision BBox in RCL_Units.
*/
#define SFG_MONSTER_COLLISION_HEIGHT 1024
2020-02-12 06:41:23 -05:00
/**
Specifies key repeat delay, in ms.
*/
#define SFG_KEY_REPEAT_DELAY 500
/**
Specifies key repeat period, in ms.
*/
#define SFG_KEY_REPEAT_PERIOD 150
2020-01-01 13:43:19 -05:00
/**
Angle in which multiple projectiles are spread, RCL_Units.
*/
#define SFG_PROJECTILE_SPREAD_ANGLE 100
2019-12-30 14:44:14 -05:00
#define SFG_MAX_MONSTERS 64
#define SFG_MAX_PROJECTILES 12
#define SFG_MAX_DOORS 32
2020-01-13 12:59:36 -05:00
#define SFG_AMMO_BULLETS 0
#define SFG_AMMO_ROCKETS 1
#define SFG_AMMO_PLASMA 2
#define SFG_AMMO_TOTAL 3
#define SFG_AMMO_NONE SFG_AMMO_TOTAL
2020-01-13 13:48:40 -05:00
#define SFG_AMMO_INCREASE_BULLETS 10
#define SFG_AMMO_INCREASE_ROCKETS 5
#define SFG_AMMO_INCREASE_PLASMA 8
2020-03-22 06:31:02 -04:00
#define SFG_AMMO_MAX_BULLETS 200
#define SFG_AMMO_MAX_ROCKETS 100
#define SFG_AMMO_MAX_PLASMA 150
2020-02-17 02:48:41 -05:00
/**
Duration of story text (intro/outro) in ms.
*/
#define SFG_STORYTEXT_DURATION 15000
2020-02-21 15:48:34 -05:00
/**
Time in ms of the player death animation.
*/
#define SFG_LOSE_ANIMATION_DURATION 2000
/**
Time in ms of the level win animation.
*/
2020-02-22 03:23:11 -05:00
#define SFG_WIN_ANIMATION_DURATION 2500
2020-02-21 15:48:34 -05:00
2020-09-16 15:02:18 -04:00
/**
Time in ms of the level start stage.
*/
2020-09-17 14:15:05 -04:00
#define SFG_LEVEL_START_DURATION 1500
2020-09-16 15:02:18 -04:00
2020-02-27 10:13:19 -05:00
/**
Vertical sprite size, in RCL_Units.
*/
#define SFG_BASE_SPRITE_SIZE RCL_UNITS_PER_SQUARE
2020-11-03 12:44:32 -05:00
// -----------------------------------------------------------------------------
2019-12-30 14:44:14 -05:00
// derived constants
#define SFG_GAME_RESOLUTION_X \
(SFG_SCREEN_RESOLUTION_X / SFG_RESOLUTION_SCALEDOWN)
#define SFG_GAME_RESOLUTION_Y \
(SFG_SCREEN_RESOLUTION_Y / SFG_RESOLUTION_SCALEDOWN)
#define SFG_MS_PER_FRAME (1000 / SFG_FPS) // ms per frame with target FPS
#if SFG_MS_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_MS_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_MS_PER_FRAME 1
#endif
2020-02-12 06:41:23 -05:00
#define SFG_KEY_REPEAT_DELAY_FRAMES \
(SFG_KEY_REPEAT_DELAY / SFG_MS_PER_FRAME)
#if SFG_KEY_REPEAT_DELAY_FRAMES == 0
2020-09-25 13:58:27 -04:00
#undef SFG_KEY_REPEAT_DELAY_FRAMES
2020-02-12 06:41:23 -05:00
#define SFG_KEY_REPEAT_DELAY_FRAMES 1
#endif
#define SFG_KEY_REPEAT_PERIOD_FRAMES \
(SFG_KEY_REPEAT_PERIOD / SFG_MS_PER_FRAME)
#if SFG_KEY_REPEAT_PERIOD_FRAMES == 0
2020-09-25 13:58:27 -04:00
#undef SFG_KEY_REPEAT_PERIOD_FRAMES
2020-02-12 06:41:23 -05:00
#define SFG_KEY_REPEAT_PERIOD_FRAMES 1
#endif
2019-12-30 14:44:14 -05:00
#define SFG_WEAPON_IMAGE_SCALE \
(SFG_GAME_RESOLUTION_X / (SFG_TEXTURE_SIZE * 5))
#if SFG_WEAPON_IMAGE_SCALE == 0
2020-09-25 13:58:27 -04:00
#undef SFG_WEAPON_IMAGE_SCALE
2019-12-30 14:44:14 -05:00
#define SFG_WEAPON_IMAGE_SCALE 1
#endif
#define SFG_WEAPONBOB_OFFSET_PIXELS \
(SFG_WEAPONBOB_OFFSET * SFG_WEAPON_IMAGE_SCALE)
#define SFG_WEAPON_IMAGE_POSITION_X \
(SFG_GAME_RESOLUTION_X / 2 - (SFG_WEAPON_IMAGE_SCALE * SFG_TEXTURE_SIZE) / 2)
2020-10-03 12:53:18 -04:00
#if SFG_GAME_RESOLUTION_Y > 70
2020-09-29 13:22:39 -04:00
#define SFG_WEAPON_IMAGE_POSITION_Y \
(SFG_GAME_RESOLUTION_Y - (SFG_WEAPON_IMAGE_SCALE * SFG_TEXTURE_SIZE))
2020-10-03 12:53:18 -04:00
#elif SFG_GAME_RESOLUTION_Y > 50
#define SFG_WEAPON_IMAGE_POSITION_Y (SFG_GAME_RESOLUTION_Y \
- ((SFG_WEAPON_IMAGE_SCALE * 3 * SFG_TEXTURE_SIZE) / 4))
2020-09-29 13:22:39 -04:00
#else
#define SFG_WEAPON_IMAGE_POSITION_Y \
(SFG_GAME_RESOLUTION_Y - SFG_TEXTURE_SIZE / 2)
#endif
2019-12-30 14:44:14 -05:00
#define SFG_PLAYER_TURN_UNITS_PER_FRAME \
((SFG_PLAYER_TURN_SPEED * RCL_UNITS_PER_SQUARE) / (360 * SFG_FPS))
#if SFG_PLAYER_TURN_UNITS_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_PLAYER_TURN_UNITS_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_PLAYER_TURN_UNITS_PER_FRAME 1
#endif
#define SFG_PLAYER_MOVE_UNITS_PER_FRAME \
((SFG_PLAYER_MOVE_SPEED * RCL_UNITS_PER_SQUARE) / SFG_FPS)
#if SFG_PLAYER_MOVE_UNITS_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_PLAYER_MOVE_UNITS_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_PLAYER_MOVE_UNITS_PER_FRAME 1
#endif
#define SFG_GRAVITY_SPEED_INCREASE_PER_FRAME \
((SFG_GRAVITY_ACCELERATION * RCL_UNITS_PER_SQUARE) / (SFG_FPS * SFG_FPS))
#if SFG_GRAVITY_SPEED_INCREASE_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_GRAVITY_SPEED_INCREASE_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_GRAVITY_SPEED_INCREASE_PER_FRAME 1
#endif
2020-03-28 12:34:09 -04:00
#define SFG_PLAYER_JUMP_OFFSET_PER_FRAME \
2020-09-13 13:53:04 -04:00
(((SFG_PLAYER_JUMP_SPEED * RCL_UNITS_PER_SQUARE) / SFG_FPS) \
- SFG_GRAVITY_SPEED_INCREASE_PER_FRAME / 2)
/* ^ This substraction corrects the initial veloc. so that the numeric curve
copies the analytical (smooth) curve. Without it the numeric curve goes
ABOVE and makes player jump higher with lower FPS. To make sense of this
try to solve the differential equation and plot it. */
2020-03-28 12:34:09 -04:00
#if SFG_PLAYER_JUMP_OFFSET_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_PLAYER_JUMP_OFFSET_PER_FRAME
2020-03-28 12:34:09 -04:00
#define SFG_PLAYER_JUMP_OFFSET_PER_FRAME 1
#endif
2019-12-30 14:44:14 -05:00
#define SFG_HEADBOB_FRAME_INCREASE_PER_FRAME \
(SFG_HEADBOB_SPEED / SFG_FPS)
#if SFG_HEADBOB_FRAME_INCREASE_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_HEADBOB_FRAME_INCREASE_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_HEADBOB_FRAME_INCREASE_PER_FRAME 1
#endif
#define SFG_HEADBOB_ENABLED (SFG_HEADBOB_SPEED > 0 && SFG_HEADBOB_OFFSET > 0)
#define SFG_CAMERA_SHEAR_STEP_PER_FRAME \
((SFG_GAME_RESOLUTION_Y * SFG_CAMERA_SHEAR_SPEED) / SFG_FPS)
#if SFG_CAMERA_SHEAR_STEP_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_CAMERA_SHEAR_STEP_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_CAMERA_SHEAR_STEP_PER_FRAME 1
#endif
#define SFG_CAMERA_MAX_SHEAR_PIXELS \
2020-09-26 18:31:38 -04:00
((SFG_CAMERA_MAX_SHEAR * SFG_GAME_RESOLUTION_Y) / 1024)
2019-12-30 14:44:14 -05:00
#define SFG_FONT_SIZE_SMALL \
(SFG_GAME_RESOLUTION_X / (SFG_FONT_CHARACTER_SIZE * 50))
#if SFG_FONT_SIZE_SMALL == 0
2020-09-25 13:58:27 -04:00
#undef SFG_FONT_SIZE_SMALL
2019-12-30 14:44:14 -05:00
#define SFG_FONT_SIZE_SMALL 1
#endif
#define SFG_FONT_SIZE_MEDIUM \
(SFG_GAME_RESOLUTION_X / (SFG_FONT_CHARACTER_SIZE * 30))
#if SFG_FONT_SIZE_MEDIUM == 0
2020-09-25 13:58:27 -04:00
#undef SFG_FONT_SIZE_MEDIUM
2019-12-30 14:44:14 -05:00
#define SFG_FONT_SIZE_MEDIUM 1
#endif
#define SFG_FONT_SIZE_BIG \
(SFG_GAME_RESOLUTION_X / (SFG_FONT_CHARACTER_SIZE * 18))
#if SFG_FONT_SIZE_BIG == 0
2020-09-25 13:58:27 -04:00
#undef SFG_FONT_SIZE_BIG
2019-12-30 14:44:14 -05:00
#define SFG_FONT_SIZE_BIG 1
#endif
#define SFG_Z_BUFFER_SIZE SFG_GAME_RESOLUTION_X
/**
Step in which walls get higher, in raycastlib units.
*/
#define SFG_WALL_HEIGHT_STEP (RCL_UNITS_PER_SQUARE / 4)
#define SFG_CEILING_MAX_HEIGHT\
(16 * RCL_UNITS_PER_SQUARE - RCL_UNITS_PER_SQUARE / 2 )
#define SFG_DOOR_UP_DOWN_MASK 0x20
2020-02-08 15:41:05 -05:00
#define SFG_DOOR_LOCK(doorRecord) ((doorRecord) >> 6)
2019-12-30 14:44:14 -05:00
#define SFG_DOOR_VERTICAL_POSITION_MASK 0x1f
#define SFG_DOOR_HEIGHT_STEP (RCL_UNITS_PER_SQUARE / 0x1f)
#define SFG_DOOR_INCREMENT_PER_FRAME \
(SFG_DOOR_OPEN_SPEED / (SFG_DOOR_HEIGHT_STEP * SFG_FPS))
#if SFG_DOOR_INCREMENT_PER_FRAME == 0
2020-09-25 13:58:27 -04:00
#undef SFG_DOOR_INCREMENT_PER_FRAME
2019-12-30 14:44:14 -05:00
#define SFG_DOOR_INCREMENT_PER_FRAME 1
#endif
#define SFG_MAX_ITEMS SFG_MAX_LEVEL_ELEMENTS
#define SFG_MAX_SPRITE_SIZE SFG_GAME_RESOLUTION_X
#define SFG_MAP_PIXEL_SIZE (SFG_GAME_RESOLUTION_Y / SFG_MAP_SIZE)
#if SFG_MAP_PIXEL_SIZE == 0
2020-09-29 13:22:39 -04:00
#undef SFG_MAP_PIXEL_SIZE
#define SFG_MAP_PIXEL_SIZE 1
2019-12-30 14:44:14 -05:00
#endif
#define SFG_AI_UPDATE_FRAME_INTERVAL \
(SFG_FPS / SFG_AI_FPS)
#if SFG_AI_UPDATE_FRAME_INTERVAL == 0
2020-09-25 13:58:27 -04:00
#undef SFG_AI_UPDATE_FRAME_INTERVAL
2019-12-30 14:44:14 -05:00
#define SFG_AI_UPDATE_FRAME_INTERVAL 1
#endif
#define SFG_SPRITE_ANIMATION_FRAME_DURATION \
(SFG_FPS / SFG_SPRITE_ANIMATION_SPEED)
#if SFG_SPRITE_ANIMATION_FRAME_DURATION == 0
2020-09-25 13:58:27 -04:00
#undef SFG_SPRITE_ANIMATION_FRAME_DURATION
2019-12-30 14:44:14 -05:00
#define SFG_SPRITE_ANIMATION_FRAME_DURATION 1
#endif
#define SFG_HUD_MARGIN (SFG_GAME_RESOLUTION_X / 40)
2020-01-12 10:48:42 -05:00
#define SFG_HUD_BORDER_INDICATOR_WIDTH_PIXELS \
(SFG_GAME_RESOLUTION_Y / SFG_HUD_BORDER_INDICATOR_WIDTH)
2019-12-30 14:44:14 -05:00
2020-01-12 10:48:42 -05:00
#define SFG_HUD_BORDER_INDICATOR_DURATION_FRAMES \
(SFG_HUD_BORDER_INDICATOR_DURATION / SFG_MS_PER_FRAME)
2019-12-30 14:44:14 -05:00
2020-01-12 10:48:42 -05:00
#if SFG_HUD_BORDER_INDICATOR_DURATION_FRAMES == 0
#define SFG_HUD_BORDER_INDICATOR_DURATION_FRAMES 1
2019-12-30 14:44:14 -05:00
#endif
2020-03-22 06:31:02 -04:00
#define SFG_BLINK_PERIOD_FRAMES (SFG_BLINK_PERIOD / SFG_MS_PER_FRAME)
2019-12-30 14:44:14 -05:00
#define SFG_HUD_BAR_HEIGHT \
(SFG_FONT_CHARACTER_SIZE * SFG_FONT_SIZE_MEDIUM + SFG_HUD_MARGIN * 2 + 1)
2020-11-03 12:44:32 -05:00
// -----------------------------------------------------------------------------
2019-12-30 18:35:35 -05:00
// monsters
#define SFG_MONSTER_ATTACK_MELEE 0
#define SFG_MONSTER_ATTACK_FIREBALL 1
#define SFG_MONSTER_ATTACK_BULLET 2
#define SFG_MONSTER_ATTACK_FIREBALL_BULLET 3
#define SFG_MONSTER_ATTACK_PLASMA 4
#define SFG_MONSTER_ATTACK_EXPLODE 5
2020-09-26 18:05:33 -04:00
#define SFG_MONSTER_ATTACK_FIREBALL_PLASMA 6
2019-12-30 18:35:35 -05:00
#define SFG_MONSTER_ATTRIBUTE(attackType,aggressivity0to255,health0to255,spriteSize0to3) \
((uint16_t) ( \
attackType | \
((aggressivity0to255 / 8) << 3) | \
(spriteSize0to3 << 8) | \
((health0to255 / 4) << 10)))
#define SFG_GET_MONSTER_ATTACK_TYPE(monsterNumber) \
(SFG_monsterAttributeTable[monsterNumber] & 0x0007)
#define SFG_GET_MONSTER_AGGRESSIVITY(monsterNumber) \
(((SFG_monsterAttributeTable[monsterNumber] >> 3) & 0x1F) * 8)
#define SFG_GET_MONSTER_SPRITE_SIZE(monsterNumber) \
((SFG_monsterAttributeTable[monsterNumber] >> 8) & 0x03)
#define SFG_GET_MONSTER_MAX_HEALTH(monsterNumber) \
(((SFG_monsterAttributeTable[monsterNumber] >> 10) & 0x3F) * 4)
/**
Table of monster attributes, each as a 16bit word in format:
MSB hhhhhhssaaaattt LSB
ttt: attack type
aaaaa: aggressivity (frequence of attacks), 0 to 31
ss: sprite size
hhhhhh: health, 0 to 63
*/
uint16_t SFG_monsterAttributeTable[SFG_MONSTERS_TOTAL] =
{
2020-09-12 05:34:11 -04:00
/* spider */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL,40,61,2),
2020-09-28 13:26:48 -04:00
/* destr. */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL_BULLET,90,170,3),
2020-09-12 05:34:11 -04:00
/* warrior */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_MELEE,255,40,1),
2020-09-28 13:26:48 -04:00
/* plasma */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_PLASMA,56,92,1),
/* ender */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_FIREBALL_PLASMA,128,255,3),
2020-09-12 05:34:11 -04:00
/* turret */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_BULLET,32,23,0),
/* explod. */ SFG_MONSTER_ATTRIBUTE(SFG_MONSTER_ATTACK_EXPLODE,255,36,1)
2019-12-30 18:35:35 -05:00
};
2020-11-03 12:44:32 -05:00
// -----------------------------------------------------------------------------
2019-12-30 15:35:19 -05:00
// weapons and projectiles
2019-12-30 14:44:14 -05:00
#define SFG_WEAPON_KNIFE 0
#define SFG_WEAPON_SHOTGUN 1
#define SFG_WEAPON_MACHINE_GUN 2
#define SFG_WEAPON_ROCKET_LAUNCHER 3
#define SFG_WEAPON_PLASMAGUN 4
2020-01-01 10:35:20 -05:00
#define SFG_WEAPON_SOLUTION 5
2019-12-30 14:44:14 -05:00
2020-01-01 10:35:20 -05:00
#define SFG_WEAPONS_TOTAL 6
2019-12-30 14:44:14 -05:00
2020-01-01 14:53:05 -05:00
#define SFG_WEAPON_ATTRIBUTE(fireType,projectileCount,fireCooldownMs) \
((uint8_t) (fireType | ((projectileCount - 1) << 2) | ((fireCooldownMs / (SFG_MS_PER_FRAME * 16)) << 4)))
2019-12-30 14:44:14 -05:00
#define SFG_GET_WEAPON_FIRE_TYPE(weaponNumber) \
2020-01-01 14:53:05 -05:00
(SFG_weaponAttributeTable[weaponNumber] & 0x03)
2019-12-30 14:44:14 -05:00
#define SFG_GET_WEAPON_FIRE_COOLDOWN_FRAMES(weaponNumber) \
2020-01-01 14:53:05 -05:00
((SFG_weaponAttributeTable[weaponNumber] >> 4) * 16)
#define SFG_GET_WEAPON_PROJECTILE_COUNT(weaponNumber) \
(((SFG_weaponAttributeTable[weaponNumber] >> 2) & 0x03) + 1)
2019-12-30 14:44:14 -05:00
2020-03-13 16:53:30 -04:00
#define SFG_MIN_WEAPON_COOLDOWN_FRAMES 8
2019-12-30 14:44:14 -05:00
#define SFG_WEAPON_FIRE_TYPE_MELEE 0
#define SFG_WEAPON_FIRE_TYPE_BULLET 1
2020-01-01 14:53:05 -05:00
#define SFG_WEAPON_FIRE_TYPE_FIREBALL 2
#define SFG_WEAPON_FIRE_TYPE_PLASMA 3
2019-12-30 14:44:14 -05:00
2020-01-02 11:22:00 -05:00
#define SFG_WEAPON_FIRE_TYPES_TOTAL 4
2019-12-30 14:44:14 -05:00
/**
2019-12-30 15:35:19 -05:00
Table of weapon attributes, each as a byte in format:
2019-12-30 14:44:14 -05:00
2020-01-01 14:53:05 -05:00
MSB ccccnnff LSB
2019-12-30 14:44:14 -05:00
2020-01-01 14:53:05 -05:00
ff: fire type
nn: number of projectiles - 1
cccc: fire cooldown in frames, i.e. time after which the next shot can be
2020-03-13 16:53:30 -04:00
shot again, ccccc has to be multiplied by 16 to get the real value
2019-12-30 14:44:14 -05:00
*/
SFG_PROGRAM_MEMORY uint8_t SFG_weaponAttributeTable[SFG_WEAPONS_TOTAL] =
{
2020-09-12 05:34:11 -04:00
/* knife */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_MELEE,1,650), // DPS: 6.2
2020-09-28 13:26:48 -04:00
/* shotgun */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_BULLET,2,1250), // DPS: 12.8
2020-09-12 05:34:11 -04:00
/* m. gun */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_BULLET,1,700), // DPS: 11.4
/* r. laun. */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_FIREBALL,1,850), // DPS: 28.2
/* plasma */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_PLASMA,1,550), // DPS: 32.7
/* solution */ SFG_WEAPON_ATTRIBUTE(SFG_WEAPON_FIRE_TYPE_PLASMA,4,1050) // DPS: 85.7
2019-12-30 14:44:14 -05:00
};
2020-01-02 11:22:00 -05:00
SFG_PROGRAM_MEMORY uint8_t SFG_attackDamageTable[SFG_WEAPON_FIRE_TYPES_TOTAL] =
{
2020-09-12 05:34:11 -04:00
/* melee */ 4,
/* bullet */ 8,
/* explostion (fireball) */ 24,
/* plasma */ 18
2020-01-02 11:22:00 -05:00
};
2019-12-30 15:35:19 -05:00
#define SFG_PROJECTILE_EXPLOSION 0
#define SFG_PROJECTILE_FIREBALL 1
#define SFG_PROJECTILE_PLASMA 2
#define SFG_PROJECTILE_DUST 3
#define SFG_PROJECTILE_BULLET 4
#define SFG_PROJECTILE_NONE 255
#define SFG_PROJECTILES_TOTAL 5
#define SFG_PROJECTILE_ATTRIBUTE(speedSquaresPerSec,timeToLiveMs) \
((uint8_t) \
((((speedSquaresPerSec / 4 == 0) && (speedSquaresPerSec != 0)) ? 1 : speedSquaresPerSec / 4) | \
((timeToLiveMs / (8 * SFG_MS_PER_FRAME)) << 3)))
#define SFG_GET_PROJECTILE_SPEED_UPS(projectileNumber) \
(((SFG_projectileAttributeTable[projectileNumber] & 0x07) * 4 * RCL_UNITS_PER_SQUARE) / SFG_FPS)
#define SFG_GET_PROJECTILE_FRAMES_TO_LIVE(projectileNumber) \
((SFG_projectileAttributeTable[projectileNumber] >> 3) * 8)
/**
Table of projectile attributes, each as a byte in format:
2019-12-30 18:35:35 -05:00
MSB lllllsss LSB
2019-12-30 15:35:19 -05:00
fff: half speed in game squares per second
lllll: eigth of frames to live
*/
2020-10-03 14:29:15 -04:00
2020-10-12 09:47:20 -04:00
#define LOW_FPS (SFG_FPS < 24) ///< low FPS needs low speeds, because collisions
2020-10-03 14:29:15 -04:00
2019-12-30 15:35:19 -05:00
SFG_PROGRAM_MEMORY uint8_t SFG_projectileAttributeTable[SFG_PROJECTILES_TOTAL] =
{
2019-12-30 18:40:37 -05:00
/* explosion */ SFG_PROJECTILE_ATTRIBUTE(0,400),
2020-09-26 09:35:09 -04:00
/* fireball */ SFG_PROJECTILE_ATTRIBUTE(10,1000),
2020-10-03 14:29:15 -04:00
#if LOW_FPS
/* plasma */ SFG_PROJECTILE_ATTRIBUTE(17,500),
#else
2020-09-26 09:35:09 -04:00
/* plasma */ SFG_PROJECTILE_ATTRIBUTE(18,500),
2020-10-03 14:29:15 -04:00
#endif
2019-12-30 15:35:19 -05:00
/* dust */ SFG_PROJECTILE_ATTRIBUTE(0,450),
2020-10-03 14:29:15 -04:00
#if LOW_FPS
/* bullet */ SFG_PROJECTILE_ATTRIBUTE(17,1000)
2020-10-03 12:53:18 -04:00
#else
2019-12-30 15:35:19 -05:00
/* bullet */ SFG_PROJECTILE_ATTRIBUTE(28,1000)
2020-10-03 12:53:18 -04:00
#endif
2019-12-30 15:35:19 -05:00
};
2020-10-03 14:29:15 -04:00
#undef LOW_FPS
2019-09-25 09:51:19 -04:00
#endif // guard