Weapon portal base: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{ent not in fgd}} | {{ent not in fgd}} | ||
{{ | {{entity|weapon_portal_base|type=e0|series=Portal}} It's a code class in {{portal}} {{p2}} which is a base class for all weapons entities in Portal 1 and 2. (Which is redundant in {{p2}} because there's only one.) | ||
{{portal | |||
While its classname entity goes entirely unused, it can be repurposed by maps and mods to make simple custom weapons. | |||
If a valid weapon script named <code>weapon_portal_base.txt</code> is placed in the <code>/scripts/</code> folder, it will use that script to define its models, ammo type, etc (this works even if the script is packed into the map!). If the script allows the weapon to fire bullets, it will shoot as a low accuracy machine gun, similar to how the [[weapon_ar2|AR2]] fires (it has no secondary fire though). If its ammo type is valid, it will do damage like any other weapon, allowing for the creation of a fully custom machine gun without any new weapon code. | |||
If the script is one that doesn't shoot bullets (for example, if the gravity gun script is copied over), it will still act as a viewmodel and play firing animations, which is perfect for making new mechanically distinct weapons via entities like {{cl|game_ui}} (for getting player left and right clicks) and {{cl|logic_measure_movement}} (to move entities to the players eye position, for spawning projectiles or other weapon effects). | |||
If the player doesn't have an [[item_suit]] (which is never the case in Portal 2, as it doesn't exist there), the command <code>use weapon_portal_base</code> can be used to switch to this weapon, and <code>use [[weapon_portalgun]]</code> can be used to switch back to the portal gun. | |||
Create a ''weapon_portal_base.txt'' and put it in the ''scripts/'' folder to create a custom weapon. | |||
{{note|Bullets don't do any damage in Portal 2, but this may be due to there not being any known valid ammo types in Portal 2.}} | |||
{{todo|If one is found, it may allow for damage.}} | |||
{{bug|Going through a [[trigger_portal_cleanser]] after the player has placed portals will show the portal gun's fizzle animation, even if the player is not holding the portal gun. This can be worked around by setting up a [[trigger_multiple]] and a [[game_ui]] to hide the player's held weapon while they walk through the fizzler.}} | |||
==FGD Code== | |||
<pre> | |||
@PointClass base(Weapon) studio("models/weapons/w_portalgun.mdl") = weapon_portal_base : "Custom Weapon (weapon_portal_base)" [] | |||
</pre> | |||
==Credits== | |||
This article has been copied from the [https://srcents.miraheze.org/wiki/Main_Page Source Entities Wiki]. | |||
Original article by Pinsplash: https://srcents.miraheze.org/wiki/CWeaponPortalBase |
Revision as of 14:50, 26 July 2023
Template:Entity It's a code class in
which is a base class for all weapons entities in Portal 1 and 2. (Which is redundant in
because there's only one.)
While its classname entity goes entirely unused, it can be repurposed by maps and mods to make simple custom weapons.
If a valid weapon script named weapon_portal_base.txt
is placed in the /scripts/
folder, it will use that script to define its models, ammo type, etc (this works even if the script is packed into the map!). If the script allows the weapon to fire bullets, it will shoot as a low accuracy machine gun, similar to how the AR2 fires (it has no secondary fire though). If its ammo type is valid, it will do damage like any other weapon, allowing for the creation of a fully custom machine gun without any new weapon code.
If the script is one that doesn't shoot bullets (for example, if the gravity gun script is copied over), it will still act as a viewmodel and play firing animations, which is perfect for making new mechanically distinct weapons via entities like Template:Cl (for getting player left and right clicks) and Template:Cl (to move entities to the players eye position, for spawning projectiles or other weapon effects).
If the player doesn't have an item_suit (which is never the case in Portal 2, as it doesn't exist there), the command use weapon_portal_base
can be used to switch to this weapon, and use weapon_portalgun
can be used to switch back to the portal gun.
Create a weapon_portal_base.txt and put it in the scripts/ folder to create a custom weapon.


FGD Code
@PointClass base(Weapon) studio("models/weapons/w_portalgun.mdl") = weapon_portal_base : "Custom Weapon (weapon_portal_base)" []
Credits
This article has been copied from the Source Entities Wiki.
Original article by Pinsplash: https://srcents.miraheze.org/wiki/CWeaponPortalBase