Jump to content

Spawning an NPC from an item


FiftyTifty

Recommended Posts

I've been working on this for a couple of days to no avail. The mod I'm making is intended to be a replacement for Robco Certified, without all the bugs it entails. But I've hit several snags.

 

The first was that I tried to make it so that you would directly repair robots through a perk entry point script, but that doesn't support variables. So I then tried calling a UDF through the entry point script, which didn't work either.

 

Now I'm resorting to having the player salvage an item from the robot (which works just fine), and then have the player get shown a message, with a robot being spawned after the player picks a choice from the message. I did this by making the salvaged item an aid item, which the player then activates to show the message.

 

But that doesn't work at all. I made the item which has the base effect that has the script to show the message. But the base effect doesn't run at all, as evidenced by my Print command not printing to the console.

 

So how do I go about this?

 

Here's a link to the mod: https://drive.google.com/open?id=1FeN45X75aD62ityuIh5c9Vx9t_OVH1KR

Link to comment
Share on other sites

Sorry can't load your mod ... has a bunch of unknown masters.

 

But for a quick question on your base effect. Does it have "Self" checked ?

Ingestibles must have that checked to work.

 

And about the entrypoint activate attempt you made ... what are you needing to do with variables ?

Because you can put a variable check in the condition field , for both perk owner and target.

And even set an external variable that you declared in some other script.

Pretty much the same as any other result script field can do I think ?

Link to comment
Share on other sites

Ah yeah, my mod requires TTW, and my damage overhaul.

 

The reason I needed variables, was because I was storing GetButtonPressed into an integer variable called iButton. There were two problems with the perk entry point script. Variables cannot be filled in entry point scripts, so iButton was always 0. And GetButtonPressed always returned -1 despite being called right after ShowMessage.

 

Here's the script that is used on the item's base effect to spawn a sentry bot:

scn AAAFyTyRoboticianSentryBotKitScript

int iButton

Begin ScriptEffectStart

    ShowMessage AAAFyTyRoboticianMessageRepairSentryBot
    let iButton := GetButtonPressed
    
    if iButton == 0
        Player.PlaceAtMe AAAFyTySentryBotGL 1
    elseif iButton == 1
        Player.PlaceAtMe AAAFyTySentryBotGLArmyDC 1
    elseif iButton == 2
        Player.PlaceAtMe AAAFyTySentryBotGLArmyNV 1
    elseif iButton == 3
        Player.PlaceAtMe AAAFyTySentryBotGLEnclaveDC 1
    elseif iButton == 4
        Player.PlaceAtMe AAAFyTySentryBotGLOutcastDC 1
    endif
    
End

The perk entry point script was almost identical.

 

The base effects didn't have self enabled, so I changed that. It makes no difference, the script still doesn't run.

Edited by FiftyTifty
Link to comment
Share on other sites

Ahh okies ...

 

I think you just need to add a scripteffectupdate block in that , like this ...

 

~~~~~~~~~~~~~~~~~~~~~

scn AAAFyTyRoboticianSentryBotKitScript

int iButton

Begin ScriptEffectStart

ShowMessage AAAFyTyRoboticianMessageRepairSentryBot
let iButton := GetButtonPressed

End

 

Begin ScriptEffectUpdate

if iButton == 0
Player.PlaceAtMe AAAFyTySentryBotGL 1
elseif iButton == 1
Player.PlaceAtMe AAAFyTySentryBotGLArmyDC 1
elseif iButton == 2
Player.PlaceAtMe AAAFyTySentryBotGLArmyNV 1
elseif iButton == 3
Player.PlaceAtMe AAAFyTySentryBotGLEnclaveDC 1
elseif iButton == 4
Player.PlaceAtMe AAAFyTySentryBotGLOutcastDC 1
endif

End

~~~~~~~~~~~~~~~~~~~~~~

 

The ScriptEffectStart won't wait to see what button you pressed , it just reads it once.

 

But if that block won't work either since it probably needs a duration on the effect item , which you could set one to cover the possible amount of time someone might sit looking at the menu buttons.

Otherwise try "Begin MenuMode 1001" or just a "Begin GameMode" which I'm pretty sure I have seen a few message button scripts use.

 

Hope that works for ya :wink:

 

Add edit: One more thing ... I think may need to be "PlayerRef" On the PlaceAtMe ?

Link to comment
Share on other sites

But that's the problem. The ScriptEffectStart block doesn't fire; the message doesn't appear. Even just having a Print "It works!" as the only line of code inside it doesn't work.

 

Edit: Ah, I think I found the issue. I didn't attach the base effect to the ingestible. But that brings another problem; there's no option for me to add the base effect to the ingestible. I can add an effect time of the Script Effect type, but that's it, I don't get an option to select my base effect.

 

2nd Edit: Okay, I'm dumb. Didn't go to the beginning of the effect list. Now the message shows, but GetButtonPressed still returns -1. I'll try that ScriptEffectUpdate block next.

 

3rd Edit: So it turns out that GetButtonPressed still returns -1, despite the message being called before it. And ScriptEffectUpdate is called three times instead of once.

 

This is getting to be a real pain in the arse. Could it be that GetButtonPressed is bugged?

Edited by FiftyTifty
Link to comment
Share on other sites

Change "Begin ScriptEffectUpdate"

 

To "Begin MenuMode 1001"

 

Or "Begin GameMode"

 

Add edit : But it looks like the example on the wiki for "GetButtonPressed" is showing it with a "GameMode" block ... so that is probably the one you want.

Link to comment
Share on other sites

I changed the script to:

 

 

scn AAAFyTyRoboticianProtectronKitScript

int iButton

Begin ScriptEffectStart
    
    Print "Showing Message"
    
    ShowMessage AAAFyTyRoboticianMessageRepairProtectron
    Print $GetButtonPressed
End

Begin ScriptEffectFinish
    
    let iButton := GetButtonPressed
    Print $iButton
    if iButton == 0
        Player.PlaceAtMe AAAFyTyFactoryProtectron 1
    elseif iButton == 1
        Player.PlaceAtMe AAAFyTyMetroProtectron 1
    elseif iButton == 2
        Player.PlaceAtMe AAAFyTyNukaColaProtectron 1
    elseif iButton == 3
        Player.PlaceAtMe AAAFyTyProtectronArmy 1
    elseif iButton == 4
        Player.PlaceAtMe AAAFyTyProtectronArmyDC 1
    elseif iButton == 5
        Player.PlaceAtMe AAAFyTyProtectronDC 1
    elseif iButton == 6
        Player.PlaceAtMe AAAFyTyProtectronNV 1
    elseif iButton == 7
        Player.PlaceAtMe AAAFyTyProtectronEnclaveDC 1
    elseif iButton == 8
        Player.PlaceAtMe AAAFyTyProtectronOutcast 1
    elseif iButton == 9
        Player.PlaceAtMe AAAFyTyVaultProtectron 1
    endif

End

 

Both blocks run, but since GetButtonPressed is always returning -1, the if iButton == block doesn't have a result.

Link to comment
Share on other sites

Both those blocks are a one frame read , therefore will not accept button presses.

Needs to be either "ScriptEffectUpdate" or "GameMode"

 

I think the problem is the duration of the spell. So make sure the "No Duration" is not checked on the Base effect.

Then on the "Effect Item" window of the ingestible. Set the duration to 1 hour for example.

And then to dispel it once the button selection is pressed. Put a line like this after the placeatme command ...

 

PlayerRef.PlaceAtMe MyRobot 1

Dispel MyIngestible

 

~~~~~~~~~~~

 

If that still doesn't work , I have an idea for useing the Perk / EntryPoint / Activate , option ... via a quest script.

Link to comment
Share on other sites

Alright, I made the script like so, after setting the effect duration to one hour:

scn AAAFyTyRoboticianProtectronKitScript

int iButton

Begin ScriptEffectStart
    
    Print "Showing Message"
    
    ShowMessage AAAFyTyRoboticianMessageRepairProtectron
    Print $GetButtonPressed
End

Begin ScriptEffectUpdate
    
    let iButton := GetButtonPressed
    Print $iButton
    if iButton == 0
        Player.PlaceAtMe AAAFyTyFactoryProtectron 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 1
        Player.PlaceAtMe AAAFyTyMetroProtectron 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 2
        Player.PlaceAtMe AAAFyTyNukaColaProtectron 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 3
        Player.PlaceAtMe AAAFyTyProtectronArmy 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 4
        Player.PlaceAtMe AAAFyTyProtectronArmyDC 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 5
        Player.PlaceAtMe AAAFyTyProtectronDC 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 6
        Player.PlaceAtMe AAAFyTyProtectronNV 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 7
        Player.PlaceAtMe AAAFyTyProtectronEnclaveDC 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 8
        Player.PlaceAtMe AAAFyTyProtectronOutcast 1
        Dispel AAAFyTyRoboticianProtectronKit
    elseif iButton == 9
        Player.PlaceAtMe AAAFyTyVaultProtectron 1
        Dispel AAAFyTyRoboticianProtectronKit
    endif

End

The ScriptEffectUpdate block is called five times, all of them returning GetButtonPressed as -1, except for the fourth time, where it returns the number selected in the message.

 

Now there's another problem that needs to be fixed, which is that the spawned actor doesn't re-evaluate it's AI after EVP has been called on it once before. I'll make a new thread.

Edited by FiftyTifty
Link to comment
Share on other sites

  • Recently Browsing   0 members

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