User:TehRealSalt/Gamma

From SRB2 Wiki
Jump to navigation Jump to search

Mapping

Things

Gamma comes with several custom objects for mappers to use. Simply copy the lua/mobj/custom.lua lump and the contents of the sprites/objs folder into your map's file. Gamma can be loaded before, after, or not at all, and these objects will still function if these lumps were added to your map properly.

ID Name Description
1789 Bustable Wall Dynamite These objects will bust FOFs when they are destroyed. Give the bomb the same tag as the FOF linedef to link them together.

If multiple bombs have the same tag, they will all need destroyed to bust the FOF.

These can be used to let Gamma destroy normal bustable walls horizontally, or to let them destroy a normally solid FOF to give them their own unique path split.

In old binary format maps, since things do not have tags, the angle parameter is used instead.

1790 Extra Time Monitor When popped, Gamma players receive 30 seconds of extra time. Otherwise, it doesn't do anything.

Header

Field Description Example
Lua.GammaTimeLimit Sets the length of Gamma's time limit for this map, in seconds.

Setting this to 0 disables the time limit on this map entirely.

-1 goes back to using the default time limit, which is automatically generated by looking at the stage's elements. This usually plays it safe and gives more time than necessary, so it is recommended to set a specific time limit when designing a map for Gamma at all.

Lua.GammaTimeLimit = 180 sets a 3 minute time limit.

Lua

Hooks

This is a list of custom hooks available for scripters to fine-tune Gamma's interactions with their objects. The set function is used to supply a function which changes Gamma's behavior with this object. The function format gives an example of what the set function expects to receive, while allowed return values is a list of all of the valid return values of this function. These hooks can return nil to fallback to a default behavior. This default behavior has been replicated as a function for example purposes, but aren't necessary to copy into your project as returning nil does the same thing.

Set Function format Allowed return values Description Default behavior replicated
Gamma.SetTargetFunc(MT_ constant type, function func) function(mobj_t mobj, table aimList, mobj_t owner) boolean or nil Determines whenever or not the lock-on laser is able to target an object. mobj is the object that the laser is attempting to target. aimList is a table containing information on all of the targets the laser has already targeted (see also: Gamma.AimListContains). owner is the Gamma player's mobj_t that the laser is coming from.

Returning true or false sets if the laser can target this object. Returning nil falls back to the default behavior.

Note that any object with MF_NOBLOCKMAP will not be able to be locked-on, regardless of return value, because the laser uses blockmap searching to find objects efficiently.

This is used frequently by Gamma to make multi-object enemies require every piece targeted before the main body can be attacked, as well as allow them to target the new destructible decoration.

local function DefaultTargetFunc(mobj, aimList, owner)
    local canTarget = false;

	if (mo.flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_MISSILE|MF_PUSHABLE))
		canTarget = true;
	end

	if (mo.flags2 & MF2_INVERTAIMABLE)
		canTarget = (not canTarget);
	end

	return canTarget;
end
Gamma.SetDamageFunc(MT_ constant type, function func) function(mobj_t target, table bullet, mobj_t owner) Gamma.SHOT_EXPLODE, Gamma.SHOT_ABSORB, Gamma.SHOT_REFLECT, or nil Determines behavior when the target object is being damaged by Gamma's projectiles. bullet is the object causing the damage. It can either be a MT_GAMMA_SHOT for the bullet itself, or a MT_GAMMA_BLASTEREXPLOSION_CENTER for the Laser Blaster upgrade explosion. owner is the Gamma player's mobj_t that the bullet came from.

The return type determines the kind of death animation to give the bullet. Gamma.SHOT_EXPLODE uses the standard explosion animation. Gamma.SHOT_ABSORB makes the shot use the fizzle animation. Gamma.SHOT_REFLECT makes the bullet bounce off and flicker away. Returning nil falls back to the default behavior.

Only Gamma.SHOT_EXPLODE gives time bonuses, and spawns the Laser Blaster upgrade's explosion for the bullet itself.

This is used frequently by Gamma to control damage states, and create new unique death animations.

local function DefaultDamageFunc(target, bullet, owner)
	local pushed = false;
	if (dest.flags & MF_PUSHABLE)
	or ((mobjinfo[dest.type].flags & MF_PUSHABLE) and dest.fuse) -- Allows pushing rollout rocks while they're being ridden
		Gamma.ShotPush(dest, mo);
		pushed = true;
	end

	-- Attempt to cause damage!!
	if (dest.flags & MF_SHOOTABLE)
		-- Standard damage
		P_DamageMobj(dest, mo, owner);
		return Gamma.SHOT_EXPLODE;
	elseif (dest.flags & MF_MISSILE)
		-- Projectile clashing
		P_ExplodeMissile(dest);
		return Gamma.SHOT_EXPLODE;
	end

	if (pushed == true)
		return Gamma.SHOT_EXPLODE;
	end

	return Gamma.SHOT_ABSORB;
end
Gamma.SetPointsFunc(MT_ constant type, function func) function(mobj_t mobj) number >= 0, or nil Sets how many seconds this object gives. By default, this is set to scale based on the health the object spawns with for enemies (see also: Gamma.HealthToPoints), and to give no time for anything else. Returning nil falls back to this default behavior.

This is used frequently by Gamma to make specific objects give 1 second, that would otherwise give 0.

local function DefaultPointsFunc(mobj)
	if (mobj.flags & (MF_ENEMY|MF_BOSS))
		-- Combo points depends on health
		return Gamma.HealthToPoints(mobj.info.spawnhealth);
	end

	-- Does not add to combo
	return 0;
end

Useful Functions

This is a list of other useful functions for developing Gamma hooks.

Function Return values Description
Gamma.AimListContains(table aimList, mobj_t mobj) boolean Returns if an object is already being aimed at by Gamma.
Gamma.HealthToPoints(number hp) number Returns the number of seconds an enemy is meant to give for their starting health, scaled for time that multi-hit enemies would spend in MF2_FRET.