home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / VDUKE / CONEDIT.ZIP / CONEDIT.FAQ
Text File  |  1996-12-28  |  64KB  |  1,754 lines

  1.                      Release date: 12/27/1996 12:55
  2.  
  3.  
  4.                        ---  CON Editing FAQ  ---
  5.  
  6.                               version 2.0
  7.  
  8.                                   by
  9.  
  10.                             Joris B. Weimar
  11.  
  12.  
  13. --------------------------------------------------------------------------
  14.  INDEX
  15. --------------------------------------------------------------------------
  16.  
  17. 1)    Information
  18.  
  19. 1.1   Who wrote this FAQ and some general info
  20. 1.2   Where did the author get the information?
  21. 1.3   What's new?
  22.  
  23. 2)    CON building blocks
  24.  
  25. 2.1   What's a state?
  26. 2.2   What's an action?
  27. 2.3   What's an ai?
  28. 2.4   What's an actor?
  29. 2.5   What's an useractor?
  30. 2.6   What is an 'if' construction?
  31. 2.7   The complete primitive list
  32. 2.8   Predefined states
  33. 2.9   Known .CON bugs
  34.  
  35. 3)    Examples
  36.  
  37. 3.1   Example 1: Make the atomic health sprite pulsating
  38. 3.2   Example 2: Make your own Duke Bot
  39.  
  40. 4)    General CON overview
  41.  
  42. 4.1   DEFS.CON
  43. 4.2   USER.CON
  44. 4.3   GAME.CON
  45.  
  46. 5)    Appendix
  47.  
  48. 5.1   What I would like to know
  49. 5.2   Contributers/Thank you's
  50. 5.3   Update and info
  51. 5.4   Where to get this FAQ
  52.  
  53. --------------------------------------------------------------------------
  54.   1.1 Who wrote this FAQ and some general info
  55. --------------------------------------------------------------------------
  56.  
  57. This FAQ was written by Joris Weimar also known as 'antiwin'. I'm a huge
  58. fan of Duke Nukem and until recently I didn't do anything with the CON
  59. files other then change some simple values such as MAXPLAYERHEALTH etc.
  60. After some of the primitives you will notice a sign like this "[PP]".
  61. This will mean the primitive or functionallity is only available in
  62. Plutonium Pak. PP is short for Plutonium Pak (do'h!).
  63.    I must admit that I'm don't know everything on .CON hacking but I know
  64. when *I* knew nothing about it I wanted to get every information I could.
  65. So here it is. Whenever I searched the net for a CON FAQ I _always_ got
  66. the same FAQ. I hope this FAQ will go furhter into subjects that that FAQ
  67. (you surely now which FAQ I'm reffering to) brought up. I'm asking you
  68. friendly to keep the name of this FAQ 'CONEDIT.FAQ' or 'CONEDIT.ZIP' when
  69. zipped. This to eliminate confusion.
  70.    If you have any questions, tips, corrections or comments about this FAQ
  71. you can reach me via e-mail at antiwin@worldonline.nl. You can also call me
  72. at +31 (0)70 3520655.
  73.  
  74. --------------------------------------------------------------------------
  75.   1.2 Were did the author get the information?
  76. --------------------------------------------------------------------------
  77.  
  78. Well, I _did_ learn something from the FAQ by Ben Cantrick. But most of
  79. the stuff I found out by myself by just trying, trying and trying. I re-
  80. wrote the entire code for the pigcop. It's still buggy and there are still
  81. some things that I don't comprehense. But he sure has gotten tougher.
  82. You'll find an PigCop-to-Duke example in this FAQ. Ok, now lets get on
  83. with the good stuff.
  84.  
  85. --------------------------------------------------------------------------
  86.   1.3 What's new?
  87. --------------------------------------------------------------------------
  88.  
  89. * version 0.1ß
  90.    - First release.
  91.  
  92. * version 0.2
  93.    - Changed the index
  94.    - Added some more primitives
  95.  
  96. * version 0.3
  97.    - Expanded the PigCop example
  98.    - Fixed some misspellings :-)
  99.  
  100. * version 0.4
  101.    - Expanded the PigCop example
  102.    - Added 'Contributor/Thank you's' part
  103.    - Added 'Where to get this FAQ' part
  104.  
  105. * version 0.5
  106.    - Added 'Predefined states' part
  107.    - Removed those 'line-drawing' chars for Windows compatiblity
  108.  
  109. * version 0.6
  110.    - Changed pigcop into duke :-)
  111.    - Fixed several code pigs
  112.  
  113. * version 0.7
  114.    - Removed pigcop example
  115.    - Started a new more simpler example
  116.  
  117. * version 0.8
  118.    - Update the new example
  119.    - Rename keywords to primitives
  120.    - Added 5 new primitives
  121.    - Documented a few unknown primitives
  122.  
  123. * version 0.9 - 1.1
  124.   - never released
  125.  
  126. * version 2.0
  127.   - New example
  128.   - Added new Plutonium Pak primitives
  129.  
  130. --------------------------------------------------------------------------
  131.   2.1 What's a state?
  132. --------------------------------------------------------------------------
  133.  
  134. A state is a subroutine. Whenever you call a state he executes that
  135. function and return to where you called it.
  136.  
  137. Example:
  138.  
  139. state saysecretplace    // Start a state definition
  140. quote 9                 // Some code
  141. ends                    // End of state (return to caller)
  142.  
  143. This is a state (subroutine). Whenever you call it it executes the code
  144. contained in it. In this example that would be the command 'quote' which
  145. prints a text on screen. 9 is the defined in USER.CON (definequote) as
  146. "A SECRET PLACE!". Now we must call it from somewhere:
  147.  
  148. state saysecretplace // execute the state, thus printing "A SECRET PLACE!"
  149.  
  150. You can call a state from within a state like this:
  151.  
  152. state test2   // State test2 definition
  153. quote 9
  154. ends          // End of state
  155.  
  156. state test1   // State test2 definition
  157. state test2   // Call the test2 state
  158. ends          // End of state
  159.  
  160.  
  161. Now to print the quote on screen do this:
  162.  
  163. state test1
  164.  
  165. or ofcourse this (this does it directly while the above example first
  166. calles another state):
  167.  
  168. state test2
  169.  
  170. Now he will print "A SECRET PLACE!". You may think to yourself: "hmmm... I
  171. can understand this but where do I put it in the .CON". Well, I'll get to
  172. that later.
  173.  
  174. --------------------------------------------------------------------------
  175.   2.2 What's an action?
  176. --------------------------------------------------------------------------
  177.  
  178. An action is used to give a group of sprites a name. Usually this group
  179. of sprites is animated. The structure of the action command is:
  180.  
  181. action <name> <startframenum> <numframes> <type> <incvalue> <delay>
  182.  
  183. <name>          = This can be any string up to 64 characters long.
  184. <startframenum> = starting frame number. Note: this number is rela-
  185.                   tive to the main sprite of the actor. If you want
  186.                   the pigcop to look like the atomic health you need
  187.                   to give the starting frame a number of -1900 since
  188.                   the pigcop main character is 2000 and the atomic
  189.                   health is 100
  190.  
  191. <numframes>     = Number of frames in action group.
  192.  
  193. <type>          = This value determines wether the picture is onesided
  194.                   (looks the same no matter what angle you
  195.                   see it from) or 3D. When 3D every sprite will contain
  196.                   actually 5 sprites. One seen from upfront, one from the
  197.                   back, one sideways and two from resp. 45 degr. and 135
  198.                   degr. The other three angles are created from the other
  199.                   sprites by flipping the x-coordinates. Give <type> a
  200.                   value of 1 to make it onesided. 5 makes it 3D. I don't
  201.                   know if there are any other legal values but I wouldn't
  202.                   bet on it. One possible value could be 8 though. I'm not
  203.                   sure, but when this value is used I guess the expects
  204.                   there to be 8 sprites for each frame (45,90,135degr etc.)
  205.  
  206. <incvalue>      = This is the incrementing value. Negative values are
  207.                   allowed.
  208.  
  209. <delay>         = This determines how long each frame lasts. Bigger values
  210.                   lets the frame take longer.
  211.  
  212.  
  213. Example:
  214.  
  215. action ATOMIC 0 15 1 1 10
  216.  
  217. Ok, this _is_ still kind of complex but you'll get to use this stuff in
  218. a minute.
  219.  
  220. --------------------------------------------------------------------------
  221.   2.3 What's an ai?
  222. --------------------------------------------------------------------------
  223. An ai is some sort of definition of a state of an actor. Here's the struc-
  224. ture:
  225.  
  226. ai <ainame> <action> <speed> <aitype>
  227.  
  228. <ainame>           = Just a string to identify it for later use.
  229.  
  230. <action>           = action group id. This is the group of frames
  231.                      the actor will cycle through as he is using this ai
  232.                      function.
  233.  
  234. <speed>            = Rate of movement of character when using this ai
  235.                      function. It seems that <speed> must be a value
  236.                      defined by move (move WALKSPEED 100). Negative
  237.                      values are allowed.
  238.  
  239. <aitype>           = Determines type of ai. The ai types are already
  240.                      programmed in the game so you can't change these.
  241.                      Some of the legal types are:
  242.  
  243.                      seekplayer:      The actor will walk up to the _nearest_
  244.                                       player.
  245.                      fleeenemy:       The actor will run away from a player.
  246.  
  247.                      faceplayer:      The actor will point his crosshair at
  248.                                       you thus facing you.
  249.  
  250.                      faceplayersmart: The actor will point his crosshair
  251.                                       a little bit next to you in the direction
  252.                                       that you're heading. Kind of smart, isn't
  253.                                       it.
  254.  
  255.                      dodgebullet:     Evasion manouvre.
  256.  
  257.                      randomangle:     Change actors direction to a random
  258.                                       angle when it hits the wall. Or walk
  259.                                       up to the player when actor is being
  260.                                       shot at.
  261.  
  262.  
  263.                      You can more than one ai at the same time by listing
  264.                      them: randomangle dodgebullet etc.
  265.  
  266.  
  267. When you want the actor to use an ai function do it like this:
  268.  
  269. ai <name>
  270.  
  271. where <name> is the same as <ainame> explained above.
  272.  
  273. --------------------------------------------------------------------------
  274.   2.4 What's an actor?
  275. --------------------------------------------------------------------------
  276.  
  277. Everything that has vertices (drawn in build) is _not_ an actor. So walls,
  278. floors, elevators, doors are _not_ actors. Every sprite has the potential
  279. of being an actor. Some examples are:
  280.  
  281. Duke, Pigcop, Medicalkit, Health, RPG sprite etc...
  282.  
  283. The structure of the actor command is:
  284.  
  285. actor <initialspritenum> <strength> <action> <speed> <aifunction>
  286.  
  287. <initialspritenum> = This number is the tile number (as in build, editart)
  288.                      from which all actions that this actor can do are
  289.                      relative. For a PIGCOP this value is PIGCOP which is
  290.                      defined (in USER.CON) to be 2000. If you look in build
  291.                      at location 2000 you'll see the PIGCOP character.
  292.  
  293. <strength>         = This value tells the game how much damage it can take.
  294.                      If you give this parameter a value of 0 the actor can
  295.                      not be destroyed (bummer).
  296.  
  297.  
  298. <action>           = The action number refers to an action group as de-
  299.                      scribed above. Regarding to monsters this is usally
  300.                      some kind of initial action group. He is just standing
  301.                      and doing nothing.
  302.  
  303. <speed>            = Speed is the rate of movement this character has, if
  304.                      the character doesn't move give this a value of 0 or
  305.                      don't give this value at all.
  306.  
  307. <aifunction>       = His initial ai routine. With monsters this is usually
  308.                      a still standing monster waiting for someone to discover
  309.                      him. You can read the defenition of ai in the section
  310.                      above.
  311.  
  312.  
  313. The actor code is the main code of a character. It's structure goes like
  314. this:
  315.  
  316. actor ... (describer above)
  317.  
  318. // The code contained hereign is the main code of the character. Each time
  319. // (frame) this code gets called!
  320.  
  321. enda    // End of Actor
  322.  
  323. As I heard from "StratonAce" we can not add new actors. We can replace
  324. other actors by removing the old code and placing in our. "StratonAce"
  325. also informed me that this restriction is possibly removed with the
  326. upcoming Plutonium Pak version of Duke (1.4)
  327.  
  328. --------------------------------------------------------------------------
  329.   2.5   What's an useractor? [PP]
  330. --------------------------------------------------------------------------
  331.  
  332. The useractor command is new to PP. It allows people to create their
  333. own actors in PP without having to replace old ones. It's almost exactly
  334. the same as a conventional actor with a few exeptions. For example,
  335. enemies created with the useractor command will not shoot straight and
  336. their size might not always be proportional (like the bug in BUILD).
  337.  
  338. The structure of the actor command is:
  339.  
  340. useractor <type> <initialspritenum> <strength> <action> <speed> <aifunction>
  341.  
  342. <type>             = This tells PP the type of actor you want to create.
  343.                      The legal values are 'enemystayput', 'enemy' and
  344.                      'notenemy'. Explenations follow:
  345.  
  346.                      enemy        = The actor's code will not be executed until
  347.                                     approximatly 1 second after the player has
  348.                                     spotted the actor.
  349.  
  350.                      notenemy     = The actor's code will not be executed until
  351.                                     the player has spotted the actor.
  352.  
  353.                      enemystayput = The actor's code will not be executed until
  354.                                     approximatly 1 second after the player has
  355.                                     spotted the actor AND the actor's code will
  356.                                     not be executed if the player is not in sight.
  357.  
  358. <initialspritenum> = This number is the tile number (as in build, editart)
  359.                      from which all actions that this actor can do are
  360.                      relative. For a PIGCOP this value is PIGCOP which is
  361.                      defined (in USER.CON) to be 2000. If you look in build
  362.                      at location 2000 you'll see the PIGCOP character.
  363.  
  364. <strength>         = This value tells the game how much damage it can take.
  365.                      If you give this parameter a value of 0 the actor can
  366.                      not be destroyed (bummer).
  367.  
  368.  
  369. <action>           = The action number refers to an action group as de-
  370.                      scribed above. Regarding to monsters this is usally
  371.                      some kind of initial action group. He is just standing
  372.                      and doing nothing.
  373.  
  374. <speed>            = Speed is the rate of movement this character has, if
  375.                      the character doesn't move give this a value of 0 or
  376.                      don't give this value at all.
  377.  
  378. <aifunction>       = His initial ai routine. With monsters this is usually
  379.  
  380. --------------------------------------------------------------------------
  381.   2.6   What's an 'if' construction?
  382. --------------------------------------------------------------------------
  383.  
  384. Okay, this is really the power of any programming language. In many
  385. occasions you want to execute some code (listed below, 2.6) IF some-
  386. thing is true, or IF something is false. You also want something ELSE
  387. to be executed if the condition is false:
  388.  
  389. IF I AM HUNGRY
  390.    EAT A SANDWICH
  391.    ELSE
  392.    WaiT UNTIL LATER
  393.  
  394. Well, now to get a bit more in Dukes direction, this is some code of
  395. my new Pig Cop. He fires a SHRINKER, but only when you're not on ste-
  396. roids because when you use steroids you won't shrink (you knew that,
  397. right?):
  398.  
  399. ifp ponsteroids
  400.    shoot SHOTGUN
  401.    else
  402.    shoot SHRINKER
  403.  
  404. in PSEUDO code that is:
  405.  
  406. if duke is on steroids
  407.    shoot him with the shotgun
  408.    or else
  409.    shoot him with the shrinker
  410.  
  411. If you didn't know the 'ifp ponsteroids' and 'shoot' command yet, don't
  412. worry. They are all listed below. Ofcourse you may want to execute MORE
  413. than one function. Then you'll have to use the braces '{' and '}'.
  414.  
  415. ifp ponsteroids
  416.    {
  417.    shoot SHOTGUN
  418.    sound SHOTGUN_FIRE
  419.    }
  420.    else
  421.    {
  422.    shoot SHRINKER
  423.    sound SHRINKER_FIRE
  424.    }
  425.  
  426. You see that all the code between the two braces is considered as ONE
  427. function.
  428.  
  429.  
  430. --------------------------------------------------------------------------
  431.   2.7   The complete primitive list
  432. --------------------------------------------------------------------------
  433.  
  434. Now, you're wondering, what kind of code can I put in these actors and
  435. STATEs. Well, you already saw one of them: QUOTE. That's ofcourse not
  436. enough to create a character like for example a PigCop. Ok, here are
  437. the most important functions:
  438.  
  439. //                           = Everything on the line after the '//' will
  440.                                be ignored.
  441.  
  442. /* ... */                    = Everything between the '/*' and the '*/' will
  443.                                be ignored.
  444. action <actiongroup>         = Assign sprite animation group to current
  445.                                actor. See definition above.
  446.  
  447. actor ...                    = See definition above.
  448.  
  449. addammo <weapon> <amount>    = Add the given number of ammo to the player.
  450.                                He does not get the weapon if he hasn't got
  451.                                it. The legal values are describer in USER.CON
  452.  
  453. addphealth <amount>          = Add the value <amount> to the players health.
  454.                                When playing with more than one player I suspect
  455.                                the closest one will be effected. This goes for
  456.                                all player related functions.
  457.  
  458. addinventory <item> <amnt>  = Add <amount> to the item <item>. The legal
  459.                                values for <item> can be seen with the
  460.                                'ifpinventory' function.
  461.  
  462. ai <name>                    = Let current actor use the ai function <name> from
  463.                                now on.
  464.  
  465. addstrength                  = Adds strength to the current actor.
  466.  
  467. addweapon <weap> <ammo>      = Gives nearest duke weapon <weap> with an initial
  468.                                amount of ammo equal to <ammo>.
  469.                                Legal weapons are:
  470.                                - HANDBOMB_WEAPON
  471.                                - RPG_WEAPON
  472.                                - SHOTGUN_WEAPON
  473.                                - PISTOL_WEAPON
  474.                                - TRIPBOMB_WEAPON
  475.                                - CHAINGUN_WEAPON
  476.                                - SHRINKER_WEAPON
  477.                                - FREEZE_WEAPON
  478.                                - DEVISTATOR_WEAPON
  479.  
  480. break                        = Immediatly leave a STATE or actor.
  481.  
  482. clipdist <value>             = I have no idea ;)
  483.  
  484. count <num>                  = Sets the counter to <num>. I believe the game
  485.                                gives every actor its own counter since this
  486.                                function could heavily mess up the timer of
  487.                                other actors
  488.  
  489. cactor <actor>               = Call the code of the actor identified by
  490.                                <actor>
  491.  
  492. cstat <mask>                 = With this function you can do some nice tricks.
  493.                                This is used to change some actor settings for
  494.                                the current actor. Some of the legal values are:
  495.                                1      = Make sprite blockable ("B" in BUILD)
  496.                                2      = make actor 'see-through'.
  497.                                4      = flip sprite around x-axis.
  498.                                8      = flip sprite around y-axis.
  499.                                16     = Draw him as wall texture (vert. flat)
  500.                                32     = Draw him as floor texture (hor. flat)
  501.                                64     = Make sprite one sided.
  502.                                128    = Half submerged.
  503.                                256    = Make sprite solid ("H" in BUILD)
  504.                                32768  = Invisible
  505.                                To use more than one setting add the values
  506.                                together (264 = solid+upsidedown, 256+8).
  507.  
  508. cstator <mask>               = Same as cstat, but it keeps doesn't reset
  509.                                all the previous settings. It just adds the
  510.                                ones you specify. A bit like the 'or' in
  511.                                several programming languages.
  512.  
  513. debris <actiongrp> <amount>  = Causes debris to fly all over the place.
  514.                                <actiongrp> is the sprite animation used for
  515.                                the debris. Legal values seem to be 'SCRAP1'
  516.                                and 'SCRAP2'. The higher the amount the more
  517.                                debris. 2 seems to be a reasonable value. But
  518.                                it's up to you.
  519.  
  520. debug <value>                = Prints a <value> on screen. This value will
  521.                                be printed in the ULGY standard font and duke
  522.                                will not try to save the background. I don't
  523.                                now what forms <value> can take.
  524.  
  525.  
  526.  
  527. define <string> <value>      = Defines a value as a string. This way you can
  528.                                use the string instead of the number (easier to
  529.                                remember). The Duke3D compiler will replace every
  530.                                occurance of <string> with <value>
  531.  
  532. definequote <value> <string> = Binds a string to a number. The string can now
  533.                                be displayed by using the 'quote' primitive.
  534.  
  535. defineskillname <value> <s>  = Defines the string 's' associated with the
  536.                                difficulty level 'value'. 0 is easy and 3
  537.                                is hard.
  538.                                [PP]
  539.  
  540. definelevelname <ep> <lev>
  541.                 <mapname>
  542.                 <par time>
  543.                 <3drealms>   = Defines a level where the episode number is
  544.                                'ep' the level number if 'lev' the mapname
  545.                                is 'mapname' the partime is 'par time' and
  546.                                3drealms' time is '3drealms'.
  547.  
  548. definesound <value> <filename>
  549.             <begin pitch>
  550.             <end pitch>
  551.             <priority>
  552.             <flags> <volume> = Binds the sound file 'filename' to 'value' and
  553.                                tells the game the sound may be pitched from
  554.                                'begin pitch' to 'end pitch'. The sound priority
  555.                                is 'priority' and the type of sound is defined
  556.                                in 'flags'. Volume is the volume adjustment.
  557.  
  558. definevolumename <ep> <name> = Defines title for each episode. 'ep' is the
  559.                                episode number and 'name' is the name it will
  560.                                get.
  561.                                [PP]
  562.  
  563. enda                         = End of actor code marker.
  564.  
  565. endofgame <number>           = Ends the game. I'm not sure what <number> means
  566.                                but 52 is used to end level 3 (BOSS2).
  567.  
  568. ends                         = End of state code marker.
  569.  
  570. fall                         = Let the current actor fall until it hits a
  571.                                surface.
  572.  
  573. gamestartup ...              = This is the main function which 'starts' the
  574.                                game. It gets all the hardcoded values passed
  575.                                as parameters. The values it gets passed can not
  576.                                be changed during gameplay.
  577.  
  578. getlastpal                   = Sets the palette of the current actor back
  579.                                to the color before the last change.
  580.  
  581. guts <actiongrp> <amount>    = Same as debris but then for bodyparts. Legal
  582.                                values for <actiongrp> seem to be:
  583.                                - JIBS(1 to 5)
  584.                                - HEADJIB/LEGJIB/ARMJIB  (trooper parts)
  585.                                - LIZMANARM1/LIZMANLEG1  (lizman parts)
  586.                                - DUKETORSO/DUKELEG/DUKEGUN (duke parts)
  587.                                <amount> determines the amount of guts to fly.
  588.  
  589. globalsound                  = Play sound that can be heard everywhere in the
  590.                                map.
  591.  
  592. hitradius <c> <1> <2> <3> <4>= Make an explosion (not the actual animation but
  593.                                just the damage). <c> is the radius. <4> is how
  594.                                much damage is done in first quarter of circle
  595.                                seen from inside to outside.
  596.                                <3> is how much damage is done in second quarter
  597.                                of circle etc.
  598.  
  599. ifactornotstayput            = (not sure) Test if the current actor already
  600.                                'activated', where 'activated' means spotted
  601.                                by a player or he has spotted the player.
  602.                                It seems that an actors code isn't executed
  603.                                at all until one of the above events occur.
  604.                                You can notice this in the game. If you
  605.                                create a map where an actor (ie. health) is
  606.                                lifted into the sky, he doens't fall down to
  607.                                the ground until you spot it!
  608.  
  609. ifactor <actorid>            = Checks if current actor was called with cactor
  610.                                by <actorid>
  611.  
  612. ifaction <actionnum>         = Test if the current actor is executing the
  613.                                giving <actionnum>. <actionnum> is defined
  614.                                by the action primitive, remember?
  615.  
  616. ifactioncount <number>       = Tests if the actors has display <number> frames
  617.                                since the last call to resetactioncount
  618.  
  619. ifai <ainame>                = Tests if the current actor is using the ai
  620.                                function <ainame> which was defined with the
  621.                                'ai' primitive.
  622.  
  623. ifangdiffl <angle>           = If the angle between the current actor and duke
  624.                                is less than <angle> it returns true. 360 degrees
  625.                                is 2048.
  626.  
  627. ifangdiffg <angle>           = If the angle between the current actor and duke
  628.                                is less than <angle> it returns false. 360 degrees
  629.                                is 2048.
  630.  
  631. ifawayfromwall               = Returns false when actor is on a wall-line.
  632.                                This would be a line that can be seen in
  633.                                BUILD.EXE. I don't know the actual use for
  634.                                this.
  635.  
  636. ifbulletnear                 = Tests if a bullet is near the current actor.
  637.                                This is a nice one because you can use it like
  638.                                this:
  639.                                ifbulletnear
  640.                                  ai AIRUNAWAYFROMBULLET
  641.                                Okay, maybe you don't understand this yet, but
  642.                                I'll explain it later. For now, let's say this
  643.                                code means:
  644.                                If there is a bullet nearby then go into another
  645.                                ai function that makes the actor runaway with high
  646.                                speed (fleeenemy aifunction).
  647.  
  648.  
  649. ifcansee                     = Tests if the current actor can see duke. It
  650.                                also seems to have another function.
  651.                                It seems as if you need to call this function
  652.                                to give an actor a new position to walk to when
  653.                                using the seekenemy and some other ai functions.
  654.                                If you don't call this when using that ai function
  655.                                he will just walk up to your previous position
  656.                                and just stop there!
  657.  
  658. ifcanseetarget               = Tests if the current actor can see duke. I'm not
  659.                                about this one though.
  660.  
  661. ifcanshoottarget             = Tests if the current actor can shoot his
  662.                                target. I don't know what 'can shoot' means.
  663.  
  664. ifceilingdistg <num>         = Tests if the distance to the ceiling is greater
  665.                                than <num>
  666.  
  667. ifceilingdistl <num>         = Tests if the distance to the ceiling is less
  668.                                than <num>
  669.  
  670.  
  671. ifcount <num>                = Tests if the number of frame (I don't actually
  672.                                know how long a frame takes) is reached. These
  673.                                are not action frames so they are not limited
  674.                                to one actor. See it as some sort of global
  675.                                counter.
  676.  
  677.  
  678. ifdead                       = Checks if actor has no health left. Good thing
  679.                                to call after he has been hit with a weapon. If
  680.                                he was and he's dead you need to remove the actor
  681.                                from the map (killit).
  682.  
  683. iffloordistg <num>           = Same as 'ifceilingdistg' but now for the floor.
  684.  
  685. iffloordistl <num>           = Same as 'ifceilingdistl' but now for the floor.
  686.  
  687. ifgotweaponce <num>          = Seems to test if a player has a particular weapon.
  688.                                The weapon tested would be the current actor.
  689.                                This code would logicaly only appear in weapon
  690.                                actors such as RPGSPRITE.
  691.                                I'm not sure what the <num>'s use is. The values
  692.                                passed in the real CONs where 0 and 1. (?)
  693.  
  694. ifhitspace                   = Checks if duke is hitting the spacebar.
  695.  
  696. ifhitweapon                  = Tests if the current actor has been hit by a
  697.                                weapon. Use 'ifwasweapon' to check which weapon
  698.                                it was.
  699.  
  700. ifgapzl <num>                = Tests if the distance between the floor and
  701.                                the ceiling at the actor's location is less than
  702.                                <num>.
  703.  
  704. ifinspace                    = Checks if current player is in space. 'space'
  705.                                means when the floor/ceiling is parralaxed and
  706.                                the texture is one of the space-textures.
  707.  
  708. ifinwater                    = Tests if the current actor is in the water.
  709.  
  710. ifinouterspace               = Tests if the current actor is in outer space?
  711.  
  712. ifonwater                    = Same as 'ininwater', but then for 'on' the water.
  713.  
  714. ifmove <name>                = Tests if variable <name> is greater than 0. (not sure)
  715.  
  716. ifnosounds                   = Tests if a sound is playing.
  717.  
  718. ifnotmoving                  = Tests if the current actor is moving. Not sure
  719.                                about this one.
  720.  
  721. ifspawnedby <actor>          = Checks if the actor who spawned the current
  722.                                actor is equal to <actor>
  723.  
  724.  
  725. ifspritepal <num>            = Tests if the palette of the current actor is
  726.                                equal to <num>
  727.  
  728. ifsquished                   = Tests if the current actor has been squished.
  729.  
  730. ifoutside                    = Tests if player is outside. A player is outside
  731.                                when he is in a room with parralaxing on!
  732.  
  733. ifp  <type>                  = Tests if the player (when I say player I always
  734.                                mean Duke, but you knew that, right?) is doing
  735.                                <type> where type can be:
  736.  
  737.                                pstanding    = Duke is standing
  738.                                pwalking     = Duke is walking
  739.                                prunning     = Duke is running
  740.                                pducking     = Duke is ducking
  741.                                pfalling     = Duke is falling
  742.                                pjumping     = Duke is jumping
  743.                                phigher      = Duke is higher than the cur. actor?
  744.                                pwalkingback = Duke is walking backwards
  745.                                prunningback = Duke is running backwards
  746.                                pkicking     = Duke is kicking (ass)
  747.                                pshrunk      = Duke is a smurf (shrunken)
  748.                                pjetpack     = Duke is flying (jetpack)
  749.                                ponsteroids  = Duke is using his steroids
  750.                                ponground    = Duke has his both feet on the ground
  751.                                palive       = Duke hasn't died yet
  752.                                pdead        = Duke has been exterminated
  753.                                pfacing      = Duke is facing the current actor
  754.  
  755.                                You can test for more things at the same time.
  756.                                'ifp prunning pwalking' returns true when either
  757.                                of the two is true.
  758.  
  759. ifpdistl <number>            = Tests if the players (nearest player) distance
  760.                                if less than <number>. 1024 appears to
  761.                                be the largest grid in BUILD.
  762.  
  763. ifpdistg <number>            = Same as ifpdistl but he now tests if the
  764.                                distance is greater.
  765.  
  766. ifphealthl <num>             = Tests if the players health is less than
  767.                                <number>.
  768.  
  769. ifphealthg <num>             = Tests if the players health is greater than
  770.                                <number>.
  771.  
  772. ifpinventory <item> <amount> = Tests if the nearest player has less than
  773.                                <amount> left of item <item> where item can
  774.                                be:
  775.                                - GET_STEROIDS
  776.                                - GET_HEATS
  777.                                - GET_BOOTS
  778.                                - GET_SHIELD
  779.                                - GET_SCUBA
  780.                                - GET_HOLODUKE
  781.                                - GET_JETPACK
  782.                                - GET_FIRSTAID
  783.                                - GET_ACCESS (when using this the amount seems
  784.                                              to be a bitlist of cards we have
  785.                                              0 = no cards 1 = blue card etc...)
  786.  
  787.  
  788. ifrespawn                    = Tests if the monster-respawn-mode is on. If
  789.                                so, the actor needs to respawn after RESPAWN
  790.                                TIME.
  791.  
  792. ifrnd <num>                  = This is a randomize function. <num> is the
  793.                                chance you give it to be true. If <num> is
  794.                                256 it wil be always true and 128 50% of the
  795.                                times. If you want less chance than 1/256 you
  796.                                need to use two ifrnd's like this:
  797.                                ifrnd 1
  798.                                  ifrnd 128
  799.                                     // This code gets executed 1/512.
  800.  
  801. ifsquished                   = Tests if the current actor has been squished
  802.                                (shrunken and stepped on).
  803.  
  804. ifstrength <num>             = Tests if current actor has <num> strength left.
  805.  
  806. ifwasweapon                  = Tests what weapon the actor has been hit by.
  807.  
  808. include <filename>           = Includes <filename> in the compiling process.
  809.  
  810. killit                       = Removes the current actor from the map. The
  811.                                won't be called anymore.
  812.  
  813. lotsofglass <amount>         = Animate glass that breaks as if a window
  814.                                has broken. <amount> determines the ehhh...
  815.                                amount of glass. 30 seems to be a reasonable
  816.                                value.
  817.  
  818. mail                         = Spawn some mail?
  819.  
  820. mikesnd                      = Plays the microphone sound...
  821.  
  822. money <num>                  = Spawns <num> dollar bills.
  823.  
  824. move <name> <v1> <v2>        = Give <name> a value of <v1> and a optional
  825.                                value of <v2>. When the variable is used to
  826.                                define the speed of an actor the second
  827.                                variable is used for vertical speed. This
  828.                                way you can simulate a character to use a
  829.                                jetpack. I've also seen <v1> and <v2> to
  830.                                be given ai function. What the meaning of
  831.                                that is I'm not entirely sure. If you change
  832.                                the velocity of an actor during it's code
  833.                                it will automaticly update.
  834.  
  835. music <ep> <m1> <m2> ...     = Defines MIDI music for each episode where
  836.                                'ep' is the episode number and m1, m2 etc.
  837.                                are the individual music files for each
  838.                                level.
  839.  
  840. nullop                       = nullop equals '{ }'. Now you can say:
  841.                                ifspritepal 1 nullop else { quote 1 }
  842.                                instead of ifspritepal 1 { } else { quote 1 }
  843.  
  844. operate                      = Let's the current actor operate. If a door
  845.                                is nearby the door will open. This is a nice
  846.                                function for a clever actor. This actor could
  847.                                open a door where you fled through. You would
  848.                                have something like this in your main code:
  849.                                ifrnd 1 operate
  850.                                You _don't_ want to operate every time because
  851.                                the second time you operate the door closes
  852.                                again.
  853.  
  854. palfrom <begin> <end> <del>  = Change palette to color <begin> and then to
  855.                                <end> and then back to normal again (I think?).
  856.                                0 or 32 = Green
  857.                                16      = Red
  858.  
  859. paper                        = Spawn some paper?
  860.  
  861. pstomp                       = Player will look down and step on the near
  862.                                actor (if one is near)
  863.  
  864. pkick                        = Player will kick. Good to call from an actor
  865.                                who has been frozen. First do:
  866.                                'ifp pfacing' then 'ifpdistl FROZENQUICKKICKDIST'
  867.                                then 'pkick'.
  868.  
  869. quote <num>                  = Print quote <num> on screen. All quotes are
  870.                                defined in USER.CON.
  871.  
  872. resetactioncount             = This resets the counter that counts how many
  873.                                frames of the current actor have been exectuted.
  874.                                The speed of actioncount is determined by the
  875.                                <delay> parameter in the action structure.
  876.  
  877. resetcount                   = This resets the global count. This is the counter
  878.                                that is not bound to a given actor but count at
  879.                                the same rate for every actor
  880.                                I believe the counter increments every 3/100th
  881.                                of a second.
  882.  
  883. resetplayer                  = Resets the player in a multiplayer game and
  884.                                places him at one of the APLAYER locations.
  885.  
  886. respawnhitag                 = This code seems to spawn the actors that need
  887.                                to be spawned when the current actor dies. An
  888.                                example of this would be the dancing girls in
  889.                                the bar in E1L2.
  890.  
  891. shoot <weapon>               = Let's the current actor shoot with <weapon>.
  892.                                Legal values for weapons are defined in USER.CON.
  893.                                The direction in which the actor shoots is de-
  894.                                termined by the AI function of the actor. If it
  895.                                is 'faceplayer' he will obviously shoot at the
  896.                                player. But if you have 'seekplayer' as AI function
  897.                                the actor may be heading to the player but since
  898.                                he doesn't go straight to him he can easily miss.
  899.                                Some of the weapons are (these names are also used
  900.                                for ifwasweapon):
  901.                                SHRINKSPARK,
  902.                                SHOTGUN,
  903.                                RPG,
  904.                                CHAINGUN,
  905.                                FREEZEBLAST,
  906.                                KNEE,
  907.                                SPIT,
  908.                                FIRELASTER,
  909.                                HEAVYHBOMB,
  910.                                BOUNCEMINE,
  911.                                MORTER,
  912.                                DEVISTATORBLAST and
  913.                                TRIPBOMB.
  914.  
  915. sizeat <x> <y>               = Makes the current actor <x> times smaller in
  916.                                x-direction and <y> times smaller in y-direction.
  917.                                The difference between sizeat and sizeto is that
  918.                                sizeat makes the change immediatly while sizeto
  919.                                resizes the actor graduatly.
  920.  
  921. sizeto <x> <y>               = Makes the current actor <x> times smaller in
  922.                                x-direction and <y> times smaller in y-direction.
  923.  
  924. sleeptime <time>             = Makes the current actor sleep for <time> counts?
  925.  
  926. sound <soundnum>             = Play a sound. The soundnumbers are defined in
  927.                                USER.CON.
  928.  
  929. soundonce <soundnum>         = I think when using this sound, it will not
  930.                                be activated again until it is finished.
  931.  
  932. spawn <actor>                = Bring a new actor into the map defined by
  933.                                <actor> There seems to be once special
  934.                                <actor> (there may be more) which has a
  935.                                unique effect on the current actor. When
  936.                                you spawn 'FRAMEEFFECT1' the current actor
  937.                                while blur. This effect can be seen when
  938.                                an actor is shrinking or a player is on
  939.                                steroids.
  940.  
  941. spritepal <num>              = Changes palette number of sprite. Legal values
  942.                                are:
  943.                                1  = Blue
  944.                                4  = Dark
  945.                                6  = Night vision Green
  946.                                7  = Yellow (sort of)
  947.                                8  = Green
  948.                                10 = Red
  949.                                19 = Red as a tomato
  950.                                22 = Almost normal
  951.  
  952. state <statename>            = Enter a state named <statename> and return
  953.                                from it. If this line is put out of any
  954.                                actor or state code it is interpreted as
  955.                                a state definition.
  956.  
  957. stopsound <sound>            = Stops to play the sound 'sound'. Good for ending
  958.                                long sound effects when they have no use anymore.
  959.  
  960. strength <num>               = This function changes the strength of the current
  961.                                actor in <num>
  962.  
  963. tossweapon                   = Let's duke spawn his currently selected weapon
  964.                                with a 50% chance. This code gets called when
  965.                                Duke dies.
  966.  
  967. wackplayer                   = Tilt the screen. As if you're struck by lightning.
  968.  
  969.  
  970. --------------------------------------------------------------------------
  971.   2.8   Predefined states
  972. --------------------------------------------------------------------------
  973.  
  974. Here's a list of states that are already defined in GAME.CON. You can
  975. ofcourse alter these but here's a list of some of them (call these
  976. state like this: 'state <name>') :
  977.  
  978. - genericshrunkcode
  979.   Shrink actor and stomp if within correct distance
  980.  
  981. - blimbhitstate
  982.   Make explosion. Spawn debris, kill actor and some other stuff...
  983.  
  984. - rats
  985.   Generate some rats.
  986.  
  987. - headhitstate
  988.   Gets called when player is being hurt bad.
  989.  
  990. - burningstate
  991.   Lites the current actor on fire.
  992.  
  993. - steamcode
  994.   Update steam sprite (subtract health from player who is near etc.)
  995.  
  996. - burningbarrelcode
  997.   Code for a burning barral (duh!)
  998.  
  999. - get_code
  1000.   Gets an item and prepares it for respawn if neccesary.
  1001.  
  1002. - randgetweapsnds
  1003.   Plays a random sound when called such as 'Groovy' or 'Come get some' etc.
  1004.  
  1005. - getweaponcode
  1006.   Gets the current weapon and prepares it for respawn if neccesary.
  1007.  
  1008. - respawnit
  1009.   Respawns the item in multiplayer game.
  1010.  
  1011. - firestate
  1012.   Updates flames and checks if duke is burning himself etc.
  1013.  
  1014. - jib_sounds
  1015.   Plays one of those nice sound like 'What a mess' or 'Let god sort them out'.
  1016.  
  1017. - standard_jibs
  1018.   Spawns some random bodyparts.
  1019.  
  1020. - femcode
  1021.   Takes care of the females in duke. Kill them or let them show their boobs.
  1022.  
  1023. - killme
  1024.   Lets woman say "kiiillll meeee...." when duke hits space near her.
  1025.  
  1026. - tipme
  1027.   Lets duke give woman a dollar bill and say 'Wanna dance' or 'Shake it baby'.
  1028.  
  1029. - troop_body_jibs
  1030.   Spawns some trooper body parts.
  1031.  
  1032. - liz_body_jibs
  1033.   Spawns some lizard body parts.
  1034.  
  1035. - delete_enemy
  1036.   Deletes the current actor (removes it from the map).
  1037.  
  1038. - standard_pjibs
  1039.   Spawns some duke body parts.
  1040.  
  1041. Ok, that's it for now.
  1042.  
  1043. --------------------------------------------------------------------------
  1044.   2.9   Known .CON bugs
  1045. --------------------------------------------------------------------------
  1046.  
  1047. I added this section since I discovered a bug. I'll bet there will be
  1048. more.
  1049.  
  1050. bug 1:
  1051.  
  1052. This 'if' construction...
  1053.  
  1054. ifcansee
  1055.   ifai AIDUKEWANTTOSTOMP
  1056.     {
  1057.     }
  1058.     else
  1059.     ai AIDUKEWANTTOSTOMP
  1060.  
  1061. ...should be equal to...
  1062.  
  1063. ifcansee
  1064.   {
  1065.   ifai AIDUKEWANTTOSTOMP
  1066.     {
  1067.     }
  1068.     else
  1069.     ai AIDUKEWANTTOSTOMP
  1070.   }
  1071.  
  1072. ... but it isn't. In the first case the 'else' part always gets
  1073. executed. _Huge_ bug.
  1074.  
  1075. I don't know if it's a bug or not but it sure is strange. When you give a
  1076. character like a pigcop a huge amount of strength like 4500 then he will
  1077. move like thunder when you hit him with a RPG.
  1078.  
  1079. --------------------------------------------------------------------------
  1080.   3.1   Example 2: Make the atomic health sprite pulsating
  1081. --------------------------------------------------------------------------
  1082.  
  1083. Okay, we're gonna make the atomice health sprite pulsate between
  1084. visibility and invisibility graduatly. Ought to look pretty cool!
  1085.  
  1086. (under construction... sorry)
  1087.  
  1088. --------------------------------------------------------------------------
  1089.   3.2   Example 2: Make your own Duke Bot
  1090. --------------------------------------------------------------------------
  1091.  
  1092. The example in the last couple of versions of this FAQ was getting a
  1093. little complex for some of you guys. It even had some huge bugs in
  1094. it. But here's a new example and I'm keeping it as clear as possible.
  1095. We're gonna try to create a new Duke character. This character will
  1096. eventually do the following:
  1097.  
  1098.  - when at a distance he will either fire some rockets or
  1099.    run up to you
  1100.  
  1101.  - when near he will shoot a shrinker ray at you
  1102.  
  1103.  - when you're shrunken he'll stomp you
  1104.  
  1105.  - when you shrink him he will shrink
  1106.    when you freeze him he will freeze
  1107.    when you kill him he will die
  1108.  
  1109.  - when he's hit he'll yell or shoot an RPG :-)
  1110.  
  1111.  - when you shoot at him he will flee
  1112.  
  1113. Ok, but how would we go about this. First we need to replace a character
  1114. with our new character. I think our PIGCOP will do fine.
  1115. Now remove all the PigCop code. These are the lines
  1116. 'action APIGWALK ...' to the line just before 'action ABOSS1WALK ...'.
  1117. I also recommend creating a one roomed sector with just one pigcop
  1118. in it so you can check the code out easy.
  1119. Whenever you see this: '*CHECK*' you can check the code out in your map.
  1120.  
  1121. First we're gonna define the basics of our character. We need to set up
  1122. an action group of Duke standing:
  1123.  
  1124. action DUKESTAND     -595  1 5 1 1
  1125.  
  1126. Since the PIGCOP standing sprite is tile number 2030 and the Duke standing
  1127. sprite is 1405. We need to use -595 since all the sprites must be relative
  1128. to 2000 (PIGCOP).
  1129.  
  1130. And we need the main actor code ofcourse:
  1131.  
  1132. define DUKESTRENGTH 200
  1133.  
  1134. actor PIGCOP DUKESTRENGTH DUKESTAND faceplayer
  1135. // Drop the character until it hits a surface.
  1136. fall
  1137.  
  1138. enda
  1139.  
  1140. *CHECK*
  1141.  
  1142. Now we want him to go look for us so we'll have to define a sprite group
  1143. (action) of duke running.
  1144.  
  1145. action DUKERUN -575 4 5 1 10
  1146.  
  1147. and a speed at which he runs:
  1148.  
  1149. move DUKERUNSPEED 240
  1150.  
  1151. And NOW we need to define ourselfs an AI function of a duke how is looking
  1152. for us:
  1153.  
  1154. ai AIDUKESEEKPLAYER DUKERUN DUKERUNSPEED seekplayer
  1155.  
  1156. Now we need to add the following code to the actor code (right after 'fall')
  1157.  
  1158. // Are we still standing?
  1159. ifaction DUKESTAND
  1160.   // Yep, so now start looking for player
  1161.   ai AIDUKESEEKPLAYER
  1162.  
  1163. *CHECK*
  1164.  
  1165. Now duke runs, but strangly enough not to you. That's because we need to
  1166. call the ifcansee { } function? to update dukes vision. You can place the
  1167. ifcansee { } right after the fall line in the actor code and then check
  1168. again. Remove this code afterwards however since we don't need it to be
  1169. _there_. Now we're gonna create a state (put this, like actions, ai's and
  1170. move's outside the actor code)...
  1171.  
  1172. state dukeseekplayer
  1173. ends
  1174.  
  1175. ... with no code in it yet. This state needs to be called whenever we are
  1176. in the seeking ai. So put this in the actor code _after_ the 'ai AIDUKE
  1177. SEEKPLAYER' line:
  1178.  
  1179. ifai AIDUKESEEKPLAYER
  1180.    state dukeseekplayer
  1181.  
  1182. So now if we are in the seekplayer ai the dukeseekplayer will be called!
  1183.  
  1184. Now we're gonna add the following: if dukes near the player he'll start
  1185. to fire shrinker rays. Put this code into the dukeseekplayer state:
  1186.  
  1187. // Can we see the player
  1188. ifcansee
  1189.   {
  1190.   // Is player near?
  1191.   ifpdistl 5000
  1192.     // Can we shoot the target?
  1193.     ifcanshoottarget
  1194.        // Go into shooting ai
  1195.          ai AIDUKESHOOTFROMCLOSE
  1196.   }
  1197.  
  1198. So you'll see we'll have to define a new AI function AIDUKESHOOTFROMCLOSE.
  1199.  
  1200. ai AIDUKESHOOTFROMCLOSE DUKERUN DUKERUNSPEED faceplayer
  1201.  
  1202. And we'll need to add this part to the actor code after the 'state dukeseek...'
  1203. line:
  1204.  
  1205. ifai AIDUKESHOOTFROMCLOSE
  1206.    state dukeseekplayer
  1207.  
  1208.  
  1209. So you see that we use the same state when he shooting. Obviously we need
  1210. something in the dukeseekplayer state to identify wether duke is seeking
  1211. or shooting. Add this before the 'ifcansee' line in the duke seekplayer
  1212. state:
  1213.  
  1214. // Are we shooting?
  1215. ifai AIDUKESHOOTFROMCLOSE
  1216.   {
  1217.   // Can we see him?
  1218.   ifcansee
  1219.     {
  1220.     // Is he still close?
  1221.     ifpdistl 6000
  1222.       {
  1223.       // Can we shoot our target?
  1224.       ifcanshoottarget
  1225.         // Only shoot every 10 counts
  1226.         ifcount 10
  1227.           {
  1228.           resetcount
  1229.           shoot SHRINKER
  1230.           sound SHRINKER_FIRE
  1231.           }
  1232.       }
  1233.       else
  1234.       // No we are not close anymore so seek him.
  1235.       ai AIDUKESEEKPLAYER
  1236.     }
  1237.     else
  1238.     // We can't see him anymore so seek him.
  1239.     ai AIDUKESEEKPLAYER
  1240.   // We don't want to rest of the state to be executed so
  1241.   // directly return
  1242.   break
  1243.   }
  1244.  
  1245. *CHECK*
  1246.  
  1247. Wooow. We got ourselfs a mad duke running after us shooting shrinker
  1248. rays. Isn't that great. But hey, when we're shrunken he keeps shooting
  1249. at us? Ok, lets fix that. We want duke to go into another ai function
  1250. when he has shrunken us.
  1251.  
  1252. ai AIDUKEWANTTOSTOMP DUKERUN DUKERUNSPEED seekplayer
  1253.  
  1254. Now add this code to the main actor code right before the 'ifai
  1255. AIDUKESEEKPLAYER' line:
  1256.  
  1257. ifp pshrunk
  1258.   {
  1259.   // Are we already wanting to stomp?
  1260.   ifai AIDUKEWANTTOSTOMP
  1261.     {
  1262.     }
  1263.     else
  1264.     // No so do it.
  1265.     ai AIDUKEWANTTOSTOMP
  1266.   }
  1267.  
  1268. and add the following after the 'ifai AIDUKESHOOTFROMCLOSE state
  1269. dukeseekplayer' line:
  1270.  
  1271.  
  1272. ifai AIDUKEWANTTOSTOMP
  1273.    {
  1274.    // If he's already dead we've got nothing to do.
  1275.    ifp pdead
  1276.      {
  1277.      }
  1278.      else
  1279.      state dukewanttostomp
  1280.    }
  1281.  
  1282. Now we're gonna define the state:
  1283.  
  1284. state dukewanttostomp
  1285.  
  1286. // Is he still shrunken?
  1287. ifp pshrunk
  1288.   {
  1289.   // Can we see him?
  1290.   ifcansee
  1291.     {
  1292.     // Is he near enough to stomp?
  1293.     ifpdistl SQUISHABLEDISTANCE
  1294.        {
  1295.        // Kill him by subtracting 400 health (ought to be enough)
  1296.        addphealth -400
  1297.        // A nice sound
  1298.        sound SQUISHED
  1299.        // Some flying body parts
  1300.        state standard_pjibs
  1301.        state standard_pjibs
  1302.        // Yet another nice sound
  1303.        sound DUKE_KILLED4
  1304.        }
  1305.     }
  1306.   }
  1307.   // He is not shrunken anymore
  1308.   else
  1309.   ai AIDUKESEEKPLAYER
  1310.  
  1311. ends
  1312.  
  1313. Ok, only this time, and this time only, I'll give you all we got now:
  1314.  
  1315. // --------------
  1316.  
  1317. define DUKESTRENGTH 200
  1318.  
  1319. action DUKESTAND     -595 1 5 1 1
  1320. action DUKERUN       -575 4 5 1 10
  1321.  
  1322. move DUKERUNSPEED 240
  1323.  
  1324. ai AIDUKESEEKPLAYER DUKERUN DUKERUNSPEED seekplayer
  1325. ai AIDUKESHOOTFROMCLOSE DUKERUN DUKERUNSPEED faceplayer
  1326. ai AIDUKEWANTTOSTOMP DUKERUN DUKERUNSPEED seekplayer
  1327.  
  1328.  
  1329. state dukeseekplayer
  1330.  
  1331. ifai AIDUKESHOOTFROMCLOSE
  1332.   {
  1333.   ifcansee
  1334.     {
  1335.     ifpdistl 6000
  1336.       {
  1337.       ifcanshoottarget
  1338.         ifcount 10
  1339.           {
  1340.           resetcount
  1341.           shoot SHRINKER
  1342.           sound SHRINKER_FIRE
  1343.           }
  1344.       }
  1345.       else
  1346.       ai AIDUKESEEKPLAYER
  1347.     }
  1348.     else
  1349.     ai AIDUKESEEKPLAYER
  1350.   break
  1351.   }
  1352.  
  1353. ifcansee
  1354.   {
  1355.   ifpdistl 5000
  1356.     ifcanshoottarget
  1357.        ai AIDUKESHOOTFROMCLOSE
  1358.   }
  1359.  
  1360.  
  1361. ends
  1362.  
  1363. state dukewanttostomp
  1364.  
  1365. ifp pshrunk
  1366.   {
  1367.   ifcansee
  1368.     {
  1369.     ifpdistl SQUISHABLEDISTANCE
  1370.        {
  1371.        addphealth -400
  1372.        sound SQUISHED
  1373.        state standard_pjibs
  1374.        state standard_pjibs
  1375.        sound DUKE_KILLED4
  1376.        }
  1377.     }
  1378.   }
  1379.   else
  1380.   ai AIDUKESEEKPLAYER
  1381.  
  1382. ends
  1383.  
  1384. actor PIGCOP MAXPLAYERHEALTH DUKESTAND faceplayer
  1385. fall
  1386.  
  1387. ifaction DUKESTAND
  1388.   ai AIDUKESEEKPLAYER
  1389.  
  1390. ifp pshrunk
  1391.   {
  1392.   ifai AIDUKEWANTTOSTOMP
  1393.     {
  1394.     }
  1395.     else
  1396.     ai AIDUKEWANTTOSTOMP
  1397.   }
  1398.  
  1399. ifai AIDUKESEEKPLAYER
  1400.    state dukeseekplayer
  1401.  
  1402. ifai AIDUKESHOOTFROMCLOSE
  1403.    state dukeseekplayer
  1404.  
  1405.  
  1406. ifai AIDUKEWANTTOSTOMP
  1407.    {
  1408.    ifp pdead
  1409.      {
  1410.      }
  1411.      else
  1412.      state dukewanttostomp
  1413.    }
  1414.  
  1415.  
  1416. enda
  1417.  
  1418. // --------------
  1419.  
  1420. *CHECK*
  1421.  
  1422. Well, he shoots and he kills. That's my kind of duke. Now, we're gonna
  1423. add the part were he shoots rockets from a distance. Yeah!
  1424.  
  1425. Ok, this code needs to be put in the dukeseekplayer state. In this state
  1426. we test if the distance is near (ifpdistl 5000). If it's true (he IS near)
  1427. then - if we can shoot the target - we go into the AIDUKESHOOTCLOSE ai
  1428. function. What we need to do is add an else like this:
  1429.  
  1430. The code was:
  1431.  
  1432. ifcansee
  1433.   {
  1434.   ifpdistl 5000
  1435.     ifcanshoottarget
  1436.        ai AIDUKESHOOTFROMCLOSE
  1437.   }
  1438.  
  1439.  
  1440. the code gets to be:
  1441.  
  1442. ifcansee
  1443.   {
  1444.   ifpdistl 5000
  1445.     {
  1446.     ifcanshoottarget
  1447.        ai AIDUKESHOOTFROMCLOSE
  1448.     }
  1449.     else
  1450.     {
  1451.     // Once in a while
  1452.     ifrnd 1
  1453.       {
  1454.       // start shooting rockets
  1455.       ai AIDUKESHOOTROCKET
  1456.       break
  1457.       }
  1458.     }
  1459.  
  1460.   }
  1461.  
  1462. Yep. A new ai function:
  1463.  
  1464. move DUKESLOWSPEED 50
  1465.  
  1466. action DUKECRAWL -509 3 5 1 30
  1467.  
  1468. ai AIDUKESHOOTROCKET DUKECRAWL DUKESLOWSPEED faceplayer
  1469.  
  1470. And now add this code after the 'ifai AIDUKESHOOTFROMCLOSE
  1471. state dukeseekplayer' line:
  1472.  
  1473. ifai AIDUKESHOOTROCKET
  1474.   state dukeshootrocket
  1475.  
  1476. Now we'll define the state:
  1477.  
  1478. state dukeshootrocket
  1479.  
  1480. // Can we see duke?
  1481. ifcansee
  1482.   {
  1483.   // Is he still far away?
  1484.   ifpdistg 8000
  1485.     {
  1486.     // Can we shoot the target?
  1487.     ifcanshoottarget
  1488.       {
  1489.       // Only shoot once in the 20 counts
  1490.       ifcount 20
  1491.         {
  1492.         // Start counting all over again.
  1493.         resetcount
  1494.         shoot RPG
  1495.         sound RPG_SHOOT
  1496.         }
  1497.       }
  1498.     }
  1499.     // No he's getting closer
  1500.     else
  1501.     ai AIDUKESEEKPLAYER
  1502.  
  1503.   }
  1504.   // Can't see him anymore so go find him.
  1505.   else
  1506.   ai AIDUKESEEKPLAYER
  1507.  
  1508. ends
  1509.  
  1510. Wooow. When at a distance, if some cases he will start shooting RPG's.
  1511. What a guy! Now we're gonna teach him to dodge bullets when they're
  1512. near.
  1513.  
  1514. So yet another ai function:
  1515.  
  1516. ai AIDUKEDODGEBULLET DUKECRAWL DUKERUN fleeenemy
  1517.  
  1518. Put this is the main actor code before 'ifp pshrunk':
  1519.  
  1520. // Is a bullet nearby?
  1521. ifbulletnear
  1522.   // Yep, so evade it.
  1523.   ai AIDUKEDODGEBULLET
  1524.  
  1525. And put this also in the actor code but after 'state dukeshootrocket':
  1526.  
  1527. // If evasion ai is active
  1528. ifai AIDUKEDOGDEBULLET
  1529.   {
  1530.   // Are we done (use evasion for 5 counts, ought to be enough)
  1531.   ifcount 5
  1532.     {
  1533.     // We're done. So go back to seekplayer
  1534.     ai AIDUKESEEKPLAYER
  1535.     // Reset counter
  1536.     resetcount
  1537.     // We're done.
  1538.     break
  1539.     }
  1540.   }
  1541.  
  1542.  
  1543. Wow. He evades rockets and stuff. Groovy. Ok, now we have given him a
  1544. chance to survive so we're gonna write to stuff that gets executed when
  1545. he is hurt and/or killed. First we need to define an ai and an action
  1546. group of duke getting hurt!
  1547.  
  1548. action DUKEPAIN -489 1 1 1 10
  1549.  
  1550. // DUKESTOPPED = 0
  1551. move DUKESTOPPED
  1552.  
  1553. ai AIDUKEBEINGHURT DUKEPAIN DUKESTOPPED faceplayer
  1554.  
  1555. Now add this code to the main actor code right before the 'ifbulletnear'
  1556. code:
  1557.  
  1558. ifai AIDUKEBEINGHURT
  1559.   {
  1560.   state dukebeinghurt
  1561.   break
  1562.   }
  1563.  
  1564. ifhitweapon
  1565.   {
  1566.   ai AIDUKEBEINGHURT
  1567.   break
  1568.   }
  1569.  
  1570. Now here's the dukebeinghurt state:
  1571.  
  1572. state dukebeinghurt
  1573.  
  1574. ifdead
  1575.   {
  1576.   // Play nice sound
  1577.   sound SQUISHED
  1578.   // Play a death sound
  1579.   ifrnd 128
  1580.     sound DUKE_KILLED4
  1581.     else
  1582.     sound DUKE_DEAD
  1583.  
  1584.   // Some body parts
  1585.   state standard_pjibs
  1586.   state standard_pjibs
  1587.  
  1588.   killit
  1589.   }
  1590.   else
  1591.   {
  1592.   // No he wasn't dead yet so play a randomly chosen
  1593.   // hurt sound.
  1594.   ifrnd 64
  1595.     sound DUKE_LONGTERM_PAIN2
  1596.     else
  1597.     ifrnd 64
  1598.       sound DUKE_LONGTERM_PAIN3
  1599.       else
  1600.       ifrnd 64
  1601.         sound DUKE_LONGTERM_PAIN4
  1602.         else
  1603.         ifrnd 64
  1604.           sound DUKE_LONGTERM_PAIN5
  1605.  
  1606.   }
  1607.  
  1608. // After two frames go back to seeking mode again.
  1609. ifactioncount 2
  1610.   ai AIDUKESEEKPLAYER
  1611.  
  1612. ends
  1613.  
  1614.  
  1615. Ok, if duke gets shot with a gun he also explodes. So what? The dying
  1616. animation doesn't work because this is _actually_ a pigcop. And pigcops
  1617. die differently. Sorry. Now you can kill him easily by just shooting
  1618. at him. I want him to - sometimes - shoot back with a RPG if he
  1619. is being hit.
  1620.  
  1621. This needs to be done in the hurt part where all the ifrnd 64's are.
  1622. The code now is:
  1623.  
  1624.   else
  1625.   {
  1626.   // No he wasn't dead yet so play a randomly chosen
  1627.   // hurt sound.
  1628.   ifrnd 64
  1629.     sound DUKE_LONGTERM_PAIN2
  1630.     else
  1631.     ifrnd 64
  1632.       sound DUKE_LONGTERM_PAIN3
  1633.       else
  1634.       ifrnd 64
  1635.         sound DUKE_LONGTERM_PAIN4
  1636.         else
  1637.         ifrnd 64
  1638.           sound DUKE_LONGTERM_PAIN5
  1639.  
  1640.   }
  1641.  
  1642. and the code gets to be:
  1643.  
  1644.   {
  1645.   // No he wasn't dead yet so play a randomly chosen
  1646.   // hurt sound.
  1647.   ifrnd 64
  1648.     sound DUKE_LONGTERM_PAIN2
  1649.     else
  1650.     ifrnd 64
  1651.       sound DUKE_LONGTERM_PAIN3
  1652.       else
  1653.       ifrnd 64
  1654.         sound DUKE_LONGTERM_PAIN4
  1655.         else
  1656.         ifrnd 64
  1657.           sound DUKE_LONGTERM_PAIN5
  1658.  
  1659.   // 25% chance he shoots when being hurt
  1660.   ifrnd 64
  1661.     {
  1662.     // Only shoot every 3 counts.
  1663.     ifcount 3
  1664.       {
  1665.       resetcount
  1666.       shoot RPG
  1667.       sound RPG_SHOOT
  1668.       }
  1669.     }
  1670.  
  1671.   }
  1672.  
  1673. Ok, now we only need two things until we're done. The possibility to shrink
  1674. him and the possibility to freeze him. You're on your own from now on...
  1675. ... so figure this out yourself. Check the code of other actors to see how
  1676. it's done. If you still have any questions you can always mail me at
  1677. antiwin@worldonline.nl
  1678.  
  1679.  
  1680. --------------------------------------------------------------------------
  1681.   4.1  DEFS.CON (overview)
  1682. --------------------------------------------------------------------------
  1683.  
  1684. DEFS.CON is the CON file in which all defines are done. This way
  1685. you can name a tile or sound by name instead of number. It is
  1686. included by GAME.CON
  1687.  
  1688. --------------------------------------------------------------------------
  1689.   4.2  USER.CON (overview)
  1690. --------------------------------------------------------------------------
  1691.  
  1692. In USER.CON all sorts of defines are done. All levels and sounds are
  1693. defined here. Also other game effects like respawning time etc. are
  1694. declared here. It is included by GAME.CON
  1695.  
  1696. --------------------------------------------------------------------------
  1697.   4.3  GAME.CON (overview)
  1698. --------------------------------------------------------------------------
  1699.  
  1700. This is the main CON file. It gets compiled first. It includes DEFS.CON
  1701. and USER.CON first. In this CON file all the actor code is located. You
  1702. could put actor code in the USER.CON but it looks better if you keep it
  1703. all in GAME.CON.
  1704.  
  1705. --------------------------------------------------------------------------
  1706.   5.1  What *I* would like to know
  1707. --------------------------------------------------------------------------
  1708.  
  1709. Here's a list of things I would like to know. So if you do, _please_
  1710. mail me.
  1711.  
  1712.  - Is there someone who would like to help me maintain this FAQ? Knowledge
  1713.    of CON hacking is required ofcourse.
  1714.  - Why is 'ifcansee' needed to let seekplayer and other ai function work
  1715.    properly?
  1716.  - Explenation of some of the ai functions.
  1717.  - What does ifnotmoving do in fact? Is this neccesary due to a bug
  1718.    in the ai functions?
  1719.  
  1720. --------------------------------------------------------------------------
  1721.   5.2  Contributers/Thank you's
  1722. --------------------------------------------------------------------------
  1723.  
  1724. I want to thank:
  1725.  
  1726.  - Reptile ( reptile@worldaccess.nl <http://www.worldaccess.nl/~reptile> )
  1727.  - Linkers ( linkers@dds.nl, <http://huizen.dds.nl/~linkers> )
  1728.  
  1729. for introducing me to Duke Nukem 3D as it is the funest game I've ever
  1730. seen (yeah, that also means more fun than Quake!).
  1731.  
  1732. --------------------------------------------------------------------------
  1733.   5.3    Update and info
  1734. --------------------------------------------------------------------------
  1735.  
  1736. An update of this FAQ will come within a week of release. I hope all of
  1737. you guys will send me lots of mail within that week, so I can make the
  1738. FAQ better. Also, I want to say, that even if it sounds that I know every-
  1739. thing, I know I don't. Please don't blame me for saying things that are
  1740. incorrect. The right thing to do is to mail me and correct me. It will be
  1741. corrected in the FAQ right away. Also there are some things, I'd like to
  1742. know more about. So if you have any info and CON hacking, don't hesitate
  1743. to mail me at antiwin@worldonline.nl
  1744.  
  1745. --------------------------------------------------------------------------
  1746.   5.4    Where to get this FAQ
  1747. --------------------------------------------------------------------------
  1748.  
  1749. I hope you can soon download this FAQ from many Duke 3D sites. An update
  1750. of this FAQ is posted _at least_ once a week in the following newsgroups:
  1751. alt.games alt.games.apogee alt.games.duke3d
  1752.  
  1753.  
  1754.