Weapon portal base: Difference between revisions
mNo edit summary |
m (Classifying as model entity) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | {{LanguageBar}} | ||
{{ent not in fgd}}{{this is a| | {{CD|CWeaponPortalBase|base=CBaseCombatWeapon|nolink=1|file1=weapon_portalbase.cpp}} | ||
{{ent not in fgd}}{{this is a|model entity|name=weapon_portal_base|series=Portal}} | |||
{{Portal topicon}}{{P2 topicon}} | {{Portal topicon}}{{P2 topicon}} | ||
[[Category:Weapons]] | [[Category:Weapons]] | ||
Line 6: | Line 7: | ||
It is functionally similar to [[baseportalcombatweapon]] and [[basehlcombatweapon]] but not entirely. | It is functionally similar to [[baseportalcombatweapon]] and [[basehlcombatweapon]] but not entirely. | ||
While its classname entity goes entirely unused, it can be repurposed by maps and mods to make simple custom weapons.<br> | While its classname entity goes entirely unused, it can be repurposed by maps and mods to make simple custom weapons.<br> | ||
{{Bug| hidetested=1 |For an unknown reason custom weapons | {{Bug| hidetested=1 |For an unknown reason, custom weapons that have a ammo type set can be used only once.}} | ||
==Creation== | ==Creation== | ||
If a valid weapon script named {{Code|preset=3|weapon_portal_base.txt}} is placed in the {{path|/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 [[weapon_ar2|AR2]] fires. | If a valid weapon script named {{Code|preset=3|weapon_portal_base.txt}} is placed in the {{path|/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 [[weapon_ar2|AR2]] fires. | ||
{{note|Weapons created using {{Code|preset=3|weapon_portal_base}} do not have a secondary fire}} | {{note|Weapons created using {{Code|preset=3|weapon_portal_base}} do not have a secondary fire}} | ||
Line 16: | Line 16: | ||
==Fixing the damage== | ==Fixing the damage== | ||
In {{portal2|4}}, all the {{hl2|4}} ammotypes exist in game, but the convars for damage and max ammo capacity are all set to 0 by default. Copying {{path|hl2/cfg/skill|cfg}} over from {{hl2|4}} into {{path|portal2/cfg/skill_portal2|cfg}} or setting the convars directly allows the {{hl2|4}} ammotypes to be used to create damaging weapons in {{p2|4}}.<br> | In {{portal2|4}}, all the {{hl2|4}} ammotypes exist in game, but the convars for damage and max ammo capacity are all set to 0 by default. Copying {{path|hl2/cfg/skill|cfg}} over from {{hl2|4}} into {{path|portal2/cfg/skill_portal2|cfg}} or setting the convars directly allows the {{hl2|4}} ammotypes to be used to create damaging weapons in {{p2|4}}.<br> | ||
Paired in conjunction with {{p2|4}}'s coop mode this allows for the creation of deathmatch style maps. | Paired in conjunction with {{p2|4}}'s coop mode this allows for the creation of deathmatch style maps. | ||
Line 23: | Line 22: | ||
==Custom "weapons"== | ==Custom "weapons"== | ||
If the script is one that doesn't shoot bullets (for example, if the [[weapon_physcannon| 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 [[game_ui]] (for getting player left and right clicks) and [[logic_measure_movement]] (to move entities to the players eye position, for spawning projectiles or other weapon effects). | If the script is one that doesn't shoot bullets (for example, if the [[weapon_physcannon|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 [[game_ui]] (for getting player left and right clicks) and [[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]], the command {{Code|preset=3|use weapon_portal_base}} can be used to switch to this weapon, and {{Code|preset=3|use [[weapon_portalgun]]}} can be used to switch back to the portal gun. | If the player doesn't have an [[item_suit]], the command {{Code|preset=3|use weapon_portal_base}} can be used to switch to this weapon, and {{Code|preset=3|use [[weapon_portalgun]]}} can be used to switch back to the portal gun. |
Latest revision as of 04:36, 19 May 2025
![]() |
---|
CWeaponPortalBase |
![]() |
weapon_portal_base
is a model entity available in Portal series.
It's a code class in Portal and
Portal 2 which is a base class for all weapon entities.
It is functionally similar to baseportalcombatweapon and basehlcombatweapon but not entirely.
While its classname entity goes entirely unused, it can be repurposed by maps and mods to make simple custom weapons.

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

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.
Fixing the damage
In Portal 2, all the
Half-Life 2 ammotypes exist in game, but the convars for damage and max ammo capacity are all set to 0 by default. Copying
hl2/cfg/skill.cfg
over from Half-Life 2 into
portal2/cfg/skill_portal2.cfg
or setting the convars directly allows the Half-Life 2 ammotypes to be used to create damaging weapons in
Portal 2.
Paired in conjunction with Portal 2's coop mode this allows for the creation of deathmatch style maps.
Custom "weapons"
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 game_ui (for getting player left and right clicks) and 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, 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.

FGD Code
@PointClass base(Weapon,Targetname, Parentname) studio("models/weapons/w_portalgun.mdl") = weapon_portal_base : "Custom Weapon"[]
See also
- weapon_portalgun
- basehlcombatweapon
- baseportalcombatweapon
- weapon_cubemap
- weapon_promo_antenna_ball
- weapon_promo_antenna_egg
- weapon_promo_helmet_ball
- weapon_promo_helmet_egg
Credits
This article has been copied from the Source Entities Wiki.
Original article by Pinsplash: https://srcents.miraheze.org/wiki/CWeaponPortalBase