~melchizedek6809/WolkenWelten

e349629491124b07b489a654e431719b4a8d83bf — Ben (X220/Arch) 11 days ago 2c15a0a
Moved MagSize over to Nujel
M client/src/gfx/textMesh.c => client/src/gfx/textMesh.c +3 -2
@@ 370,9 370,10 @@ void textMeshItem(textMesh *m, int x, int y, int size, int style, item *itm){
	const int itemsizeoff = (size-itemsize)/2;
	textMeshItemSprite(m,x+itemsizeoff,y+itemsizeoff,itemsize,itm->ID);
	if(itemGetStackSize(itm) <= 1){
		if(hasGetMagSize(itm)){
		const int magSize = itemGetMagazineSize(itm);
		if(magSize){
			textMeshNumber(m,x+size/4,y+size/8,1,itemGetAmmo(itm));
			textMeshNumber(m,x+size-size/4,y+size/8,1,getMagSizeDispatch(itm));
			textMeshNumber(m,x+size-size/4,y+size/8,1,magSize);
			textMeshDigit (m,x+size/2-size/16,y+size/8, 1, 10);
		}
	}else{

M client/src/gui/gui.c => client/src/gui/gui.c +3 -2
@@ 545,10 545,11 @@ void drawAmmunition(){
	textMeshItemSprite(guim,guim->sx+32,guim->sy-18,64,ammo);

	if(itemGetStackSize(activeItem) <= 1){
		if(hasGetMagSize(activeItem)){
		const int magSize = itemGetMagazineSize(activeItem);
		if(magSize){
			guim->sx += 4;
			textMeshNumber(guim,guim->sx-32,guim->sy-tilesize+tilesize/3,2,itemGetAmmo(activeItem));
			textMeshNumber(guim,guim->sx+32,guim->sy-tilesize+tilesize/3,2,getMagSizeDispatch(activeItem));
			textMeshNumber(guim,guim->sx+32,guim->sy-tilesize+tilesize/3,2,magSize);
			textMeshDigit(guim,guim->sx-12,guim->sy-tilesize+tilesize/3, 2, 10);
		}
	}

M common/src/game/character.c => common/src/game/character.c +1 -1
@@ 408,7 408,7 @@ void characterStartAnimation(character *c, int index, int duration){
}

bool characterItemReload(character *c, item *i, int cooldown){
	const int MAGSIZE = getMagSizeDispatch(i);
	const int MAGSIZE = itemGetMagazineSize(i);
	const int AMMO    = itemGetAmmunition(i);
	int ammoleft      = characterGetItemAmount(c,AMMO);


M common/src/game/item.c => common/src/game/item.c +5 -1
@@ 81,7 81,7 @@ int itemGetAmmo(const item *i){

int itemIncAmmo(item *i, i16 amount){
	if(i == NULL)      {return 0;}
	const int ma = getMagSizeDispatch(i)+1;
	const int ma = itemGetMagazineSize(i)+1;
	if((i->amount+amount)>ma){amount = ma - i->amount;}
	i->amount += amount;
	return amount;


@@ 112,6 112,10 @@ int itemGetStackSize(const item *i){
	if((i == NULL) || (i->ID < 256) || (i->ID > 512)){return 99;}
	return itemTypes[i->ID - 256].stackSize;
}
int itemGetMagazineSize(const item *i){
	if((i == NULL) || (i->ID < 256) || (i->ID > 512)){return 0;}
	return itemTypes[i->ID - 256].magazineSize;
}
int itemGetAmmunition(const item *i){
	if((i == NULL) || (i->ID > 512)){return -1;}
	if(i->ID < 256){return i->ID;}

M common/src/game/item.h => common/src/game/item.h +9 -8
@@ 14,14 14,15 @@ int   itemGetAmmo    (const item *i);
int   itemIncAmmo    (      item *i, i16 amount);
int   itemDecAmmo    (      item *i, i16 amount);

const char *itemGetName      (const item *i);
      mesh *itemGetMesh      (const item *i);
      int   itemGetStackSize (const item *i);
      int   itemGetAmmunition(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);
const char *itemGetName         (const item *i);
      mesh *itemGetMesh         (const item *i);
      int   itemGetStackSize    (const item *i);
      int   itemGetMagazineSize (const item *i);
      int   itemGetAmmunition   (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 +17 -0
@@ 122,6 122,22 @@ static lVal *wwlnfITStackSize(lClosure *c, lVal *v){
	return lValInt(it->stackSize);
}

static lVal *wwlnfITMagazineSize(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 = lnfInt(c,lEval(c,v->vList.car));
		if(t != NULL){it->magazineSize = t->vInt;}
	}
	return lValInt(it->magazineSize);
}

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



@@ 175,6 191,7 @@ void itemTypeLispClosure(lClosure *c){
	lAddNativeFunc(c,"it-mesh",       "(id &m)",    "Sets the mesh of itemType ID to &m if passed",                 wwlnfITMesh);
	lAddNativeFunc(c,"it-ammunition", "(id &a)",    "Sets the ammunition of itemType ID to &a if passed",           wwlnfITAmmunition);
	lAddNativeFunc(c,"it-stack-size", "(id &s)",    "Sets the stackSize of itemType ID to &d if passed",            wwlnfITStackSize);
	lAddNativeFunc(c,"it-mag-size",   "(id &s)",    "Sets the Magazine Size of itemType ID to &d if passed",        wwlnfITMagazineSize);
	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);

M common/src/game_structs.h => common/src/game_structs.h +1 -1
@@ 41,7 41,7 @@ typedef struct {
	char name[32];
	mesh *iMesh;
	i16 damage[5];
	u16 ammunition,stackSize;
	u16 ammunition,stackSize,magazineSize;
	i16 fireDmg;
	u16 fireHealth;
	float inaccuracy;

M common/src/mods/items/assaultblaster.c => common/src/mods/items/assaultblaster.c +0 -7
@@ 1,5 1,4 @@
static const int ITEMID=263;
static const int MAGSIZE=60;

#include "../api_v1.h"



@@ 33,12 32,6 @@ bool assaultblasterTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 50);
}

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

	return MAGSIZE;
}

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

M common/src/mods/items/blaster.c => common/src/mods/items/blaster.c +0 -7
@@ 1,5 1,4 @@
static const int ITEMID=261;
static const int MAGSIZE=30;

#include "../api_v1.h"



@@ 30,12 29,6 @@ bool blasterTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 50);
}

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

	return MAGSIZE;
}

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/flamethrower.c => common/src/mods/items/flamethrower.c +0 -6
@@ 1,5 1,4 @@
static const int ITEMID=283;
static const int MAGSIZE=90;

#include "../api_v1.h"



@@ 34,11 33,6 @@ bool flamethrowerTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 50);
}

int flamethrowerGetMagSize(const item *cItem){
	(void)cItem;
	return MAGSIZE;
}

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

M common/src/mods/items/masterblaster.c => common/src/mods/items/masterblaster.c +0 -7
@@ 1,5 1,4 @@
static const int ITEMID=262;
static const int MAGSIZE=90;

#include "../api_v1.h"



@@ 29,12 28,6 @@ bool masterblasterTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 200);
}

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

	return MAGSIZE;
}

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

M common/src/mods/items/shotgunblaster.c => common/src/mods/items/shotgunblaster.c +0 -7
@@ 1,5 1,4 @@
static const int ITEMID=264;
static const int MAGSIZE=60;

#include "../api_v1.h"



@@ 34,12 33,6 @@ bool shotgunblasterTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 256);
}

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

	return MAGSIZE;
}

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

M common/src/mods/items/waterthrower.c => common/src/mods/items/waterthrower.c +0 -6
@@ 1,5 1,4 @@
static const int ITEMID=288;
static const int MAGSIZE=90;

#include "../api_v1.h"



@@ 33,8 32,3 @@ bool waterthrowerSecondaryAction(item *cItem, character *cChar){
bool waterthrowerTertiaryAction(item *cItem, character *cChar){
	return characterItemReload(cChar, cItem, 50);
}

int waterthrowerGetMagSize(const item *cItem){
	(void)cItem;
	return MAGSIZE;
}

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

	return false;
}
int getMagSizeDefault (const item *cItem){
	(void)cItem;

	return 0;
}

int itemDropCallbackDefault(const item *cItem, float x, float y, float z){
	(void)cItem;
	(void)x;

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

bool        primaryActionDefault    (      item *cItem, character *cChar);
bool        secondaryActionDefault  (      item *cItem, character *cChar);
bool        tertiaryActionDefault   (      item *cItem, character *cChar);
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 +10 -4
@@ 46,35 46,39 @@
		(it-damage ID cat-dirt  2)
		(it-name ID "Stone Pick"))
	(let ((ID 261))
		(it-stack-size ID 1)
		(it-ammunition ID i-crystalbulle)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 2)
		(it-stack-size ID 1)
		(it-mag-size ID 30)
		(it-mesh ID m-blaster)
		(it-name ID "Blaster"))
	(let ((ID 262))
		(it-stack-size ID 1)
		(it-ammunition ID i-crystalbulle)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 4)
		(it-stack-size ID 1)
		(it-mag-size ID 90)
		(it-mesh ID m-masterblaster)
		(it-name ID "Master Blaster"))
	(let ((ID 263))
		(it-stack-size ID 1)
		(it-ammunition ID i-flamebullet)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 8)
		(it-stack-size ID 1)
		(it-mag-size ID 60)
		(it-mesh ID m-assaultblaste)
		(it-name ID "Assault Rifle"))
	(let ((ID 264))
		(it-stack-size ID 1)
		(it-ammunition ID i-flamebullet)
		(it-fire-dmg ID 6)
		(it-fire-health ID 64)
		(it-inaccuracy ID 48)
		(it-stack-size ID 1)
		(it-mag-size ID 60)
		(it-mesh ID m-shotgunblaste)
		(it-name ID "Shotgun"))
	(let ((ID 265))


@@ 168,6 172,7 @@
		(it-fire-dmg ID 8)
		(it-fire-health ID 64)
		(it-inaccuracy ID 16)
		(it-mag-size ID 90)
		(it-name ID "Flamethrower"))
	(let ((ID 284))
		(it-stack-size ID 999)


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

M tools/modscg.c => tools/modscg.c +0 -2
@@ 297,8 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("GetMagSize","const item *cItem","cItem","int ");
	printHasTypeSwitch   ("GetMagSize");
	printItemTypeDispatch("ItemDropCallback","const item *cItem, float x, float y, float z","cItem, x, y, z","int ");
	printItemDropDispatch("ItemDropBurnUp","itemDrop *id","id","int ");