]> git.jsancho.org Git - lugaru.git/blob - Source/Devtools/ConsoleCmds.cpp
Devtools: Add clotheslist cmd and fix devkeys in console
[lugaru.git] / Source / Devtools / ConsoleCmds.cpp
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "Devtools/ConsoleCmds.hpp"
22
23 #include "Game.hpp"
24 #include "Level/Dialog.hpp"
25 #include "Level/Hotspot.hpp"
26 #include "Tutorial.hpp"
27 #include "Utils/Folders.hpp"
28
29 const char* cmd_names[cmd_count] = {
30 #define DECLARE_COMMAND(cmd) #cmd,
31 #include "ConsoleCmds.def"
32 #undef DECLARE_COMMAND
33 };
34
35 console_handler cmd_handlers[cmd_count] = {
36 #define DECLARE_COMMAND(cmd) ch_##cmd,
37 #include "ConsoleCmds.def"
38 #undef DECLARE_COMMAND
39 };
40
41 using namespace Game;
42
43 /* globals */
44
45 extern bool campaign;
46 extern bool cellophane;
47 extern int editoractive;
48 extern int editorpathtype;
49 extern int environment;
50 extern float fadestart;
51 extern float slomospeed;
52 extern float slomofreq;
53 extern int hostile;
54 extern int maptype;
55 extern int slomo;
56 extern float slomodelay;
57 extern bool skyboxtexture;
58 extern float skyboxr;
59 extern float skyboxg;
60 extern float skyboxb;
61 extern float skyboxlightr;
62 extern float skyboxlightg;
63 extern float skyboxlightb;
64 extern Terrain terrain;
65 extern float viewdistance;
66
67 /* defined in GameTick.cpp */
68
69 extern int whichlevel;
70
71 float tintr = 1, tintg = 1, tintb = 1;
72
73 /* Helpers used in console commands */
74
75 /* Return true if PFX is a prefix of STR (case-insensitive).  */
76 static bool stripfx(const char* str, const char* pfx)
77 {
78     return !strncasecmp(str, pfx, strlen(pfx));
79 }
80
81 static void set_proportion(int pnum, const char* args)
82 {
83     float headprop, bodyprop, armprop, legprop;
84
85     sscanf(args, "%f%f%f%f", &headprop, &bodyprop, &armprop, &legprop);
86
87     Person::players[pnum]->setProportions(headprop, bodyprop, armprop, legprop);
88 }
89
90 static void set_protection(int pnum, const char* args)
91 {
92     float head, high, low;
93     sscanf(args, "%f%f%f", &head, &high, &low);
94
95     Person::players[pnum]->protectionhead = head;
96     Person::players[pnum]->protectionhigh = high;
97     Person::players[pnum]->protectionlow = low;
98 }
99
100 static void set_armor(int pnum, const char* args)
101 {
102     float head, high, low;
103     sscanf(args, "%f%f%f", &head, &high, &low);
104
105     Person::players[pnum]->armorhead = head;
106     Person::players[pnum]->armorhigh = high;
107     Person::players[pnum]->armorlow = low;
108 }
109
110 static void set_metal(int pnum, const char* args)
111 {
112     float head, high, low;
113     sscanf(args, "%f%f%f", &head, &high, &low);
114
115     Person::players[pnum]->metalhead = head;
116     Person::players[pnum]->metalhigh = high;
117     Person::players[pnum]->metallow = low;
118 }
119
120 static void set_noclothes(int pnum, const char*)
121 {
122     Person::players[pnum]->numclothes = 0;
123     Person::players[pnum]->skeleton.drawmodel.textureptr.load(
124         PersonType::types[Person::players[pnum]->creature].skins[Person::players[pnum]->whichskin], 1,
125         &Person::players[pnum]->skeleton.skinText[0], &Person::players[pnum]->skeleton.skinsize);
126 }
127
128 static void set_clothes(int pnum, const char* args)
129 {
130     char buf[64];
131     snprintf(buf, 63, "Textures/%s.png", args);
132
133     const std::string file_path = Folders::getResourcePath(buf);
134     FILE* tfile;
135     tfile = fopen(file_path.c_str(), "rb");
136     if (tfile == NULL) {
137         perror((std::string("Couldn't find file ") + file_path + " to assign as clothes").c_str());
138
139         // FIXME: Reduce code duplication with GameTick (should come from a Console class)
140         for (int k = 14; k >= 1; k--) {
141             consoletext[k] = consoletext[k - 1];
142         }
143         consoletext[0] = std::string("Could not load the requested texture '") + args + "', aborting.";
144         consoleselected = 0;
145
146         return;
147     }
148
149     int id = Person::players[pnum]->numclothes;
150     strncpy(Person::players[pnum]->clothes[id], buf, 64);
151     Person::players[pnum]->clothestintr[id] = tintr;
152     Person::players[pnum]->clothestintg[id] = tintg;
153     Person::players[pnum]->clothestintb[id] = tintb;
154     Person::players[pnum]->numclothes++;
155
156     if (!Person::players[pnum]->addClothes(id)) {
157         return;
158     }
159
160     Person::players[pnum]->DoMipmaps();
161 }
162
163 static void list_clothes(int pnum)
164 {
165     printf("Clothes from player %d:\n", pnum);
166     for (int i = 0; i < Person::players[pnum]->numclothes; i++) {
167         printf("%s (%f %f %f)\n",
168                Person::players[pnum]->clothes[i],
169                Person::players[pnum]->clothestintr[i],
170                Person::players[pnum]->clothestintg[i],
171                Person::players[pnum]->clothestintb[i]);
172     }
173 }
174
175 /* Console commands themselves */
176
177 void ch_quit(const char*)
178 {
179     tryquit = 1;
180 }
181
182 void ch_map(const char* args)
183 {
184     if (!LoadLevel(args)) {
185         // FIXME: Reduce code duplication with GameTick (should come from a Console class)
186         for (int k = 14; k >= 1; k--) {
187             consoletext[k] = consoletext[k - 1];
188         }
189         consoletext[0] = std::string("Could not load the requested level '") + args + "', aborting.";
190         consoleselected = 0;
191     }
192     whichlevel = -2;
193     campaign = 0;
194 }
195
196 void ch_save(const char* args)
197 {
198     std::string map_path = Folders::getUserDataPath() + "/Maps";
199     Folders::makeDirectory(map_path);
200     map_path = map_path + "/" + args;
201
202     int mapvers = 12;
203
204     FILE* tfile;
205     tfile = fopen(map_path.c_str(), "wb");
206     if (tfile == NULL) {
207         perror((std::string("Couldn't open file ") + map_path + " for saving").c_str());
208         return;
209     }
210     fpackf(tfile, "Bi", mapvers);
211     fpackf(tfile, "Bi", maptype);
212     fpackf(tfile, "Bi", hostile);
213     fpackf(tfile, "Bf Bf", viewdistance, fadestart);
214     fpackf(tfile, "Bb Bf Bf Bf", skyboxtexture, skyboxr, skyboxg, skyboxb);
215     fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
216     fpackf(tfile, "Bf Bf Bf Bf Bf Bi", Person::players[0]->coords.x, Person::players[0]->coords.y, Person::players[0]->coords.z,
217            Person::players[0]->yaw, Person::players[0]->targetyaw, Person::players[0]->num_weapons);
218     if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5) {
219         for (int j = 0; j < Person::players[0]->num_weapons; j++) {
220             fpackf(tfile, "Bi", weapons[Person::players[0]->weaponids[j]].getType());
221         }
222     }
223
224     fpackf(tfile, "Bf Bf Bf", Person::players[0]->armorhead, Person::players[0]->armorhigh, Person::players[0]->armorlow);
225     fpackf(tfile, "Bf Bf Bf", Person::players[0]->protectionhead, Person::players[0]->protectionhigh, Person::players[0]->protectionlow);
226     fpackf(tfile, "Bf Bf Bf", Person::players[0]->metalhead, Person::players[0]->metalhigh, Person::players[0]->metallow);
227     fpackf(tfile, "Bf Bf", Person::players[0]->power, Person::players[0]->speedmult);
228
229     fpackf(tfile, "Bi", Person::players[0]->numclothes);
230
231     fpackf(tfile, "Bi Bi", Person::players[0]->whichskin, Person::players[0]->creature);
232
233     Dialog::saveDialogs(tfile);
234
235     for (int k = 0; k < Person::players[0]->numclothes; k++) {
236         int templength = strlen(Person::players[0]->clothes[k]);
237         fpackf(tfile, "Bi", templength);
238         for (int l = 0; l < templength; l++) {
239             fpackf(tfile, "Bb", Person::players[0]->clothes[k][l]);
240         }
241         fpackf(tfile, "Bf Bf Bf", Person::players[0]->clothestintr[k], Person::players[0]->clothestintg[k], Person::players[0]->clothestintb[k]);
242     }
243
244     fpackf(tfile, "Bi", environment);
245
246     fpackf(tfile, "Bi", Object::objects.size());
247
248     for (unsigned int k = 0; k < Object::objects.size(); k++) {
249         fpackf(tfile, "Bi Bf Bf Bf Bf Bf Bf", Object::objects[k]->type, Object::objects[k]->yaw, Object::objects[k]->pitch,
250                Object::objects[k]->position.x, Object::objects[k]->position.y, Object::objects[k]->position.z, Object::objects[k]->scale);
251     }
252
253     fpackf(tfile, "Bi", Hotspot::hotspots.size());
254     for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
255         fpackf(tfile, "Bi Bf Bf Bf Bf", Hotspot::hotspots[i].type, Hotspot::hotspots[i].size, Hotspot::hotspots[i].position.x, Hotspot::hotspots[i].position.y, Hotspot::hotspots[i].position.z);
256         int templength = strlen(Hotspot::hotspots[i].text);
257         fpackf(tfile, "Bi", templength);
258         for (int l = 0; l < templength; l++) {
259             fpackf(tfile, "Bb", Hotspot::hotspots[i].text[l]);
260         }
261     }
262
263     fpackf(tfile, "Bi", Person::players.size());
264     if (Person::players.size() > maxplayers) {
265         cout << "Warning: this level contains more players than allowed" << endl;
266     }
267     for (unsigned j = 1; j < Person::players.size(); j++) {
268         fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", Person::players[j]->whichskin, Person::players[j]->creature,
269                Person::players[j]->coords.x, Person::players[j]->coords.y, Person::players[j]->coords.z,
270                Person::players[j]->num_weapons, Person::players[j]->howactive, Person::players[j]->scale, Person::players[j]->immobile, Person::players[j]->yaw);
271         if (Person::players[j]->num_weapons < 5) {
272             for (int k = 0; k < Person::players[j]->num_weapons; k++) {
273                 fpackf(tfile, "Bi", weapons[Person::players[j]->weaponids[k]].getType());
274             }
275         }
276         if (Person::players[j]->numwaypoints < 30) {
277             fpackf(tfile, "Bi", Person::players[j]->numwaypoints);
278             for (int k = 0; k < Person::players[j]->numwaypoints; k++) {
279                 fpackf(tfile, "Bf", Person::players[j]->waypoints[k].x);
280                 fpackf(tfile, "Bf", Person::players[j]->waypoints[k].y);
281                 fpackf(tfile, "Bf", Person::players[j]->waypoints[k].z);
282                 fpackf(tfile, "Bi", Person::players[j]->waypointtype[k]);
283             }
284             fpackf(tfile, "Bi", Person::players[j]->waypoint);
285         } else {
286             Person::players[j]->numwaypoints = 0;
287             Person::players[j]->waypoint = 0;
288             fpackf(tfile, "Bi Bi Bi", Person::players[j]->numwaypoints, Person::players[j]->waypoint, Person::players[j]->waypoint);
289         }
290
291         fpackf(tfile, "Bf Bf Bf", Person::players[j]->armorhead, Person::players[j]->armorhigh, Person::players[j]->armorlow);
292         fpackf(tfile, "Bf Bf Bf", Person::players[j]->protectionhead, Person::players[j]->protectionhigh, Person::players[j]->protectionlow);
293         fpackf(tfile, "Bf Bf Bf", Person::players[j]->metalhead, Person::players[j]->metalhigh, Person::players[j]->metallow);
294         fpackf(tfile, "Bf Bf", Person::players[j]->power, Person::players[j]->speedmult);
295         fpackf(tfile, "Bf Bf Bf Bf", Person::players[j]->getProportion(0), Person::players[j]->getProportion(1), Person::players[j]->getProportion(2), Person::players[j]->getProportion(3));
296
297         fpackf(tfile, "Bi", Person::players[j]->numclothes);
298         if (Person::players[j]->numclothes) {
299             for (int k = 0; k < Person::players[j]->numclothes; k++) {
300                 int templength;
301                 templength = strlen(Person::players[j]->clothes[k]);
302                 fpackf(tfile, "Bi", templength);
303                 for (int l = 0; l < templength; l++) {
304                     fpackf(tfile, "Bb", Person::players[j]->clothes[k][l]);
305                 }
306                 fpackf(tfile, "Bf Bf Bf", Person::players[j]->clothestintr[k], Person::players[j]->clothestintg[k], Person::players[j]->clothestintb[k]);
307             }
308         }
309     }
310
311     fpackf(tfile, "Bi", numpathpoints);
312     for (int j = 0; j < numpathpoints; j++) {
313         fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
314         for (int k = 0; k < numpathpointconnect[j]; k++) {
315             fpackf(tfile, "Bi", pathpointconnect[j][k]);
316         }
317     }
318
319     fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
320
321     fclose(tfile);
322 }
323
324 void ch_cellar(const char*)
325 {
326     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurDarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
327 }
328
329 void ch_tint(const char* args)
330 {
331     sscanf(args, "%f%f%f", &tintr, &tintg, &tintb);
332 }
333
334 void ch_tintr(const char* args)
335 {
336     tintr = atof(args);
337 }
338
339 void ch_tintg(const char* args)
340 {
341     tintg = atof(args);
342 }
343
344 void ch_tintb(const char* args)
345 {
346     tintb = atof(args);
347 }
348
349 void ch_speed(const char* args)
350 {
351     Person::players[0]->speedmult = atof(args);
352 }
353
354 void ch_strength(const char* args)
355 {
356     Person::players[0]->power = atof(args);
357 }
358
359 void ch_power(const char* args)
360 {
361     Person::players[0]->power = atof(args);
362 }
363
364 void ch_size(const char* args)
365 {
366     Person::players[0]->scale = atof(args) * .2;
367 }
368
369 void ch_sizenear(const char* args)
370 {
371     int closest = findClosestPlayer();
372     if (closest >= 0) {
373         Person::players[closest]->scale = atof(args) * .2;
374     }
375 }
376
377 void ch_proportion(const char* args)
378 {
379     set_proportion(0, args);
380 }
381
382 void ch_proportionnear(const char* args)
383 {
384     int closest = findClosestPlayer();
385     if (closest >= 0) {
386         set_proportion(closest, args);
387     }
388 }
389
390 void ch_protection(const char* args)
391 {
392     set_protection(0, args);
393 }
394
395 void ch_protectionnear(const char* args)
396 {
397     int closest = findClosestPlayer();
398     if (closest >= 0) {
399         set_protection(closest, args);
400     }
401 }
402
403 void ch_armor(const char* args)
404 {
405     set_armor(0, args);
406 }
407
408 void ch_armornear(const char* args)
409 {
410     int closest = findClosestPlayer();
411     if (closest >= 0) {
412         set_armor(closest, args);
413     }
414 }
415
416 void ch_protectionreset(const char*)
417 {
418     set_protection(0, "1 1 1");
419     set_armor(0, "1 1 1");
420 }
421
422 void ch_metal(const char* args)
423 {
424     set_metal(0, args);
425 }
426
427 void ch_noclothes(const char* args)
428 {
429     set_noclothes(0, args);
430 }
431
432 void ch_noclothesnear(const char* args)
433 {
434     int closest = findClosestPlayer();
435     if (closest >= 0) {
436         set_noclothes(closest, args);
437     }
438 }
439
440 void ch_clothes(const char* args)
441 {
442     set_clothes(0, args);
443 }
444
445 void ch_clothesnear(const char* args)
446 {
447     int closest = findClosestPlayer();
448     if (closest >= 0) {
449         set_clothes(closest, args);
450     }
451 }
452
453 void ch_clotheslist(const char*)
454 {
455     list_clothes(0);
456 }
457
458 void ch_clotheslistnear(const char*)
459 {
460     int closest = findClosestPlayer();
461     if (closest >= 0) {
462         list_clothes(closest);
463     }
464 }
465
466 void ch_belt(const char*)
467 {
468     Person::players[0]->skeleton.clothes = !Person::players[0]->skeleton.clothes;
469 }
470
471 void ch_cellophane(const char*)
472 {
473     cellophane = !cellophane;
474 }
475
476 void ch_funnybunny(const char*)
477 {
478     Person::players[0]->creature = rabbittype;
479     Person::players[0]->skeletonLoad(true);
480     Person::players[0]->scale = .2;
481     Person::players[0]->headless = 0;
482     Person::players[0]->damagetolerance = 200;
483     set_proportion(0, "1 1 1 1");
484 }
485
486 void ch_wolfie(const char*)
487 {
488     Person::players[0]->creature = wolftype;
489     Person::players[0]->skeletonLoad();
490     Person::players[0]->scale = .23;
491     Person::players[0]->damagetolerance = 300;
492     set_proportion(0, "1 1 1 1");
493 }
494
495 void ch_wolf(const char*)
496 {
497     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurWolfGrey.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
498 }
499
500 void ch_snowwolf(const char*)
501 {
502     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurWolfSnow.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
503 }
504
505 void ch_darkwolf(const char*)
506 {
507     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurWolfDark.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
508 }
509
510 void ch_lizardwolf(const char*)
511 {
512     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurWolfLizard.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
513 }
514
515 void ch_white(const char*)
516 {
517     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurWhite.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
518 }
519
520 void ch_brown(const char*)
521 {
522     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurBrown.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
523 }
524
525 void ch_black(const char*)
526 {
527     Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/FurBlack.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
528 }
529
530 void ch_sizemin(const char*)
531 {
532     for (unsigned i = 1; i < Person::players.size(); i++) {
533         if (Person::players[i]->scale < 0.8 * 0.2) {
534             Person::players[i]->scale = 0.8 * 0.2;
535         }
536     }
537 }
538
539 void ch_tutorial(const char* args)
540 {
541     Tutorial::active = atoi(args);
542 }
543
544 void ch_hostile(const char* args)
545 {
546     hostile = atoi(args);
547 }
548
549 void ch_type(const char* args)
550 {
551     int n = sizeof(editortypenames) / sizeof(editortypenames[0]);
552     for (int i = 0; i < n; i++) {
553         if (stripfx(args, editortypenames[i])) {
554             editoractive = i;
555             break;
556         }
557     }
558 }
559
560 void ch_path(const char* args)
561 {
562     unsigned int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
563     for (unsigned int i = 0; i < n; i++) {
564         if (stripfx(args, pathtypenames[i])) {
565             editorpathtype = i;
566             break;
567         }
568     }
569 }
570
571 void ch_hs(const char* args)
572 {
573     float size;
574     int type, shift;
575     sscanf(args, "%f%d %n", &size, &type, &shift);
576
577     Hotspot::hotspots.emplace_back(Person::players[0]->coords, type, size);
578
579     strcpy(Hotspot::hotspots.back().text, args + shift);
580     strcat(Hotspot::hotspots.back().text, "\n");
581 }
582
583 void ch_dialogue(const char* args)
584 {
585     int type;
586     char buf1[32];
587
588     sscanf(args, "%d %31s", &type, buf1);
589     std::string filename = std::string("Dialogues/") + buf1 + ".txt";
590
591     Dialog::dialogs.push_back(Dialog(type, filename));
592
593     Dialog::directing = true;
594     Dialog::indialogue = 0;
595     Dialog::whichdialogue = Dialog::dialogs.size();
596 }
597
598 void ch_fixdialogue(const char* args)
599 {
600     char buf1[32];
601     int whichdi;
602
603     sscanf(args, "%d %31s", &whichdi, buf1);
604     std::string filename = std::string("Dialogues/") + buf1 + ".txt";
605
606     Dialog::dialogs[whichdi] = Dialog(Dialog::dialogs[whichdi].type, filename);
607 }
608
609 void ch_fixtype(const char* args)
610 {
611     int dlg;
612     sscanf(args, "%d", &dlg);
613     Dialog::dialogs[0].type = dlg;
614 }
615
616 void ch_fixrotation(const char*)
617 {
618     int playerId = Dialog::currentScene().participantfocus;
619     Dialog::currentDialog().participantyaw[playerId] = Person::players[playerId]->yaw;
620 }
621
622 void ch_ddialogue(const char*)
623 {
624     if (!Dialog::dialogs.empty()) {
625         Dialog::dialogs.pop_back();
626     }
627 }
628
629 void ch_dhs(const char*)
630 {
631     if (!Hotspot::hotspots.empty()) {
632         Hotspot::hotspots.pop_back();
633     }
634 }
635
636 void ch_immobile(const char*)
637 {
638     Person::players[0]->immobile = 1;
639 }
640
641 void ch_allimmobile(const char*)
642 {
643     for (unsigned i = 1; i < Person::players.size(); i++) {
644         Person::players[i]->immobile = 1;
645     }
646 }
647
648 void ch_mobile(const char*)
649 {
650     Person::players[0]->immobile = 0;
651 }
652
653 void ch_default(const char*)
654 {
655     Person::players[0]->armorhead = 1;
656     Person::players[0]->armorhigh = 1;
657     Person::players[0]->armorlow = 1;
658     Person::players[0]->protectionhead = 1;
659     Person::players[0]->protectionhigh = 1;
660     Person::players[0]->protectionlow = 1;
661     Person::players[0]->metalhead = 1;
662     Person::players[0]->metalhigh = 1;
663     Person::players[0]->metallow = 1;
664     Person::players[0]->power = 1;
665     Person::players[0]->speedmult = 1;
666     if (Person::players[0]->creature == wolftype) {
667         Person::players[0]->scale = .23;
668     } else if (Person::players[0]->creature == rabbittype) {
669         Person::players[0]->scale = .2;
670     }
671
672     Person::players[0]->setProportions(1, 1, 1, 1);
673
674     Person::players[0]->numclothes = 0;
675     Person::players[0]->skeleton.drawmodel.textureptr.load(
676         PersonType::types[Person::players[0]->creature].skins[Person::players[0]->whichskin], 1,
677         &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
678
679     editoractive = typeactive;
680     Person::players[0]->immobile = 0;
681 }
682
683 void ch_play(const char* args)
684 {
685     int dlg;
686     sscanf(args, "%d", &dlg);
687     Dialog::whichdialogue = dlg;
688
689     if (Dialog::whichdialogue >= int(Dialog::dialogs.size())) {
690         return;
691     }
692
693     Dialog::currentDialog().play();
694 }
695
696 void ch_mapkilleveryone(const char*)
697 {
698     maptype = mapkilleveryone;
699 }
700
701 void ch_mapkillmost(const char*)
702 {
703     maptype = mapkillmost;
704 }
705
706 void ch_mapkillsomeone(const char*)
707 {
708     maptype = mapkillsomeone;
709 }
710
711 void ch_mapgosomewhere(const char*)
712 {
713     maptype = mapgosomewhere;
714 }
715
716 void ch_viewdistance(const char* args)
717 {
718     viewdistance = atof(args) * 100;
719 }
720
721 void ch_fadestart(const char* args)
722 {
723     fadestart = atof(args);
724 }
725
726 void ch_slomo(const char* args)
727 {
728     slomospeed = atof(args);
729     slomo = !slomo;
730     slomodelay = 1000;
731 }
732
733 void ch_slofreq(const char* args)
734 {
735     slomofreq = atof(args);
736 }
737
738 void ch_skytint(const char* args)
739 {
740     sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb);
741
742     skyboxlightr = skyboxr;
743     skyboxlightg = skyboxg;
744     skyboxlightb = skyboxb;
745
746     SetUpLighting();
747
748     terrain.DoShadows();
749     Object::DoShadows();
750 }
751
752 void ch_skylight(const char* args)
753 {
754     sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb);
755
756     SetUpLighting();
757
758     terrain.DoShadows();
759     Object::DoShadows();
760 }
761
762 void ch_skybox(const char*)
763 {
764     skyboxtexture = !skyboxtexture;
765
766     SetUpLighting();
767
768     terrain.DoShadows();
769     Object::DoShadows();
770 }