Defineprojectile

From EDukeWiki
(Redirected from PROJ PAL)
Jump to navigation Jump to search

defineprojectile <tilenum> <function> <value>

Defines a projectile to be fired by the shoot command and its variants.

First, we must figure out a proper WORKSLIKE flag for our projectile.

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.

If the velocity is too high (usually over 1000), clipping errors may increse drastically. Instead, set PROJ_VELMULT and a lower PROJ_VEL.

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.

Functions

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.

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.

PROJ_SPAWNS Used to spawn an actor on impact. Set <value> to -1 to spawn nothing, otherwise <value> defaults to SMALLSMOKE.

Doesn't work with bullet-type projectiles fired by actors other than the player.

PROJ_SXREPEAT Used to set the x size of an actor spawned on impact. <value> is the size you wish to set the spawned actor's x to.
PROJ_SYREPEAT Used to set the y size of an actor spawned on impact. <value> is the size you wish to set the spawned 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.

PROJ_TRAIL Used to set the tilenum of any trail sprites spawned. <value> is the tilenum of the trail sprites spawned.
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.
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.
PROJ_TOFFSET The y offset of the trail spawned by the PROJ_TRAIL variable. Positive numbers move the sprite down.
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.

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.

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.
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.

Set PROJ_ISOUND to -1 to disable impact sounds.

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.
PROJ_VEL_MULT Used to set multiply velocity of a projectile (causes an artificial acceleration). <value> is the amount to multiply by.

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.

PROJ_EXTRA

Used to set the damage strength of a projectile. <value> is the damage strength.

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.

PROJ_EXTRA_RAND

<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.

Setting it to zero should cause the projectile to inflict the precise damage defined by PROJ_EXTRA.

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.
PROJ_CSTAT Used to set the cstat flag(s) of the projectile. <value> is the cstat flag(s) of the projectile.
PROJ_CLIPDIST The clipdist of the projectile. Has no effect and is hardcoded to 4 unless workslike flag PROJECTILE_REALCLIPDIST is set.
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 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 sprites or certain hitscanning 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

The following values are used with defineprojectile.

Exposed Value Hex Label Description
Yes 1 0x000001 PROJECTILE_HITSCAN Indicates that the projectile is hitscan.

It cannot be applied simultaneously with PROJECTILE_KNEE, PROJECTILE_RPG, or PROJECTILE_BLOOD.

Yes 2 0x000002 PROJECTILE_RPG Indicates that the projectile is a moving actor.

It cannot be applied simultaneously with PROJECTILE_HITSCAN, PROJECTILE_KNEE, or PROJECTILE_BLOOD.

Yes 4 0x000004 PROJECTILE_BOUNCESOFFWALLS Nounce off of all walls, like pipebombs and freezeblasts.
Yes 8 0x000008 PROJECTILE_BOUNCESOFFMIRRORS Bounce off of mirrors only, like shrinker blasts and firelasers.
Yes 16 0x000010 PROJECTILE_KNEE Indicates that the projectile is melee, essentially hitscan with limited range.

It cannot be applied simultaneously with PROJECTILE_HITSCAN, PROJECTILE_RPG, or PROJECTILE_BLOOD.

Yes 32 0x000020 PROJECTILE_WATERBUBBLES Spawn water bubbles (WATERBUBBLE, tile #661) if underwater.
Yes 64 0x000040 PROJECTILE_TIMED If projectile is flagged as an RPG projectile, then this flag will make the projectile disappear.

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.

Yes 128 0x000080 PROJECTILE_BOUNCESOFFSPRITES Bounce off of sprites.
Yes 256 0x000100 PROJECTILE_SPIT Draw loogies on a player's screen and tint it green if the player is hit by the projectile.
Yes 512 0x000200 PROJECTILE_COOLEXPLOSION1
Yes 1024 0x000400 PROJECTILE_BLOOD Indicates that the projectile is a blood splat, like the hardcoded BLOODSPLAT1 through 4 found in state random_wall_jibs.

It cannot be applied simultaneously with PROJECTILE_HITSCAN, PROJECTILE_RPG, or PROJECTILE_KNEE.

Yes 2048 0x000800 PROJECTILE_LOSESVELOCITY
Yes 4096 0x001000 PROJECTILE_NOAIM The projectile will not automatically aim at any targets
Yes 8192 0x002000 PROJECTILE_RANDDECALSIZE If this flag is set in the PROJ_WORKSLIKE variable, then the projectile will randomize the size of its decals.
Yes 16384 0x004000 PROJECTILE_EXPLODEONTIMER If projectile is an RPG with PROJECTILE_FLAG_TIMED flag set, then it normally wouldn't spawn sounds and more things. To prevent that, use this flag.
Yes 32768 0x008000 PROJECTILE_RPG_IMPACT Setting this flag in the PROJ_WORKSLIKE variable means that the actors\players that are hit by the projectile will receive direct damage in addition to hitradius, making the total damage close to twice PROJ_EXTRA, similar to the hard-coded RPG projectile. The projectile will also add momentum with direct damage, which can be used in conjunction with setting PROJ_HITRADIUS to 0 in order to create an effect like shooting a rock, if you want it to be realistic.
Yes 65536 0x010000 PROJECTILE_RADIUS_PICNUM This flag sets the projectile's picnum to its target's htpicnum instead of the default RADIUSEXPLOSION, or 1670.
Yes 131072 0x020000 PROJECTILE_ACCURATE_AUTOAIM
Yes 262144 0x040000 PROJECTILE_FORCEIMPACT
Yes 524288 0x080000 PROJECTILE_REALCLIPDIST Allows the value of PROJ_CLIPDIST to take effect if set. Otherwise the hardcoded clipdist of 4 takes effect.
Yes 1048576 0x100000 PROJECTILE_ACCURATE
Yes 2097152 0x200000 PROJECTILE_NOSETOWNERSHADE
Yes 4194304 0x400000 PROJECTILE_RPG_IMPACT_DAMAGE

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.