Thread: Tripmines
View Single Post
naris
AlliedModders Donor
Join Date: Dec 2006
Old 06-01-2010 , 22:49   Re: Tripmines
Reply With Quote #422

Here is a version that I got to work without encountering any crashes or physics issues in TF2. It should also work in DoD:S, CS:S and other mods.

It also supports team-specific tripmines, team colored lasers, restricting tripmines to a specific team, per client maximum, purchasing tripmines in CSS, etc...

The following convars are available to customize the plugin:

sm_tripmines_activate_time (default 2.0)
Tripmine activation time.

sm_tripmines_reactivate_time (default 0.5)
Tripmine reactivation time, after touched by a teammate.

sm_tripmines_model
Tripmine model

sm_tripmines_admin (admin flag character or empty)
Admin flag required to use tripmines (empty=anyone can use tripmines)

sm_tripmines_restrictedteam (0-3, default 0)
Team that does NOT get any tripmines

sm_tripmines_teamspecific (0-2, default 1)
Allow teammates of planter to pass (0 = no | 1 = yes | 2 = also allow planter to pass)

sm_tripmines_touch (0-1, default 0)
Tripmines explode when touched. (0=no|1=yes)

sm_tripmines_allowspec (1/0, default 0)
Allow spectators to use tripmines

sm_tripmines_type (1/0, default 1)
Explosion type of Tripmines (0 = normal explosion | 1 = fire explosion)

sm_tripmines_stay (0-2, default 1)
Tripmines stay if the owner dies. (0 = no | 1 = yes | 2 = destruct)

sm_tripmines_health (default 10)
Tripmines Health

sm_tripmines_radius (default 256.0)
Tripmines Explosion Radius

sm_tripmines_damage (default 200)
Tripmines Explosion Damage

sm_tripmines_maximum (default 6)
Maximum Number of tripmines allowed to be active per client (-1=unlimited)

sm_tripmines_allowed (default 3)
Number of tripmines allowed per life (-1=unlimited)

sm_tripmines_mine_color_1 (default "0 255 255")
Mine Color (can include alpha) for team 1 (Spectators)

sm_tripmines_mine_color_2 (default "255 0 0")
Mine Color (can include alpha) for team 2 (Red / Allies / Terrorists)

sm_tripmines_mine_color_3 (default "0 0 255")
Mine Color (can include alpha) for team 3 (Blue / Axis / Counter-Terrorists)

sm_tripmines_beam_color_1 (default "0 255 255")
Beam Color (can include alpha) for team 1 (Spectators)

sm_tripmines_beam_color_2 (default "255 0 0")
Beam Color (can include alpha) for team 2 (Red / Allies / Terrorists)

sm_tripmines_beam_color_3 (default "0 0 255")
Beam Color (can include alpha) for team 3 (Blue / Axis / Counter-Terrorists)

sm_tripmines_placed_sound (default "npc/roller/blade_cut.wav")
Sound when a tripmine is placed

sm_tripmines_removed_sound (default "npc/roller/mine/rmine_blades_in2.wav")
Sound when a tripmine is removed

sm_tripmines_activated_sound (default "npc/roller/mine/rmine_blades_in2.wav")
Sound when a tripmine is activated

sm_tripmines_reactivated_sound (default "ui/hint.wav")
Sound when a tripmine is reactivated, after touched by a teammate

The following convar is available in CS:S:

sm_tripmines_cost (default 50)
Price to purchase Tripmines in Counter-Strike (0=give mines at round start,-1=also disable buying mines)

The following convars are available in TF2:

sm_tripmines_scout_limit (default -1)
Number of tripmines allowed per life for Scouts (-1=use generic variable)

ssm_tripmines_sniper_limit (default -1)
Number of tripmines allowed per life for Snipers (-1=use generic variable)

sm_tripmines_soldier_limit (default -1)
Number of tripmines allowed per life for Soldiers (-1=use generic variable)

sm_tripmines_demoman_limit (default -1)
Number of tripmines allowed per life for Demomen (-1=use generic variable)

sm_tripmines_medic_limit (default -1)
Number of tripmines allowed per life for Medics (-1=use generic variable)

sm_tripmines_heavy_limit (default -1)
Number of tripmines allowed per life for Heavys (-1=use generic variable)

sm_tripmines_pyro_limit (default -1)
Number of tripmines allowed per life for Pyros (-1=use generic variable)

sm_tripmines_spy_limit (default -1)
Number of tripmines allowed per life for Spys (-1=use generic variable)

sm_tripmines_engi_limit (default -1)
Number of tripmines allowed per life for Engineers (-1=use generic variable)

I also added a native interface to control tipmines from another plugin
PHP Code:
/**
 * Assume control of the tripmines plugin
 *
 * @param plugin_only     Set to 1 to assume complete control of the Tripmines plugin.
 * @return                none
 */
native ControlTripmines(bool:plugin_only=true);

/**
 * Give a player one or more tripmines to plant
 *
 * @param index     Client index
 * @param number    Set to number of tripmines to give the player. (-1 is plugin default)
 * @param per_spawn Set to number of tripmines to give the player on each spawn. (-1 is plugin default)
 * @param maximum   Set to number of tripmines allowed to be active. (-1 is plugin default)
 * @return            none
 */
native GiveTripmines(client,number=-1,per_spawn=-1,maximum=-1);

/**
 * Takes the player's tripmines away
 *
 * @param index     Client index
 * @return            none
 */
native TakeTripmines(client);

/**
 * Adds one or more tripmines for the player to plant
 *
 * @param index     Client index
 * @param number    Number of tripmines to add.
 * @return            none
 */
native AddTripmines(client,number=1);

/**
 * Subtracts one or more tripmines for the player to plant
 *
 * @param index     Client index
 * @param number    Number of tripmines to subtract.
 * @return            none
 */
native SubTripmines(client,number=1);

/**
 * Returns how many tripmines a player has (or is allowed).
 *
 * @param index     Client index
 * @param allowed   Set to  true to return number allowed, otherwise
 * @return            returns number of remaining tripmines.
 */
native HasTripmines(client,bool:allowed=false);

/**
 * Sets (Plants) a tripmine.
 *
 * @param index     Client index
 * @return            none
 */
native SetTripmine(client);

/**
 * Counts how many tripmines the player has active.
 *
 * @param index     Client index
 * @return            none
 */
native CountTripmines(client);

/**
 * Gets called when when a tripmine is set
 * @param client     Client index of the player setting the tripmine
 */
forward Action:OnSetTripmine(client); 
**Updated to version 3.3
  • Added convars to set beam and mine color and alpha
  • Added sm_tripmines_allowspec convar to allow/disallow spectators to plant mines
  • Changed sm_tripmines_teamspecific to have additional setting (2) to allow planter to pass
  • Changed tripmine properties for CSS to match original plugin
  • Hooked OnTouchedByEntity for tripmines so they can't be used like stairs

**Updated to version 3.4
  • Fixed player_spawn not getting hooked in CSS
  • Tweaked tripmine entity creation to attempt to fix invulerable tripmines

**Updated to version 3.5
  • Added sm_tripmines_admin convar to specify admin flag to check (if any)
  • Fixed sm_tripmines_maximum not getting used if NativeControl is off
  • Changed to check TeamSpecific in addition to FriendlyFire when igniting players
  • Check TeamSpecific setting if the tripmine's owner touches the tripmine itself.
  • Disable buying tripmines in CSS when the cost is set to -1

**Updated to version 3.6
  • Fixed admin flag check, which was backwards (only allowed non-admins)

**Updated to version 3.7
  • Added sm_tripmines_reactivate_time to specify reactivation time, after touched by a teammate.
  • Added convars (sm_tripmines_placed_sound, sm_tripmines_removed_sound, sm_tripmines_activated_sound, sm_tripmines_reactivated_sound) to specify sounds
  • Added sm_tripmines_touch convar to enable/disable tripmines exploding when they are touched
  • Merged crash from re-creating beams fix from Quimbo
  • Merged crash from removing tripmines fix from Quimbo

**Updated to version 3.8
  • Added sm_tripmines_health to specify tripmines health, defaults to 10.

**Updated to version 3.9
  • Ignore deaths due to fishes that aren't actual deaths.
  • Check to ensure entities are actually created.

**Updated to version 4.0
  • Re-factored to reduce crashes.
Attached Files
File Type: sp Get Plugin or Get Source (tripmines.sp - 1517 views - 50.1 KB)
File Type: inc tripmines.inc (2.8 KB, 749 views)
File Type: txt plugin.tripmines.txt (1.1 KB, 858 views)
File Type: smx tripmines.smx (22.6 KB, 584 views)

Last edited by naris; 11-07-2010 at 16:01. Reason: Added translations
naris is offline