Test: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Fox (talk | contribs)
No edit summary
Fox (talk | contribs)
No edit summary
Line 1: Line 1:
'''defineprojectile''' <tilenum> <function> <value>
These are [[gamevar]]s which are defined as direct pointers to internal variables in the game.  While some will change frequently, others will remain static for the whole game.


Defines a projectile to be fired by the [[shoot]] command and its variants.
Please note that the values of most of these variables will be different on each peer, so you must be careful for anything that could possibly have an effect on sync.


First, we must figure out a proper WORKSLIKE flag for our projectile.
The "Current actor or player" group of variables point to the current actor/player. The other ones point to internal and usually global variables.


To determine the proper WORKSLIKE flag for your projectile, simply add the numbers for the various functions you'd like your projectile to have together.  Obviously, some flags are not compatible.  Note that either PROJECTILE_FLAG_HITSCAN, PROJECTILE_FLAG_RPG or PROJECTILE_FLAG_KNEE must be part of your WORKSLIKE flag.
<strong>Do not attempt to redefine these unless you know what you are doing or you will have problems.</strong>


If the velocity is too high (usually over 1000), clipping errors may increse drastically. Instead, set PROJ_VELMULT and a lower PROJ_VEL.
{| cellpadding="0" cellspacing="0" border="0" width="100%"
| width="33%" valign="top" style="border-right: none; padding: 0.6em;" |
Map
*[[RESPAWN_MONSTERS]]
*[[RESPAWN_ITEMS]]
*[[RESPAWN_INVENTORY]]
*[[MONSTERS_OFF]]
*[[MARKER]]
*[[FFIRE]]
*[[LEVEL]]
*[[VOLUME]]
*[[NUMWALLS]]
*[[NUMSECTORS]]
*[[Numsprites]]


To be able to use the [[ifwasweapon]] with custom RPG-type projectiles (PROJ_WORKSLIKE includes bit 2), make sure to include the PROJECTILE_FLAG_RPG_IMPACT flag (32768) in PROJ_WORKSLIKE.
Multiplayer
*[[COOP]]
*[[MULTIMODE]]


== Functions ==
Current actor or player
*[[WEAPON]]
*[[WORKSLIKE]]
*[[RETURN]]
*[[ZRANGE]]
*[[ANGRANGE]]
*[[AUTOAIMANGLE]]
*[[LOTAG]]
*[[HITAG]]
*[[TEXTURE]]
*[[THISACTOR]]


{| {{prettytable}}
|-
| '''PROJ_WORKSLIKE''' || Used to set flags for projectile function. Add all the desired flags together, and use that value for <value>. This works similar to [[cstat (sprite)|cstat]].


Note that the damage on impact bit (32768) must be set on the WORKSLIKE of any RPG type projectile (i.e. nonhitscan) for which the projectile itself does damage, as opposed to the damage being caused only by the hitradius.
| width="33%" valign="top" style="border-right: none; border-left: none; padding: 0.6em;" |
|-
Screen drawing
| '''PROJ_SPAWNS''' || Used to [[spawn]] an [[actor]] on impact. Set <value> to -1 to [[spawn]] nothing, otherwise <value> defaults to SMALLSMOKE.
*[[gs]]
*[[gun_pos]]
*[[looking_angSR1]]
*[[looking_arc]]
*[[weapon_xoffset]]
*[[weaponcount]]
*[[windowx1]]
*[[windowx2]]
*[[windowy1]]
*[[windowy2]]
*[[xdim]]
*[[ydim]]
*[[viewingrange]]
*[[yxaspect]]


Doesn't work with bullet-type projectiles fired by actors other than the player.
Renderer
|-
*[[framerate]]
| '''PROJ_SXREPEAT''' || Used to set the x size of an [[actor]] [[spawn]]ed on impact. <value> is the size you wish to set the [[spawn]]ed [[actor]]'s x to.
*[[rendmode]]
|-
| '''PROJ_SYREPEAT''' || Used to set the y size of an [[actor]] [[spawn]]ed on impact. <value> is the size you wish to set the [[spawn]]ed [[actor]]'s y to.
|-
| '''PROJ_DECAL''' || Used to set the tilenum of any decal spawned by the projectile, i.e. bullet holes. <value> is the tilenum of the decal used. Only works with bullet projectiles.


Doesn't work with bullet type projectiles fired by actors other than players.
Misc
|-
*[[current_menu]]
| '''PROJ_TRAIL''' || Used to set the tilenum of any trail sprites spawned. <value> is the tilenum of the trail sprites spawned.
*[[currentweapon]]
|-
*[[display_mirror]]
| '''PROJ_TXREPEAT''' || The x size of the trail used by the projectile.  Note that if the trail is an [[actor]] with a size specified in its code (e.g. by a [[sizeat]] command) then the specified size will override the one you give it.
*[[gametype_flags]]
|-
*[[gravitationalconstant]]
| '''PROJ_TYREPEAT''' || The y size of the trail used by the projectile.  Note that if the trail is an [[actor]] with a size specified in its code (e.g. by a [[sizeat]] command) then the specified size will override the one you give it.
*[[lastvisinc]]
|-
*[[myconnectindex]]
| '''PROJ_TOFFSET''' || The y offset of the trail spawned by the PROJ_TRAIL variable.  Positive numbers move the sprite down.
*[[numplayers]]
|-
*[[randomseed]]
| '''PROJ_TNUM''' || The maximum number of trails that an individual projectile can spawn.  By default, RPG (non-hitscan) type projectiles will spawn trails even if TNUM is not set.  But bullet type (hitscan) projectiles will not spawn any trails unless TNUM is given a non-zero value.
*[[screenpeek]]
*[[totalclock]]
*[[lastsavepos]]


The way it works, is that if TNUM value is set to 2, then it will spawn 2 of the sprites on the same location. The default value is 1 if a trail is set for the projectile.
| width="33%" valign="top" style="border-left: none; padding: 0.6em;" |
|-
Camera
| '''PROJ_SOUND''' || Used to play a [[sound]] when a projectile is fired. For bullet projectiles this is the [[sound]] played on impact. <value> is the name of the [[sound]] you wish to play.
*[[camerax]]
|-
*[[cameray]]
| '''PROJ_ISOUND''' || Used to play a [[sound]] when a projectile impacts a surface. This is ignored on bullet-type projectiles. <value> is the name of the [[sound]] you wish to play.
*[[cameraz]]
*[[cameraang]]
*[[camerahoriz]]
*[[camerasect]]
*[[cameradist]]
*[[cameraclock]]


Set PROJ_ISOUND to -1 to disable impact sounds.
Player position
|-
*[[myx]]
| '''PROJ_VEL''' || Used to set the velocity of a projectile. <value> is the speed of the projectile. Values over 1000 are not encouraged. Use PROJ_VEL_MULT to go at higher speeds.
*[[myy]]
|-
*[[myz]]
| '''PROJ_VEL_MULT''' || Used to set multiply velocity of a projectile (causes an artificial acceleration). <value> is the amount to multiply by.
*[[omyx]]
*[[omyy]]
*[[omyz]]
*[[myxvel]]
*[[myyvel]]
*[[myzvel]]


On a given tic the projectile will move PROJ_VEL_MULT times, for example, if you set PROJ_VEL_MULT to 1, it will only move at its current velocity (stored in its sprite's [[xvel]] / [[zvel]]) once per tic.
Player properties
|-
*[[myang]]
| '''PROJ_EXTRA''' ||
*[[mycursectnum]]
Used to set the damage strength of a projectile. <value> is the damage strength.
*[[myhardlanding]]
 
*[[myhoriz]]
Negative numbers do not work to create a healing projectile. You must set this value to 0 and have the actor that is hit manually add health back to itself.
*[[myhorizoff]]
|-
*[[myjumpingcounter]]
| '''PROJ_EXTRA_RAND''' ||
*[[myjumpingtoggle]]
<value> is a random value added to a projectile damage. By default it is 5, meaning that a SHOTGUN projectile (which damage is defined as 10 in USER.CON) will make cause a damage of 10 to 15.
*[[myonground]]
 
*[[myreturntocenter]]
Setting it to zero should cause the projectile to inflict the precise damage defined by PROJ_EXTRA.
*[[omyang]]
|-
*[[omyhoriz]]
| '''PROJ_DROP''' || Used to set the rate at which the projectile drops (arcs). <value> is the speed of the projectile's dropping. Note that a negative number is needed for it to move toward the ground.
*[[omyhorizoff]]
|-
| '''PROJ_CSTAT''' || Used to set the [[cstat (sprite)|cstat]] flag(s) of the projectile. <value> is the [[cstat (sprite)|cstat]] flag(s) of the projectile.
|-
| '''PROJ_CLIPDIST''' || The [[clipdist]] of the projectile.
|-
| '''PROJ_SHADE''' || The [[shade]] of the projectile.
|-
| '''PROJ_XREPEAT''' || Used to set the [[xrepeat]] of the projectile. <value> is the size you wish to set the projectile's x to. For hitscan type projectiles this determines the x size of the decal.
|-
| '''PROJ_YREPEAT''' || Used to set the [[yrepeat]] of the projectile. <yrepeat> is the size you wish to set the projectile's y to. For hitscan type projectiles this determines the y size of the decal.
|-
| '''PROJ_PAL''' || Used to set the [[pal|palette reference (or color)]] of the projectile. <pal> is the palette reference of the projectile.
 
See [[pal]] for more information about palette swaps.
|-
| '''PROJ_HITRADIUS''' || The distance at which [[sprite|sprites]] or certain hitscanning [[wall|walls]] will be affected by the [[hitradius]] of the projectile. If set to a value lower than 1, no hitradius will be generated.
|-
| '''PROJ_OFFSET''' || Sets the x offset of the projectile fired. As the numbers get higher, the projectile's initial position will move further to the left.
 
A value of 224 will make the projectile spawn at the "right hand" (for example Battlelord morters). To make it spawn centered, use a value of 14354.
|-
| '''PROJ_BOUNCES''' || Number of times the projectile will bounce off of walls before destruction.  Will only count wall bounces even if PROJECTILE_FLAG_BOUNCESOFFSPRITES is included in the PROJ_WORKSLIKE flag.
Only works for RPG-type projectiles.
|-
| '''PROJ_BSOUND''' || The sound that will play when the projectile bounces. Defaults to PIPEBOMB_BOUNCE.
|-
| '''PROJ_RANGE''' || 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.
 
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.
|-
| '''PROJ_FLASH_COLOR''' || Used to set the color (if any) of a Polymer light. <value> is the color of the light.
 
The number can be determined from RGB color values by adding the red value plus the green value shifted left 8 bits plus the blue value shifted left 16 bits. So, RGB of 100, 100, 100 would be 6579300 = 100 + 100<<8 + 100<<16 = 100 + 25600 + 6553600. 150, 100, 255 would be 16737380.
|-
|}
|}


== WORKSLIKE flags ==
[[Category:Gamevar manipulation]]
 
[[Category:Scripting documentation]]
{{Proj workslike}}
 
== Examples ==
 
Here is an example of a working user-defined projectile:
 
defineprojectile 1653 [[PROJ_WORKSLIKE]] 6150
defineprojectile 1653 [[PROJ_SPAWNS]] EXPLOSION2
defineprojectile 1653 [[PROJ_VEL]] 1000
defineprojectile 1653 [[PROJ_EXTRA]] 300
defineprojectile 1653 [[PROJ_DROP]] -200
defineprojectile 1653 [[PROJ_ISOUND]] PIPEBOMB_EXPLODE
defineprojectile 1653 [[PROJ_HITRADIUS]] 2560
defineprojectile 1653 [[PROJ_BOUNCES]] 5
defineprojectile 1653 [[PROJ_OFFSET]] 224
defineprojectile 1653 [[PROJ_CLIPDIST]] 24
defineprojectile 1653 [[PROJ_TRAIL]] SMALLSMOKE
 
In this example, the projectile has the following WORKSLIKE flags set: PROJECTILE_FLAG_NOAIM, PROJECTILE_FLAG_LOSESVELOCITY, PROJECTILE_FLAG_RPG and PROJECTILE_FLAG_BOUNCESOFFWALLS.  This gives us an RPG-like projectile that doesn't automatically aim at enemies/players (we need this because the projectile in question fires in an arc), automatically slows down during flight, fires like an RPG and bounces off the walls.
 
[[Category:EDuke32 specific commands]]
[[Category:Projectile manipulation]]

Revision as of 11:19, 22 February 2020

These are gamevars which are defined as direct pointers to internal variables in the game. While some will change frequently, others will remain static for the whole game.

Please note that the values of most of these variables will be different on each peer, so you must be careful for anything that could possibly have an effect on sync.

The "Current actor or player" group of variables point to the current actor/player. The other ones point to internal and usually global variables.

Do not attempt to redefine these unless you know what you are doing or you will have problems.

Map

Multiplayer

Current actor or player


Screen drawing

Renderer

Misc

Camera

Player position

Player properties