home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -screenplay- / otherstuff / adoomppc_src / dehacked.c < prev    next >
C/C++ Source or Header  |  1998-04-23  |  19KB  |  728 lines

  1. // Emacs style mode select   -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Cyril Deble 1998 (cyril.deble@inforoute.cgs.fr)
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. //      Doom internal dehacked file loader for amiga only :)
  19. //      0.1 (11/02/98) First internal release
  20. //      0.2 (15/02/98) Currently only a few options supported
  21. //      0.3 (08/03/98) Added much more (almost all) options support
  22. //                     and corrected some pointless bugs
  23. //
  24. //-----------------------------------------------------------------------------
  25.  
  26. static const char
  27. rcsid[] = "$Id: dehacked.c,v 0.3 1998/03/08 23:05:00 b1 Exp $";
  28.  
  29. #include <ctype.h>
  30. #include <stdlib.h>
  31.  
  32. // Data.
  33. #include "doomdef.h"
  34. #include "sounds.h"
  35. #include "m_fixed.h"
  36. #include "doomstat.h"
  37. #include "info.h"
  38. #include "m_cheat.h"
  39.  
  40. #ifdef __GNUG__
  41. #pragma implementation "info.h"
  42. #endif
  43. #include "info.h"
  44.  
  45. #include "p_mobj.h"
  46.  
  47. /* for ammo */
  48. extern int clipammo[];
  49.  
  50. /* for misc */
  51. extern int idfa_armor;
  52. extern int idfa_armor_class;
  53. extern int idkfa_armor;
  54. extern int idkfa_armor_class;
  55. extern int god_health;
  56. extern int initial_health;
  57. extern int initial_bullets;
  58. extern int MAXHEALTH;
  59. extern int max_armor;
  60. extern int green_armor_class;
  61. extern int blue_armor_class;
  62. extern int maxsoul;
  63. extern int soul_health;
  64. extern int mega_health;
  65. extern int BFGCELLS;
  66.  
  67. /* for cheat */
  68. extern char cheat_mus_seq[];
  69. extern char cheat_choppers_seq[];
  70. extern char cheat_god_seq[];
  71. extern char cheat_ammo_seq[];
  72. extern char cheat_ammonokey_seq[];
  73. extern char cheat_noclip_seq[];
  74. extern char cheat_commercial_noclip_seq[];
  75. extern char cheat_powerup_seq[7][10];
  76. extern char cheat_clev_seq[];
  77. extern char cheat_mypos_seq[];
  78. extern char cheat_amap_seq[];
  79.  
  80. enum
  81. {
  82.   THING_ID = 0,
  83.   THING_HIT_POINTS,
  84.   THING_SPEED,
  85.   THING_WIDTH,
  86.   THING_HEIGHT,
  87.   THING_MISSILE_DAMAGE,
  88.   THING_REACTION_TIME,
  89.   THING_PAIN_CHANCE,
  90.   THING_MASS,
  91.   THING_BITS,
  92.   THING_ALERT_SOUND,
  93.   THING_ATTACK_SOUND,
  94.   THING_PAIN_SOUND,
  95.   THING_DEATH_SOUND,
  96.   THING_ACTION_SOUND,
  97.   THING_INITIAL_FRAME,
  98.   THING_FIRST_MOVING_FRAME,
  99.   THING_INJURY_FRAME,
  100.   THING_CLOSE_ATTACK_FRAME,
  101.   THING_FAR_ATTACK_FRAME,
  102.   THING_DEATH_FRAME,
  103.   THING_EXPLODING_FRAME,
  104.   THING_RESPAWN_FRAME,
  105.  
  106.   FRAME_SPRITE_NUMBER,
  107.   FRAME_SPRITE_SUBNUMBER,
  108.   FRAME_DURATION,
  109.   FRAME_NEXT_FRAME,
  110.   FRAME_UNKNOWN_1,
  111.   FRAME_UNKNOWN_2,
  112.  
  113.   SPRITE_OFFSET,
  114.  
  115.   AMMO_MAX_AMMO,
  116.   AMMO_PER_AMMO,
  117.  
  118.   WEAPON_AMMO_TYPE,
  119.   WEAPON_DESELECT_FRAME,
  120.   WEAPON_SELECT_FRAME,
  121.   WEAPON_BOBBING_FRAME,
  122.   WEAPON_SHOOTING_FRAME,
  123.   WEAPON_FIRING_FRAME,
  124.  
  125.   POINTER_CODEP_FRAME,
  126.  
  127.   CHEAT_CHANGE_MUSIC,
  128.   CHEAT_CHAINSAW,
  129.   CHEAT_GOD_MODE,
  130.   CHEAT_AMMO_KEYS,
  131.   CHEAT_AMMO,
  132.   CHEAT_NO_CLIPPING_1,
  133.   CHEAT_NO_CLIPPING_2,
  134.   CHEAT_INVINCIBILITY,
  135.   CHEAT_BERSERK,
  136.   CHEAT_INVISIBILITY,
  137.   CHEAT_RADIATION_SUIT,
  138.   CHEAT_AUTO_MAP,
  139.   CHEAT_LITE_AMP_GOGGLES,
  140.   CHEAT_BEHOLD_MENU,
  141.   CHEAT_LEVEL_WARP,
  142.   CHEAT_PLAYER_POSITION,
  143.   CHEAT_MAP_CHEAT,
  144.  
  145.   MISC_INITIAL_HEALTH,
  146.   MISC_INITIAL_BULLETS,
  147.   MISC_MAX_HEALTH,
  148.   MISC_MAX_ARMOR,
  149.   MISC_GREEN_ARMOR_CLASS,
  150.   MISC_BLUE_ARMOR_CLASS,
  151.   MISC_MAX_SOULSPHERE,
  152.   MISC_SOULSPHERE_HEALTH,
  153.   MISC_MEGASPHERE_HEALTH,
  154.   MISC_GOD_MODE_HEALTH,
  155.   MISC_IDFA_ARMOR,
  156.   MISC_IDFA_ARMOR_CLASS,
  157.   MISC_IDKFA_ARMOR,
  158.   MISC_IDKFA_ARMOR_CLASS,
  159.   MISC_BFG_CELLS_SHOT,
  160.   MISC_MONSTERS_INFIGHT,
  161.  
  162.   NUM_KEYWORD
  163. };
  164.  
  165.  
  166. /* All keywords supported */
  167. char *Keywords[] = {
  168. /* Things */
  169. "id # = ",                  /* mobjinfo.doomednum    */
  170. "hit points = ",            /* mobjinfo.spawnhealth  */
  171. "speed = ",                 /* mobjinfo.speed        */
  172. "width = ",                 /* mobjinfo.radius       */
  173. "height = ",                /* mobjinfo.height       */
  174. "missile damage = ",        /* mobjinfo.damage       */
  175. "reaction time = ",         /* mobjinfo.reactiontime */
  176. "pain chance = ",           /* mobjinfo.painchance   */
  177. "mass = ",                  /* mobjinfo.mass         */
  178. "bits = ",                  /* mobjinfo.flags        */
  179. "alert sound = ",           /* mobjinfo.seesound     */
  180. "attack sound = ",          /* mobjinfo.attacksound  */
  181. "pain sound = ",            /* mobjinfo.painsound    */
  182. "death sound = ",           /* mobjinfo.deathsound   */
  183. "action sound = ",          /* mobjinfo.activesound  */
  184. "initial frame = ",         /* mobjinfo.spawnstate   */
  185. "first moving frame = ",    /* mobjinfo.seestate     */
  186. "injury frame = ",          /* mobjinfo.painstate    */
  187. "close attack frame = ",    /* mobjinfo.meleestate   */
  188. "far attack frame = ",      /* mobjinfo.missilestate */
  189. "death frame = ",           /* mobjinfo.deathstate   */
  190. "exploding frame = ",       /* mobjinfo.xdeathstate  */
  191. "respawn frame = ",         /* mobjinfo.raisestate   */
  192.  
  193. /* Frame */
  194.  
  195. "sprite number = ",         /* states.sprite    */
  196. "sprite subnumber = ",      /* states.frame     */
  197. "duration = ",              /* states.tics      */
  198. "next frame = ",            /* states.nextstate */
  199. "unknown 1 = ",             /* states.misc1     */
  200. "unknown 2 = ",             /* states.misc2     */
  201.  
  202. /* Sprite */
  203.  
  204. "offset =",                 /* supported */
  205.  
  206. /* Ammo */
  207.                            
  208. "max ammo = ",              /* maxammo  */
  209. "per ammo = ",              /* clipammo */
  210.  
  211. /* Weapon */
  212.  
  213. "ammo type = ",             /* weaponinfo.ammo       */
  214. "deselect frame = ",        /* weaponinfo.upstate    */
  215. "select frame = ",          /* weaponinfo.downstate  */
  216. "bobbing frame = ",         /* weaponinfo.readystate */
  217. "shooting frame = ",        /* weaponinfo.atkstate   */
  218. "firing frame = ",          /* weaponinfo.flashstate */
  219.  
  220. /* Pointer */
  221.  
  222. "codep frame = ",           /* supported */
  223.  
  224. /* Cheat */
  225.  
  226. "change music = ",          /* supported */
  227. "chainsaw = ",              /* supported */
  228. "god mode = ",              /* supported */
  229. "ammo & keys = ",           /* supported */
  230. "ammo = ",                  /* supported */
  231. "no clipping 1 = ",         /* supported */
  232. "no clipping 2 = ",         /* supported */
  233. "invincibility = ",         /* supported */
  234. "berserk = ",               /* supported */
  235. "invisibility = ",          /* supported */
  236. "radiation suit = ",        /* supported */
  237. "auto-map = ",              /* supported */
  238. "lite-amp goggles = ",      /* supported */
  239. "behold menu = ",           /* supported */
  240. "level warp = ",            /* supported */
  241. "player position = ",       /* supported */
  242. "map cheat = ",             /* supported */
  243.  
  244. /* Misc */
  245.  
  246. "initial health = ",        /* initial_health    */
  247. "initial bullets = ",       /* initial_bullets   */
  248. "max health = ",            /* maxhealth         */
  249. "max armor = ",             /* max_armor         */
  250. "green armor class = ",     /* green_armor_class */
  251. "blue armor class = ",      /* blue_armor_class  */
  252. "max soulsphere = ",        /* maxsoul           */
  253. "soulsphere health = ",     /* soul_health       */
  254. "megasphere health = ",     /* mega_health       */
  255. "god mode health = ",       /* god_health        */
  256. "idfa armor = ",            /* idfa_armor        */
  257. "idfa armor class = ",      /* idfa_armor_class  */
  258. "idkfa armor = ",           /* idkfa_armor       */
  259. "idkfa armor class = ",     /* idfa_armor_class  */
  260. "bfg cells/shot = ",        /* bfgcells          */
  261. "monsters infight = ",      /* not supported     */
  262.  
  263.  
  264. /* Others to follow :) */
  265. "\n"                     /* The last              */
  266. };
  267.  
  268.  
  269. /* Backup of action pointer */
  270. actionf_t actions[NUMSTATES];
  271. /* Backup of sprites names */
  272. char * oldsprnames[NUMSPRITES];
  273.  
  274. void DE_Cheat(char *cheatseq, char* newcheat)
  275. {
  276.   unsigned char *i,*j;
  277.  
  278.   for(i=newcheat;*i!='\0';i++)
  279.       *i=SCRAMBLE(*i);
  280.  
  281.   for(i=cheatseq,j=newcheat;*j!='\0' && *j!=0xff;i++,j++)
  282.       if(*i==1 || *i==0xff) // no more place in the cheat
  283.          return;
  284.       else
  285.          *i=*j;
  286.  
  287.   j=i;
  288.  
  289.   for(;*i!=0xff;i++)
  290.       if(*i==1)
  291.       {
  292.          *j++=1;
  293.          *j++=0;
  294.          *j++=0;
  295.          break;
  296.       }
  297.   *j=0xff;
  298.  
  299.   return;
  300. }
  301.  
  302.  
  303. void DE_Text(FILE* f,int len1,int len2)
  304. {
  305.   char s[50];
  306.   int i;
  307.  
  308.   // it is hard to change all the text in doom
  309.   // here i implement only vital things
  310.   // yes text change somes tables like music, sound and sprite name
  311.   if(len1>6)
  312.     return;
  313.  
  314.     if(fread(s,len1+len2,1,f))
  315.     {
  316.       for(i=0;i<108;i++)
  317.         if(!strncmp(S_sfx[i].name,s,len1))
  318.         {
  319.           strncpy(S_sfx[i].name,&(s[len1]),len2);
  320.           return;
  321.         }
  322.       for(i=0;i<NUMSPRITES;i++)
  323.         if(!strncmp(sprnames[i],s,len1))
  324.         {
  325.           strncpy(sprnames[i],&(s[len1]),len2);
  326.           return;
  327.         }
  328.       for(i=0;i<NUMSPRITES;i++)
  329.         if(!strncmp(sprnames[i],s,len1))
  330.         {
  331.           strncpy(sprnames[i],&(s[len1]),len2);
  332.           return;
  333.         }
  334.       for(i=1;i<68;i++)
  335.         if(!strncmp(S_music[i].name,s,len1))
  336.         {
  337.           strncpy(S_music[i].name,&(s[len1]),len2);
  338.           return;
  339.         }
  340.       /* more text to follow */
  341.  
  342.  
  343.     }
  344. }
  345.  
  346.  
  347. int
  348. DE_Search(char *arg, char **list)
  349. {
  350.   int i, l;
  351.  
  352.   /* Make into lower case, and get length of string */
  353.   for (l = 0; *(arg + l); l++)
  354.     *(arg + l) = tolower(*(arg + l));
  355.   /*printf("arg = '%s'\n", arg);*/
  356.  
  357.   for (i = 0; **(list + i) != '\n'; i++) {
  358.     /*printf("arg = '%s' list = '%s'\n", arg, *(list + i));*/
  359.     if (strstr(arg,*(list + i)))
  360.         return(i);
  361.   }
  362.   return(-1);
  363. }
  364.  
  365.  
  366. int
  367. DE_Hack( char * line)
  368. {
  369.     static int thing = 0;
  370.     static int frame = 0;
  371.     static int ammo = 0;
  372.     static int weapon = 0;
  373.     static int sprite = 0;
  374.     static int pointer = 0;
  375.  
  376.     int choice;
  377.     char * arg;
  378.  
  379.     /* scanf variables */
  380.     int n1;
  381.     char buf1[255];
  382.  
  383.     /* first check for main keywords */
  384.     if(sscanf(line, "Thing %d (%s)", &n1, buf1) == 2)
  385.     {
  386.          thing = n1-1;
  387.          //buf1[strlen(buf1)-1] = '\0';
  388.          //printf("-> Changing Thing %d (%s)\n", n1, buf1);
  389.          return(1);
  390.     }
  391.  
  392.     if(thing >= NUMMOBJTYPES) return(0);
  393.  
  394.     if(sscanf(line, "Frame %d", &n1) == 1)
  395.     {
  396.          frame = n1;
  397.          //printf("-> Changing Frame %d\n", n1);
  398.          return(1);
  399.     }
  400.  
  401.     if(frame >= NUMSTATES) return(0);
  402.  
  403.     if(sscanf(line, "Pointer %d", &n1) == 1)
  404.     {
  405.          pointer = n1;
  406.          //printf("-> Changing Pointer %d\n", n1);
  407.          return(1);
  408.     }
  409.  
  410.     if(pointer >= NUMSTATES) return(0);
  411.  
  412.     if(sscanf(line, "Ammo %d", &n1) == 1)
  413.     {
  414.          ammo = n1;
  415.          //printf("-> Changing Ammo %d\n", n1);
  416.          return(1);
  417.     }
  418.  
  419.     if(ammo >= NUMAMMO) return(0);
  420.  
  421.     if(sscanf(line, "Cheat %d", &n1) == 1)
  422.     {
  423.          //printf("-> Changing Cheat\n");
  424.          return(1);
  425.     }
  426.  
  427.     if(sscanf(line, "Weapon %d", &n1) == 1)
  428.     {
  429.          weapon = n1;
  430.          //printf("-> Changing Weapon %d\n", n1);
  431.          return(1);
  432.     }
  433.  
  434.     if(weapon >= NUMWEAPONS) return(0);
  435.  
  436.     if(sscanf(line, "Sprite %d", &n1) == 1)
  437.     {
  438.          sprite = n1;
  439.          //printf("-> Changing Sprite %d\n", n1);
  440.          return(1);
  441.     }
  442.  
  443.     if(sprite >= NUMSPRITES) return(0);
  444.  
  445.     if(sscanf(line, "Misc %d", &n1) == 1)
  446.     {
  447.          //printf("-> Changing Misc\n");
  448.          return(1);
  449.     }
  450.  
  451.     /* search for option */
  452.     choice = DE_Search(line, Keywords);
  453.  
  454.     if(choice < 0 || choice > NUM_KEYWORD-1) return(0);
  455.  
  456.     arg = strstr(line, Keywords[choice]) +
  457.           strlen(Keywords[choice]);
  458.  
  459.     /*printf("Choice = %d, Arg = %s\n", choice, arg);*/
  460.  
  461.     switch(choice)
  462.     {
  463.       case THING_ID:
  464.           mobjinfo[thing].doomednum = atoi(arg);
  465.           break;
  466.       case THING_HIT_POINTS:
  467.           mobjinfo[thing].spawnhealth = atoi(arg);
  468.           break;
  469.       case THING_SPEED:
  470.           mobjinfo[thing].speed = atoi(arg);
  471.           break;
  472.       case THING_WIDTH:
  473.           mobjinfo[thing].radius = atoi(arg);
  474.           break;
  475.       case THING_HEIGHT:
  476.           mobjinfo[thing].height = atoi(arg);
  477.           break;
  478.       case THING_MISSILE_DAMAGE:
  479.           mobjinfo[thing].damage = atoi(arg);
  480.           break;
  481.       case THING_REACTION_TIME:
  482.           mobjinfo[thing].reactiontime = atoi(arg);
  483.           break;
  484.       case THING_PAIN_CHANCE:
  485.           mobjinfo[thing].painchance = atoi(arg);
  486.           break;
  487.       case THING_MASS:
  488.           mobjinfo[thing].mass = atoi(arg);
  489.           break;
  490.       case THING_BITS:
  491.           mobjinfo[thing].flags = atoi(arg);
  492.           break;
  493.       case THING_ALERT_SOUND:
  494.           mobjinfo[thing].seesound = atoi(arg);
  495.           break;
  496.       case THING_ATTACK_SOUND:
  497.           mobjinfo[thing].attacksound = atoi(arg);
  498.           break;
  499.       case THING_PAIN_SOUND:
  500.           mobjinfo[thing].painsound = atoi(arg);
  501.           break;
  502.       case THING_DEATH_SOUND:
  503.           mobjinfo[thing].deathsound = atoi(arg);
  504.           break;
  505.       case THING_ACTION_SOUND:
  506.           mobjinfo[thing].activesound = atoi(arg);
  507.           break;
  508.       case THING_INITIAL_FRAME:
  509.           mobjinfo[thing].spawnstate = atoi(arg);
  510.           break;
  511.       case THING_FIRST_MOVING_FRAME:
  512.           mobjinfo[thing].seestate = atoi(arg);
  513.           break;
  514.       case THING_INJURY_FRAME:
  515.           mobjinfo[thing].painstate = atoi(arg);
  516.           break;
  517.       case THING_CLOSE_ATTACK_FRAME:
  518.           mobjinfo[thing].meleestate = atoi(arg);
  519.           break;
  520.       case THING_FAR_ATTACK_FRAME:
  521.           mobjinfo[thing].missilestate = atoi(arg);
  522.           break;
  523.       case THING_DEATH_FRAME:
  524.           mobjinfo[thing].deathstate = atoi(arg);
  525.           break;
  526.       case THING_EXPLODING_FRAME:
  527.           mobjinfo[thing].xdeathstate = atoi(arg);
  528.           break;
  529.       case THING_RESPAWN_FRAME:
  530.           mobjinfo[thing].raisestate = atoi(arg);
  531.           break;
  532.       case FRAME_SPRITE_NUMBER:
  533.           states[frame].sprite = atoi(arg);
  534.           break;
  535.       case FRAME_SPRITE_SUBNUMBER:
  536.           states[frame].frame = atoi(arg);
  537.           break;
  538.       case FRAME_DURATION:
  539.           states[frame].tics = atoi(arg);
  540.           break;
  541.       case FRAME_NEXT_FRAME:
  542.           states[frame].nextstate = atoi(arg);
  543.           break;
  544.       case FRAME_UNKNOWN_1:
  545.           states[frame].misc1 = atoi(arg);
  546.           break;
  547.       case FRAME_UNKNOWN_2:
  548.           states[frame].misc2 = atoi(arg);
  549.           break;
  550.       case WEAPON_AMMO_TYPE:
  551.           weaponinfo[weapon].ammo = atoi(arg);
  552.           break;
  553.       case WEAPON_DESELECT_FRAME:
  554.           weaponinfo[weapon].upstate = atoi(arg);
  555.           break;
  556.       case WEAPON_SELECT_FRAME:
  557.           weaponinfo[weapon].downstate = atoi(arg);
  558.           break;
  559.       case WEAPON_BOBBING_FRAME:
  560.           weaponinfo[weapon].readystate = atoi(arg);
  561.           break;
  562.       case WEAPON_SHOOTING_FRAME:
  563.           weaponinfo[weapon].atkstate = atoi(arg);
  564.           break;
  565.       case WEAPON_FIRING_FRAME:
  566.           weaponinfo[weapon].flashstate = atoi(arg);
  567.           break;
  568.       case AMMO_MAX_AMMO:
  569.           maxammo[ammo] = atoi(arg);
  570.           break;
  571.       case AMMO_PER_AMMO:
  572.           clipammo[ammo] = atoi(arg);
  573.           break;
  574.       case CHEAT_CHANGE_MUSIC:
  575.           DE_Cheat(cheat_mus_seq,arg);
  576.           break;
  577.       case CHEAT_CHAINSAW:
  578.           DE_Cheat(cheat_choppers_seq,arg);
  579.           break;
  580.       case CHEAT_GOD_MODE:
  581.           DE_Cheat(cheat_god_seq,arg);
  582.           break;
  583.       case CHEAT_AMMO_KEYS:
  584.           DE_Cheat(cheat_ammonokey_seq,arg);
  585.           break;
  586.       case CHEAT_AMMO:
  587.           DE_Cheat(cheat_ammo_seq,arg);
  588.           break;
  589.       case CHEAT_NO_CLIPPING_1:
  590.           DE_Cheat(cheat_noclip_seq,arg);
  591.           break;
  592.       case CHEAT_NO_CLIPPING_2:
  593.           DE_Cheat(cheat_commercial_noclip_seq,arg);
  594.           break;
  595.       case CHEAT_INVINCIBILITY:
  596.           DE_Cheat(cheat_powerup_seq[0],arg);
  597.           break;
  598.       case CHEAT_BERSERK:
  599.           DE_Cheat(cheat_powerup_seq[1],arg);
  600.           break;
  601.       case CHEAT_INVISIBILITY:
  602.           DE_Cheat(cheat_powerup_seq[2],arg);
  603.           break;
  604.       case CHEAT_RADIATION_SUIT:
  605.           DE_Cheat(cheat_powerup_seq[3],arg);
  606.           break;
  607.       case CHEAT_AUTO_MAP:
  608.           DE_Cheat(cheat_powerup_seq[4],arg);
  609.           break;
  610.       case CHEAT_LITE_AMP_GOGGLES:
  611.           DE_Cheat(cheat_powerup_seq[5],arg);
  612.           break;
  613.       case CHEAT_BEHOLD_MENU:
  614.           DE_Cheat(cheat_powerup_seq[6],arg);
  615.           break;
  616.       case CHEAT_LEVEL_WARP:
  617.           DE_Cheat(cheat_clev_seq,arg);
  618.           break;
  619.       case CHEAT_PLAYER_POSITION:
  620.           DE_Cheat(cheat_mypos_seq,arg);
  621.           break;
  622.       case CHEAT_MAP_CHEAT:
  623.           DE_Cheat(cheat_amap_seq,arg);
  624.           break;
  625.       case MISC_INITIAL_HEALTH:
  626.           initial_health = atoi(arg);
  627.           break;
  628.       case MISC_INITIAL_BULLETS:
  629.           initial_bullets = atoi(arg);
  630.           break;
  631.       case MISC_MAX_HEALTH:
  632.           MAXHEALTH = atoi(arg);
  633.           break;
  634.       case MISC_MAX_ARMOR:
  635.           max_armor = atoi(arg);
  636.           break;
  637.       case MISC_GREEN_ARMOR_CLASS:
  638.           green_armor_class = atoi(arg);
  639.           break;
  640.       case MISC_BLUE_ARMOR_CLASS:
  641.           blue_armor_class = atoi(arg);
  642.           break;
  643.       case MISC_MAX_SOULSPHERE:
  644.           maxsoul = atoi(arg);
  645.           break;
  646.       case MISC_SOULSPHERE_HEALTH:
  647.           soul_health = atoi(arg);
  648.           break;
  649.       case MISC_MEGASPHERE_HEALTH:
  650.           mega_health = atoi(arg);
  651.           break;
  652.       case MISC_GOD_MODE_HEALTH:
  653.           god_health = atoi(arg);
  654.           break;
  655.       case MISC_IDFA_ARMOR:
  656.           idfa_armor = atoi(arg);
  657.           break;
  658.       case MISC_IDFA_ARMOR_CLASS:
  659.           idfa_armor_class = atoi(arg);
  660.           break;
  661.       case MISC_IDKFA_ARMOR:
  662.           idkfa_armor = atoi(arg);
  663.           break;
  664.       case MISC_IDKFA_ARMOR_CLASS:
  665.           idfa_armor_class = atoi(arg);
  666.           break;
  667.       case MISC_BFG_CELLS_SHOT:
  668.           BFGCELLS = atoi(arg);
  669.           break;
  670.       case SPRITE_OFFSET:
  671.           sprnames[sprite]=oldsprnames[(atoi(arg)-151328)/8];
  672.  
  673.       case POINTER_CODEP_FRAME:
  674.           states[frame].action = actions[atoi(arg)];
  675.  
  676.       default:
  677.         return(0);
  678.     }
  679.  
  680.     return(1);
  681. }
  682.  
  683.  
  684. void
  685. DE_AddDeh(char * name)
  686. {
  687.   FILE *fp;
  688.   char text[255];
  689.  
  690.   printf("DE_AddDeh: Adding %s\n", name);
  691.  
  692.   if(fp = fopen(name,"r"))
  693.   {
  694.     int i;
  695.  
  696.     /* Backup all action pointer */
  697.     for(i=0;i<NUMSTATES;i++)
  698.         actions[i] = states[i].action;
  699.  
  700.     /* Backup all sprite name pointer */
  701.     for(i=0;i<NUMSPRITES;i++)
  702.         oldsprnames[i] = sprnames[i];
  703.  
  704.     /* Start parsing the file */
  705.     while(fgets(text, 255, fp))
  706.     {
  707.         int len1 = 0, len2 = 0;
  708.         text[strlen(text)-1] = '\0';
  709.  
  710.         if(text[0] == '#') continue;
  711.         if(text[0] == '\n') continue;
  712.  
  713.         /* Check for text or hack */
  714.         if(sscanf(text, "Text %d %d", &len1, len2) == 2)
  715.           DE_Text(fp, len1, len2);
  716.         else
  717.           DE_Hack(text);
  718.     }
  719.  
  720.     fclose(fp);
  721.   }
  722.   else
  723.   {
  724.     printf("Dehacked file '%s' not found\nPress ENTER to continue\n", name);
  725.     getchar();
  726.   }
  727. }
  728.