Skip to content

Grr! This is a vent (ignore if you like). Multiple skins wanted.

I'm venting because I want a NPC monster to have multiple skins, but I've discovered that the toolset only allows you to put a skin straight from the blueprints into the skin slot, not into the creature's inventory.

You might be asking why I'd want multiple skins for a single NPC and it's a fair enough question.

I want a particular enemy type to have certain immunities and abilities at night but lose them during the day time. The easiest way to do this would be to have two skins which get swapped by a heartbeat script which checks which skin is equipped plus the day/night flag and, if the wrong skin is equipped for the time of day, switches skins.

I'm hoping that the scripting language will allow me to create two skins on the NPC at spawn and equip the correct skin, but I'm not sure if skins can even be in the inventory at all. I'm pretty sure it was possible in 1.69 but it might not be possible now, with EE.

If I can't create two skins on the NPC then I'll have to go the slow, tedious, inflexible and error-prone route of scripting "add" and "remove" effects scripting commands, and I'm really not looking forward to that.

Thank you for reading my rant.

Comments

  • ProlericProleric Member Posts: 1,269
    AFAIK this can be scripted.

    It should be possible to place the second skin in inventory using CreateItemOnObject().

    To change skins, you'd use ActionEquipItem().

    Ensure that both skins are not droppable on death.

    Shouldn't be hard to test.
  • MelkiorMelkior Member Posts: 179
    I just did a test. Fortunately, you are right. I forgot at first to make the skins undroppable but creating them and switching them does seem to work. (Making them undroppable was simple and I got it right on the second test)

    I used an onspawn script to create the skins (although I'd have to put the creation of the skins in the onheartbeat script if I ever want to put the creature directly in a module without it being spawned) and also equipped the correct skin at that time. I then had the heartbeat check the time of day and the equipped skin in order to switch if the wrong one was equipped.

    It's annoying that I can't just put them into the blueprint inventory, but it works okay this way.

    Now that I come to think of it, this might be even better since if I update the skins, I don't need to remember to update them in the creature's inventory.

    Anyway, thanks for the reply.
  • MelkiorMelkior Member Posts: 179
    AAAAAAAAHRG! (Stress reliever. Hadda be done.)
    I just discovered that the skin switching simply isn't working, and at this point I don't know why not.
    The OnSpawn script seems to do exactly nothing when the creature spawns in from an encounter.
    The OnHeartbeat does seem to run, but it doesn't switch the skins. If there's a default skin, it remains in the slot. If the default skin is removed, it's not replaced by one of the two (day/night) skins, despite there being commands to do exactly that.
    I'm going to have to do a lot of debugging scripting to try to figure out exactly where it's failing.
    More nonsense to come...
  • ProlericProleric Member Posts: 1,269
    OnSpawn, try a one second delay before creating and equipping the skin.

    I sometimes find this helps, when messing with inventory - perhaps it lets the module Acquire and Equip events settle down.

    Not sure what could be wrong OnHeartbeat, beyond a coding error - maybe post the script?

  • RifkinRifkin Member Posts: 141
    Instead of using items to do this, just apply the effects and remove the effects when it's day/night. The effects you want from the items can almost certainly be applied as "Supernatural effects" which are not dispellable and you can set the duration either to the length of night time, or simply set them as permanent but then remove them when the heartbeat detects it's daytime.
  • RifkinRifkin Member Posts: 141
    Also an important note about the "Action" functions, they add an action to the action queue, which can end up not happened because the creature may cancel all of the actions in it's queue (especially if you still have any of the default AI scripts attached)
  • ProlericProleric Member Posts: 1,269
    Yes, adding / removing effects is an option - the OP found having two skins easier, so I went along with that.

    There are similar issues - you have to ensure that the skin exists, and is equipped after every reload - but it works.

    As for Actions, they can be issued safely in the default spawn and heartbeat scripts, as long as they aren't delayed, in my experience.
  • MelkiorMelkior Member Posts: 179
    I'm guessing that the OnSpawn script has a ClearAllActions somewhere in the default part which is cancelling the equip action since it does work in the heartbeat, IF I delay executing the default script for a tenth of a second. The on-spawn does not work this way, though. Even delaying the default script for a tenth of a second doesn't work.

    One problem is that the equipping has to happen practically instantly on-spawn so that the enemy will be weaker in the daytime right from the beginning.

    I really wanted to avoid the "solution" of adding and removing effects on the skin because that's just plain messy, but it looks very much like it will be the only way around this problem.

    Now I'm going to have to mess around with adding and removing variables to keep track of which state the skin is in so that the heartbeat doesn't have to go through the whole, CPU-time-expensive mess of trying to search for effects every time just to confirm whether or not they should be added or removed.

    It also means that adjusting any of the effects later is going to be a messy business of having to edit the scripts.

    Excuse me while I growl with frustration.
    GRRRRRRRRRRR! >:E
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited October 2022
    Suggestion - make a spreadsheet to keep info on which each variable is for and what scripts use it.

    TR
  • MelkiorMelkior Member Posts: 179
    All being well, I won't need more than one variable, to keep track of which "mode" the skin is in.
Sign In or Register to comment.