onepixelsquare Posted July 27, 2006 Share Posted July 27, 2006 Hi Guys, I have had a good search around to find this, but I'm stumped. I know there must be a function to find the object under the player's crosshair ('who you're targetting' basically) - but what is it? something like player.getTarget or similar? Thanks! Link to comment Share on other sites More sharing options...
Vagrant0 Posted July 27, 2006 Share Posted July 27, 2006 Hi Guys, I have had a good search around to find this, but I'm stumped. I know there must be a function to find the object under the player's crosshair ('who you're targetting' basically) - but what is it? something like player.getTarget or similar? Thanks! As far as I'm able to gather, there isn't one. There are only 2 functions that return a target ref. GetCombatTarget doesn't work for player period as the game uses this seperately from what is in crosshair, or something. GetPackageTarget doesn't work either as the player will never execute AI packages. The only way anything similar can be done is through a scripted spell effect, and that has obvious, and not so obvious, limitations. Depending on what you're trying to do, there may be some other ways around this. But those tend to be rather complicated and yield only partial results. Link to comment Share on other sites More sharing options...
onepixelsquare Posted July 27, 2006 Author Share Posted July 27, 2006 Really? Man - that seems like a fairly obvious omission. I mean, I can return a reference to any in game object, just by opening the console and clicking, but the game doesn't allow us to use the same functionality in scripts!? Bah. However, I am already using a scripted spell effect, so maybe that's not such a bad solution - basically I want to move an activator to the ground underneath the targeted entity. You seem like a knowledgable fellow Vagrant - can you point me in the right direction on how to do this in my script? Link to comment Share on other sites More sharing options...
mmmpld Posted July 27, 2006 Share Posted July 27, 2006 Really? Man - that seems like a fairly obvious omission. I mean, I can return a reference to any in game object, just by opening the console and clicking, but the game doesn't allow us to use the same functionality in scripts!? Bah. However, I am already using a scripted spell effect, so maybe that's not such a bad solution - basically I want to move an activator to the ground underneath the targeted entity. You seem like a knowledgable fellow Vagrant - can you point me in the right direction on how to do this in my script?Try this tutorial: http://cs.elderscrolls.com/constwiki/index...om_An_Activator Link to comment Share on other sites More sharing options...
Vagrant0 Posted July 27, 2006 Share Posted July 27, 2006 Hmm, yeah that link does deal with the subject, but I'm not sure if that is helpful here. I guess the main question is what your scripted spell is currently, and what the use of the activator is. Without knowing what methods you're using, or what you want to accomplish, I can't really tell you anything too useful. Link to comment Share on other sites More sharing options...
onepixelsquare Posted July 27, 2006 Author Share Posted July 27, 2006 Hi again, Yep - that tutorial on the wiki is what got me started - however, the example given places the activator on the player, using 'placeAtMe' - as I understand it, this isn't such a great way to go for spell effects, as it leaves activators all over the place. The effect of that tute is, set the activator over the player, then have the activator cast a ranged spell over a given radius. Casting the spell will either create an activator, or move a pre built one (better) to a given location, and then trigger a spell effect from the activator. The script that creates the activator and triggers its effect is fine. That's fine, but I would like to be able to cast a spell to move an activator to a given location (typically around the location of an NPC, or ideally at the location the crosshair is on, thought this could be problematic), and then have other effects emanate from the activator. http://cs.elderscrolls.com/constwiki/index...r_Nearby_Actors demonstrates how to find nearby NPCs - I'm thinking that could be combined with a headingAngle calculation to find the nearest NPC within 1-2 degrees of dead ahead. So really, all I need is a way to target nearby NPCs, and quickly grab their locations. I'll keep trying - thanks for your help guys! Link to comment Share on other sites More sharing options...
Vagrant0 Posted July 27, 2006 Share Posted July 27, 2006 Hi again, Yep - that tutorial on the wiki is what got me started - however, the example given places the activator on the player, using 'placeAtMe' - as I understand it, this isn't such a great way to go for spell effects, as it leaves activators all over the place. The effect of that tute is, set the activator over the player, then have the activator cast a ranged spell over a given radius. Casting the spell will either create an activator, or move a pre built one (better) to a given location, and then trigger a spell effect from the activator. The script that creates the activator and triggers its effect is fine. That's fine, but I would like to be able to cast a spell to move an activator to a given location (typically around the location of an NPC, or ideally at the location the crosshair is on, thought this could be problematic), and then have other effects emanate from the activator. http://cs.elderscrolls.com/constwiki/index...r_Nearby_Actors demonstrates how to find nearby NPCs - I'm thinking that could be combined with a headingAngle calculation to find the nearest NPC within 1-2 degrees of dead ahead. So really, all I need is a way to target nearby NPCs, and quickly grab their locations. I'll keep trying - thanks for your help guys! Yeah, that nearby actor thing would be pretty much the only way to do it without having the player just cast a spell at the target you want to be affected by the activator. As for moving the activator, you might want to look at the moveto function. You just need to place the activator somewhere unreachable so that it can be referenced by the script. However, when I was testing this in relation to a chest, it did seem a bit buggy, ended up crashing the game. So you might want to take some care in testing. If your main concern isn't needing to constantly move the activator, but instead just prevent having so many useless activators from being all over the place, the removeme function might be an easier solution. Just put it in your activator's script, and once the script finishes or when that block is run, the activator will be removed from the world. Their script uses disable at the end to remove the activator, which also works too I think. Link to comment Share on other sites More sharing options...
onepixelsquare Posted July 27, 2006 Author Share Posted July 27, 2006 Excellent mate - that removeMe function is just what I needed. I knew there had to be an equivalent, but I've not seen it in any references. If I did just use the 'cast spell' technique, is it possible to set the activator to the position of the 'strike'? That's exactly what I want, but I don't know how to determine the position the spell has hit. Thanks heaps for all your help! Link to comment Share on other sites More sharing options...
Vagrant0 Posted July 27, 2006 Share Posted July 27, 2006 Excellent mate - that removeMe function is just what I needed. I knew there had to be an equivalent, but I've not seen it in any references. If I did just use the 'cast spell' technique, is it possible to set the activator to the position of the 'strike'? That's exactly what I want, but I don't know how to determine the position the spell has hit. Thanks heaps for all your help! Scripted spells always run on what is affected by that spell. You cast a spell with a script effect on an NPC, that NPC will be the target of the script. Link to comment Share on other sites More sharing options...
onepixelsquare Posted July 29, 2006 Author Share Posted July 29, 2006 Thanks to your help, my new spells are shaping up pretty nicely. I've set a scripted spell to spawn over the target, and cast lightning - the effect is that of summoning a lightning strike down onto your enemy. However, the spell only works when the cast is successful - that is, when you hit someone with it. Is there any way to get the coordinates of the strike? Or another way to activate the script, even if you miss - I'd like the lightning bolt to strike the ground if that's where you cast the spell... On another note - how can I trigger a sound effect via script? Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.