https://wiki.eduke32.com/w/api.php?action=feedcontributions&user=Rasmusthorup&feedformat=atomEDukeWiki - User contributions [en]2024-03-29T11:01:26ZUser contributionsMediaWiki 1.42.0-alphahttps://wiki.eduke32.com/w/index.php?title=Gamevar_operators&diff=10708Gamevar operators2012-04-18T20:22:19Z<p>Rasmusthorup: </p>
<hr />
<div><'''operator'''>'''var''' <gamevar> <value><br><br />
<'''operator'''>'''varvar''' <gamevar> <value><br />
<br />
Gamevar operators are commands that perform various mathematical and bitwise logical operations on [[gamevar]]s. The first argument must be a writable gamevar and is taken as the destination as well and the first operand (2-address code).<br />
<br />
For example:<br />
<br />
setvar temp 3 // assigns a value of 1 to the gamevar ''temp''. Am i reading this wrong? Rasmusthorup.<br />
<br />
addvar temp 1 // adds 1 to ''temp'', causing its value to become 2.<br />
<br />
mulvar temp 2 // multiplies ''temp'' by 2, causing its value to become 4.<br />
<br />
{| {{prettytable}}<br />
!Operator!!C/C++!!Math!!Description!!Notes!!<br />
|-<br />
|set<br />
|<code>=</code><br />
|=<br />
|assignment<br />
|-<br />
|add<br />
|<code><nowiki>+</nowiki></code><br />
|<nowiki>+</nowiki><br />
|addition<br />
|<br />
|-<br />
|sub<br />
|<code><nowiki>-</nowiki></code><br />
|<nowiki>&ndash;</nowiki><br />
|subtraction<br />
|<br />
|-<br />
|mul<br />
|<code>*</code><br />
|&times;<br />
|multiplication<br />
|<br />
|-<br />
|div<br />
|<code>/</code><br />
|&#247;<br />
|division with rounding toward 0<br />
|Ensure that <value> does not equal 0 at any time.<br />
|-<br />
|mod<br />
|<code>%</code><br />
|<br />
|[[Wikipedia:Modulo operation|modulo]], remainder<br />
|Ensure that <value> does not equal 0 at any time; '''It is undefined whether the sign of the result follows the divisor or the dividend''' (for now). <strike>sign of the result is that of left hand side operand</strike><br />
|-<br />
|and<br />
|<code>&</code><br />
| <br />
|[[Wikipedia:Bitwise operation|bitwise]] AND<br />
|The bits in the result are set only if they were set in both of the values being operated on. Ex.:<br/><br />
01001010 AND<br/><br />
11110100 is<br/><br />
01000000<br />
|-<br />
|or<br />
|<code><nowiki>|</nowiki></code><br />
| <br />
|[[Wikipedia:Bitwise operation|bitwise]] OR<br />
|The bits in the result are set only if they were set in either of the values being operated on. Ex.:<br/><br />
01001010 OR<br/><br />
11110100 is<br/><br />
11111110<br />
|-<br />
|xor<br />
|<code>^</code><br />
| <br />
|[[Wikipedia:Bitwise operation|bitwise]] XOR<br />
|The bits in the result are set if only one of the values being operated on has those bits set. Ex.:<br/><br />
01001010 XOR<br/><br />
11110100 is<br/><br />
10111110<br />
|}<br />
<br />
{{varsuffix}}<br />
<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Pitch&diff=10021Pitch2011-11-13T14:38:36Z<p>Rasmusthorup: </p>
<hr />
<div>pitch <number><br />
<br />
Sets the value of a pitch rotation (about the Y-axis) for the [[actor]]'s model. The rotation center can be offset from the model center by settings the [[mdxoff]], [[mdyoff]] and [[mdzoff]] members to non-zero values.<br />
<br />
<number> is an angle exprimed in [[Build units]]. -512 looks up while 512 looks down.<br />
<br />
See the [[model rotation]] guide for further explanation about the usage of this command. <br />
<br />
[[Category:EDuke32 specific commands]]<br />
[[Category:Sprite manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Mouseaiming&diff=9813Mouseaiming2011-06-15T01:22:49Z<p>Rasmusthorup: Created page with "A value of 0 is if mouse aim = toggle on/off. A value of 1 is if mouse aim = hold button. Remember that changing the mouse aim to hold button, it automaticly changes the use ..."</p>
<hr />
<div>A value of 0 is if mouse aim = toggle on/off. A value of 1 is if mouse aim = hold button.<br />
<br />
Remember that changing the mouse aim to hold button, it automaticly changes the use mouse aim option to no. But changing mouse aim back to toggle on/off won't change use mouse aim to yes.<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Mouseflip&diff=9812Mouseflip2011-06-15T01:18:13Z<p>Rasmusthorup: </p>
<hr />
<div>1 means mouse look invert is NOT enabled. 0 means mouse look is inverted.<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Mouseflip&diff=9811Mouseflip2011-06-15T01:17:51Z<p>Rasmusthorup: Created page with "1 means mouse look invert is NOT enabled. 0 means mouse look is inverted."</p>
<hr />
<div>1 means mouse look invert is NOT enabled. 0 means mouse look is inverted.</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Uw_framerate&diff=9794Uw framerate2011-06-07T23:04:49Z<p>Rasmusthorup: Created page with "This is not used Category:Userdef structure members"</p>
<hr />
<div>This is not used<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Walking_snd_toggle&diff=9793Walking snd toggle2011-06-07T22:54:38Z<p>Rasmusthorup: </p>
<hr />
<div>This is initialized to zero. It is a non-zero count-down timer This is used to delay making walking sounds to that they occur every 'other' frame. It randomly sets this number to 0 and 1. When the number is 1, a walking sound will start depending on the floor duke is running on. <br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogcnt&diff=9792Loogcnt2011-06-06T17:43:01Z<p>Rasmusthorup: </p>
<hr />
<div>If the player is hit by the enforcers SPIT, loogcnt is set to 24*4.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogcnt&diff=9791Loogcnt2011-06-06T17:42:42Z<p>Rasmusthorup: Created page with "If the player is hit by the enforcers SPIT, loogcnt is set to 24*4."</p>
<hr />
<div>If the player is hit by the enforcers SPIT, loogcnt is set to 24*4.</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogiex&diff=9790Loogiex2011-06-06T17:41:29Z<p>Rasmusthorup: </p>
<hr />
<div>Not accessable.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogiey&diff=9789Loogiey2011-06-06T17:41:15Z<p>Rasmusthorup: </p>
<hr />
<div>Not accessable.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogiex&diff=9788Loogiex2011-06-06T17:41:00Z<p>Rasmusthorup: </p>
<hr />
<div>Not in accessable.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Numloogs&diff=9787Numloogs2011-06-06T16:30:23Z<p>Rasmusthorup: Created page with "If the player is hit by the enforcers SPIT, numloogs is set to 3 + a random number 0-8 Category:Player structure members"</p>
<hr />
<div>If the player is hit by the enforcers SPIT, numloogs is set to 3 + a random number 0-8<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogiey&diff=9786Loogiey2011-06-06T16:28:08Z<p>Rasmusthorup: Created page with "Not in use. Category:Player structure members"</p>
<hr />
<div>Not in use.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Loogiex&diff=9785Loogiex2011-06-06T16:27:54Z<p>Rasmusthorup: Created page with "Not in use. Category:Player structure members"</p>
<hr />
<div>Not in use.<br />
<br />
[[Category:Player structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Tickrate&diff=9784Tickrate2011-06-06T16:10:08Z<p>Rasmusthorup: </p>
<hr />
<div>When set to 1, it shows the framerate in the upper right corner.<br />
<br />
When set to 0, it doesn't show framerate.<br />
<br />
You can toggle this on and off in the GAME SETUP options. It's called "SHOW FRAMERATE".<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Tickrate&diff=9783Tickrate2011-06-06T16:08:16Z<p>Rasmusthorup: Created page with "When set to 1, it shows the framerate in the upper right corner. When set to 0, it doesn't show framerate. You can toggle this on and off in the GAME SETUP options. It's cal..."</p>
<hr />
<div>When set to 1, it shows the framerate in the upper right corner.<br />
<br />
When set to 0, it doesn't show framerate.<br />
<br />
You can toggle this on and off in the GAME SETUP options. It's called "SHOW FRAMERATE".</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Auto_run&diff=9782Auto run2011-06-06T16:05:56Z<p>Rasmusthorup: </p>
<hr />
<div>When this is set to 1, auto run is enabled. <br />
<br />
When set to 0, auto run is not enabled.<br />
<br />
Auto run enabled is exacly double as fast as if auto run wasn't enabled. To toggle auto run on and off you press CAPS LOCK.<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Auto_run&diff=9781Auto run2011-06-06T15:52:13Z<p>Rasmusthorup: </p>
<hr />
<div>When this is set to 1, auto run is enabled. <br />
<br />
When set to 0, auto run is not enabled.<br />
<br />
Auto run enabled is exacly double as fast as if auto run wasn't enabled.<br />
<br />
[[Category:Userdef structure members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_EXPLODEONTIMER&diff=9767PROJECTILE EXPLODEONTIMER2011-05-15T15:26:49Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is an RPG with the [[PROJECTILE_FLAG_TIMED|FLAG_TIMED]] flag set. Then it normally wouldn't spawn sounds and more things. To prevent that, use this flag.<br />
<br />
[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_EXPLODEONTIMER&diff=9766PROJECTILE EXPLODEONTIMER2011-05-15T15:26:13Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is an RPG with the [[PROJECTILE_FLAG_TIMED]] flag set. Then it normally wouldn't spawn sounds and more things. To prevent that, use this flag.<br />
<br />
[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_EXPLODEONTIMER&diff=9765PROJECTILE EXPLODEONTIMER2011-05-15T15:25:42Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is an RPG with the FLAG_TIMED flag set. Then it normally wouldn't spawn sounds and more things. To prevent that, use this flag.<br />
<br />
[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_TIMED&diff=9764PROJECTILE TIMED2011-05-15T15:24:50Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.<br />
<br />
You have to define the projectile with [[PROJ_RANGE]]. 30 units = 1 second. Which is the ammount of time before the projectile will disappear. Keep in mind. If this flag is set, the projectile won't start the spawn option, sound options, and probably a few more options. See <br />
<br />
[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJ_RANGE&diff=9763PROJ RANGE2011-05-15T15:23:17Z<p>Rasmusthorup: </p>
<hr />
<div>When [[PROJ_WORKSLIKE]] is a [[hitscan]] type projectile ([[PROJECTILE_FLAG_KNEE]] or [[PROJECTILE_FLAG_HITSCAN]]) this number must be equal to the desired range in [[BUILD]] units. For example if the range is 1024 it will travel exactly one square in the largest grid size. <br />
<br />
If [[PROJ_WORKSLIKE]] is an rpg type ([[PROJECTILE_FLAG_RPG]]) this number is amount of time (in ticks) that a projectile travels before expiring. For example, if a projectile has a range of 60, then it will last for exactly two seconds before dying. This works together with [[PROJECTILE_FLAG_TIMED]] and [[PROJECTILE_FLAG_EXPLODEONTIMER]].<br />
<br />
<br />
<br />
[[Category:Projectile_structure_members]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_EXPLODEONTIMER&diff=9762PROJECTILE EXPLODEONTIMER2011-05-15T15:22:56Z<p>Rasmusthorup: Created page with "Category:Projectile_Workslike_flags"</p>
<hr />
<div>[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_TIMED&diff=9761PROJECTILE TIMED2011-05-15T15:22:40Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.<br />
<br />
You have to define the projectile with PROJ_RANGE. 30 units = 1 second. Which is the ammount of time before the projectile will disappear.<br />
<br />
[[Category:Projectile_Workslike_flags]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_TIMED&diff=9760PROJECTILE TIMED2011-05-15T15:22:10Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.<br />
<br />
You have to define the projectile with PROJ_RANGE. 30 units = 1 second. Which is the ammount of time before the projectile will disappear.</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_TIMED&diff=9759PROJECTILE TIMED2011-05-15T15:21:16Z<p>Rasmusthorup: </p>
<hr />
<div>If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.<br />
<br />
You have to define the projectile with</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=PROJECTILE_TIMED&diff=9758PROJECTILE TIMED2011-05-15T15:20:47Z<p>Rasmusthorup: Created page with "If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear. You have to define the projectile with"</p>
<hr />
<div>If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.<br />
You have to define the projectile with</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Talk:Gamevar_operators&diff=9756Talk:Gamevar operators2011-05-09T16:21:46Z<p>Rasmusthorup: </p>
<hr />
<div>[[User:Rasmusthorup]] has given this page a lot of flak, but I don't understand how splitting it back up into tiny individual articles like a swarm of bees can be any better than this concise, clear reference. For example, take a look at the last revision of [[setvar]] before I redirected it here: [http://wiki.eduke32.com/w/index.php?title=Setvar&oldid=8154]. It says nothing that could not be inferred from the command's name itself, "'''set'''var", and the word "assignment", both of which are in my table. -[[User:Hendricks 266|Hendricks266]] 17:02, 8 May 2011 (PDT)<br />
<br />
<br />
I am trying to make the site more simple to look through for new guys. I find your list confusing, and that is being said by a guy who knows most of the stuff on the wiki already. I understand why new guys get confused. I want things to be less confusing and easier go trough. If you want to, i can ask you before i edit the pages that you have been editing before. I find the operators page a bad idea.</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9751Scripting2011-05-08T07:22:37Z<p>Rasmusthorup: The gamevar operators list is stupid, it needs to be changed. I don't know how to do it lol. I think it would be perfect if we could make links that directs the viewer to the site, like set so you can actually read what it does.</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[:Category:Screen drawing commands|screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9750Scripting2011-05-08T07:20:07Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
[[Setvar]]<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[:Category:Screen drawing commands|screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9749Scripting2011-05-08T07:19:43Z<p>Rasmusthorup: </p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
[[setvar]]<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[:Category:Screen drawing commands|screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Gamevar_operators&diff=9748Gamevar operators2011-05-08T07:19:16Z<p>Rasmusthorup: </p>
<hr />
<div><'''operator'''>'''var''' <gamevar> <value><br><br />
<'''operator'''>'''varvar''' <gamevar> <value><br />
<br />
Gamevar operators are commands that perform various mathematical operations on [[gamevar]]s.<br />
<br />
For example:<br />
<code>setvar temp 1</code> assigns a value of 1 to the gamevar ''temp''.<br />
<br />
<code>addvar temp 1</code> adds 1 to ''temp'', causing its value to become 2.<br />
<br />
<code>mulvar temp 2</code> multiplies ''temp'' by 2, causing its value to become 4.<br />
<br />
{| {{prettytable}}<br />
!Operator!!C/C++!!Math!!Description!!Notes!!<br />
|-<br />
|set<br />
|=<br />
|=<br />
|assignment<br />
|-<br />
|add<br />
|<nowiki>+</nowiki><br />
|<nowiki>+</nowiki><br />
|addition<br />
|<br />
|-<br />
|sub<br />
|<nowiki>-</nowiki><br />
|<nowiki>-</nowiki><br />
|subtraction<br />
|<br />
|-<br />
|mul<br />
|*<br />
|&times;<br />
|multiplication<br />
|<br />
|-<br />
|div<br />
|/<br />
|&#247;<br />
|division<br />
|Ensure that <value> does not equal 0 at any time.<br />
|-<br />
|mod<br />
|%<br />
|<br />
|[[Wikipedia:Modulo operation|modulo]], remainder<br />
|Ensure that <value> does not equal 0 at any time.<br />
|-<br />
|and<br />
|&<br />
| <br />
|bitwise AND<br />
|The bits in the result are set only if they were set in both of the values being operated on.<br />
|-<br />
|or<br />
|<nowiki>|</nowiki><br />
| <br />
|bitwise OR<br />
|The bits in the result are set only if they were set in either of the values being operated on.<br />
|-<br />
|xor<br />
|^<br />
| <br />
|bitwise XOR<br />
|The bits in the result are set if only one of the values being operated on has those bits set.<br />
|}<br />
<br />
{{varsuffix}}<br />
<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Gamevar_operators&diff=9747Gamevar operators2011-05-08T07:18:41Z<p>Rasmusthorup: </p>
<hr />
<div><'''operator'''>'''var''' <gamevar> <value><br><br />
<'''operator'''>'''varvar''' <gamevar> <value><br />
<br />
Gamevar operators are commands that perform various mathematical operations on [[gamevar]]s.<br />
<br />
For example:<br />
[[setvar]]<br />
<code>setvar temp 1</code> assigns a value of 1 to the gamevar ''temp''.<br />
<br />
<code>addvar temp 1</code> adds 1 to ''temp'', causing its value to become 2.<br />
<br />
<code>mulvar temp 2</code> multiplies ''temp'' by 2, causing its value to become 4.<br />
<br />
{| {{prettytable}}<br />
!Operator!!C/C++!!Math!!Description!!Notes!!<br />
|-<br />
|set<br />
|=<br />
|=<br />
|assignment<br />
|-<br />
|add<br />
|<nowiki>+</nowiki><br />
|<nowiki>+</nowiki><br />
|addition<br />
|<br />
|-<br />
|sub<br />
|<nowiki>-</nowiki><br />
|<nowiki>-</nowiki><br />
|subtraction<br />
|<br />
|-<br />
|mul<br />
|*<br />
|&times;<br />
|multiplication<br />
|<br />
|-<br />
|div<br />
|/<br />
|&#247;<br />
|division<br />
|Ensure that <value> does not equal 0 at any time.<br />
|-<br />
|mod<br />
|%<br />
|<br />
|[[Wikipedia:Modulo operation|modulo]], remainder<br />
|Ensure that <value> does not equal 0 at any time.<br />
|-<br />
|and<br />
|&<br />
| <br />
|bitwise AND<br />
|The bits in the result are set only if they were set in both of the values being operated on.<br />
|-<br />
|or<br />
|<nowiki>|</nowiki><br />
| <br />
|bitwise OR<br />
|The bits in the result are set only if they were set in either of the values being operated on.<br />
|-<br />
|xor<br />
|^<br />
| <br />
|bitwise XOR<br />
|The bits in the result are set if only one of the values being operated on has those bits set.<br />
|}<br />
<br />
{{varsuffix}}<br />
<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Shiftvarr&diff=9746Shiftvarr2011-05-08T07:14:25Z<p>Rasmusthorup: </p>
<hr />
<div>'''shiftvarr''' <[[gamevar]]> <number><br />
<br />
Shifts the value of <[[gamevar]]> <number> bits to the right. See [[shiftvarl]].<br />
<br />
If the gamevar is shifted right with 1, then it will double the value of the gamevar. If you shift it right with 2, then it will double the number, and then double it again.<br />
<br />
[[Category:EDuke32 specific commands]]<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Shiftvarl&diff=9745Shiftvarl2011-05-08T07:13:35Z<p>Rasmusthorup: </p>
<hr />
<div>'''shiftvarl''' <[[gamevar]]> <number><br />
<br />
Shifts the value of <[[gamevar]]> <number> bits to the left. See [[shiftvarr]].<br />
<br />
If the gamevar is shifted left with 1, then it will halve the value of the gamevar. If you shift it left with 2, then it will halve the number, and then halve it again.<br />
<br />
[[Category:EDuke32 specific commands]]<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Shiftvarl&diff=9744Shiftvarl2011-05-08T07:13:21Z<p>Rasmusthorup: </p>
<hr />
<div>'''shiftvarl''' <[[gamevar]]> <number><br />
<br />
Shifts the value of <[[gamevar]]> <number> bits to the left. See [[shiftvarr]].<br />
If the gamevar is shifted left with 1, then it will halve the value of the gamevar. If you shift it left with 2, then it will halve the number, and then halve it again.<br />
<br />
[[Category:EDuke32 specific commands]]<br />
[[Category:Gamevar manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Category:Screen_drawing_commands&diff=9733Category:Screen drawing commands2011-04-18T14:57:04Z<p>Rasmusthorup: </p>
<hr />
<div>[[Category:All commands]]<br />
[[Category:Player manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9732Scripting2011-04-18T14:56:48Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9731Scripting2011-04-18T14:56:39Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[screen drawing commands]]<br />
*[[EDuke32 event list|event list]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Category:Screen_drawing_commands&diff=9730Category:Screen drawing commands2011-04-18T14:56:20Z<p>Rasmusthorup: </p>
<hr />
<div>'''screen drawing commands'''<br />
[[Category:All commands]]<br />
[[Category:Player manipulation]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9729Scripting2011-04-18T14:53:35Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9728Scripting2011-04-18T14:53:23Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[Category:Screen drawing commands|hey]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9727Scripting2011-04-18T14:53:06Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
[[Category:Screen drawing commands|hey]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9726Scripting2011-04-18T14:52:51Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
[[Category:Screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9725Scripting2011-04-18T14:52:27Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9724Scripting2011-04-18T14:52:19Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[Screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9723Scripting2011-04-18T14:52:08Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[:Screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthoruphttps://wiki.eduke32.com/w/index.php?title=Scripting&diff=9722Scripting2011-04-18T14:51:49Z<p>Rasmusthorup: /* Links */</p>
<hr />
<div>{{EDuke32 Intro}}<br />
<div class="floatleft">__NOTOC__</div> <!-- changed to NOTOC to get rid of it temporarily --><br />
==About This Guide==<br />
===Intro===<br />
This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide assumes both that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3D/1.5, and that the reader is familiar with a few basic programming concepts.<br />
<br />
===CON Basics===<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
If you are not already familiar with the default commands, the authors of this guide recommend the following guide, imported into the EDukeWiki for your convenience:<br />
* [[Confaq42|Con FAQ 4.2 by Jonah Bishop (note: some sections have been shuffled around a bit by TX)]] <br />
<br />
Another good source of basic information is the following FAQ:<br />
* [http://rtcm.thecomitatus.com/knowledge-base/downloads-rtcm/duke3d-faqs-con/H_CONFAQ.zip Con Editing Information v1.3 by James Ferry]<br />
<br />
==Gamevars==<br />
<br />
===Overview===<br />
*[[gamevar|gamevars]]<br />
Gamevars were introduced in [[WWII GI]] and remain the single most important aspect of the new commandset. Everything that sets EDuke32 scripting apart from regular Duke Nukem 3D scripting revolves around gamevars. Gamevars work similarly to integer variables in various programming languages, allowing the user to store, manipulate, and compare various information. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and move commands.<br />
<br />
===Types===<br />
There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:<br />
* '''Global variable''': If a variable is declared as global, there is only one copy of it which may be accessed by any actor in the game.<br />
<br />
For example:<br />
<br />
gamevar shots_fired 0 0 // gamevar declarations must not occur inside states, events, or actor code<br />
<br />
This line tells the game to create a variable named "shots_fired" which is initialized to 0. But wait -- what's the second 0 for? If you're asking yourself this question, go back and read the actual page on [[gamevar|gamevars]]. Now that you know that gamevars have flags which must be declared along with the var's name and value, let's continue.<br />
<br />
So, we've created a gamevar. Now what? For this example, we'll find the places in the GAME.CON code where the command "shoot SHOTSPARK1" occurs, and in each instance add the line "addvar shots_fired 1", so that in each case it looks like this:<br />
<br />
shoot SHOTSPARK1<br />
addvar shots_fired 1 // increments the counter<br />
<br />
This will make the shots_fired var increment each time an enemy fires a SHOTSPARK1 projectile.<br />
<br />
* '''Per-player variable''': If a variable is declared as per-player, there is one copy of it for each player in the game, meaning that the variable is set independently for each player. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor what changed it. You can use the [[setplayervar]] command to set a per-player var for a particular player who is not the closest one, but this is only necessary in multiplayer games (and even then it is seldom necessary). In single player games, there is little practical difference between a global gamevar and a per-player variable.<br />
<br />
* '''Per-actor variable''': If a variable is declared as per-actor, then there is separate copy of it for each sprite in the game. That means that every monster, projectile, player, decorative sprite -- pretty much anything in the game that isn't a wall or sector -- has its own copy of the variable. This is useful if you want to have actors other than the player store information for more than one tick. For example, suppose you want each monster to keep track of how many bullets it has fired:<br />
<br />
gamevar shots_fired 0 2<br />
<br />
This line tells the game that there is a variable named "shots_fired" which is initialized to 0 ( the 0 ) and is per-actor( the 2 ).<br />
With the gamevar declared, you could then add code to the monsters to increment the var when firing shots (just like in the example above for global gamevars). Since the gamevar is per-actor, the same code would now increment the variable separately for each monster. <br />
<br />
'''There are also some [[pre-defined gamevars]] and special [[constantly updated gamevars]] which should only be used in certain ways.'''<br />
<br />
===Use and manipulation===<br />
<br />
Custom variables, or "gamevars" are declared with the [[gamevar]] command.<br />
<br />
The syntax for defining a gamevar is:<br />
:gamevar <varname> <value> <flags><br />
<br />
You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit. <br />
<br />
The <value> of the gamevar may be positive or negative and must be a whole number.<br />
<br />
The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).<br />
<br />
*[[ifvar conditions]]<br />
*[[gamevar operators]]<br />
<br />
==Members of game structures==<br />
<br />
===Overview===<br />
*[[full list of structure members]]<br />
EDuke32, like prior EDuke iterations, gives you access to game structures--basic elements of the game such as the player, sprites, walls, and sectors--and their predefined property variables, or members.<br />
<br />
===Actor / Sprite===<br />
*[[members of the sprite and hittype structures]]<br />
You can control the sector structures with the [[getactor]] and [[setactor]] commands.<br />
<br />
Objects in the game world, such as monsters, missiles, bits of debris, and so on, are referred to as "sprites" (because they are typically rendered as 2D pictures). Sprites that execute code are usually referred to as "actors". Every sprite has its own data structure containing all of the member elements in the list linked to above. Various original CON commands, such as "cstat", "spritepal", "sizeat", etc. work by changing values in the sprite structure of the actor executing the command. These structure members can be modified directly in an EDuke32 script by using the [[setactor]] command. Commands like setactor enable us to modify every member of the structure, even those that could not be accessed with the original scripting system. See [[getactor]] and [[setactor]] to see how these commands are used.<br />
<br />
===Player===<br />
*[[members of the player structure]]<br />
You can control the sector structures with the [[getplayer]] and [[setplayer]] commands.<br />
<br />
The members of the player structure are controlled using the [[getplayer]] and [[setplayer]] commands. The player structure members deal with properties unique to the player which are not shared with other actors. These include variables associated to the players weapons, inventory items, special animations, jumping counters, etc. See the complete list of [[members of the player structure]] for details. [[Make_Nightvision_light_rooms|This example]] shows how to get a member of the player structure into a variable, check its value, then alter a member of the player structure accordingly.<br />
<br />
===Sector===<br />
*[[members of the sector structure]]<br />
You can control the sector structures with the [[getsector]] and [[setsector]] commands.<br />
<br />
===Wall===<br />
*[[members of the wall structure]]<br />
You can control the wall structures with the [[getwall]] and [[setwall]] commands<br />
<br />
===Game configuration===<br />
*[[members of the userdef structure]]<br />
The userdef structures are controlled with the [[getuserdef]] and [[setuserdef]] commands.<br />
<br />
===Player input===<br />
*[[members of the input structure]]<br />
The input structures are controlled with the [[getinput]] and [[setinput]] commands.<br />
<br />
===Tsprite===<br />
*[[members of the tsprite structure]]<br />
The tsprite structures are controlled with the [[gettspr]] and [[settspr]] commands.<br />
<br />
==Events==<br />
<br />
===Overview===<br />
EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an [[events|event]] is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.<br />
<br />
Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.<br />
<br />
===Event use===<br />
*[[EDuke32 event list|events list]]<br />
Using an event is very easy &mdash; similar to the [[actor]] or [[state]] primitives, [[onevent]] is the primitive used to start the definition of a block of code to be associated with one of the [[EDuke32 event list|events]]. Furthering the similarity, onevent must be terminated by the equivalent of an [[enda]] or an [[ends]], an [[endevent]].<br />
<br />
The following example of event code will cause the player to have a full first aid kit every time the inventory is reset (e.g. when the player starts a game):<br />
<br />
onevent EVENT_RESETINVENTORY<br />
setplayer[THISACTOR].firstaid_amount 100<br />
endevent<br />
<br />
==Drawing to the screen==<br />
The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3D and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).<br />
<br />
===Drawing commands===<br />
*[[rotatesprite]]<br />
*[[gametext]]<br />
*[[minitext]]<br />
*[[digitalnumber]]<br />
<br />
==Custom projectiles==<br />
===Overview===<br />
EDuke32 adds the ability to create new projectiles in addition to the default types. A few basic types exist (shorthand: melee, hitscan (bullets), and visible projectiles like RPGs) which can be used to create a nearly infinite variety of weapon types and even some entirely new effects, such as new types of debris, gibs, clouds of billowing smoke, et cetera.<br />
<br />
===Defining custom projectiles===<br />
*[[defineprojectile]]<br />
The input structures are controlled with the [[getprojectile]], [[getthisprojectile]] and [[setprojectile]], [[setthisprojectile]] commands.<br />
<br />
Projectiles are defined via the defineprojectile command. The syntax for this command is:<br />
defineprojectile <tilenum> <function> <value><br />
<br />
==String manipulation==<br />
*[[:Category:String manipulation|string manipulation]]<br />
Strings (lines of text) are called "quotes" in Duke Nukem 3D. String manipulation consists of some simple copying and concatenation commands, as well as the ability to print the text to the screen. <br />
<br />
==Links==<br />
*full command list<br />
**[[Full command list|alphabetized]]<br />
**[[:Category:All commands|categorized]]<br />
*[[gamevar]]s<br />
*[[pre-defined gamevars]]<br />
*[[constantly updated gamevars]]<br />
*[[full list of structure members|structure members]]<br />
*[[EDuke32 event list|event list]]<br />
*[[Category:Screen drawing commands]]<br />
*[[defineprojectile|projectile information]]</div>Rasmusthorup