Modifying entity spawnflags / keyvalues with a script file
I've been looking at the KeyValues Class and found this site: http://wiki.alliedmods.net/KeyValues_(S ... _Scripting.
I still have no clue as to how to address the various keyvalues properly. This vscript command:
if (KvJumpToKey(EntityGroup[2], "enabled"))
produces the following error message:
AN ERROR HAS OCCURED [the index 'KvJumpToKey' does not exist]
Does that mean that the entity itself cannot be addressed as the 'holder' of the keyvalues? I have Basic knowledge of C++ and have only started to look into vscripting a couple of days ago so please forgive me if I'm totally blind here. Any help would be greatly appreciated.
). However, this set of commands provides read-only features ... any chance that there is a way to modify keyvalues?
What you're looking for is the second (undocumented) use of AddOutput. You can use it to change any keyvalues you want, although for some (such as changing to a non-precached model) it might not be a smooth change.
Instead of the string with all of the colons specifying an output, use AddOutput > KeyValue Value. For example, to make a cube become invisible when a button is pressed, OnPressed > cube > AddOutput > rendermode 10.
Note: If you're doing this from the console, you need to wrap the "KeyValue Value" bit in quotes or it will complain.
Spawnflags I'm not sure about, but you should be able to change them (albeit all at once) with AddOutput spawnflags 42 (or whatever).
However, EntFire doesn't touch spawnflags so I will try your suggestion. Thanks for your input!!! ![]()
Thanks for the AddOutput hint. Will be trying that tomorrow!
- Flags can be changed through an output using the ent_fire [name] addoutput "spawnflags [#]" command.
- Changing the keyvalues can cause errors or even crashes when the entity relies on this single state. I can't tell you what exact entities, but there are a few.EntFire([name], addoutput, spawnflags [number], [delay])
However I wouldn't rely on changing the keyvalues for your mapping solution. Usually the only reason why you would want to change the keyvalues is if you want to script and create things inside the game. A single state of flags is only what you need as you can create other entities to fulfil your solution.
""""""
ChickenMobile wrote:
However I wouldn't rely on changing the keyvalues for your mapping solution. Usually the only reason why you would want to change the keyvalues is if you want to script and create things inside the game. A single state of flags is only what you need as you can create other entities to fulfil your solution.
That's great advice and I already thought of the alternative solution to just add multiple entities with different spawnflags and to switch between them. However, the amount of actions available with EntFire for each entity is poorly documented in the VDC. At least I couldn't find any overview of what actions are available for each entity and on top of that it would be great to have an explanation of what some of the actions do. So far I always check in the console with the ent_fire command and autocomplete which is a bit annoying ... is there another documentation of this?
Just wondering...you do understand inputs and outputs, right? You learned those before you started VScripting?
It would be so much more efficient if you could just access the KeyValues ... that's all.
As launchtarget you can take preferably info_targets, but !player is possible, too. In my map (a bossfight), I parented a point_template to the player, which created static info_targets, which were then shot by bombss a short period of time afterwards.
Also, remember that the catapult only applies a force once. If bombs target the player, for example, the player can dodge, because it won't keep correcting them. This wrecked a big section of a map once when I didn't count on player movement.
Let's just take the trigger_catapult as an example: when I check the corresponding page on VDC, I see multiple entries. Looking at the keyvalues of a trigger_catapult in Hammer will show quite a lot in SmartEdit but once you turn it off there's just about half of the keyvalues left. So this is where you start trying what would be the right key value combination to work with. On top of that, and not necessarily making things easier, there's the autocomplete of the ingame console on the ent_fire command. I've gone through the trouble of compiling the list of 'actions' the Portal 2 console offers for a trigger_catapult entity:
addcontext
addoutput
alpha
alternativesorting
callscriptfunction
clearcontext
clearparent
color
disable
disabledamageforces
disabledraw
disabledrawinfastreflection
disablereceivingflashlight
disableshadow
dispatchresponse
enable
enabledamageforces
enabledraw
enabledrawinfastreflection
enablereceivingflashlight
enableshadow
endtouch
fireuser1
fireuser2
fireuser3
fireuser4
kill
killhierarchy
removecontext
removepaint
runscriptcode
runscriptfile
setdamagefilter
setexactvelocitychoicetype
setlaunchtarget
setlocalangles
setlocalorigin
setparent
setparentattachment
setparentattachmentmainoffset
setphysicsspeed
setplayerspeed
setteam
starttouch
toggle
touchtest
use
You see that there are substantial differences between all 'lists' either on VDC or in Hammer or in Portal 2 console. I thought it would be easy to go to the source and make sense of this all ... look into the entity keyvalues themselves instead of looking into secondary sources.
Have I made myself clear now? Is there a way to access (read-only) the Entity keyvalue keys and preferably also their values through vscript or whatever else?
Brainstone wrote:
Give your trigger_catapult the input setlaunchtarget . Not listed anywhere, but actually works. Some guys on the forum found this out once. I stumbled upon it and used it. Works perfectly.As launchtarget you can take preferably info_targets, but !player is possible, too. In my map (a bossfight), I parented a point_template to the player, which created static info_targets, which were then shot by bombss a short period of time afterwards.
Thanks for that tip ... but I don't want the trigger_catapult to aim at the player and I had already found 'setlaunchtarget' as you can see in my previous post. Believe me when I say there's no way you can achieve what I want with the IO system of Hammer because (a) there is no particular target to catapult to, and (b) I need to stay in Charge of the flight route which is not possible with Launch targets. In fact I need vector calculations with coordinates that are set by actions of the player. I wish I could be more clear but i don't wanna give my idea away.
Thanks again!