allow particle type names in md2emit and md3emit

md[2|3]emit <tag name> <particle type> <attrib1> <attrib2>

  particle type may now be numeric 0..19 or one of SPARK, SMOKE, ECLOSEST,
  BLOOD, DEMOTRACK, FIREBALL, SHOTLINE, BULLETHOLE, BLOODSTAIN, SCORCH,
  HUDMUZZLEFLASH, MUZZLEFLASH, ELIGHT, ESPAWN, EAMMO, EPICKUP, EMODEL,
  ECARROT, ELADDER, EFLAG

also: cleanup

DOCREF md2emit md3emit
This commit is contained in:
ac-stef
2017-05-16 17:50:00 +02:00
parent 6f03d1819b
commit 6bafdb0037
18 changed files with 42 additions and 38 deletions
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 8 md3anim "gun shoot" 8 8
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 75 md3emit tag_muzzle HUDMUZZLEFLASH 50 75
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 75 md2emit tag_muzzle MUZZLEFLASH 50 75
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 50 md3anim "gun shoot" 8 50
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 50 md3emit tag_muzzle HUDMUZZLEFLASH 50 50
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 50 md2emit tag_muzzle MUZZLEFLASH 50 50
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 8 md3anim "gun shoot" 8 8
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 25 md3emit tag_muzzle HUDMUZZLEFLASH 50 25
+1 -1
View File
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 25 md2emit tag_muzzle MUZZLEFLASH 50 25
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 25 md3anim "gun shoot" 8 25
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 75 md3emit tag_muzzle HUDMUZZLEFLASH 50 75
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 75 md2emit tag_muzzle MUZZLEFLASH 50 75
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 50 md3anim "gun shoot" 8 50
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 100 md3emit tag_muzzle HUDMUZZLEFLASH 50 100
+1 -1
View File
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 100 md2emit tag_muzzle MUZZLEFLASH 50 100
+1 -1
View File
@@ -4,4 +4,4 @@ md3skin hands ../knife/skin_hands.jpg
md3anim "gun idle" 0 1 md3anim "gun idle" 0 1
md3anim "gun shoot" 8 8 md3anim "gun shoot" 8 8
md3anim "gun reload" 0 1 md3anim "gun reload" 0 1
md3emit tag_muzzle 10 50 55 md3emit tag_muzzle HUDMUZZLEFLASH 50 55
+1 -1
View File
@@ -3,5 +3,5 @@ mdltrans 2 2 24
mdlshadowdist 32 mdlshadowdist 32
md2tag tag_muzzle X md2tag tag_muzzle X
md2emit tag_muzzle 11 50 55 md2emit tag_muzzle MUZZLEFLASH 50 55
+1 -1
View File
@@ -286,7 +286,7 @@ void CBotManager::RenderBots()
{ {
if (bots[i] && (bots[i] != m_pBotToView)) if (bots[i] && (bots[i] != m_pBotToView))
{ {
renderclient(bots[i]); renderclientp(bots[i]);
} }
} }
} }
+7 -6
View File
@@ -282,6 +282,7 @@ void md2anim(char *anim, int *frame, int *range, float *speed)
if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); return; } if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); return; }
loadingmd2->parts.last()->setanim(num, *frame, *range, *speed); loadingmd2->parts.last()->setanim(num, *frame, *range, *speed);
} }
COMMAND(md2anim, "siif");
void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4) void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4)
{ {
@@ -321,14 +322,14 @@ void md2tag(char *name, char *vert1, char *vert2, char *vert3, char *vert4)
} }
if(!mdl.gentag(name, indexes, numverts)) { conoutf("could not generate tag %s", name); flagmapconfigerror(LWW_MODELERR); return; } if(!mdl.gentag(name, indexes, numverts)) { conoutf("could not generate tag %s", name); flagmapconfigerror(LWW_MODELERR); return; }
} }
COMMAND(md2tag, "sssss");
void md2emit(char *tag, int *type, int *arg1, int *arg2) void md2emit(char *tag, char *_type, int *arg1, int *arg2)
{ {
if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); flagmapconfigerror(LWW_MODELERR); return; }; if(!loadingmd2 || loadingmd2->parts.empty()) { conoutf("not loading an md2"); flagmapconfigerror(LWW_MODELERR); return; };
int type = getlistindex(_type, particletypenames, true, -1);
if(type < 0 || type >= MAXPARTYPES) { conoutf("unknown particle type %s", _type); flagmapconfigerror(LWW_MODELERR); return; };
md2::part &mdl = *loadingmd2->parts.last(); md2::part &mdl = *loadingmd2->parts.last();
if(!mdl.addemitter(tag, *type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); return; } if(!mdl.addemitter(tag, type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); return; }
} }
COMMAND(md2emit, "ssii");
COMMAND(md2anim, "siif");
COMMAND(md2tag, "sssss");
COMMAND(md2emit, "siii");
+9 -8
View File
@@ -262,6 +262,7 @@ void md3load(char *model)
mdl.index = loadingmd3->parts.length()-1; mdl.index = loadingmd3->parts.length()-1;
if(!mdl.load(path(filename))) { conoutf("could not load %s", filename); flagmapconfigerror(LWW_MODELERR); } // ignore failure if(!mdl.load(path(filename))) { conoutf("could not load %s", filename); flagmapconfigerror(LWW_MODELERR); } // ignore failure
} }
COMMAND(md3load, "s");
void md3skin(char *objname, char *skin) void md3skin(char *objname, char *skin)
{ {
@@ -287,6 +288,7 @@ void md3skin(char *objname, char *skin)
flagmapconfigerror(LWW_MODELERR); flagmapconfigerror(LWW_MODELERR);
} }
} }
COMMAND(md3skin, "ss");
void md3anim(char *anim, int *startframe, int *range, float *speed) void md3anim(char *anim, int *startframe, int *range, float *speed)
{ {
@@ -295,6 +297,7 @@ void md3anim(char *anim, int *startframe, int *range, float *speed)
if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); return; }; if(num<0) { conoutf("could not find animation %s", anim); flagmapconfigerror(LWW_MODELERR); return; };
loadingmd3->parts.last()->setanim(num, *startframe, *range, *speed); loadingmd3->parts.last()->setanim(num, *startframe, *range, *speed);
} }
COMMAND(md3anim, "siif");
void md3link(int *parent, int *child, char *tagname) void md3link(int *parent, int *child, char *tagname)
{ {
@@ -302,16 +305,14 @@ void md3link(int *parent, int *child, char *tagname)
if(!loadingmd3->parts.inrange(*parent) || !loadingmd3->parts.inrange(*child)) { conoutf("no models loaded to link"); flagmapconfigerror(LWW_MODELERR); return; } if(!loadingmd3->parts.inrange(*parent) || !loadingmd3->parts.inrange(*child)) { conoutf("no models loaded to link"); flagmapconfigerror(LWW_MODELERR); return; }
if(!loadingmd3->parts[*parent]->link(loadingmd3->parts[*child], tagname)) { conoutf("could not link model %s", loadingmd3->loadname); flagmapconfigerror(LWW_MODELERR); } if(!loadingmd3->parts[*parent]->link(loadingmd3->parts[*child], tagname)) { conoutf("could not link model %s", loadingmd3->loadname); flagmapconfigerror(LWW_MODELERR); }
} }
COMMAND(md3link, "iis");
void md3emit(char *tag, int *type, int *arg1, int *arg2) void md3emit(char *tag, char *_type, int *arg1, int *arg2)
{ {
if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); return; }; if(!loadingmd3 || loadingmd3->parts.empty()) { conoutf("not loading an md3"); flagmapconfigerror(LWW_MODELERR); return; };
int type = getlistindex(_type, particletypenames, true, -1);
if(type < 0 || type >= MAXPARTYPES) { conoutf("unknown particle type %s", _type); flagmapconfigerror(LWW_MODELERR); return; };
md3::part &mdl = *loadingmd3->parts.last(); md3::part &mdl = *loadingmd3->parts.last();
if(!mdl.addemitter(tag, *type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); return; } if(!mdl.addemitter(tag, type, *arg1, *arg2)) { conoutf("could not find tag %s", tag); flagmapconfigerror(LWW_MODELERR); return; }
} }
COMMAND(md3emit, "ssii");
COMMAND(md3load, "s");
COMMAND(md3skin, "ss");
COMMAND(md3anim, "siif");
COMMAND(md3link, "iis");
COMMAND(md3emit, "siii");
+4 -3
View File
@@ -818,7 +818,8 @@ enum
PART_EMODEL, PART_EMODEL,
PART_ECARROT, PART_ECARROT,
PART_ELADDER, PART_ELADDER,
PART_EFLAG PART_EFLAG,
MAXPARTYPES
}; };
extern void particleinit(); extern void particleinit();
@@ -832,8 +833,8 @@ extern void particle_fireball(int type, const vec &o);
extern void addshotline(dynent *d, const vec &from, const vec &to); extern void addshotline(dynent *d, const vec &from, const vec &to);
extern bool addbullethole(dynent *d, const vec &from, const vec &to, float radius = 1, bool noisy = true); extern bool addbullethole(dynent *d, const vec &from, const vec &to, float radius = 1, bool noisy = true);
extern bool addscorchmark(vec &o, float radius = 7); extern bool addscorchmark(vec &o, float radius = 7);
extern void render_particles(int time, int typemask = ~0); extern void render_particles(int time, int typemask = ~0);
extern const char *particletypenames[MAXPARTYPES + 1];
// worldio // worldio
enum { LWW_ENTATTROVERFLOW = 0x1, LWW_DECODEERR = 0x10, LWW_WORLDERROR = 0x100, LWW_MISSINGMEDIA = 0x1000, LWW_CONFIGERR = 0x10000, LWW_MODELERR = 0x100000, LWW_SCRIPTERR = 0x1000000 }; enum { LWW_ENTATTROVERFLOW = 0x1, LWW_DECODEERR = 0x10, LWW_WORLDERROR = 0x100, LWW_MISSINGMEDIA = 0x1000, LWW_CONFIGERR = 0x10000, LWW_MODELERR = 0x100000, LWW_SCRIPTERR = 0x1000000 };
@@ -907,7 +908,7 @@ extern void preload_entmodels();
extern void preload_hudguns(); extern void preload_hudguns();
extern bool preload_mapmodels(bool trydl = false); extern bool preload_mapmodels(bool trydl = false);
extern void renderclients(); extern void renderclients();
extern void renderclient(playerent *d); extern void renderclientp(playerent *d);
extern void renderclient(playerent *d, const char *mdlname, const char *vwepname, int tex = 0); extern void renderclient(playerent *d, const char *mdlname, const char *vwepname, int tex = 0);
extern void updateclientname(playerent *d); extern void updateclientname(playerent *d);
extern void updatemapmodeldependencies(); extern void updatemapmodeldependencies();
+5 -5
View File
@@ -1063,7 +1063,7 @@ void updateclientname(playerent *d)
d->skin_rvsf = getclientskin(d->name, "_rvsf"); d->skin_rvsf = getclientskin(d->name, "_rvsf");
} }
void renderclient(playerent *d) void renderclientp(playerent *d)
{ {
if(!d) return; if(!d) return;
int team = team_base(d->team); int team = team_base(d->team);
@@ -1079,10 +1079,10 @@ void renderclient(playerent *d)
formatstring(skin)("%s/custom/%s.jpg", skinbase, cs); formatstring(skin)("%s/custom/%s.jpg", skinbase, cs);
else else
{ {
if(!m_teammode || !teamdisplaymode) formatstring(skin)("%s/%s/%02i.jpg", skinbase, teamname, skinid); if(!m_teammode || !teamdisplaymode) formatstring(skin)("%s/%s/%02d.jpg", skinbase, teamname, skinid);
else switch(teamdisplaymode) else switch(teamdisplaymode)
{ {
case 1: formatstring(skin)("%s/%s/%02i_%svest.jpg", skinbase, teamname, skinid, team ? "blue" : "red"); break; case 1: formatstring(skin)("%s/%s/%02d_%svest.jpg", skinbase, teamname, skinid, team ? "blue" : "red"); break;
case 2: default: formatstring(skin)("%s/%s/%s.jpg", skinbase, teamname, team ? "blue" : "red"); break; case 2: default: formatstring(skin)("%s/%s/%s.jpg", skinbase, teamname, team ? "blue" : "red"); break;
} }
} }
@@ -1095,8 +1095,8 @@ void renderclient(playerent *d)
void renderclients() void renderclients()
{ {
playerent *d; playerent *d;
loopv(players) if((d = players[i]) && d->state!=CS_SPAWNING && d->state!=CS_SPECTATE && (!player1->isspectating() || player1->spectatemode != SM_FOLLOW1ST || player1->followplayercn != i)) renderclient(d); loopv(players) if((d = players[i]) && d->state!=CS_SPAWNING && d->state!=CS_SPECTATE && (!player1->isspectating() || player1->spectatemode != SM_FOLLOW1ST || player1->followplayercn != i)) renderclientp(d);
if(player1->state==CS_DEAD || (reflecting && !refracting)) renderclient(player1); if(player1->state==CS_DEAD || (reflecting && !refracting)) renderclientp(player1);
} }
void loadallmapmodels() // try to find all mapmodels in packages/models/mapmodels void loadallmapmodels() // try to find all mapmodels in packages/models/mapmodels
+4 -3
View File
@@ -184,8 +184,6 @@ void cleanupexplosion()
} }
} }
#define MAXPARTYPES 20
struct particle { vec o, d; int fade, type; int millis; particle *next; }; struct particle { vec o, d; int fade, type; int millis; particle *next; };
particle *parlist[MAXPARTYPES], *parempty = NULL; particle *parlist[MAXPARTYPES], *parempty = NULL;
@@ -248,7 +246,10 @@ void newparticle(const vec &o, const vec &d, int fade, int type)
parlist[type] = p; parlist[type] = p;
} }
static struct parttype { int type; float r, g, b; int gr, tex; float sz; } parttypes[] = const char *particletypenames[MAXPARTYPES + 1] = { "SPARK", "SMOKE", "ECLOSEST", "BLOOD", "DEMOTRACK", "FIREBALL", "SHOTLINE", "BULLETHOLE", "BLOODSTAIN", "SCORCH", // 0..9
"HUDMUZZLEFLASH", "MUZZLEFLASH", "ELIGHT", "ESPAWN", "EAMMO", "EPICKUP", "EMODEL", "ECARROT", "ELADDER", "EFLAG", "" }; // 10..19
static struct parttype { int type; float r, g, b; int gr, tex; float sz; } parttypes[MAXPARTYPES] =
{ {
{ PT_PART, 0.4f, 0.4f, 0.4f, 2, 0, 0.06f }, // yellow: sparks { PT_PART, 0.4f, 0.4f, 0.4f, 2, 0, 0.06f }, // yellow: sparks
{ PT_PART, 1.0f, 1.0f, 1.0f, 20, 1, 0.15f }, // grey: small smoke { PT_PART, 1.0f, 1.0f, 1.0f, 20, 1, 0.15f }, // grey: small smoke