Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##########################################################
- #
- # Customizable, modular, CPU efficient target practice
- #
- # Author: /u/finicu
- # Last modified: 2020/08/29
- # For /r/wiremod
- # Requires propcore, constraintcore
- #
- @name shooting target
- @outputs TargetPitch
- @persist TARGET_MASS HEIGHT RAND_TIME_SET_UPRIGHT TARGET_PROP:string
- @persist [BOUNDS TARGET]:entity
- @persist TargetPitch
- @trigger none
- if (first())
- {
- # Customize settings here
- HEIGHT = 75 # Distance from chip in source units
- TARGET_MASS = 15000 # in kg
- RAND_TIME_SET_UPRIGHT = 1000 # in ms
- TARGET_PROP = "models/hunter/plates/plate025x025.mdl" # path to prop
- # Do not change things below here
- function number getRelativeRoll(Ent1:entity, Ent2:entity)
- {
- return Ent1:angles():roll() - Ent2:angles():roll()
- }
- entity():propGravity(0)
- entity():setAlpha(0)
- POS = entity():pos() + vec(0, 0, HEIGHT)
- BOUNDS = propSpawn("models/props_phx/construct/metal_wire1x1.mdl", POS, ang(0, 0, 90), 1)
- TARGET = propSpawn(TARGET_PROP, BOUNDS:boxCenterW(), ang(0, 0, 90), 1)
- LINK = holoCreate(0, TARGET:pos() - vec(1, -1, 22), vec(0.3, 0.55, 0.3), ang(0, 0, 90), vec4(255), "models/phxtended/bar1x.mdl")
- holoParent(0, TARGET)
- #Entity=holoCreate(number index,vector position,vector scale,angle ang,vector4 color,string model)
- BOUNDS:setMaterial("models/props_wasteland/wood_fence01a_skin2")
- TARGET:setMaterial("phoenix_storms/stripes")
- noCollideAll(BOUNDS, 1)
- noCollideAll(TARGET, 1)
- TARGET:setMass(TARGET_MASS)
- BOUNDS:setMass(TARGET_MASS * 2)
- BOUNDS:propGravity(0)
- ANCHOR_POINT = BOUNDS:boxCenter() - vec(0, 21, 0)
- BOUNDS:ballsocketTo(TARGET, ANCHOR_POINT, 0, 0, 1)
- BOUNDS:advBallsocketTo(
- 0,
- TARGET,
- 0,
- 0,
- vec(0),
- vec(0),
- 0,
- 0,
- vec(0.1, -0.001, -0.001),
- vec(87.5, 0.001, 0.001),
- vec(0.07),
- 1,
- 0)
- runOnDamage(1, TARGET)
- runOnKeys(owner(), 1)
- }
- # clean up
- if (owner():keyPressed("Z"))
- {
- TARGET:propDelete()
- BOUNDS:propDelete()
- selfDestruct()
- }
- TickDamage = TARGET:getDamage()
- if (TickDamage != 0)
- {
- print("dealt " + TickDamage)
- TARGET:propFreeze(0)
- owner():soundPlay(0, 0, "hl1/fvox/bell.wav")
- TARGET:applyForce(TARGET:up() * vec(TARGET_MASS * 50)) # just a small impulse to knock it over
- timer("ResetTarget", 2000 + randint(-RAND_TIME_SET_UPRIGHT, RAND_TIME_SET_UPRIGHT))
- }
- if (clk("ResetTarget"))
- {
- timer("checkOrientation", 50)
- TargetPitch = getRelativeRoll(TARGET, BOUNDS)
- }
- elseif(clk("checkOrientation"))
- {
- TargetPitch = getRelativeRoll(TARGET, BOUNDS)
- if (abs(TargetPitch) > 2.35)
- {
- timer("checkOrientation", 50)
- TARGET:applyForce(TARGET:up() * vec(-TARGET_MASS * 41))
- }
- else
- {
- TARGET:propFreeze(1)
- owner():soundPlay(1, 0, "hl1/fvox/fuzz.wav")
- }
- }
Add Comment
Please, Sign In to add comment