~melchizedek6809/WolkenWelten

2c15a0a4b8675af3e58da61b2341f7c42cd0cd3a — Ben (X220/Arch) 11 days ago c6a0726
Migrated item inaccuracy over to nujel
M client/src/game/character.c => client/src/game/character.c +1 -1
@@ 126,7 126,7 @@ void characterRemovePlayer(int c, int len){

void characterUpdateInaccuracy(character *c){
	item *itm = &c->inventory[c->activeItem];
	float minInaccuracy = getInaccuracyDispatch(itm);
	float minInaccuracy = itemGetInaccuracy(itm);

	if(c->shake > c->inaccuracy){c->inaccuracy = c->shake;}
	c->inaccuracy = MINMAX(minInaccuracy,128.f,c->inaccuracy - 0.5f);

M common/src/game/item.c => common/src/game/item.c +4 -0
@@ 131,3 131,7 @@ int itemGetDamage(const item *i, blockCategory cat){
	if((i == NULL) || (i->ID < 256) || (i->ID > 512)){return 1;}
	return itemTypes[i->ID - 256].damage[cat];
}
float itemGetInaccuracy(const item *i){
	if((i == NULL) || (i->ID < 256) || (i->ID > 512)){return 8.f;}
	return itemTypes[i->ID - 256].inaccuracy;
}

M common/src/game/item.h => common/src/game/item.h +1 -0
@@ 21,6 21,7 @@ const char *itemGetName      (const item *i);
      int   itemGetFireDamage(const item *i);
      int   itemGetFireHealth(const item *i);
      int   itemGetDamage    (const item *i, blockCategory cat);
      float itemGetInaccuracy(const item *i);

#define I_Dirt           1
#define I_Grass          2

M common/src/game/itemType.c => common/src/game/itemType.c +18 -0
@@ 28,6 28,7 @@ itemType itemTypes[256];
void itemTypeInit(){
	for(int i=0;i<256;i++){
		itemTypes[i].stackSize = 99;
		itemTypes[i].inaccuracy = 8.f;
		for(int ii=0;ii<5;ii++){itemTypes[i].damage[ii] = 1;}
	}
}


@@ 153,6 154,22 @@ static lVal *wwlnfITFireHealth(lClosure *c, lVal *v){
	return lValInt(it->fireHealth);
}

static lVal *wwlnfITInaccuracy(lClosure *c, lVal *v){
	if((v == NULL) || (v->type != ltPair)){return NULL;}

	lVal *t = lnfInt(c,lEval(c,v->vList.car));
	if((t->vInt < 256) || (t->vInt > 512)){return NULL;}
	const int ID = t->vInt;
	itemType *it = &itemTypes[ID-256];
	v = v->vList.cdr;

	if((v != NULL) && (v->type == ltPair)){
		t = lnfFloat(c,lEval(c,v->vList.car));
		if(t != NULL){it->inaccuracy = t->vFloat;}
	}
	return lValFloat(it->inaccuracy);
}

void itemTypeLispClosure(lClosure *c){
	lAddNativeFunc(c,"it-name",       "(id &n)",    "Sets the name of itemType ID to &n if passed",                 wwlnfITName);
	lAddNativeFunc(c,"it-mesh",       "(id &m)",    "Sets the mesh of itemType ID to &m if passed",                 wwlnfITMesh);


@@ 161,4 178,5 @@ void itemTypeLispClosure(lClosure *c){
	lAddNativeFunc(c,"it-damage" ,    "(id cat &d)","Sets the damage to cat blocks of itemType ID to &d if passed", wwlnfITDamage);
	lAddNativeFunc(c,"it-fire-damage","(id &d)",    "Sets the fire damage of itemType ID to &d if passed",          wwlnfITFireDamage);
	lAddNativeFunc(c,"it-fire-health","(id &h)",    "Sets the fire health of itemType ID to &h if passed",          wwlnfITFireHealth);
	lAddNativeFunc(c,"it-inaccuracy", "(id &a)",    "Sets the fire inaccuracy of itemType ID to &a if passed",      wwlnfITInaccuracy);
}

M common/src/game_structs.h => common/src/game_structs.h +1 -0
@@ 44,6 44,7 @@ typedef struct {
	u16 ammunition,stackSize;
	i16 fireDmg;
	u16 fireHealth;
	float inaccuracy;
} itemType;

typedef uint32_t being;

M common/src/mods/items/blaster.c => common/src/mods/items/blaster.c +0 -6
@@ 36,12 36,6 @@ int blasterGetMagSize(const item *cItem){
	return MAGSIZE;
}

float blasterGetInaccuracy(const item *cItem){
	(void)cItem;

	return 2.f;
}

int blasterItemDropBurnUp(itemDrop *id){
	if(id->ent == NULL){return 0;}
	explode(id->ent->pos, 0.2f*id->itm.amount, 0);

M common/src/mods/items/crystalbullet.c => common/src/mods/items/crystalbullet.c +0 -10
@@ 12,13 12,3 @@ int crystalbulletItemDropBurnUp(itemDrop *id){
	explode(id->ent->pos, 0.2f*id->itm.amount, 0);
	return 0;
}

int crystalbulletGetFireDmg(const itemDrop *id){
	(void)id;
	return 6;
}

int crystalbulletGetFireHealth(const itemDrop *id){
	(void)id;
	return 64;
}

M common/src/mods/items/flamethrower.c => common/src/mods/items/flamethrower.c +0 -6
@@ 44,9 44,3 @@ int flamethrowerItemDropBurnUp(itemDrop *id){
	explode(id->ent->pos, 0.2f*id->itm.amount, 0);
	return 0;
}

float flamethrowerGetInaccuracy(const item *cItem){
	(void)cItem;

	return 16.f;
}

M common/src/mods/items/shotgunblaster.c => common/src/mods/items/shotgunblaster.c +0 -6
@@ 34,12 34,6 @@ bool shotgunblasterTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 256);
}

float shotgunblasterGetInaccuracy(const item *cItem){
	(void)cItem;

	return 48.f;
}

int shotgunblasterGetMagSize(const item *cItem){
	(void)cItem;


M common/src/mods/items/waterthrower.c => common/src/mods/items/waterthrower.c +0 -6
@@ 38,9 38,3 @@ int waterthrowerGetMagSize(const item *cItem){
	(void)cItem;
	return MAGSIZE;
}

float waterthrowerGetInaccuracy(const item *cItem){
	(void)cItem;

	return 16.f;
}

M common/src/mods/mods.c => common/src/mods/mods.c +0 -5
@@ 38,11 38,6 @@ bool hasPrimaryActionDefault(const item *cItem){

	return false;
}
float getInaccuracyDefault(const item *cItem){
	(void)cItem;

	return 4.f;
}
int getMagSizeDefault (const item *cItem){
	(void)cItem;


M common/src/mods/mods.h => common/src/mods/mods.h +0 -2
@@ 11,7 11,6 @@ bool        hasSecondaryAction      (const item *cItem);
bool        tertiaryActionDispatch  (      item *cItem, character *cChar);
bool        throwActionDispatch     (      item *cItem, character *cChar);
bool        hasTertiaryAction       (const item *cItem);
float       getInaccuracyDispatch   (const item *cItem);
int         getMagSizeDispatch      (const item *cItem);
bool        hasGetMagSize           (const item *cItem);
int         itemDropCallbackDispatch(const item *cItem, float x, float y, float z);


@@ 19,7 18,6 @@ int         itemDropCallbackDispatch(const item *cItem, float x, float y, float 
bool        primaryActionDefault    (      item *cItem, character *cChar);
bool        secondaryActionDefault  (      item *cItem, character *cChar);
bool        tertiaryActionDefault   (      item *cItem, character *cChar);
float       getInaccuracyDefault    (const item *cItem);
int         getMagSizeDefault       (const item *cItem);
int         itemDropCallbackDefault (const item *cItem, float x, float y, float z);
int         throwActionDefault      (      item *cItem, character *cChar);

M common/src/nuj/items.nuj => common/src/nuj/items.nuj +6 -0
@@ 50,6 50,7 @@
		(it-ammunition ID i-crystalbulle)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 2)
		(it-mesh ID m-blaster)
		(it-name ID "Blaster"))
	(let ((ID 262))


@@ 57,6 58,7 @@
		(it-ammunition ID i-crystalbulle)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 4)
		(it-mesh ID m-masterblaster)
		(it-name ID "Master Blaster"))
	(let ((ID 263))


@@ 64,6 66,7 @@
		(it-ammunition ID i-flamebullet)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 8)
		(it-mesh ID m-assaultblaste)
		(it-name ID "Assault Rifle"))
	(let ((ID 264))


@@ 71,6 74,7 @@
		(it-ammunition ID i-flamebullet)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 48)
		(it-mesh ID m-shotgunblaste)
		(it-name ID "Shotgun"))
	(let ((ID 265))


@@ 163,6 167,7 @@
		(it-ammunition ID i-flamebullet)
		(it-fire-dmg ID 8)
		(it-fire-health ID 64)
		(it-inaccuracy ID 16)
		(it-name ID "Flamethrower"))
	(let ((ID 284))
		(it-stack-size ID 999)


@@ 184,6 189,7 @@
		(it-stack-size ID 1)
		(it-mesh ID m-waterthrower)
		(it-ammunition ID i-flamebullet)
		(it-inaccuracy ID 16)
		(it-name ID "Waterthrower"))
	(let ((ID 289))
		(it-stack-size ID 1)

M tools/modscg.c => tools/modscg.c +0 -1
@@ 297,7 297,6 @@ int main(int argc, char *argv[]){
	printItemTypeDispatch("TertiaryAction","item *cItem, character *cChar","cItem, cChar","bool ");
	printHasTypeSwitch   ("TertiaryAction");
	printItemTypeDispatch("ThrowAction","item *cItem, character *cChar","cItem, cChar","bool ");
	printItemTypeDispatch("GetInaccuracy","const item *cItem","cItem","float ");
	printItemTypeDispatch("GetMagSize","const item *cItem","cItem","int ");
	printHasTypeSwitch   ("GetMagSize");
	printItemTypeDispatch("ItemDropCallback","const item *cItem, float x, float y, float z","cItem, x, y, z","int ");