Jump to content

Applying object effects to a non-actor on hit


Recommended Posts

That really depends on the object you are talking about and the effect you want. Give some more explicit details. I Mean, you can shoot at a door and have it explode, but you can't use the stimpak heal effect on a wall tile, know what I mean?
Link to comment
Share on other sites

I wrote a script that, depending on the object type, either adds Repairable Parts to your inventory, or adds to your scrap material count for the RTS - New Wave mod, after which the object is disabled and marked for deletion. I would like the script to run on any object hit (Even statics as my code correctly handles them), but the only objects that it actually does something to will be inventory items and movable statics, basically anything you could grab. I would prefer to have not only the object directly hit, but also all objects in the range of a custom explosion be affected. The only way I know how to accomplish this at the moment is to add an OnHitWith script to every individual object I would like to be affected and I don't want to do that because it would interfere with other mods and is a ton of work. Through debugging I've found that my ScriptEffectStart block runs only on actors (Dead or alive) that are hit with the projectile/explosion and nothing else. Any ideas?
Link to comment
Share on other sites

First, I want to say that in accomplishing this, there is the chance that your script will kill quests and possibly cause CTDs in the game. That might happen if the affected objects happen to be quest items or persistent references used by other objects. Going around deleting vanilla objects in the game is never a good idea.

 

You can't cast spells (effect scripts) on non-Actors, but you can apply object scripts. There may be a better way, but the only way I can think of doing this would be to use FOSE's ref-walk capability and have a script that check all nearby references by object type before the explosion occurs and store their X-Y-Z coordinates in several Form Lists (one form list for each coordinate and one for the reference itself). Then after the explosion occurs, run through the form lists and check the X-Y-Z coordinates again to see if they have been moved by the explosion. Then apply your disable and mark for delete to the reference objects that have been moved. You can do the second check a few frames after the explosion to catch them in mid-air.

 

To me, this is a massive undertaking for very little gain and a large downside, not to mention that the amount of ref-walking will surely cause an FPS drop while the script is running. Why not just make a perk that allows a new menu option that will allow the player to choose to transform a selected object into the parts you want instead? Its a whole lot easier. You could then just 'dismantle' the object for its parts and leave it in the game so as not to break the game. You would still need to add the object to a form list to prevent any further dismantling.

 

Just my opinion, Good luck.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...