Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Removal of [instant_trig] without [noclear 1] variable  (Read 1032 times)

0 Members and 1 Guest are viewing this topic.

Offline Pepsifan04

  • *
  • *
  • +12% chance to make useful post
  • Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...
Basically I've made an mapadd logic that checks every 0.5 second for ent. and tries to addoutput to it.
Now the thing I want to do is to remove the instant_trig that is responsible for checking if said ent exists.
I can't use "noclear" variable that would allow me to remove the instant_trig, because if I'll use instant_trig with delay and noclear it basically crashes source with "noFree allocs"
Is there any other way of removing it, or at least stopping it from checking for ents every 0.5 second?
Here my mappadd code:
Code: [Select]

"entities:force_output"
{
"event" {
"targetname" "weapon_custom##"
"action" "addoutput"
"value" "OnPlayerPickup cmd,command,hurrdurr"
}
}


"entities:timer_relay1" {
"instant_trig"
{
"targetname" "force_addoutput"
"keyvalues"
{
"timer" "0.1"
"label" "force_output"
}
}

"instant_trig"
{
"targetname" "timer_relay_1"
"keyvalues"
{
"group" "16"
"timer" "0.3"
"label" "timer_relay2"
}
}
}

"entities:timer_relay2" {
"instant_trig"
{
"targetname" "timer_relay_2"
"keyvalues"
{
"group" "16"
"timer" "0.1"
"label" "timer_relay1"
}
}
}

"entities"{
// it starts checking for entity when player reaches this point
"instant_trig" {
"origin" "-9920 -3366 320"
"keyvalues"
{
"Radius" "40"
"label" "timer_relay1"
}
}

// it should stop when player reaches this point or when player picks up Ent (weapon_custom##)
// "instant_trig" {
// "origin" "-9121 -3423 272"
// "keyvalues"
// {
// "removegroup" "16"
// }
// }
}

Ideally it'd be to remove the instant_trig when player picks up weapon, but removing said ents when player reaches certain point will also satisfy me.
Thanks in advance.
« Last Edit: April 19, 2014, 03:04:36 PM by Pepsifan04 »
DROP DATABASE bsnooch

Offline Rook

  • *
  • +2% chance to make useful post
  • Rook has no influence.
Re: Removal of [instant_trig] without [noclear 1] variable
« Reply #1 on: April 19, 2014, 01:12:48 PM »
You should be wary of checking items and weapons for collisions. They seem to have their own collision code and I always had problems getting them to collide with sensors. I also try to stay away from instant_trig because of the 500ms delay and a few other things. That said, here's my concept for an alternative (as taken from one of my old projects):

Code: [Select]
// map_name.txt

"entities" {
"lua" {
"callfunc" "boot"
}
}

Code: [Select]
-- map_name.lua

function boot()
weaponChecks()
end

function weaponChecks()
local ents = {
logic_auto = {
spawnflags = '1',
OnMapSpawn = {
'trigger_multiple,FireUser1,,0,-1',
'cmd,Command,ent_bbox trigger_multiple,0,-1',
'cmd,Command,developer 1,0,-1'
}
},
playerArch = {
org = HL2.Vector(-9920, -3366, 320),
classname = 'trigger_multiple',
targetname = 'player_arch',
spawnflags = '1', -- collide with player only
onStartTouch = 'weapon_timer,Enable,,0,-1',
onEndTouch = 'weapon_timer,Disable,,0,-1',
OnUser1 = {
'!self,addoutput,mins -40 -40 0,0,-1',
'!self,addoutput,maxs 40 40 64,0,-1',
'!self,addoutput,solid 2,0,-1',
},
},
playerHall = {
org = HL2.Vector(-9921, -3423, 272),
classname = 'trigger_multiple',
targetname = 'player_hall',
spawnflags = '1',
OnTrigger = 'weapon_relay,FireUser2,,0,-1',
OnUser1 = {
'!self,addoutput,mins -40 -40 0,0,-1',
'!self,addoutput,maxs 40 40 64,0,-1',
'!self,addoutput,solid 2,0,-1',
},
},
weaponTimer = {
classname = 'logic_timer',
targetname = 'weapon_timer',
startDisabled = '1',
refireTime = '0.5',
OnTimer = {
'weapon_custom##,AddOutput,OnPlayerPickup weapon_relay:FireUser1::0:1,0,-1',
},
},
weaponRelay = {
classname = 'logic_relay',
targetname = 'weapon_relay',
OnUser1 = { -- weapon acquired
'player_arch,Kill,,0,1',
'player_hall,Kill,,0,1',
'weapon_timer,Kill,,0,1',
'!self,Kill,,0,1'
},
OnUser2 = { -- weapon skipped
'weapon_custom##,Kill,,0,-1'
'!self,FireUser1,,0.1,-1',
}
}
}
spawn(ents)
end

function spawn(ents)
local org, ang = VECTORZERO, VECTORZERO
for entry, settings in pairs(ents) do
local ent = HL2.CreateEntity(settings.classname or entry, settings.org or org, settings.ang or ang)
if ent then
for k, v in pairs(settings) do
if type(v) ~= 'table' then
HL2.KeyValue(ent, k, v)
else
for _, output in pairs(v) do
HL2.KeyValue(ent, k, output)
end
end
end
HL2.SpawnEntity(ent)
end
end
end

If you want, you can disable the triggers in-game and tweak their exact shapes to suit you (e.g. ent_fire player_arch Disable & ent_fire player_arch addoutput "mins -64 -64 -200"). It beats eyeballing the radius if you ask me. In the example, I've already made the bounding boxes visible to make this easy.

e: And please forgive me for not making the example in .txt. I always preferred doing it in Lua because it's a hell of a lot easier to catch a syntax error. Even if you don't, the console will tell you where it is.
« Last Edit: April 19, 2014, 01:27:22 PM by Rook »

Offline Pepsifan04

  • *
  • *
  • +12% chance to make useful post
  • Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...Pepsifan04 might someday be someone...
Re: Removal of [instant_trig] without [noclear 1] variable
« Reply #2 on: April 19, 2014, 03:02:31 PM »
Thanks for quick reply.
I've actually made it work with Logic_timer just before you posted.
It's much more manageable and less resource demanding, I'm still using Instant_trig to enable it though.
(I'm spawning it with "StartDisabled" "1")

And thanks to Logic_timer being an actual source ent I can easily kill it by adding
Code: [Select]
"OnTimer" "Weapon_custom##,addoutput,OnPlayerPickup force_output_timer:kill,0,-1"
Thanks anyway, I still might use some of your code in the future.
 
DROP DATABASE bsnooch