Jump to content
ℹ️ Intermittent Download History issues ×

How to reference all actors in a script?


Nexusmodsaccountno2

Recommended Posts

I want to make a weapon that heals the player's combat target.

 

Setignorefriendlyhits

 

seems the best way to do this but that function requires a reference to work right?

 

Actorref.Setignorefriendlyhits 1

 

I want to be able to heal any actor, so how do I set up the script so all actors everywhere ignore a friendly hit and don't get aggroed at the player for trying to heal them?

Link to comment
Share on other sites

Looking at how other mods handle a similar situation is a useful idea. There is the mod "Medicine Gun George - NPC Healing Medical Rifle", which uses two different types of ammo to put the "patient" to "sleep" (probably "unconscious" by way of zero fatigue) before healing, then different ammo to "wake them up". The mod "Heal Others" or the related "Heal Others - Craftable" uses "aid items" such as a stim-pack instead of a weapon.

 

It's my understanding that, as stated, your goal of a script affecting ALL actors is unobtainable. The best you could do would be to affect all the actors in the current cell, but there isn't a built-in function for that. (You would have to build an array of all the actor references in the cell whenever the cell loads, and then apply your desired effect to each ref in the array.) But for your purposes, that wouldn't work out either. In order for someone to "Ignore friendly hits", they first have to be a member of a "faction" which is friendly to the "player faction". And if they are "friendly", then they aren't going to be "hostile" in the first place.

 

It would appear what is needed in order to use the specific "Setignorefriendlyhits" function is an "object effect" to the weapon's projectile which then set the actor into a special faction which is already "friendly", then inflict the "healing" damage, and finally remove them from that special faction (perhaps after the "effect duration").

 

-Dubious-

Link to comment
Share on other sites

Shameless plug but I made a gun that had exactly this: https://www.nexusmods.com/newvegas/mods/66111

The ionic scrambler ammo heals companions and does not aggro neutrals, but knock down hostiles. Feel free to rip out the code and change the actor filtering conditions however you need.

 

The gun does it by ref walking but for your purpose, GetCombatAllies should be enough.

Link to comment
Share on other sites

Thanks all for the helpful advice.

 

I looked at the groovatron code...that is some complex scripting right there...

From what I can tell it seems to have a mix of things happening.

 

Stopcombat

 

Seems to be in there but it won't quite work for what I want. There is some faction changing and other stuff that I have no idea what it is doing.

 

I'll check out those other mods and see if I can make some sense of what is going on, thanks for the leads.

 

 

I considered listing each and every actorref.setignorefriendlyhits to get the job done...there are only what, a couple hundred actors to list right...heh.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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