Jump to content

Help with Spawn Script


LanguageWriter123

Recommended Posts

Hello I need help with this script:

 

Scriptname HoundedPlayer

Begin GameMode

if GetIsReference Player

player.placeatme HoundingZombie 1, 10, 1

return

elseif GetIsID HoundingZombie == 5

player.placeatme HoundingZombie == 0

return

else HoundingZombie.GetDead

player.placeatme HoundingZombie 1, 10, 1

return

endif

end

 

As you can see I'm trying to spawn a limited 5 zombies next to the player so that it simulates that everywhere he goes he is constantly being chased. But the thing is, they won't stop spawning! Everytime I load the game up they keep spawning infinitely basically until the game basically freezes. Can anyone find a solution for me please for what I should add or take out of the script to get it to spawn 5 zombies at a time?

Edited by LanguageWriter123
Link to comment
Share on other sites

Scriptname HoundedPlayer

Short Count == 0

Begin GameMode

GetIsReference Player

GetIsID HoundingZombie

If Count < 5

player.placeatme HoundingZombie, 1, 10, 1

short count + 1

elseif GetIsID HoundingZOmbie + 1

short count + 1

else count == 5

DeleteFullActorCopy HoundingZombie

endif

end

 

This script does not work either that I made. Can anyone help me with this?

Edited by LanguageWriter123
Link to comment
Share on other sites

Well, GetIsReference only returns 1, if what is calling it is a reference of the parameter provided, 0 otherwise. If this is a Quest script, that would not work at all, as the calling reference would be nothing (or I don't know what). If it's an Object script, it'd be the object itself that's checked on being a reference to Player. If it's a Spell script, the spell's target. Don't really see why it should even be checked here, if the script is anyways meant to only spawn zombies around the player.

And GetIsID is similarly only returning 1, if the calling reference is the same as the parameter given, 0 otherwise. So in case of your script it also doesn't make sense using it.

Asking via GetDead if the BaseObject HoundedZombie is dead also won't make sense, if it's not a reference spawned into the game world.


The problem is, it's not so easy as checking how many alive zombies there are in the vicinity around the player. And there's also no way I know of to simply check how many zombies there are left spawned in the entire game world.
I think I'd go about this a little bit differently.

First you need to keep track of the 5 spawned instances of your zombies individually and react to when all of them are dead.
And then, once they are all dead, the script would just spawn 5 new ones again instantly, so you would also need some form of delay, if you want the spawning to go on indefinitely, or an abort condition otherwise couldn't hurt, too.

Scriptname HoundedPlayer
 
ref rEnemy1
ref rEnemy2
ref rEnemy3
ref rEnemy4
ref rEnemy5
float fDelay
short bSpawn
 
Begin GameMode
    if 0 < fDelay
        set fDelay to fDelay - GetSecondsPassed
        return
    endif
 
    if 1 == bSpawn
        set rEnemy1 to player.PlaceAtMe HoundingZombie 1 10 1
        set rEnemy2 to player.PlaceAtMe HoundingZombie 1 10 1
        set rEnemy3 to player.PlaceAtMe HoundingZombie 1 10 1
        set rEnemy4 to player.PlaceAtMe HoundingZombie 1 10 1
        set rEnemy5 to player.PlaceAtMe HoundingZombie 1 10 1
        set bSpawn to 0
    endif
 
    if rEnemy1 && rEnemy2 && rEnemy3 && rEnemy4 && rEnemy5 ;all exist
        if 1 == (rEnemy1.GetDead) && 1 == (rEnemy2.GetDead) && 1 == (rEnemy3.GetDead) && 1 == (rEnemy4.GetDead) && 1 == (rEnemy5.GetDead) ;all are dead
            set bSpawn to 1
            set fDelay to 300 ;a fixed 5 minutes delay for now, could also be random instead
        endif
    endif
End

That should do for a first version.

Link to comment
Share on other sites

Drake the Dragon you are the most legendary legend, thank you so much. I really appreciate you doing that thank you so much. If I could give you 8 or more bucks for that I would because you deserve it. And ReverendFelix you are probably right I just haven't thought of that anytime until you mentioned so forgive my dumbass but I probably should have looked into that template before asking this question.

Link to comment
Share on other sites

Just sharing my knowledge is all. Plus, I love writing scripts. And not rarely I also enjoy teaching it. If just my free time would allow for more of either. :ermm:

 

@ReverendFelix: Good catch with the Staff of Everscamp scripting. I'm just not sure it does -exactly- the same. Plus, where's the fun in copying existing scripts, when it's much more enjoyable for me to write them from scratch?

(Besides, Bethesda's Vanilla scripts aren't exactly known for always being the most optimized or performant ones. If anything, I would learn from them, not re-use them as is. But to each their own. Skills differ and everybody has to start somewhere else.)

Link to comment
Share on other sites

I wasn't suggesting to copy, just for an idea. For me, learning from the work of others is fundamental. At least for a sense of direction, I find it invaluable. That's is not to say that once I've learned, I don't stray far outside the box. Experimentation using what you've learned is key.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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