Creating "medkit" drops on player death

All other Source.Python topics and issues.
JustGR
Junior Member
Posts: 20
Joined: Tue Apr 28, 2020 12:39 pm

Creating "medkit" drops on player death

Postby JustGR » Tue Jun 02, 2020 1:43 am

This is a WIP, but I wish to spawn a medkit at a player when they die. For now I have it hooked up to spawn a medkit when a TypedSayCommand is triggered. Snippet below:

Syntax: Select all

from entities.entity import Entity
from engines.precache import Model
from players.entity import Player

my_model = Model('models/weapons/w_eq_medkit.mdl')

....
player = Player.from_userid(index)
entity = Entity.create('item_healthkit')
entity.model = my_model
entity.origin = player.view_coordinates
entity.spawn()
....

I know that the medkit model exists in CS:GO, but for some reason item_healthkit is not a recognized classname for Sourcepython. I tried swapping out Entity for Weapon, but same result, so am a bit lost.

Also might need a primer on how entities and props work together in SP.
Last edited by L'In20Cible on Tue Jun 02, 2020 4:27 am, edited 1 time in total.
Reason: [code] → [python]
User avatar
L'In20Cible
Project Leader
Posts: 1381
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Creating "medkit" drops on player death

Postby L'In20Cible » Tue Jun 02, 2020 4:24 am

That isn't a valid entity for that game. You can get a full list of entities for a game with the dumpentityfactories command:

Syntax: Select all

_firesmoke
_plasma
ai_ally_speech_manager
ai_battle_line
ai_changehintgroup
ai_changetarget
ai_goal_assault
ai_goal_fightfromcover
ai_goal_follow
ai_goal_lead
ai_goal_lead_weapon
ai_goal_standoff
ai_hint
ai_network
ai_script_conditions
ai_sound
ai_speechfilter
aiscripted_schedule
aitesthull
ambient_generic
ammo_338mag
ammo_357sig
ammo_357sig_np_reserve
ammo_357sig_p250
ammo_357sig_small
ammo_45acp
ammo_50ae
ammo_556mm
ammo_556mm_box
ammo_556mm_small
ammo_57mm
ammo_762mm
ammo_9mm
ammo_buckshot
assault_assaultpoint
assault_rallypoint
baseprojectile
beam
beam_spotlight
breachcharge_projectile
bumpmine_projectile
cfe_player_decal
chicken
color_correction
color_correction_volume
commentary_auto
cs_bot
cs_bot_patrol_area
cs_bot_patrol_area_group
cs_bot_patrol_area_respawn
cs_bot_patrol_route_respawn
cs_bot_patrol_route_waypoint
cs_gamerules
cs_player_manager
cs_ragdoll
cs_team_manager
cycler
cycler_actor
cycler_blender
cycler_flex
cycler_weapon
cycler_wreckage
dangerzone_controller
dangerzone_entity
decoy_projectile
drone
dronegun
dynamic_prop
dz_door
ent_snowball_pile
entity_blocker
entityflame
env_ambient_light
env_beam
env_beverage
env_blood
env_bubbles
env_cascade_light
env_credits
env_debughistory
env_detail_controller
env_dof_controller
env_dustpuff
env_dusttrail
env_effectscript
env_embers
env_entity_dissolver
env_entity_freezing
env_entity_igniter
env_entity_maker
env_explosion
env_fade
env_fire
env_fire_trail
env_firesensor
env_firesource
env_fog_controller
env_funnel
env_gascanister
env_global
env_glow
env_gunfire
env_hudhint
env_instructor_hint
env_laser
env_lightglow
env_message
env_microphone
env_movieexplosion
env_muzzleflash
env_outtro_stats
env_particle_performance_monitor
env_particle_trail
env_particlefire
env_particlelight
env_particlescript
env_particlesmokegrenade
env_physexplosion
env_physimpact
env_physwire
env_player_surface_trigger
env_projectedtexture
env_quadraticbeam
env_ragdoll_boogie
env_rockettrail
env_rotorshooter
env_screeneffect
env_screenoverlay
env_shake
env_shooter
env_smokestack
env_smoketrail
env_soundscape
env_soundscape_proxy
env_soundscape_triggerable
env_spark
env_splash
env_sporeexplosion
env_sporetrail
env_sprite
env_sprite_clientside
env_sprite_oriented
env_spritetrail
env_steam
env_steamjet
env_sun
env_texturetoggle
env_tilt
env_tonemap_controller
env_tracer
env_viewpunch
env_wind
env_zoom
event_queue_saveload_proxy
filter_activator_class
filter_activator_context
filter_activator_mass_greater
filter_activator_model
filter_activator_name
filter_activator_team
filter_base
filter_damage_type
filter_enemy
filter_multi
fire_cracker_blast
fish
flashbang_projectile
fog_volume
func_areaportal
func_areaportalwindow
func_block_dm_spawns
func_bomb_target
func_breakable
func_breakable_surf
func_brush
func_button
func_buyzone
func_clip_vphysics
func_conveyor
func_detail_blocker
func_door
func_door_rotating
func_dustcloud
func_dustmotes
func_fish_pool
func_footstep_control
func_guntarget
func_hostage_rescue
func_illusionary
func_instance_io_proxy
func_ladderendpoint
func_lod
func_monitor
func_movelinear
func_nav_avoidance_obstacle
func_nav_blocker
func_no_defuse
func_occluder
func_physbox
func_physbox_multiplayer
func_plat
func_platrot
func_precipitation
func_precipitation_blocker
func_proprrespawnzone
func_pushable
func_reflective_glass
func_rot_button
func_rotating
func_smokevolume
func_survival_c4_target
func_tablet_blocker
func_tank
func_tankairboatgun
func_tankapcrocket
func_tanklaser
func_tankpulselaser
func_tankrocket
func_tanktrain
func_trackautochange
func_trackchange
func_tracktrain
func_train
func_traincontrols
func_useableladder
func_vehicleclip
func_wall
func_wall_toggle
func_water
func_water_analog
func_weight_button
funCBaseFlex
game_coopmission_manager
game_end
game_gib_manager
game_money
game_player_equip
game_player_team
game_ragdoll_manager
game_round_end
game_score
game_survival_logic
game_text
game_ui
game_weapon_manager
game_zone_player
generic_actor
gib
gibshooter
global_chatter
grassburn
grenade
hammer_updateignorelist
handle_dummy
handle_test
hegrenade_projectile
hostage_carriable_prop
hostage_entity
inferno
info_armsrace_counterterrorist
info_armsrace_terrorist
info_bomb_target_hint_A
info_bomb_target_hint_B
info_camera_link
info_constraint_anchor
info_deathmatch_spawn
info_enemy_terrorist_spawn
info_game_event_proxy
info_gascanister_launchpoint
info_hint
info_hostage_rescue_zone_hint
info_hostage_spawn
info_intermission
info_ladder_dismount
info_landmark
info_map_parameters
info_map_region
info_mass_center
info_node
info_node_air
info_node_air_hint
info_node_climb
info_node_hint
info_node_link
info_node_link_controller
info_null
info_overlay_accessor
info_paradrop_denial
info_particle_system
info_player_counterterrorist
info_player_deathmatch
info_player_logo
info_player_ping
info_player_start
info_player_teamspawn
info_player_terrorist
info_projecteddecal
info_radial_link_controller
info_remarkable
info_target
info_target_instructor_hint
info_teleport_destination
info_vehicle_groundspawn
info_view_parameters
infodecal
instanced_scripted_scene
item_assaultsuit
item_cash
item_coop_coin
item_cutters
item_defuser
item_dogtags
item_heavyassaultsuit
item_kevlar
item_nvgs
item_sodacan
keyframe_rope
keyframe_track
light
light_directional
light_dynamic
light_environment
light_glspot
light_spot
logic_active_autosave
logic_auto
logic_autosave
logic_branch
logic_branch_listener
logic_case
logic_choreographed_scene
logic_collision_pair
logic_compare
logic_eventlistener
logic_eventlistener_itemequip
logic_lineto
logic_measure_movement
logic_multicompare
logic_navigation
logic_playerproxy
logic_playmovie
logic_proximity
logic_random_outputs
logic_register_activator
logic_relay
logic_scene_list_manager
logic_script
logic_timer
material_modify_control
math_colorblend
math_counter
math_remap
model_studio
molotov_projectile
momentary_door
momentary_rot_button
monster_furniture
monster_generic
move_keyframed
move_rope
multisource
npc_furniture
npc_heardanger
npc_vehicledriver
paradrop_chopper
path_corner
path_corner_crash
path_track
phys_ballsocket
phys_bone_follower
phys_constraint
phys_constraintsystem
phys_convert
phys_hinge
phys_keepupright
phys_lengthconstraint
phys_magnet
phys_motor
phys_pulleyconstraint
phys_ragdollconstraint
phys_ragdollmagnet
phys_slideconstraint
phys_spring
phys_thruster
phys_torque
physics_cannister
physics_entity_solver
physics_npc_solver
physics_prop
physics_prop_ragdoll
physics_prop_statue
planted_c4
planted_c4_survival
planted_c4_training
player
player_loadsaved
player_manager
player_speedmod
player_weaponstrip
point_anglesensor
point_angularvelocitysensor
point_bonusmaps_accessor
point_broadcastclientcommand
point_camera
point_clientcommand
point_commentary_node
point_commentary_viewpoint
point_devshot_camera
point_dz_coop_itemspawn
point_dz_coop_itemspawn_group
point_dz_dronegun
point_dz_itemspawn
point_dz_itemspawn_group
point_dz_parachute
point_dz_weaponspawn
point_dz_weaponspawn_group
point_enable_motion_fixup
point_entity_finder
point_gamestats_counter
point_give_ammo
point_hiding_spot
point_hurt
point_message
point_playermoveconstraint
point_posecontroller
point_proximity_sensor
point_servercommand
point_spotlight
point_surroundtest
point_teleport
point_template
point_tesla
point_velocitysensor
point_viewcontrol
point_viewcontrol_multiplayer
point_viewproxy
point_worldtext
postprocess_controller
predicted_viewmodel
prop_ammo_box_generic
prop_counter
prop_door_rotating
prop_dynamic
prop_dynamic_glow
prop_dynamic_ornament
prop_dynamic_override
prop_exploding_barrel
prop_hallucination
prop_loot_crate
prop_mapplaced_long_use_entity
prop_metal_crate
prop_money_crate
prop_paradrop_crate
prop_physics
prop_physics_multiplayer
prop_physics_override
prop_physics_respawnable
prop_ragdoll
prop_ragdoll_attached
prop_sphere
prop_talker
prop_vehicle
prop_vehicle_driveable
prop_weapon_refill_heavyarmor
prop_weapon_upgrade_armor
prop_weapon_upgrade_armor_helmet
prop_weapon_upgrade_chute
prop_weapon_upgrade_contractkill
prop_weapon_upgrade_exojump
prop_weapon_upgrade_helmet
prop_weapon_upgrade_tablet_droneintel
prop_weapon_upgrade_tablet_highres
prop_weapon_upgrade_tablet_zoneintel
radar_jammer
raggib
rope_anchor
scene_manager
scripted_scene
scripted_sentence
scripted_sequence
scripted_target
shadow_control
simple_physics_brush
simple_physics_prop
sky_camera
skybox_swapper
smokegrenade_projectile
snowball_projectile
soundent
spark_shower
spotlight_end
sunlight_shadow_control
survival_spawn_chopper
tagrenade_projectile
tanktrain_ai
tanktrain_aitarget
target_cdaudio
target_changegravity
te_tester
team_manager
test_effect
test_proxytoggle
test_traceline
trigger
trigger_auto_crouch
trigger_autosave
trigger_bomb_reset
trigger_brush
trigger_cdaudio
trigger_changelevel
trigger_fog
trigger_gravity
trigger_hierarchy
trigger_hurt
trigger_impact
trigger_look
trigger_multiple
trigger_once
trigger_playermovement
trigger_proximity
trigger_push
trigger_remove
trigger_safemoneygather
trigger_serverragdoll
trigger_softbarrier
trigger_soundoperator
trigger_soundscape
trigger_survival_playarea
trigger_teleport
trigger_togglesave
trigger_tonemap
trigger_transition
trigger_vphysics_motion
trigger_wind
vgui_movie_display
vgui_screen
vgui_screen_team
vgui_slideshow_display
vgui_world_text_panel
viewmodel
vote_controller
water_lod_control
waterbullet
weapon_ak47
weapon_aug
weapon_awp
weapon_basecsgrenade
weapon_bizon
weapon_breachcharge
weapon_bumpmine
weapon_c4
weapon_cs_base
weapon_csbase_gun
weapon_deagle
weapon_decoy
weapon_elite
weapon_famas
weapon_fists
weapon_fiveseven
weapon_flashbang
weapon_g3sg1
weapon_galil
weapon_galilar
weapon_glock
weapon_healthshot
weapon_hegrenade
weapon_hkp2000
weapon_incgrenade
weapon_knife
weapon_knifegg
weapon_m249
weapon_m3
weapon_m4a1
weapon_mac10
weapon_mag7
weapon_melee
weapon_molotov
weapon_mp5navy
weapon_mp7
weapon_mp9
weapon_negev
weapon_nova
weapon_p228
weapon_p250
weapon_p90
weapon_sawedoff
weapon_scar17
weapon_scar20
weapon_scout
weapon_sg550
weapon_sg552
weapon_sg556
weapon_shield
weapon_smokegrenade
weapon_snowball
weapon_ssg08
weapon_tablet
weapon_tagrenade
weapon_taser
weapon_tec9
weapon_tmp
weapon_ump45
weapon_usp
weapon_xm1014
weapon_zone_repulsor
weaponworldmodel
wearable_item
window_pane
world_items
worldspawn


Your best bet is to create it as a prop and implement all its logic yourself. The following thread could gives you some good pointers: viewtopic.php?f=20&t=848&p=5145
JustGR
Junior Member
Posts: 20
Joined: Tue Apr 28, 2020 12:39 pm

Re: Creating "medkit" drops on player death

Postby JustGR » Tue Jun 02, 2020 11:10 pm

I had a look, have a couple of questions. If it would be appropriate to talk about them on the other thread, let me know. For now I'll leave them here.

1. I've never messed with PreHooks or metaclasses before (though I understand the use for the latter). How is it used here?
2. There are a couple of differences between that thread and mine, and I'd rather get things cleared up before I begin. Would there be any real differences going from CS:S to CS:GO? And is it possible to have the medkit be "picked up and used" when walking to it rather than having to "use" it?
User avatar
L'In20Cible
Project Leader
Posts: 1381
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Creating "medkit" drops on player death

Postby L'In20Cible » Wed Jun 03, 2020 1:51 am

JustGR wrote:1. I've never messed with PreHooks or metaclasses before (though I understand the use for the latter). How is it used here?


Most of them has since been added to Entity so you shouldn't have to use those directly. You can find some example by searching for start_touch.

JustGR wrote:2. There are a couple of differences between that thread and mine, and I'd rather get things cleared up before I begin. Would there be any real differences going from CS:S to CS:GO? And is it possible to have the medkit be "picked up and used" when walking to it rather than having to "use" it?

No idea if there will be difference between the 2 games. Probably not, but I have no idea.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests