Start function pointers
This commit is contained in:
parent
ed8c0031f4
commit
1ab4d328a6
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
SOURCES := src/*.c
|
||||
SOURCES := src/*.c src/elements/*.c
|
||||
|
||||
CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/
|
||||
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef POWDER_H
|
||||
#define POWDER_H
|
||||
|
||||
#include "air.h"
|
||||
#include "graphics.h"
|
||||
#include "defines.h"
|
||||
#include "interface.h"
|
||||
@ -220,6 +221,17 @@
|
||||
#define PROP_RADIOACTIVE 0x2000 //8192 Radioactive
|
||||
#define FLAG_STAGNANT 1
|
||||
|
||||
#define UPDATE_FUNC_ARGS int i, int x, int y, int nx, int ny, float lx, float ly
|
||||
|
||||
int update_PCLN(UPDATE_FUNC_ARGS);
|
||||
int update_PHOT(UPDATE_FUNC_ARGS);
|
||||
int update_PSTE(UPDATE_FUNC_ARGS);
|
||||
int update_SPAWN(UPDATE_FUNC_ARGS);
|
||||
int update_SPAWN2(UPDATE_FUNC_ARGS);
|
||||
int update_STKM(UPDATE_FUNC_ARGS);
|
||||
int update_STKM2(UPDATE_FUNC_ARGS);
|
||||
|
||||
|
||||
struct particle
|
||||
{
|
||||
int type;
|
||||
@ -256,7 +268,7 @@ struct part_type
|
||||
unsigned char hconduct;
|
||||
const char *descs;
|
||||
const unsigned short properties;
|
||||
int (*update_func) (int);
|
||||
int (*update_func) (UPDATE_FUNC_ARGS);
|
||||
};
|
||||
typedef struct part_type part_type;
|
||||
|
||||
@ -316,7 +328,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"DMND", PIXPACK(0xCCFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Diamond. Indestructable.", TYPE_SOLID, NULL}, //ief015 - Added diamond. Because concrete blocks are kinda pointless.
|
||||
{"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
|
||||
{"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", TYPE_PART|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
|
||||
{"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", TYPE_ENERGY, NULL},
|
||||
{"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", TYPE_ENERGY, &update_PHOT},
|
||||
{"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", TYPE_PART | PROP_RADIOACTIVE, NULL},
|
||||
{"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", TYPE_SOLID, NULL},
|
||||
{"MWAX", PIXPACK(0xE0E0AA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 5, 0, 0, 2, 1, 25, SC_LIQUID, R_TEMP+28.0f+273.15f, 44, "Liquid Wax.", TYPE_LIQUID, NULL},
|
||||
@ -340,7 +352,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when intruduced to electricity", TYPE_GAS, NULL},
|
||||
{"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", TYPE_SOLID, NULL},
|
||||
{"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", TYPE_SOLID, NULL},
|
||||
{"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL},
|
||||
{"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, &update_STKM},
|
||||
{"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", TYPE_SOLID, NULL},
|
||||
{"SMKE", PIXPACK(0x222222), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+320.0f+273.15f, 88, "Smoke", TYPE_GAS, NULL},
|
||||
{"DESL", PIXPACK(0x440000), 1.0f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.0f, 0.0f * CFDS, 2, 2, 0, 0, 5, 1, 15, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Explodes under high pressure and temperatures", TYPE_LIQUID, NULL},
|
||||
@ -359,7 +371,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", TYPE_PART, NULL},
|
||||
{"AMTR", PIXPACK(0x808080), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.00f, 0.10f, 1.00f, 0.0000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Anti-Matter, Destroys a majority of particles", TYPE_PART, NULL}, //Maybe TYPE_ENERGY?
|
||||
{"BCOL", PIXPACK(0x333333), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Coal. Heavy particles. See COAL", TYPE_PART, NULL},
|
||||
{"PCLN", PIXPACK(0x3B3B10), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. When actived, duplicates any particles it touches.", TYPE_SOLID, NULL},
|
||||
{"PCLN", PIXPACK(0x3B3B10), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. When actived, duplicates any particles it touches.", TYPE_SOLID, &update_PCLN},
|
||||
{"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", TYPE_SOLID, NULL},
|
||||
{"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrlosis of WATR", TYPE_SOLID, NULL},
|
||||
{"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", TYPE_PART, NULL},
|
||||
@ -396,14 +408,14 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"ISZS", PIXPACK(0x662089), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0007f* CFDS, 0, 0, 0, 1, 1, 1, 100, SC_NUCLEAR, 140.00f, 251, "Solid form of ISOZ, slowly decays.", TYPE_SOLID, NULL},
|
||||
{"PRTI", PIXPACK(0xEB5917), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal IN. Things go in here. Alter temperature for channels", TYPE_SOLID, NULL},
|
||||
{"PRTO", PIXPACK(0x0020EB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.005f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 0, "Portal OUT. Things come out here. Alter temperature for channels", TYPE_SOLID, NULL},
|
||||
{"PSTE", PIXPACK(0xAA99AA), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Colloid, Hardens under pressure", TYPE_LIQUID, NULL},
|
||||
{"PSTE", PIXPACK(0xAA99AA), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 31, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Colloid, Hardens under pressure", TYPE_LIQUID, &update_PSTE},
|
||||
{"PSTS", PIXPACK(0x776677), 0.0f, 0.00f * CFDS, 0.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 20, 0, 100, SC_CRACKER, R_TEMP-2.0f +273.15f, 29, "Solid form of PSTE, temporary", TYPE_SOLID, NULL},
|
||||
{"ANAR", PIXPACK(0xFFFFEE), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.1f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Behaves opposite gravity", TYPE_PART, NULL},
|
||||
{"VINE", PIXPACK(0x079A00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Vine, grows", TYPE_SOLID, NULL},
|
||||
{"INVS", PIXPACK(0x00CCCC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Invisible to everything while under pressure.", TYPE_SOLID | PROP_NEUTPASS, NULL},
|
||||
{"EQVE", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 0, 85, SC_CRACKER2, R_TEMP+0.0f +273.15f, 70, "Shared velocity test", TYPE_PART, NULL},
|
||||
{"SPWN2", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL},
|
||||
{"SPWN", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL},
|
||||
{"SPWN2", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, &update_SPAWN2},
|
||||
{"SPWN", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, &update_SPAWN},
|
||||
{"SHLD", PIXPACK(0xAAAAAA), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 0, "Shield, spark it to grow", 0, NULL},
|
||||
{"SHD2", PIXPACK(0x777777), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 2", 0, NULL},
|
||||
{"SHD3", PIXPACK(0x444444), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 0, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 0, "Shield lvl 3", 0, NULL},
|
||||
@ -413,7 +425,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", TYPE_SOLID, NULL},
|
||||
{"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emmitter. Rays create points when they collide", TYPE_SOLID, NULL},
|
||||
{"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL},
|
||||
{"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL},
|
||||
{"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, &update_STKM2},
|
||||
{"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", TYPE_PART, NULL},
|
||||
{"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", TYPE_SOLID | PROP_NEUTPENETRATE, NULL},
|
||||
{"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", TYPE_PART, NULL},
|
||||
@ -670,6 +682,10 @@ extern unsigned pmap[YRES][XRES];
|
||||
unsigned cb_pmap[YRES][XRES];
|
||||
|
||||
int try_move(int i, int x, int y, int nx, int ny);
|
||||
int eval_move(int pt, int nx, int ny, unsigned *rr);
|
||||
|
||||
static void create_cherenkov_photon(int pp);
|
||||
static void create_gain_photon(int pp);
|
||||
|
||||
void kill_part(int i);
|
||||
|
||||
|
5
src/elements/none.c
Normal file
5
src/elements/none.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_(UPDATE_FUNC_ARGS) {
|
||||
|
||||
}
|
42
src/elements/pcln.c
Normal file
42
src/elements/pcln.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_PCLN(UPDATE_FUNC_ARGS) {
|
||||
if (!parts[i].ctype)
|
||||
for (nx=-1; nx<2; nx++)
|
||||
for (ny=-1; ny<2; ny++)
|
||||
if (x+nx>=0 && y+ny>0 &&
|
||||
x+nx<XRES && y+ny<YRES &&
|
||||
pmap[y+ny][x+nx] &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_SPRK &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_NSCN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_PSCN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
|
||||
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
|
||||
if (parts[i].ctype && parts[i].life==10) {
|
||||
if (parts[i].ctype==PT_PHOT) {
|
||||
for (nx=-1; nx<2; nx++) {
|
||||
for (ny=-1; ny<2; ny++) {
|
||||
int r = create_part(-1, x+nx, y+ny, parts[i].ctype);
|
||||
if (r!=-1) {
|
||||
parts[r].vx = nx*3;
|
||||
parts[r].vy = ny*3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ptypes[parts[i].ctype].properties&PROP_LIFE) {
|
||||
for (nx=-1; nx<2; nx++) {
|
||||
for (ny=-1; ny<2; ny++) {
|
||||
create_part(-1, x+nx, y+ny, parts[i].ctype);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
}
|
||||
}
|
||||
}
|
7
src/elements/phot.c
Normal file
7
src/elements/phot.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_PHOT(UPDATE_FUNC_ARGS) {
|
||||
// TODO
|
||||
|
||||
return 0;
|
||||
}
|
7
src/elements/pste.c
Normal file
7
src/elements/pste.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_PSTE(UPDATE_FUNC_ARGS) {
|
||||
if (parts[i].temp>747.0f)
|
||||
parts[i].type = PT_BRCK;
|
||||
return 0;
|
||||
}
|
403
src/elements/stkm.c
Normal file
403
src/elements/stkm.c
Normal file
@ -0,0 +1,403 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_SPAWN(UPDATE_FUNC_ARGS) {
|
||||
if (death)
|
||||
{
|
||||
playerspawn = create_part(-1,x,y,PT_STKM);
|
||||
isplayer = 1;
|
||||
death = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int update_STKM(UPDATE_FUNC_ARGS) {
|
||||
int r;
|
||||
float pp, d;
|
||||
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
|
||||
//Tempirature handling
|
||||
if (parts[i].temp<243)
|
||||
parts[i].life -= 1;
|
||||
if ((parts[i].temp<309.6f) && (parts[i].temp>=243))
|
||||
parts[i].temp += 1;
|
||||
|
||||
//Death
|
||||
if (parts[i].life<1 || death || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
|
||||
{
|
||||
for (r=-2; r<=1; r++)
|
||||
{
|
||||
create_part(-1, x+r, y-2, player[2]);
|
||||
create_part(-1, x+r+1, y+2, player[2]);
|
||||
create_part(-1, x-2, y+r+1, player[2]);
|
||||
create_part(-1, x+2, y+r, player[2]);
|
||||
}
|
||||
kill_part(i); //Kill him
|
||||
return 1;
|
||||
}
|
||||
|
||||
parts[i].vy += -0.7*dt; //Head up!
|
||||
|
||||
//Verlet integration
|
||||
pp = 2*player[3]-player[5]+player[19]*dt*dt;;
|
||||
player[5] = player[3];
|
||||
player[3] = pp;
|
||||
pp = 2*player[4]-player[6]+player[20]*dt*dt;;
|
||||
player[6] = player[4];
|
||||
player[4] = pp;
|
||||
|
||||
pp = 2*player[7]-player[9]+player[21]*dt*dt;;
|
||||
player[9] = player[7];
|
||||
player[7] = pp;
|
||||
pp = 2*player[8]-player[10]+(player[22]+1)*dt*dt;;
|
||||
player[10] = player[8];
|
||||
player[8] = pp;
|
||||
|
||||
pp = 2*player[11]-player[13]+player[23]*dt*dt;;
|
||||
player[13] = player[11];
|
||||
player[11] = pp;
|
||||
pp = 2*player[12]-player[14]+player[24]*dt*dt;;
|
||||
player[14] = player[12];
|
||||
player[12] = pp;
|
||||
|
||||
pp = 2*player[15]-player[17]+player[25]*dt*dt;;
|
||||
player[17] = player[15];
|
||||
player[15] = pp;
|
||||
pp = 2*player[16]-player[18]+(player[26]+1)*dt*dt;;
|
||||
player[18] = player[16];
|
||||
player[16] = pp;
|
||||
|
||||
//Setting acceleration to 0
|
||||
player[19] = 0;
|
||||
player[20] = 0;
|
||||
|
||||
player[21] = 0;
|
||||
player[22] = 0;
|
||||
|
||||
player[23] = 0;
|
||||
player[24] = 0;
|
||||
|
||||
player[25] = 0;
|
||||
player[26] = 0;
|
||||
|
||||
//Go left
|
||||
if (((int)(player[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = -3;
|
||||
player[22] = -2;
|
||||
player[19] = -2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = -3;
|
||||
player[26] = -2;
|
||||
player[23] = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids
|
||||
{
|
||||
player[21] = -1;
|
||||
player[22] = -1;
|
||||
player[19] = -1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = -1;
|
||||
player[26] = -1;
|
||||
player[23] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Go right
|
||||
if (((int)(player[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = 3;
|
||||
player[22] = -2;
|
||||
player[19] = 2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = 3;
|
||||
player[26] = -2;
|
||||
player[23] = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = 1;
|
||||
player[22] = -1;
|
||||
player[19] = 1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = 1;
|
||||
player[26] = -1;
|
||||
player[23] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Jump
|
||||
if (((int)(player[0])&0x04) == 0x04 && (pstates[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS))
|
||||
{
|
||||
if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])])
|
||||
{
|
||||
parts[i].vy = -5;
|
||||
player[22] -= 1;
|
||||
player[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Charge detector wall if foot inside
|
||||
if (bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)player[7]/CELL, (int)player[8]/CELL);
|
||||
if (bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL);
|
||||
|
||||
//Searching for particles near head
|
||||
for (nx = -2; nx <= 2; nx++)
|
||||
for (ny = 0; ny>=-2; ny--)
|
||||
{
|
||||
if (!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
|
||||
continue;
|
||||
if (ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT)
|
||||
{
|
||||
player[2] = pmap[ny+y][nx+x]&0xFF; //Current element
|
||||
}
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
|
||||
{
|
||||
if (parts[i].life<=95)
|
||||
parts[i].life += 5;
|
||||
else
|
||||
parts[i].life = 100;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
|
||||
{
|
||||
parts[i].life -= (102-parts[i].life)/2;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
if (bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
|
||||
player[2] = SPC_AIR;
|
||||
}
|
||||
|
||||
//Head position
|
||||
nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01);
|
||||
ny = y - 3*(player[1] == 0);
|
||||
|
||||
//Spawn
|
||||
if (((int)(player[0])&0x08) == 0x08)
|
||||
{
|
||||
ny -= 2*(rand()%2)+1;
|
||||
r = pmap[ny][nx];
|
||||
if (!((r>>8)>=NPART))
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_SOLID)
|
||||
{
|
||||
create_part(-1, nx, ny, PT_SPRK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player[2] == SPC_AIR)
|
||||
create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
|
||||
else
|
||||
create_part(-1, nx, ny, player[2]);
|
||||
|
||||
r = pmap[ny][nx];
|
||||
if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR)
|
||||
parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
|
||||
if (((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT)
|
||||
{
|
||||
int random = abs(rand()%3-1)*3;
|
||||
if (random==0)
|
||||
{
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].type = PT_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
parts[r>>8].vy = 0;
|
||||
parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Simulation of joints
|
||||
d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance
|
||||
player[7] -= (player[3]-player[7])*d;
|
||||
player[8] -= (player[4]-player[8])*d;
|
||||
player[3] += (player[3]-player[7])*d;
|
||||
player[4] += (player[4]-player[8])*d;
|
||||
|
||||
d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5;
|
||||
player[15] -= (player[11]-player[15])*d;
|
||||
player[16] -= (player[12]-player[16])*d;
|
||||
player[11] += (player[11]-player[15])*d;
|
||||
player[12] += (player[12]-player[16])*d;
|
||||
|
||||
d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player[3]-parts[i].x)*d;
|
||||
parts[i].vy -= (player[4]-parts[i].y)*d;
|
||||
player[3] += (player[3]-parts[i].x)*d;
|
||||
player[4] += (player[4]-parts[i].y)*d;
|
||||
|
||||
d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player[11]-parts[i].x)*d;
|
||||
parts[i].vy -= (player[12]-parts[i].y)*d;
|
||||
player[11] += (player[11]-parts[i].x)*d;
|
||||
player[12] += (player[12]-parts[i].y)*d;
|
||||
|
||||
//Side collisions checking
|
||||
for (nx = -3; nx <= 3; nx++)
|
||||
{
|
||||
r = pmap[(int)(player[16]-2)][(int)(player[15]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player[15] -= nx;
|
||||
|
||||
r = pmap[(int)(player[8]-2)][(int)(player[7]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player[7] -= nx;
|
||||
}
|
||||
|
||||
//Collision checks
|
||||
for (ny = -2-(int)parts[i].vy; ny<=0; ny++)
|
||||
{
|
||||
r = pmap[(int)(player[8]+ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-)
|
||||
|
||||
//For left leg
|
||||
if (r && (r&0xFF)!=PT_STKM)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks
|
||||
{
|
||||
if (parts[i].y<(player[8]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player[8] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player[9] = player[7];
|
||||
}
|
||||
|
||||
r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)];
|
||||
|
||||
//For right leg
|
||||
if (r && (r&0xFF)!=PT_STKM)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)
|
||||
{
|
||||
if (parts[i].y<(player[16]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player[16] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player[17] = player[15];
|
||||
}
|
||||
|
||||
//If it falls too fast
|
||||
if (parts[i].vy>=30)
|
||||
{
|
||||
parts[i].y -= (10+ny)*dt;
|
||||
parts[i].vy = -10*dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Keeping legs distance
|
||||
if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1)
|
||||
{
|
||||
player[21] -= 0.2;
|
||||
player[25] += 0.2;
|
||||
}
|
||||
|
||||
if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1)
|
||||
{
|
||||
player[19] -= 0.2;
|
||||
player[23] += 0.2;
|
||||
}
|
||||
|
||||
//If legs touch something
|
||||
r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player[22] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
isplayer = 1;
|
||||
}
|
404
src/elements/stkm2.c
Normal file
404
src/elements/stkm2.c
Normal file
@ -0,0 +1,404 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_SPAWN2(UPDATE_FUNC_ARGS) {
|
||||
if (death2)
|
||||
{
|
||||
player2spawn = create_part(-1,x,y,PT_STKM2);
|
||||
isplayer2 = 1;
|
||||
death2 = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int update_STKM2(UPDATE_FUNC_ARGS) {
|
||||
int r;
|
||||
float pp, d;
|
||||
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
|
||||
//Tempirature handling
|
||||
if (parts[i].temp<243)
|
||||
parts[i].life -= 1;
|
||||
if ((parts[i].temp<309.6f) && (parts[i].temp>=243))
|
||||
parts[i].temp += 1;
|
||||
|
||||
//Death
|
||||
if (parts[i].life<1 || death2 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
|
||||
{
|
||||
for (r=-2; r<=1; r++)
|
||||
{
|
||||
create_part(-1, x+r, y-2, player2[2]);
|
||||
create_part(-1, x+r+1, y+2, player2[2]);
|
||||
create_part(-1, x-2, y+r+1, player2[2]);
|
||||
create_part(-1, x+2, y+r, player2[2]);
|
||||
}
|
||||
kill_part(i); //Kill him
|
||||
return 1;
|
||||
}
|
||||
|
||||
parts[i].vy += -0.7*dt; //Head up!
|
||||
|
||||
//Verlet integration
|
||||
pp = 2*player2[3]-player2[5]+player2[19]*dt*dt;;
|
||||
player2[5] = player2[3];
|
||||
player2[3] = pp;
|
||||
pp = 2*player2[4]-player2[6]+player2[20]*dt*dt;;
|
||||
player2[6] = player2[4];
|
||||
player2[4] = pp;
|
||||
|
||||
pp = 2*player2[7]-player2[9]+player2[21]*dt*dt;;
|
||||
player2[9] = player2[7];
|
||||
player2[7] = pp;
|
||||
pp = 2*player2[8]-player2[10]+(player2[22]+1)*dt*dt;;
|
||||
player2[10] = player2[8];
|
||||
player2[8] = pp;
|
||||
|
||||
pp = 2*player2[11]-player2[13]+player2[23]*dt*dt;;
|
||||
player2[13] = player2[11];
|
||||
player2[11] = pp;
|
||||
pp = 2*player2[12]-player2[14]+player2[24]*dt*dt;;
|
||||
player2[14] = player2[12];
|
||||
player2[12] = pp;
|
||||
|
||||
pp = 2*player2[15]-player2[17]+player2[25]*dt*dt;;
|
||||
player2[17] = player2[15];
|
||||
player2[15] = pp;
|
||||
pp = 2*player2[16]-player2[18]+(player2[26]+1)*dt*dt;;
|
||||
player2[18] = player2[16];
|
||||
player2[16] = pp;
|
||||
|
||||
//Setting acceleration to 0
|
||||
player2[19] = 0;
|
||||
player2[20] = 0;
|
||||
|
||||
player2[21] = 0;
|
||||
player2[22] = 0;
|
||||
|
||||
player2[23] = 0;
|
||||
player2[24] = 0;
|
||||
|
||||
player2[25] = 0;
|
||||
player2[26] = 0;
|
||||
|
||||
//Go left
|
||||
if (((int)(player2[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = -3;
|
||||
player2[22] = -2;
|
||||
player2[19] = -2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = -3;
|
||||
player2[26] = -2;
|
||||
player2[23] = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) //It should move another way in liquids
|
||||
{
|
||||
player2[21] = -1;
|
||||
player2[22] = -1;
|
||||
player2[19] = -1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = -1;
|
||||
player2[26] = -1;
|
||||
player2[23] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Go right
|
||||
if (((int)(player2[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = 3;
|
||||
player2[22] = -2;
|
||||
player2[19] = 2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = 3;
|
||||
player2[26] = -2;
|
||||
player2[23] = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = 1;
|
||||
player2[22] = -1;
|
||||
player2[19] = 1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = 1;
|
||||
player2[26] = -1;
|
||||
player2[23] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Jump
|
||||
if (((int)(player2[0])&0x04) == 0x04 && (pstates[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS))
|
||||
{
|
||||
if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])])
|
||||
{
|
||||
parts[i].vy = -5;
|
||||
player2[22] -= 1;
|
||||
player2[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Charge detector wall if foot inside
|
||||
if (bmap[(int)(player2[8]+0.5)/CELL][(int)(player2[7]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)player2[7]/CELL, (int)player2[8]/CELL);
|
||||
if (bmap[(int)(player2[16]+0.5)/CELL][(int)(player2[15]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)(player2[15]+0.5)/CELL, (int)(player2[16]+0.5)/CELL);
|
||||
|
||||
//Searching for particles near head
|
||||
for (nx = -2; nx <= 2; nx++)
|
||||
for (ny = 0; ny>=-2; ny--)
|
||||
{
|
||||
if (!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
|
||||
continue;
|
||||
if (ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT)
|
||||
{
|
||||
player2[2] = pmap[ny+y][nx+x]&0xFF; //Current element
|
||||
}
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
|
||||
{
|
||||
if (parts[i].life<=95)
|
||||
parts[i].life += 5;
|
||||
else
|
||||
parts[i].life = 100;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
|
||||
{
|
||||
parts[i].life -= (102-parts[i].life)/2;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
if (bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
|
||||
player2[2] = SPC_AIR;
|
||||
}
|
||||
|
||||
//Head position
|
||||
nx = x + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01);
|
||||
ny = y - 3*(player2[1] == 0);
|
||||
|
||||
//Spawn
|
||||
if (((int)(player2[0])&0x08) == 0x08)
|
||||
{
|
||||
ny -= 2*(rand()%2)+1;
|
||||
r = pmap[ny][nx];
|
||||
if (!((r>>8)>=NPART))
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_SOLID)
|
||||
{
|
||||
create_part(-1, nx, ny, PT_SPRK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player2[2] == SPC_AIR)
|
||||
create_parts(nx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
|
||||
else
|
||||
create_part(-1, nx, ny, player2[2]);
|
||||
|
||||
r = pmap[ny][nx];
|
||||
if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
|
||||
parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
|
||||
if (((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT)
|
||||
{
|
||||
int random = abs(rand()%3-1)*3;
|
||||
if (random==0)
|
||||
{
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].type = PT_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
parts[r>>8].vy = 0;
|
||||
parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Simulation of joints
|
||||
d = 25/(pow((player2[3]-player2[7]), 2) + pow((player2[4]-player2[8]), 2)+25) - 0.5; //Fast distance
|
||||
player2[7] -= (player2[3]-player2[7])*d;
|
||||
player2[8] -= (player2[4]-player2[8])*d;
|
||||
player2[3] += (player2[3]-player2[7])*d;
|
||||
player2[4] += (player2[4]-player2[8])*d;
|
||||
|
||||
d = 25/(pow((player2[11]-player2[15]), 2) + pow((player2[12]-player2[16]), 2)+25) - 0.5;
|
||||
player2[15] -= (player2[11]-player2[15])*d;
|
||||
player2[16] -= (player2[12]-player2[16])*d;
|
||||
player2[11] += (player2[11]-player2[15])*d;
|
||||
player2[12] += (player2[12]-player2[16])*d;
|
||||
|
||||
d = 36/(pow((player2[3]-parts[i].x), 2) + pow((player2[4]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player2[3]-parts[i].x)*d;
|
||||
parts[i].vy -= (player2[4]-parts[i].y)*d;
|
||||
player2[3] += (player2[3]-parts[i].x)*d;
|
||||
player2[4] += (player2[4]-parts[i].y)*d;
|
||||
|
||||
d = 36/(pow((player2[11]-parts[i].x), 2) + pow((player2[12]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player2[11]-parts[i].x)*d;
|
||||
parts[i].vy -= (player2[12]-parts[i].y)*d;
|
||||
player2[11] += (player2[11]-parts[i].x)*d;
|
||||
player2[12] += (player2[12]-parts[i].y)*d;
|
||||
|
||||
//Side collisions checking
|
||||
for (nx = -3; nx <= 3; nx++)
|
||||
{
|
||||
r = pmap[(int)(player2[16]-2)][(int)(player2[15]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player2[15] -= nx;
|
||||
|
||||
r = pmap[(int)(player2[8]-2)][(int)(player2[7]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player2[7] -= nx;
|
||||
}
|
||||
|
||||
//Collision checks
|
||||
for (ny = -2-(int)parts[i].vy; ny<=0; ny++)
|
||||
{
|
||||
r = pmap[(int)(player2[8]+ny)][(int)(player2[7]+0.5)]; //This is to make coding more pleasant :-)
|
||||
|
||||
//For left leg
|
||||
if (r && (r&0xFF)!=PT_STKM2)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks
|
||||
{
|
||||
if (parts[i].y<(player2[8]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player2[8] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player2[9] = player2[7];
|
||||
}
|
||||
|
||||
r = pmap[(int)(player2[16]+ny)][(int)(player2[15]+0.5)];
|
||||
|
||||
//For right leg
|
||||
if (r && (r&0xFF)!=PT_STKM2)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)
|
||||
{
|
||||
if (parts[i].y<(player2[16]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player2[16] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player2[17] = player2[15];
|
||||
}
|
||||
|
||||
//If it falls too fast
|
||||
if (parts[i].vy>=30)
|
||||
{
|
||||
parts[i].y -= (10+ny)*dt;
|
||||
parts[i].vy = -10*dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Keeping legs distance
|
||||
if (pow((player2[7] - player2[15]), 2)<16 && pow((player2[8]-player2[16]), 2)<1)
|
||||
{
|
||||
player2[21] -= 0.2;
|
||||
player2[25] += 0.2;
|
||||
}
|
||||
|
||||
if (pow((player2[3] - player2[11]), 2)<16 && pow((player2[4]-player2[12]), 2)<1)
|
||||
{
|
||||
player2[19] -= 0.2;
|
||||
player2[23] += 0.2;
|
||||
}
|
||||
|
||||
//If legs touch something
|
||||
r = pmap[(int)(player2[8]+0.5)][(int)(player2[7]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player2[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
r = pmap[(int)(player2[16]+0.5)][(int)(player2[15]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player2[22] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
isplayer2 = 1;
|
||||
return 0;
|
||||
}
|
858
src/powder.c
858
src/powder.c
@ -58,7 +58,7 @@ static void photoelectric_effect(int nx, int ny)
|
||||
0 = No move/Bounce
|
||||
2 = Both particles occupy the same space.
|
||||
*/
|
||||
static int eval_move(int pt, int nx, int ny, unsigned *rr)
|
||||
int eval_move(int pt, int nx, int ny, unsigned *rr)
|
||||
{
|
||||
unsigned r;
|
||||
|
||||
@ -125,9 +125,6 @@ static int eval_move(int pt, int nx, int ny, unsigned *rr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void create_cherenkov_photon(int pp);
|
||||
static void create_gain_photon(int pp);
|
||||
|
||||
int try_move(int i, int x, int y, int nx, int ny)
|
||||
{
|
||||
unsigned r, e;
|
||||
@ -1339,11 +1336,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
lx = parts[i].x;
|
||||
ly = parts[i].y;
|
||||
t = parts[i].type;
|
||||
if (ptypes[t].update_func)
|
||||
{
|
||||
if (ptypes[t].update_func (i))
|
||||
goto killed;
|
||||
}
|
||||
//printf("parts[%d].type: %d\n", i, parts[i].type);
|
||||
|
||||
|
||||
@ -1687,9 +1679,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
parts[i].vy = rr*sinf(rrr);
|
||||
create_part(i, x, y, t);
|
||||
}
|
||||
if (t==PT_PSTE)
|
||||
if (parts[i].temp>747.0f)
|
||||
t = parts[i].type = PT_BRCK;
|
||||
if (t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1)
|
||||
{
|
||||
nearp = nearest_part(i, PT_ETRD);
|
||||
@ -4053,804 +4042,6 @@ killed:
|
||||
if (parts[i].type == PT_NONE)
|
||||
continue;
|
||||
}
|
||||
if (t==PT_STKM)
|
||||
{
|
||||
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
|
||||
//Tempirature handling
|
||||
if (parts[i].temp<243)
|
||||
parts[i].life -= 1;
|
||||
if ((parts[i].temp<309.6f) && (parts[i].temp>=243))
|
||||
parts[i].temp += 1;
|
||||
|
||||
//Death
|
||||
if (parts[i].life<1 || death == 1 || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
|
||||
{
|
||||
for (r=-2; r<=1; r++)
|
||||
{
|
||||
create_part(-1, x+r, y-2, player[2]);
|
||||
create_part(-1, x+r+1, y+2, player[2]);
|
||||
create_part(-1, x-2, y+r+1, player[2]);
|
||||
create_part(-1, x+2, y+r, player[2]);
|
||||
}
|
||||
kill_part(i); //Kill him
|
||||
goto killed;
|
||||
}
|
||||
|
||||
parts[i].vy += -0.7*dt; //Head up!
|
||||
|
||||
//Verlet integration
|
||||
pp = 2*player[3]-player[5]+player[19]*dt*dt;;
|
||||
player[5] = player[3];
|
||||
player[3] = pp;
|
||||
pp = 2*player[4]-player[6]+player[20]*dt*dt;;
|
||||
player[6] = player[4];
|
||||
player[4] = pp;
|
||||
|
||||
pp = 2*player[7]-player[9]+player[21]*dt*dt;;
|
||||
player[9] = player[7];
|
||||
player[7] = pp;
|
||||
pp = 2*player[8]-player[10]+(player[22]+1)*dt*dt;;
|
||||
player[10] = player[8];
|
||||
player[8] = pp;
|
||||
|
||||
pp = 2*player[11]-player[13]+player[23]*dt*dt;;
|
||||
player[13] = player[11];
|
||||
player[11] = pp;
|
||||
pp = 2*player[12]-player[14]+player[24]*dt*dt;;
|
||||
player[14] = player[12];
|
||||
player[12] = pp;
|
||||
|
||||
pp = 2*player[15]-player[17]+player[25]*dt*dt;;
|
||||
player[17] = player[15];
|
||||
player[15] = pp;
|
||||
pp = 2*player[16]-player[18]+(player[26]+1)*dt*dt;;
|
||||
player[18] = player[16];
|
||||
player[16] = pp;
|
||||
|
||||
//Setting acceleration to 0
|
||||
player[19] = 0;
|
||||
player[20] = 0;
|
||||
|
||||
player[21] = 0;
|
||||
player[22] = 0;
|
||||
|
||||
player[23] = 0;
|
||||
player[24] = 0;
|
||||
|
||||
player[25] = 0;
|
||||
player[26] = 0;
|
||||
|
||||
//Go left
|
||||
if (((int)(player[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = -3;
|
||||
player[22] = -2;
|
||||
player[19] = -2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = -3;
|
||||
player[26] = -2;
|
||||
player[23] = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])]) //It should move another way in liquids
|
||||
{
|
||||
player[21] = -1;
|
||||
player[22] = -1;
|
||||
player[19] = -1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = -1;
|
||||
player[26] = -1;
|
||||
player[23] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Go right
|
||||
if (((int)(player[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = 3;
|
||||
player[22] = -2;
|
||||
player[19] = 2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = 3;
|
||||
player[26] = -2;
|
||||
player[23] = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player[8]-1)][(int)(player[7])])
|
||||
{
|
||||
player[21] = 1;
|
||||
player[22] = -1;
|
||||
player[19] = 1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player[16]-1)][(int)(player[15])])
|
||||
{
|
||||
player[25] = 1;
|
||||
player[26] = -1;
|
||||
player[23] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Jump
|
||||
if (((int)(player[0])&0x04) == 0x04 && (pstates[pmap[(int)(player[8]-0.5)][(int)(player[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player[16]-0.5)][(int)(player[15])]&0xFF].state != ST_GAS))
|
||||
{
|
||||
if (pmap[(int)(player[8]-0.5)][(int)(player[7])] || pmap[(int)(player[16]-0.5)][(int)(player[15])])
|
||||
{
|
||||
parts[i].vy = -5;
|
||||
player[22] -= 1;
|
||||
player[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Charge detector wall if foot inside
|
||||
if (bmap[(int)(player[8]+0.5)/CELL][(int)(player[7]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)player[7]/CELL, (int)player[8]/CELL);
|
||||
if (bmap[(int)(player[16]+0.5)/CELL][(int)(player[15]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)(player[15]+0.5)/CELL, (int)(player[16]+0.5)/CELL);
|
||||
|
||||
//Searching for particles near head
|
||||
for (nx = -2; nx <= 2; nx++)
|
||||
for (ny = 0; ny>=-2; ny--)
|
||||
{
|
||||
if (!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
|
||||
continue;
|
||||
if (ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT)
|
||||
{
|
||||
player[2] = pmap[ny+y][nx+x]&0xFF; //Current element
|
||||
}
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
|
||||
{
|
||||
if (parts[i].life<=95)
|
||||
parts[i].life += 5;
|
||||
else
|
||||
parts[i].life = 100;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
|
||||
{
|
||||
parts[i].life -= (102-parts[i].life)/2;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
if (bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
|
||||
player[2] = SPC_AIR;
|
||||
}
|
||||
|
||||
//Head position
|
||||
nx = x + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01);
|
||||
ny = y - 3*(player[1] == 0);
|
||||
|
||||
//Spawn
|
||||
if (((int)(player[0])&0x08) == 0x08)
|
||||
{
|
||||
ny -= 2*(rand()%2)+1;
|
||||
r = pmap[ny][nx];
|
||||
if (!((r>>8)>=NPART))
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_SOLID)
|
||||
{
|
||||
create_part(-1, nx, ny, PT_SPRK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player[2] == SPC_AIR)
|
||||
create_parts(nx + 3*((((int)player[1])&0x02) == 0x02) - 3*((((int)player[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
|
||||
else
|
||||
create_part(-1, nx, ny, player[2]);
|
||||
|
||||
r = pmap[ny][nx];
|
||||
if ( ((r>>8) < NPART) && (r>>8)>=0 && player[2] != PT_PHOT && player[2] != SPC_AIR)
|
||||
parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player[1])&0x02) == 0x02) - 5*(((int)(player[1])&0x01) == 0x01);
|
||||
if (((r>>8) < NPART) && (r>>8)>=0 && player[2] == PT_PHOT)
|
||||
{
|
||||
int random = abs(rand()%3-1)*3;
|
||||
if (random==0)
|
||||
{
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].type = PT_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
parts[r>>8].vy = 0;
|
||||
parts[r>>8].vx = (((((int)player[1])&0x02) == 0x02) - (((int)(player[1])&0x01) == 0x01))*random;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Simulation of joints
|
||||
d = 25/(pow((player[3]-player[7]), 2) + pow((player[4]-player[8]), 2)+25) - 0.5; //Fast distance
|
||||
player[7] -= (player[3]-player[7])*d;
|
||||
player[8] -= (player[4]-player[8])*d;
|
||||
player[3] += (player[3]-player[7])*d;
|
||||
player[4] += (player[4]-player[8])*d;
|
||||
|
||||
d = 25/(pow((player[11]-player[15]), 2) + pow((player[12]-player[16]), 2)+25) - 0.5;
|
||||
player[15] -= (player[11]-player[15])*d;
|
||||
player[16] -= (player[12]-player[16])*d;
|
||||
player[11] += (player[11]-player[15])*d;
|
||||
player[12] += (player[12]-player[16])*d;
|
||||
|
||||
d = 36/(pow((player[3]-parts[i].x), 2) + pow((player[4]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player[3]-parts[i].x)*d;
|
||||
parts[i].vy -= (player[4]-parts[i].y)*d;
|
||||
player[3] += (player[3]-parts[i].x)*d;
|
||||
player[4] += (player[4]-parts[i].y)*d;
|
||||
|
||||
d = 36/(pow((player[11]-parts[i].x), 2) + pow((player[12]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player[11]-parts[i].x)*d;
|
||||
parts[i].vy -= (player[12]-parts[i].y)*d;
|
||||
player[11] += (player[11]-parts[i].x)*d;
|
||||
player[12] += (player[12]-parts[i].y)*d;
|
||||
|
||||
//Side collisions checking
|
||||
for (nx = -3; nx <= 3; nx++)
|
||||
{
|
||||
r = pmap[(int)(player[16]-2)][(int)(player[15]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player[15] -= nx;
|
||||
|
||||
r = pmap[(int)(player[8]-2)][(int)(player[7]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player[7] -= nx;
|
||||
}
|
||||
|
||||
//Collision checks
|
||||
for (ny = -2-(int)parts[i].vy; ny<=0; ny++)
|
||||
{
|
||||
r = pmap[(int)(player[8]+ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-)
|
||||
|
||||
//For left leg
|
||||
if (r && (r&0xFF)!=PT_STKM)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks
|
||||
{
|
||||
if (parts[i].y<(player[8]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player[8] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player[9] = player[7];
|
||||
}
|
||||
|
||||
r = pmap[(int)(player[16]+ny)][(int)(player[15]+0.5)];
|
||||
|
||||
//For right leg
|
||||
if (r && (r&0xFF)!=PT_STKM)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)
|
||||
{
|
||||
if (parts[i].y<(player[16]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player[16] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player[17] = player[15];
|
||||
}
|
||||
|
||||
//If it falls too fast
|
||||
if (parts[i].vy>=30)
|
||||
{
|
||||
parts[i].y -= (10+ny)*dt;
|
||||
parts[i].vy = -10*dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Keeping legs distance
|
||||
if (pow((player[7] - player[15]), 2)<16 && pow((player[8]-player[16]), 2)<1)
|
||||
{
|
||||
player[21] -= 0.2;
|
||||
player[25] += 0.2;
|
||||
}
|
||||
|
||||
if (pow((player[3] - player[11]), 2)<16 && pow((player[4]-player[12]), 2)<1)
|
||||
{
|
||||
player[19] -= 0.2;
|
||||
player[23] += 0.2;
|
||||
}
|
||||
|
||||
//If legs touch something
|
||||
r = pmap[(int)(player[8]+0.5)][(int)(player[7]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
r = pmap[(int)(player[16]+0.5)][(int)(player[15]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player[22] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
isplayer = 1;
|
||||
}
|
||||
if (t==PT_STKM2)
|
||||
{
|
||||
float dt = 0.9;///(FPSB*FPSB); //Delta time in square
|
||||
//Tempirature handling
|
||||
if (parts[i].temp<243)
|
||||
parts[i].life -= 1;
|
||||
if ((parts[i].temp<309.6f) && (parts[i].temp>=243))
|
||||
parts[i].temp += 1;
|
||||
|
||||
//Death
|
||||
if (parts[i].life<1 || death2 == 1 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind...
|
||||
{
|
||||
for (r=-2; r<=1; r++)
|
||||
{
|
||||
create_part(-1, x+r, y-2, player2[2]);
|
||||
create_part(-1, x+r+1, y+2, player2[2]);
|
||||
create_part(-1, x-2, y+r+1, player2[2]);
|
||||
create_part(-1, x+2, y+r, player2[2]);
|
||||
}
|
||||
kill_part(i); //Kill him
|
||||
goto killed;
|
||||
}
|
||||
|
||||
parts[i].vy += -0.7*dt; //Head up!
|
||||
|
||||
//Verlet integration
|
||||
pp = 2*player2[3]-player2[5]+player2[19]*dt*dt;;
|
||||
player2[5] = player2[3];
|
||||
player2[3] = pp;
|
||||
pp = 2*player2[4]-player2[6]+player2[20]*dt*dt;;
|
||||
player2[6] = player2[4];
|
||||
player2[4] = pp;
|
||||
|
||||
pp = 2*player2[7]-player2[9]+player2[21]*dt*dt;;
|
||||
player2[9] = player2[7];
|
||||
player2[7] = pp;
|
||||
pp = 2*player2[8]-player2[10]+(player2[22]+1)*dt*dt;;
|
||||
player2[10] = player2[8];
|
||||
player2[8] = pp;
|
||||
|
||||
pp = 2*player2[11]-player2[13]+player2[23]*dt*dt;;
|
||||
player2[13] = player2[11];
|
||||
player2[11] = pp;
|
||||
pp = 2*player2[12]-player2[14]+player2[24]*dt*dt;;
|
||||
player2[14] = player2[12];
|
||||
player2[12] = pp;
|
||||
|
||||
pp = 2*player2[15]-player2[17]+player2[25]*dt*dt;;
|
||||
player2[17] = player2[15];
|
||||
player2[15] = pp;
|
||||
pp = 2*player2[16]-player2[18]+(player2[26]+1)*dt*dt;;
|
||||
player2[18] = player2[16];
|
||||
player2[16] = pp;
|
||||
|
||||
//Setting acceleration to 0
|
||||
player2[19] = 0;
|
||||
player2[20] = 0;
|
||||
|
||||
player2[21] = 0;
|
||||
player2[22] = 0;
|
||||
|
||||
player2[23] = 0;
|
||||
player2[24] = 0;
|
||||
|
||||
player2[25] = 0;
|
||||
player2[26] = 0;
|
||||
|
||||
//Go left
|
||||
if (((int)(player2[0])&0x01) == 0x01 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = -3;
|
||||
player2[22] = -2;
|
||||
player2[19] = -2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = -3;
|
||||
player2[26] = -2;
|
||||
player2[23] = -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])]) //It should move another way in liquids
|
||||
{
|
||||
player2[21] = -1;
|
||||
player2[22] = -1;
|
||||
player2[19] = -1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = -1;
|
||||
player2[26] = -1;
|
||||
player2[23] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Go right
|
||||
if (((int)(player2[0])&0x02) == 0x02 && pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_GAS)
|
||||
{
|
||||
if (pstates[pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF].state != ST_LIQUID
|
||||
&& (pmap[(int)(parts[i].y+10)][(int)(parts[i].x)]&0xFF) != PT_LNTG)
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = 3;
|
||||
player2[22] = -2;
|
||||
player2[19] = 2;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = 3;
|
||||
player2[26] = -2;
|
||||
player2[23] = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pmap[(int)(player2[8]-1)][(int)(player2[7])])
|
||||
{
|
||||
player2[21] = 1;
|
||||
player2[22] = -1;
|
||||
player2[19] = 1;
|
||||
}
|
||||
|
||||
if (pmap[(int)(player2[16]-1)][(int)(player2[15])])
|
||||
{
|
||||
player2[25] = 1;
|
||||
player2[26] = -1;
|
||||
player2[23] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Jump
|
||||
if (((int)(player2[0])&0x04) == 0x04 && (pstates[pmap[(int)(player2[8]-0.5)][(int)(player2[7])]&0xFF].state != ST_GAS || pstates[pmap[(int)(player2[16]-0.5)][(int)(player2[15])]&0xFF].state != ST_GAS))
|
||||
{
|
||||
if (pmap[(int)(player2[8]-0.5)][(int)(player2[7])] || pmap[(int)(player2[16]-0.5)][(int)(player2[15])])
|
||||
{
|
||||
parts[i].vy = -5;
|
||||
player2[22] -= 1;
|
||||
player2[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Charge detector wall if foot inside
|
||||
if (bmap[(int)(player2[8]+0.5)/CELL][(int)(player2[7]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)player2[7]/CELL, (int)player2[8]/CELL);
|
||||
if (bmap[(int)(player2[16]+0.5)/CELL][(int)(player2[15]+0.5)/CELL]==WL_DETECT)
|
||||
set_emap((int)(player2[15]+0.5)/CELL, (int)(player2[16]+0.5)/CELL);
|
||||
|
||||
//Searching for particles near head
|
||||
for (nx = -2; nx <= 2; nx++)
|
||||
for (ny = 0; ny>=-2; ny--)
|
||||
{
|
||||
if (!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
|
||||
continue;
|
||||
if (ptypes[pmap[ny+y][nx+x]&0xFF].falldown!=0 || (pmap[ny+y][nx+x]&0xFF) == PT_NEUT || (pmap[ny+y][nx+x]&0xFF) == PT_PHOT)
|
||||
{
|
||||
player2[2] = pmap[ny+y][nx+x]&0xFF; //Current element
|
||||
}
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
|
||||
{
|
||||
if (parts[i].life<=95)
|
||||
parts[i].life += 5;
|
||||
else
|
||||
parts[i].life = 100;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
|
||||
if ((pmap[ny+y][nx+x]&0xFF) == PT_NEUT)
|
||||
{
|
||||
parts[i].life -= (102-parts[i].life)/2;
|
||||
kill_part(pmap[ny+y][nx+x]>>8);
|
||||
}
|
||||
if (bmap[(ny+y)/CELL][(nx+x)/CELL]==WL_FAN)
|
||||
player2[2] = SPC_AIR;
|
||||
}
|
||||
|
||||
//Head position
|
||||
nx = x + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01);
|
||||
ny = y - 3*(player2[1] == 0);
|
||||
|
||||
//Spawn
|
||||
if (((int)(player2[0])&0x08) == 0x08)
|
||||
{
|
||||
ny -= 2*(rand()%2)+1;
|
||||
r = pmap[ny][nx];
|
||||
if (!((r>>8)>=NPART))
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_SOLID)
|
||||
{
|
||||
create_part(-1, nx, ny, PT_SPRK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player2[2] == SPC_AIR)
|
||||
create_parts(nx + 3*((((int)player2[1])&0x02) == 0x02) - 3*((((int)player2[1])&0x01) == 0x01), ny, 4, 4, SPC_AIR);
|
||||
else
|
||||
create_part(-1, nx, ny, player2[2]);
|
||||
|
||||
r = pmap[ny][nx];
|
||||
if ( ((r>>8) < NPART) && (r>>8)>=0 && player2[2] != PT_PHOT && player2[2] != SPC_AIR)
|
||||
parts[r>>8].vx = parts[r>>8].vx + 5*((((int)player2[1])&0x02) == 0x02) - 5*(((int)(player2[1])&0x01) == 0x01);
|
||||
if (((r>>8) < NPART) && (r>>8)>=0 && player2[2] == PT_PHOT)
|
||||
{
|
||||
int random = abs(rand()%3-1)*3;
|
||||
if (random==0)
|
||||
{
|
||||
parts[r>>8].life = 0;
|
||||
parts[r>>8].type = PT_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
parts[r>>8].vy = 0;
|
||||
parts[r>>8].vx = (((((int)player2[1])&0x02) == 0x02) - (((int)(player2[1])&0x01) == 0x01))*random;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Simulation of joints
|
||||
d = 25/(pow((player2[3]-player2[7]), 2) + pow((player2[4]-player2[8]), 2)+25) - 0.5; //Fast distance
|
||||
player2[7] -= (player2[3]-player2[7])*d;
|
||||
player2[8] -= (player2[4]-player2[8])*d;
|
||||
player2[3] += (player2[3]-player2[7])*d;
|
||||
player2[4] += (player2[4]-player2[8])*d;
|
||||
|
||||
d = 25/(pow((player2[11]-player2[15]), 2) + pow((player2[12]-player2[16]), 2)+25) - 0.5;
|
||||
player2[15] -= (player2[11]-player2[15])*d;
|
||||
player2[16] -= (player2[12]-player2[16])*d;
|
||||
player2[11] += (player2[11]-player2[15])*d;
|
||||
player2[12] += (player2[12]-player2[16])*d;
|
||||
|
||||
d = 36/(pow((player2[3]-parts[i].x), 2) + pow((player2[4]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player2[3]-parts[i].x)*d;
|
||||
parts[i].vy -= (player2[4]-parts[i].y)*d;
|
||||
player2[3] += (player2[3]-parts[i].x)*d;
|
||||
player2[4] += (player2[4]-parts[i].y)*d;
|
||||
|
||||
d = 36/(pow((player2[11]-parts[i].x), 2) + pow((player2[12]-parts[i].y), 2)+36) - 0.5;
|
||||
parts[i].vx -= (player2[11]-parts[i].x)*d;
|
||||
parts[i].vy -= (player2[12]-parts[i].y)*d;
|
||||
player2[11] += (player2[11]-parts[i].x)*d;
|
||||
player2[12] += (player2[12]-parts[i].y)*d;
|
||||
|
||||
//Side collisions checking
|
||||
for (nx = -3; nx <= 3; nx++)
|
||||
{
|
||||
r = pmap[(int)(player2[16]-2)][(int)(player2[15]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player2[15] -= nx;
|
||||
|
||||
r = pmap[(int)(player2[8]-2)][(int)(player2[7]+nx)];
|
||||
if (r && pstates[r&0xFF].state != ST_GAS && pstates[r&0xFF].state != ST_LIQUID)
|
||||
player2[7] -= nx;
|
||||
}
|
||||
|
||||
//Collision checks
|
||||
for (ny = -2-(int)parts[i].vy; ny<=0; ny++)
|
||||
{
|
||||
r = pmap[(int)(player2[8]+ny)][(int)(player2[7]+0.5)]; //This is to make coding more pleasant :-)
|
||||
|
||||
//For left leg
|
||||
if (r && (r&0xFF)!=PT_STKM2)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG) //Liquid checks //Liquid checks
|
||||
{
|
||||
if (parts[i].y<(player2[8]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player2[8] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player2[9] = player2[7];
|
||||
}
|
||||
|
||||
r = pmap[(int)(player2[16]+ny)][(int)(player2[15]+0.5)];
|
||||
|
||||
//For right leg
|
||||
if (r && (r&0xFF)!=PT_STKM2)
|
||||
{
|
||||
if (pstates[r&0xFF].state == ST_LIQUID || (r&0xFF) == PT_LNTG)
|
||||
{
|
||||
if (parts[i].y<(player2[16]-10))
|
||||
parts[i].vy = 1*dt;
|
||||
else
|
||||
parts[i].vy = 0;
|
||||
if (abs(parts[i].vx)>1)
|
||||
parts[i].vx *= 0.5*dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pstates[r&0xFF].state != ST_GAS)
|
||||
{
|
||||
player2[16] += ny-1;
|
||||
parts[i].vy -= 0.5*parts[i].vy*dt;
|
||||
}
|
||||
}
|
||||
player2[17] = player2[15];
|
||||
}
|
||||
|
||||
//If it falls too fast
|
||||
if (parts[i].vy>=30)
|
||||
{
|
||||
parts[i].y -= (10+ny)*dt;
|
||||
parts[i].vy = -10*dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Keeping legs distance
|
||||
if (pow((player2[7] - player2[15]), 2)<16 && pow((player2[8]-player2[16]), 2)<1)
|
||||
{
|
||||
player2[21] -= 0.2;
|
||||
player2[25] += 0.2;
|
||||
}
|
||||
|
||||
if (pow((player2[3] - player2[11]), 2)<16 && pow((player2[4]-player2[12]), 2)<1)
|
||||
{
|
||||
player2[19] -= 0.2;
|
||||
player2[23] += 0.2;
|
||||
}
|
||||
|
||||
//If legs touch something
|
||||
r = pmap[(int)(player2[8]+0.5)][(int)(player2[7]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player2[26] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
r = pmap[(int)(player2[16]+0.5)][(int)(player2[15]+0.5)];
|
||||
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
|
||||
{
|
||||
parts[i].life -= (int)(rand()/1000)+38;
|
||||
}
|
||||
|
||||
if (r>0 && (r>>8)<NPART) //If hot or cold
|
||||
{
|
||||
if (parts[r>>8].temp>=323 || parts[r>>8].temp<=243)
|
||||
{
|
||||
parts[i].life -= 2;
|
||||
player2[22] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r&0xFF)==PT_ACID) //If on acid
|
||||
parts[i].life -= 5;
|
||||
|
||||
if ((r&0xFF)==PT_PLUT) //If on plut
|
||||
parts[i].life -= 1;
|
||||
|
||||
isplayer2 = 1;
|
||||
}
|
||||
if (t==PT_SPAWN)
|
||||
{
|
||||
if (death==1)
|
||||
{
|
||||
playerspawn = create_part(-1,x,y,PT_STKM);
|
||||
isplayer = 1;
|
||||
}
|
||||
death = 0;
|
||||
}
|
||||
if (t==PT_SPAWN2)
|
||||
{
|
||||
if (death2==1)
|
||||
{
|
||||
player2spawn = create_part(-1,x,y,PT_STKM2);
|
||||
isplayer2 = 1;
|
||||
}
|
||||
death2 = 0;
|
||||
}
|
||||
if (t==PT_CLNE)
|
||||
{
|
||||
if (!parts[i].ctype)
|
||||
@ -4895,47 +4086,6 @@ killed:
|
||||
}
|
||||
|
||||
}
|
||||
if (parts[i].type==PT_PCLN)
|
||||
{
|
||||
if (!parts[i].ctype)
|
||||
for (nx=-1; nx<2; nx++)
|
||||
for (ny=-1; ny<2; ny++)
|
||||
if (x+nx>=0 && y+ny>0 &&
|
||||
x+nx<XRES && y+ny<YRES &&
|
||||
pmap[y+ny][x+nx] &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_PCLN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_BCLN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_SPRK &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_NSCN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_PSCN &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=PT_STKM2 &&
|
||||
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
|
||||
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
|
||||
if (parts[i].ctype && parts[i].life==10) {
|
||||
if (parts[i].ctype==PT_PHOT) {
|
||||
for (nx=-1; nx<2; nx++) {
|
||||
for (ny=-1; ny<2; ny++) {
|
||||
r = create_part(-1, x+nx, y+ny, parts[i].ctype);
|
||||
if (r!=-1) {
|
||||
parts[r].vx = nx*3;
|
||||
parts[r].vy = ny*3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ptypes[parts[i].ctype].properties&PROP_LIFE) {
|
||||
for (nx=-1; nx<2; nx++) {
|
||||
for (ny=-1; ny<2; ny++) {
|
||||
create_part(-1, x+nx, y+ny, parts[i].ctype);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t==PT_YEST)
|
||||
{
|
||||
if (parts[i].temp>303&&parts[i].temp<317) {
|
||||
@ -4965,6 +4115,12 @@ killed:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ptypes[t].update_func)
|
||||
{
|
||||
if ((*(ptypes[t].update_func))(i,x,y,nx,ny,lx,ly))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parts[i].type == PT_PHOT) {
|
||||
rt = pmap[ny][nx] & 0xFF;
|
||||
|
||||
|
Reference in New Issue
Block a user