+
+static const char *cmd_names[] = {
+#define DECLARE_COMMAND(cmd) #cmd " ",
+#include "ConsoleCmds.h"
+#undef DECLARE_COMMAND
+};
+
+typedef void (*console_handler)(Game *game, const char *args);
+
+#define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args);
+#include "ConsoleCmds.h"
+#undef DECLARE_COMMAND
+
+static console_handler cmd_handlers[] = {
+#define DECLARE_COMMAND(cmd) ch_##cmd,
+#include "ConsoleCmds.h"
+#undef DECLARE_COMMAND
+};
+
+static void ch_quit(Game *game, const char *args)
+{
+ game->tryquit = 1;
+}
+
+static void ch_map(Game *game, const char *args)
+{
+ char buf[64];
+ snprintf(buf, 63, ":Data:Maps:%s", args);
+ game->Loadlevel(buf);
+ game->whichlevel = -2;
+ campaign = 0;
+}
+
+static void ch_save(Game *game, const char *args)
+{
+ char buf[64];
+ int i, j, k, l, m, templength;
+ float headprop, bodyprop, armprop, legprop;
+ snprintf(buf, 63, ":Data:Maps:%s", args);
+
+
+ int mapvers = 12;;
+
+ FILE *tfile;
+ tfile=fopen( ConvertFileName(buf), "wb" );
+ fpackf(tfile, "Bi", mapvers);
+ fpackf(tfile, "Bi", maptype);
+ fpackf(tfile, "Bi", hostile);
+ fpackf(tfile, "Bf Bf", viewdistance, fadestart);
+ fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
+ fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
+ fpackf(tfile, "Bf Bf Bf Bf Bf Bi", player[0].coords.x, player[0].coords.y, player[0].coords.z, player[0].rotation, player[0].targetrotation, player[0].num_weapons);
+ if(player[0].num_weapons>0&&player[0].num_weapons<5)
+ for(j=0;j<player[0].num_weapons;j++){
+ fpackf(tfile, "Bi", weapons.type[player[0].weaponids[j]]);
+ }
+
+ fpackf(tfile, "Bf Bf Bf", player[0].armorhead, player[0].armorhigh, player[0].armorlow);
+ fpackf(tfile, "Bf Bf Bf", player[0].protectionhead, player[0].protectionhigh, player[0].protectionlow);
+ fpackf(tfile, "Bf Bf Bf", player[0].metalhead, player[0].metalhigh, player[0].metallow);
+ fpackf(tfile, "Bf Bf", player[0].power, player[0].speedmult);
+
+ fpackf(tfile, "Bi", player[0].numclothes);
+
+ fpackf(tfile, "Bi Bi", player[0].whichskin, player[0].creature);
+
+ fpackf(tfile, "Bi", numdialogues);
+ if(numdialogues)
+ for(k=0;k<numdialogues;k++){
+ fpackf(tfile, "Bi", numdialogueboxes[k]);
+ fpackf(tfile, "Bi", dialoguetype[k]);
+ for(l=0;l<10;l++){
+ fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z);
+ fpackf(tfile, "Bf", participantrotation[k][l]);
+ }
+ if(numdialogueboxes)
+ for(l=0;l<numdialogueboxes[k];l++){
+ fpackf(tfile, "Bi", dialogueboxlocation[k][l]);
+ fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]);
+ fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]);
+ fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]);
+ fpackf(tfile, "Bi", dialogueboxsound[k][l]);
+
+ templength=strlen(dialoguetext[k][l]);
+ fpackf(tfile, "Bi",(templength));
+ for(m=0;m<templength;m++){
+ fpackf(tfile, "Bb", dialoguetext[k][l][m]);
+ if(dialoguetext[k][l][m]=='\0')break;
+ }
+
+ templength=strlen(dialoguename[k][l]);
+ fpackf(tfile, "Bi",templength);
+ for(m=0;m<templength;m++){
+ fpackf(tfile, "Bb", dialoguename[k][l][m]);
+ if(dialoguename[k][l][m]=='\0')break;
+ }
+
+ fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z);
+ fpackf(tfile, "Bi", participantfocus[k][l]);
+ fpackf(tfile, "Bi", participantaction[k][l]);
+
+ for(m=0;m<10;m++)
+ fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z);
+
+ fpackf(tfile, "Bf Bf",dialoguecamerarotation[k][l],dialoguecamerarotation2[k][l]);
+ }
+ }
+
+ if(player[0].numclothes)
+ for(k=0;k<player[0].numclothes;k++){
+ templength=strlen(player[0].clothes[k]);
+ fpackf(tfile, "Bi", templength);
+ for(l=0;l<templength;l++)
+ fpackf(tfile, "Bb", player[0].clothes[k][l]);
+ fpackf(tfile, "Bf Bf Bf", player[0].clothestintr[k], player[0].clothestintg[k], player[0].clothestintb[k]);
+ }
+
+ fpackf(tfile, "Bi", environment);
+
+ fpackf(tfile, "Bi", objects.numobjects);
+
+ if(objects.numobjects)
+ for(k=0;k<objects.numobjects;k++){
+ fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", objects.type[k], objects.rotation[k], objects.rotation2[k], objects.position[k].x, objects.position[k].y, objects.position[k].z, objects.scale[k]);
+ }
+
+ fpackf(tfile, "Bi", numhotspots);
+ if(numhotspots)
+ for(i=0;i<numhotspots;i++){
+ fpackf(tfile, "Bi Bf Bf Bf Bf", hotspottype[i],hotspotsize[i],hotspot[i].x,hotspot[i].y,hotspot[i].z);
+ templength=strlen(hotspottext[i]);
+ fpackf(tfile, "Bi",templength);
+ for(l=0;l<templength;l++)
+ fpackf(tfile, "Bb", hotspottext[i][l]);
+ }
+
+ fpackf(tfile, "Bi", numplayers);
+ if(numplayers>1&&numplayers<maxplayers)
+ for(j=1;j<numplayers;j++){
+ fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", player[j].whichskin, player[j].creature, player[j].coords.x, player[j].coords.y, player[j].coords.z, player[j].num_weapons, player[j].howactive, player[j].scale, player[j].immobile, player[j].rotation);
+ if(player[j].num_weapons>0&&player[j].num_weapons<5)
+ for(k=0;k<player[j].num_weapons;k++){
+ fpackf(tfile, "Bi", weapons.type[player[j].weaponids[k]]);
+ }
+ if(player[j].numwaypoints<30){
+ fpackf(tfile, "Bi", player[j].numwaypoints);
+ for(k=0;k<player[j].numwaypoints;k++){
+ fpackf(tfile, "Bf", player[j].waypoints[k].x);
+ fpackf(tfile, "Bf", player[j].waypoints[k].y);
+ fpackf(tfile, "Bf", player[j].waypoints[k].z);
+ fpackf(tfile, "Bi", player[j].waypointtype[k]);
+ }
+ fpackf(tfile, "Bi", player[j].waypoint);
+ }
+ else{
+ player[j].numwaypoints=0;
+ player[j].waypoint=0;
+ fpackf(tfile, "Bi Bi Bi", player[j].numwaypoints, player[j].waypoint, player[j].waypoint);
+ }
+
+ fpackf(tfile, "Bf Bf Bf", player[j].armorhead, player[j].armorhigh, player[j].armorlow);
+ fpackf(tfile, "Bf Bf Bf", player[j].protectionhead, player[j].protectionhigh, player[j].protectionlow);
+ fpackf(tfile, "Bf Bf Bf", player[j].metalhead, player[j].metalhigh, player[j].metallow);
+ fpackf(tfile, "Bf Bf", player[j].power, player[j].speedmult);
+
+ if(player[j].creature==wolftype){
+ headprop=player[j].proportionhead.x/1.1;
+ bodyprop=player[j].proportionbody.x/1.1;
+ armprop=player[j].proportionarms.x/1.1;
+ legprop=player[j].proportionlegs.x/1.1;
+ }
+
+ if(player[j].creature==rabbittype){
+ headprop=player[j].proportionhead.x/1.2;
+ bodyprop=player[j].proportionbody.x/1.05;
+ armprop=player[j].proportionarms.x/1.00;
+ legprop=player[j].proportionlegs.x/1.1;
+ }
+
+ fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
+
+
+
+ fpackf(tfile, "Bi", player[j].numclothes);
+ if(player[j].numclothes)
+ for(k=0;k<player[j].numclothes;k++){
+ int templength;
+ templength=strlen(player[j].clothes[k]);
+ fpackf(tfile, "Bi", templength);
+ for(l=0;l<templength;l++)
+ fpackf(tfile, "Bb", player[j].clothes[k][l]);
+ fpackf(tfile, "Bf Bf Bf", player[j].clothestintr[k], player[j].clothestintg[k], player[j].clothestintb[k]);
+ }
+ }
+
+ fpackf(tfile, "Bi", game->numpathpoints);
+ if(game->numpathpoints)
+ for(j=0;j<game->numpathpoints;j++){
+ fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]);
+ for(k=0;k<game->numpathpointconnect[j];k++){
+ fpackf(tfile, "Bi", game->pathpointconnect[j][k]);
+ }
+ }
+
+ fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius);
+
+ fclose(tfile);
+}
+
+static void ch_cellar(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_tint(Game *game, const char *args)
+{
+ sscanf(args, "%f%f%f", &tintr, &tintg, &tintb);
+}
+
+static void ch_tintr(Game *game, const char *args)
+{
+ tintr = atof(args);
+}
+
+static void ch_tintg(Game *game, const char *args)
+{
+ tintg = atof(args);
+}
+
+static void ch_tintb(Game *game, const char *args)
+{
+ tintb = atof(args);
+}
+
+static void ch_speed(Game *game, const char *args)
+{
+ player[0].speedmult = atof(args);
+}
+
+static void ch_strength(Game *game, const char *args)
+{
+ player[0].power = atof(args);
+}
+
+static void ch_power(Game *game, const char *args)
+{
+ player[0].power = atof(args);
+}
+
+static void ch_size(Game *game, const char *args)
+{
+ player[0].scale = atof(args) * .2;
+}
+
+static int find_closest()
+{
+ int closest = 0;
+ float closestdist = 1.0/0.0;
+
+ for (int i = 1; i < numplayers; i++) {
+ float distance;
+ distance = findDistancefast(&player[i].coords,&player[0].coords);
+ if (distance < closestdist) {
+ closestdist = distance;
+ closest = i;
+ }
+ }
+ return closest;
+}
+
+static void ch_sizenear(Game *game, const char *args)
+{
+ int closest = find_closest();
+
+ if (closest)
+ player[closest].scale = atof(args) * .2;
+}
+
+static void set_proportion(int pnum, const char *args)
+{
+ float headprop,bodyprop,armprop,legprop;
+
+ sscanf(args, "%f%f%f%f", &headprop, &bodyprop, &armprop, &legprop);
+
+ if(player[pnum].creature==wolftype){
+ player[pnum].proportionhead=1.1*headprop;
+ player[pnum].proportionbody=1.1*bodyprop;
+ player[pnum].proportionarms=1.1*armprop;
+ player[pnum].proportionlegs=1.1*legprop;
+ }
+
+ if(player[pnum].creature==rabbittype){
+ player[pnum].proportionhead=1.2*headprop;
+ player[pnum].proportionbody=1.05*bodyprop;
+ player[pnum].proportionarms=1.00*armprop;
+ player[pnum].proportionlegs=1.1*legprop;
+ player[pnum].proportionlegs.y=1.05*legprop;
+ }
+}
+
+static void ch_proportion(Game *game, const char *args)
+{
+ set_proportion(0, args);
+}
+
+static void ch_proportionnear(Game *game, const char *args)
+{
+ int closest = find_closest();
+ if (closest)
+ set_proportion(closest, args);
+}
+
+static void set_protection(int pnum, const char *args)
+{
+ float head, high, low;
+ sscanf(args, "%f%f%f", &head, &high, &low);
+
+ player[pnum].protectionhead = head;
+ player[pnum].protectionhigh = high;
+ player[pnum].protectionlow = low;
+}
+
+static void ch_protection(Game *game, const char *args)
+{
+ set_protection(0, args);
+}
+
+static void ch_protectionnear(Game *game, const char *args)
+{
+ int closest = find_closest();
+ if (closest)
+ set_protection(closest, args);
+}
+
+static void set_armor(int pnum, const char *args)
+{
+ float head, high, low;
+ sscanf(args, "%f%f%f", &head, &high, &low);
+
+ player[pnum].armorhead = head;
+ player[pnum].armorhigh = high;
+ player[pnum].armorlow = low;
+}
+
+static void ch_armor(Game *game, const char *args)
+{
+ set_armor(0, args);
+}
+
+static void ch_armornear(Game *game, const char *args)
+{
+ int closest = find_closest();
+ if (closest)
+ set_armor(closest, args);
+}
+
+static void ch_protectionreset(Game *game, const char *args)
+{
+ set_protection(0, "1 1 1");
+ set_armor(0, "1 1 1");
+}
+
+static void set_metal(int pnum, const char *args)
+{
+ float head, high, low;
+ sscanf(args, "%f%f%f", &head, &high, &low);
+
+ player[pnum].metalhead = head;
+ player[pnum].metalhigh = high;
+ player[pnum].metallow = low;
+}
+
+static void ch_metal(Game *game, const char *args)
+{
+ set_metal(0, args);
+}
+
+static void set_noclothes(int pnum, Game *game, const char *args)
+{
+ player[pnum].numclothes = 0;
+ game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin],
+ &player[pnum].skeleton.drawmodel.textureptr,1,
+ &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize);
+}
+
+static void ch_noclothes(Game *game, const char *args)
+{
+ set_noclothes(0, game, args);
+}
+
+static void ch_noclothesnear(Game *game, const char *args)
+{
+ int closest = find_closest();
+ if (closest)
+ set_noclothes(closest, game, args);
+}
+
+
+static void set_clothes(int pnum, Game *game, const char *args)
+{
+ char buf[64];
+ snprintf(buf, 63, ":Data:Textures:%s.png", args);
+
+ if (!game->AddClothes(buf,0,1,&player[pnum].skeleton.skinText[pnum],&player[pnum].skeleton.skinsize))
+ return;
+
+ player[pnum].DoMipmaps(5,0,0,player[pnum].skeleton.skinsize,player[pnum].skeleton.skinsize);
+ strcpy(player[pnum].clothes[player[pnum].numclothes],buf);
+ player[pnum].clothestintr[player[pnum].numclothes]=tintr;
+ player[pnum].clothestintg[player[pnum].numclothes]=tintg;
+ player[pnum].clothestintb[player[pnum].numclothes]=tintb;
+ player[pnum].numclothes++;
+}
+
+static void ch_clothes(Game *game, const char *args)
+{
+ set_clothes(0, game, args);
+}
+
+static void ch_clothesnear(Game *game, const char *args)
+{
+ int closest = find_closest();
+ if (closest)
+ set_clothes(closest, game, args);
+}
+
+static void ch_belt(Game *game, const char *args)
+{
+ player[0].skeleton.clothes = !player[0].skeleton.clothes;
+}
+
+
+static void ch_cellophane(Game *game, const char *args)
+{
+ cellophane = !cellophane;
+ float mul = cellophane ? 0 : 1;
+
+ for (int i = 0; i < numplayers; i++) {
+ player[i].proportionhead.z = player[i].proportionhead.x * mul;
+ player[i].proportionbody.z = player[i].proportionbody.x * mul;
+ player[i].proportionarms.z = player[i].proportionarms.x * mul;
+ player[i].proportionlegs.z = player[i].proportionlegs.x * mul;
+ }
+}
+
+static void ch_funnybunny(Game *game, const char *args)
+{
+ player[0].skeleton.id=0;
+ player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow",
+ ":Data:Skeleton:Rabbitbelt",":Data:Models:Body.solid",
+ ":Data:Models:Body2.solid",":Data:Models:Body3.solid",
+ ":Data:Models:Body4.solid",":Data:Models:Body5.solid",
+ ":Data:Models:Body6.solid",":Data:Models:Body7.solid",
+ ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1);
+ game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].creature=rabbittype;
+ player[0].scale=.2;
+ player[0].headless=0;
+ player[0].damagetolerance=200;
+ set_proportion(0, "1 1 1 1");
+}
+
+static void ch_wolfie(Game *game, const char *args)
+{
+ player[0].skeleton.id=0;
+ player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low",
+ ":Data:Skeleton:Rabbitbelt",":Data:Models:Wolf.solid",
+ ":Data:Models:Wolf2.solid",":Data:Models:Wolf3.solid",
+ ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid",
+ ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid",
+ ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0);
+ game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+ player[0].creature=wolftype;
+ player[0].damagetolerance=300;
+ set_proportion(0, "1 1 1 1");
+}
+
+static void ch_wolf(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_snowwolf(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_darkwolf(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_white(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_brown(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_black(Game *game, const char *args)
+{
+ game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+ &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+}
+
+static void ch_sizemin(Game *game, const char *args)
+{
+ int i;
+ for (i = 1; i < numplayers; i++)
+ if (player[i].scale < 0.8 * 0.2)
+ player[i].scale = 0.8 * 0.2;
+}
+
+static void ch_tutorial(Game *game, const char *args)
+{
+ tutoriallevel = atoi(args);
+}
+
+static void ch_hostile(Game *game, const char *args)
+{
+ hostile = atoi(args);
+}
+
+static void ch_indemo(Game *game, const char *args)
+{
+ game->indemo=1;
+ hotspot[numhotspots]=player[0].coords;
+ hotspotsize[numhotspots]=0;
+ hotspottype[numhotspots]=-111;
+ strcpy(hotspottext[numhotspots],"mapname");
+ numhotspots++;
+}
+
+static void ch_notindemo(Game *game, const char *args)
+{
+ game->indemo=0;
+ numhotspots--;
+}
+
+static void ch_type(Game *game, const char *args)
+{
+ int i, n = sizeof(editortypenames) / sizeof(editortypenames[0]);
+ for (i = 0; i < n; i++)
+ if (stripfx(args, editortypenames[i]))
+ {
+ editoractive = i;
+ break;
+ }
+}
+
+static void ch_path(Game *game, const char *args)
+{
+ int i, n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
+ for (i = 0; i < n; i++)
+ if (stripfx(args, pathtypenames[i]))
+ {
+ editorpathtype = i;
+ break;
+ }
+}
+
+static void ch_hs(Game *game, const char *args)
+{
+ hotspot[numhotspots]=player[0].coords;
+
+ float size;
+ int type, shift;
+ sscanf(args, "%f%d %n", &size, &type, &shift);
+
+ hotspotsize[numhotspots] = size;
+ hotspottype[numhotspots] = type;
+
+ strcpy(hotspottext[numhotspots], args + shift);
+ strcat(hotspottext[numhotspots], "\n");
+
+ numhotspots++;
+}
+
+static void ch_dialogue(Game *game, const char *args)
+{
+ int dlg, i, j;
+ char buf1[32], buf2[64];
+
+ sscanf(args, "%d %31s", &dlg, buf1);
+ snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1);
+
+ dialoguetype[numdialogues] = dlg;
+
+ memset(dialoguetext[numdialogues], 0, sizeof(dialoguetext[numdialogues]));
+ memset(dialoguename[numdialogues], 0, sizeof(dialoguename[numdialogues]));
+
+ ifstream ipstream(ConvertFileName(buf2));
+ ipstream.ignore(256,':');
+ ipstream >> numdialogueboxes[numdialogues];
+ for(i=0;i<numdialogueboxes[numdialogues];i++){
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,' ');
+ ipstream >> dialogueboxlocation[numdialogues][i];
+ ipstream.ignore(256,':');
+ ipstream >> dialogueboxcolor[numdialogues][i][0];
+ ipstream >> dialogueboxcolor[numdialogues][i][1];
+ ipstream >> dialogueboxcolor[numdialogues][i][2];
+ ipstream.ignore(256,':');
+ ipstream.getline(dialoguename[numdialogues][i],64);
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,' ');
+ ipstream.getline(dialoguetext[numdialogues][i],128);
+ for(j=0;j<128;j++){
+ if(dialoguetext[numdialogues][i][j]=='\\')dialoguetext[numdialogues][i][j]='\n';
+ }
+ ipstream.ignore(256,':');
+ ipstream >> dialogueboxsound[numdialogues][i];
+ }
+
+ for(i=0;i<numdialogueboxes[numdialogues];i++){
+ for(j=0;j<numplayers;j++){
+ participantfacing[numdialogues][i][j]=player[j].facing;
+ }
+ }
+ ipstream.close();
+
+ directing=1;
+ indialogue=0;
+ whichdialogue=numdialogues;
+
+ numdialogues++;
+}
+
+static void ch_fixdialogue(Game *game, const char *args)
+{
+ char buf1[32], buf2[64];
+ int whichdi, i, j;
+
+ sscanf(args, "%d %31s", &whichdi, buf1);
+ snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1);
+
+ memset(dialoguetext[whichdi], 0, sizeof(dialoguetext[whichdi]));
+ memset(dialoguename[whichdi], 0, sizeof(dialoguename[whichdi]));
+
+ ifstream ipstream(ConvertFileName(buf2));
+ ipstream.ignore(256,':');
+ ipstream >> numdialogueboxes[whichdi];
+ for(i=0;i<numdialogueboxes[whichdi];i++){
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,' ');
+ ipstream >> dialogueboxlocation[whichdi][i];
+ ipstream.ignore(256,':');
+ ipstream >> dialogueboxcolor[whichdi][i][0];
+ ipstream >> dialogueboxcolor[whichdi][i][1];
+ ipstream >> dialogueboxcolor[whichdi][i][2];
+ ipstream.ignore(256,':');
+ ipstream.getline(dialoguename[whichdi][i],64);
+ ipstream.ignore(256,':');
+ ipstream.ignore(256,' ');
+ ipstream.getline(dialoguetext[whichdi][i],128);
+ for(j=0;j<128;j++){
+ if(dialoguetext[whichdi][i][j]=='\\')dialoguetext[whichdi][i][j]='\n';
+ }
+ ipstream.ignore(256,':');
+ ipstream >> dialogueboxsound[whichdi][i];
+ }
+
+ ipstream.close();
+}
+
+static void ch_fixtype(Game *game, const char *args)
+{
+ int dlg;
+ sscanf(args, "%d", &dlg);
+ dialoguetype[0] = dlg;
+}
+
+static void ch_fixrotation(Game *game, const char *args)
+{
+ participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
+}
+
+static void ch_ddialogue(Game *game, const char *args)
+{
+ if (numdialogues)
+ numdialogues--;
+}
+
+static void ch_dhs(Game *game, const char *args)
+{
+ if (numhotspots)
+ numhotspots--;
+}
+
+static void ch_immobile(Game *game, const char *args)
+{
+ player[0].immobile = 1;
+}
+
+static void ch_allimmobile(Game *game, const char *args)
+{
+ for (int i = 1; i < numplayers; i++)
+ player[i].immobile = 1;
+}
+
+static void ch_mobile(Game *game, const char *args)
+{
+ player[0].immobile = 0;
+}
+
+static void ch_default(Game *game, const char *args)
+{
+ player[0].armorhead=1;
+ player[0].armorhigh=1;
+ player[0].armorlow=1;
+ player[0].protectionhead=1;
+ player[0].protectionhigh=1;
+ player[0].protectionlow=1;
+ player[0].metalhead=1;
+ player[0].metalhigh=1;
+ player[0].metallow=1;
+ player[0].power=1;
+ player[0].speedmult=1;
+ player[0].scale=1;
+
+ if(player[0].creature==wolftype){
+ player[0].proportionhead=1.1;
+ player[0].proportionbody=1.1;
+ player[0].proportionarms=1.1;
+ player[0].proportionlegs=1.1;
+ }
+
+ if(player[0].creature==rabbittype){
+ player[0].proportionhead=1.2;
+ player[0].proportionbody=1.05;
+ player[0].proportionarms=1.00;
+ player[0].proportionlegs=1.1;
+ player[0].proportionlegs.y=1.05;
+ }
+
+ player[0].numclothes=0;
+ game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
+ &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],
+ &player[0].skeleton.skinsize);
+
+ editoractive=typeactive;
+ player[0].immobile=0;
+}
+
+static void ch_play(Game *game, const char *args)
+{
+ int dlg, i;
+ sscanf(args, "%d", &dlg);
+ whichdialogue = dlg;
+
+ if (whichdialogue >= numdialogues)
+ return;
+
+ for(i=0;i<numdialogueboxes[whichdialogue];i++){
+ player[participantfocus[whichdialogue][i]].coords=participantlocation[whichdialogue][participantfocus[whichdialogue][i]];
+ player[participantfocus[whichdialogue][i]].rotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
+ player[participantfocus[whichdialogue][i]].targetrotation=participantrotation[whichdialogue][participantfocus[whichdialogue][i]];
+ player[participantfocus[whichdialogue][i]].velocity=0;
+ player[participantfocus[whichdialogue][i]].targetanimation=player[participantfocus[whichdialogue][i]].getIdle();
+ player[participantfocus[whichdialogue][i]].targetframe=0;
+ }
+
+ directing=0;
+ indialogue=0;
+
+ float gLoc[3];
+ float vel[3];
+ XYZ temppos;
+ temppos=player[participantfocus[whichdialogue][indialogue]].coords;
+ temppos=temppos-viewer;
+ Normalise(&temppos);
+ temppos+=viewer;
+
+ gLoc[0]=temppos.x;
+ gLoc[1]=temppos.y;
+ gLoc[2]=temppos.z;
+ vel[0]=0;
+ vel[1]=0;
+ vel[2]=0;
+ int whichsoundplay;
+ whichsoundplay=rabbitchitter;
+ if(dialogueboxsound[whichdialogue][indialogue]==2)whichsoundplay=rabbitchitter2;
+ if(dialogueboxsound[whichdialogue][indialogue]==3)whichsoundplay=rabbitpainsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==4)whichsoundplay=rabbitpain1sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==5)whichsoundplay=rabbitattacksound;
+ if(dialogueboxsound[whichdialogue][indialogue]==6)whichsoundplay=rabbitattack2sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==7)whichsoundplay=rabbitattack3sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==8)whichsoundplay=rabbitattack4sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==9)whichsoundplay=growlsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==10)whichsoundplay=growl2sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==11)whichsoundplay=snarlsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==12)whichsoundplay=snarl2sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==13)whichsoundplay=barksound;
+ if(dialogueboxsound[whichdialogue][indialogue]==14)whichsoundplay=bark2sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==15)whichsoundplay=bark3sound;
+ if(dialogueboxsound[whichdialogue][indialogue]==16)whichsoundplay=barkgrowlsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==-1)whichsoundplay=fireendsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==-2)whichsoundplay=firestartsound;
+ if(dialogueboxsound[whichdialogue][indialogue]==-3)whichsoundplay=consolesuccesssound;
+ if(dialogueboxsound[whichdialogue][indialogue]==-4)whichsoundplay=consolefailsound;
+ PlaySoundEx( whichsoundplay, samp[whichsoundplay], NULL, true);
+ OPENAL_3D_SetAttributes(channels[whichsoundplay], gLoc, vel);
+ OPENAL_SetVolume(channels[whichsoundplay], 256);
+ OPENAL_SetPaused(channels[whichsoundplay], false);
+}
+
+static void ch_mapkilleveryone(Game *game, const char *args)
+{
+ maptype = mapkilleveryone;
+}
+
+static void ch_mapkillmost(Game *game, const char *args)
+{
+ maptype = mapkillmost;
+}
+
+static void ch_mapkillsomeone(Game *game, const char *args)
+{
+ maptype = mapkillsomeone;
+}
+
+static void ch_mapgosomewhere(Game *game, const char *args)
+{
+ maptype = mapgosomewhere;
+}
+
+static void ch_viewdistance(Game *game, const char *args)
+{
+ viewdistance = atof(args)*100;
+}
+
+static void ch_fadestart(Game *game, const char *args)
+{
+ fadestart = atof(args);
+}
+
+static void ch_slomo(Game *game, const char *args)
+{
+ slomospeed = atof(args);
+ slomo = !slomo;
+ slomodelay = 1000;
+}
+
+static void ch_slofreq(Game *game, const char *args)
+{
+ slomofreq = atof(args);
+}
+
+static void ch_skytint(Game *game, const char *args)
+{
+ sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb);
+
+ skyboxlightr=skyboxr;
+ skyboxlightg=skyboxg;
+ skyboxlightb=skyboxb;
+
+ game->SetUpLighting();
+
+ terrain.DoShadows();
+ objects.DoShadows();
+}
+
+static void ch_skylight(Game *game, const char *args)
+{
+ sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb);
+
+ game->SetUpLighting();
+
+ terrain.DoShadows();
+ objects.DoShadows();
+}
+
+static void ch_skybox(Game *game, const char *args)
+{
+ skyboxtexture = !skyboxtexture;
+
+ game->SetUpLighting();
+
+ terrain.DoShadows();
+ objects.DoShadows();
+}
+
+static void cmd_dispatch(Game *game, const char *cmd)
+{
+ int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]);
+
+ for (i = 0; i < n_cmds; i++)
+ if (stripfx(cmd, cmd_names[i]))
+ {
+ cmd_handlers[i](game, cmd + strlen(cmd_names[i]));
+ break;
+ }
+ if (i < n_cmds)
+ {
+ PlaySoundEx(consolesuccesssound, samp[consolesuccesssound], NULL, true);
+ OPENAL_SetVolume(channels[consolesuccesssound], 256);
+ OPENAL_SetPaused(channels[consolesuccesssound], false);
+ }
+ else
+ {
+ PlaySoundEx(consolefailsound, samp[consolefailsound], NULL, true);
+ OPENAL_SetVolume(channels[consolefailsound], 256);
+ OPENAL_SetPaused(channels[consolefailsound], false);
+ }
+}
+
+
+
+/********************> Tick() <*****/