Jump to content

Spawn a NPC?


Recommended Posts

I am working on a mod, in which I want the following things to happen...

 

Once character A dies, character B is spawned. I would like character b to spawn at a map marker at the entrance to town (anvil). But before this, for testing purposes, I would like character b to spawn either near me or dead character A. (note: character B I made in the construction set and is not placed in the game world). Here is what I have on character A script...

 

Begin OnDeath

enable charB
player.PlaceAtMe charB
;MoveToMarker AnvilMapMarkerNEW (commented out)
End

 

 

And it did not work... any help please? Thank you... excuse my noobish-ness

 

I would also like to delay the spawn if possible

Link to comment
Share on other sites

Greetings fellow modder !
make sure this things first :
- charB is NPC base object
- using OBSE v21 in your setup & CSE for building mods
- script below is attached to NPC char A
suggestion for testing case
scn charAScr
ref rf1
Begin OnDeath
;Once character A dies, character B is spawned.
Let rf1 := PlaceAtMe charB
;I would like character b to spawn either near me or dead character A (testing purpose)
if  GetRandomPercent < 50
rf1.MoveTo PlayerRef
endif
End
.
suggestion for solution
scn charAScr
Begin OnDeath
;Once character A dies, character B is spawned. I would like character b to spawn at a map marker at the entrance to town (anvil)
AnvilMapMarkerNEW.PlaceAtMe charB
End

 

EDIT :

testing script improved, using less variable, & more efficient logic

Edited by lubronbrons
Link to comment
Share on other sites

Much thanks my friend!

 

a few more questions?

-if character A already has a begin gamemode script block is it okay to put a begin ondeath block below that?

-scn is i guess short for script name?

-why is the colon in front of the = sign? i usually just use two equal signs

-is it necessary to use the let statements or can they be defined before the ondeath script?

-the NPC cannot be spawned at the map marker without first being called from a player.placeatme command? in this case would the player see the NPC for a split second?

 

also what is your opinion on spawning him near skingrad gate and having him walk to anvil to achieve the delay? do you think he might get killed.

 

thanks again

Edited by masternoxx
Link to comment
Share on other sites

quote : "if character A already has a begin gamemode script block is it okay to put a begin ondeath block below that?
>>> it is fine, just remember if you move to another cell (pc far away from char A)
the GameMode script will stop working until you get near char A again..
the radius distance when the script attached to reference stop working I think is around 12k radius, to make it works again pc must get near the reference around 8k radius
quote : "scn is i guess short for script name?
>>> Yes it is, 'scn' is equal with 'ScriptName'
quote : "why is the colon in front of the = sign? i usually just use two equal signs
>>> that is how you use syntax 'Let'
I prefer 'Let :=' rather than 'Set to' because 'Let' is much more flexible, especially when handling String type variables
quote : "is it necessary to use the let statements or can they be defined before the ondeath script?
>>> the reaseon I use 'Let' same as above, and ... No, the syntax will works only within 'begin Block' mode
so you can't do this
ref rf1 := charA

you should do it like this

ref rf1
begin <BlockMode>
Let rf1 := someReference
end

...or this

ref rf1
begin <BlockMode>
Set rf1 to someReference
end
quote : "the NPC cannot be spawned at the map marker without first being called from a player.placeatme command? in this case would the player see the NPC for a split second?
>>> pardon I don't understand this question ??
every object CAN be spawned by using syntax PlaceAtMe
No,
in this case if the spawned NPC created & moved to somewhere in same frame, you'll not see the NPC in split second
but for 'test case' that you requested, there is 50% chance that you'll see charB spawned near pc
EDIT :
quote : "also what is your opinion on spawning him near skingrad gate and having him walk to anvil to achieve the delay? do you think he might get killed."
>>> I don't know ... he might get killed or not factor is based on user modlist, if the user using mod that add many hostile actors then the answer is 'Yes' he could be killed
delay... hmm... this is a bit tricky
I suggest that you use quest script rather than reference script
reference script / attached script is unreliable, if the reference is too far away the script will not working at all (from my experience usually >12k radius from player)
also
PlaceAtMe will produce dynamic reference, means... if the object is too far away, even the Great Quest script can't reach this reference (because the NPC is NOT loaded into memory)
so in this case, if you teleport the char B to far away location. both method will be invalid, that unreliable reference script & Quest script can't reach the char B
why ?
the reason is simple, because char B is only dynamic reference (has index FF / crated in-game / reference stored in savegame / bloat potential)
if dynamic ref is NOT loaded into memory / RAM they CAN'T BE called or accessed, but we can still validate this thing....
Edited by lubronbrons
Link to comment
Share on other sites

Much thanks, I will test it out now.

I'm still not totally sure why you cannot do the ref rf1 = charB beforehand, I was taught to do that in c programming, but maybe I can google some info on that. This is how I would have done it

 

ref rf1 = charB
;;;;;;;;;;;
Begin OnDeath
;Once character A dies, character B is spawned.
PlayerRef.PlaceAtMe rf1
;I would like character b to spawn at a map marker at the entrance to town (anvil)
rf1.MoveTo AnvilMapMarkerNEW
;End

 

that would not work?

 

Thank you for your knowledge script master =]

Link to comment
Share on other sites

quote : "I'm still not totally sure why you cannot do the ref rf1 = charB beforehand, I was taught to do that in c programming, but maybe I can google some info on that. This is how I would have done it"

>>> I think... OBSE is pascal, not c language, dunnno...

but here is the documentation syntax Let

No,

ref rf1 = charB

will not work


if it is not too much

what is this mod you working on?

also

I think I recognized you...

you're updated several of your mods recently,

congrats ! Welcome back to Oblivion modding o'fellow modder :)

sorry to be blunt but your invisible spell mod could be exploited in many ways man.. it is hard thing to do to achieve complete isolation of that invisibility, I don't think I can achieve that

Link to comment
Share on other sites

Yes I started playing Oblivion again a month ago and noticed a couple bugs with my mods, and had to start out slow because I forgot a lot about how to use the CS =] . Yes the invis spell can be gained by birthsign and from 1 heaven stone and from spell tomes, but already it is simple to make potions of it (the mod does not affect potions), the mod is only to make it harder to get the spells in general since I felt they ruined the danger from enemies. If you dont choose the birthsign, or find the heaven stone, or use spell tomes, you will never get the invis spell.

My new char is a archer, But recently I have also found out that with 100 sneak and ring of chameleon (khajit) I can just keep firing arrows at enemies without them ever detecting me, so there is another exploit, add that to a long list of exploits I found such as hacking away at horses to raise my blade skill, making underpowered spells, holding down the spell button c key with a rock and coming back later LOL, taking the jemane brothers everywhere with me and just killing everything easily lol, and many others. These exploits really should have probably been fixed by bethesda along with the tedious leveling system, but whatever.. For example when I play ESO all these bugs have been fixed, such as, invisibility spell or potion have very short duration, you can't hack on horses, etc.

This mod I just started is one just for fun at this point where the idea is, you must eliminate all argonians, or possibly other races from a town LOL, the problem is, some of them are merchants or whatever and so I need to spawn a replacement merchant when they die. Otherwise the player may not be able to buy spells, sell items etc.

 

But unfortunately the script did not work. Is it possibly because placeatme is called from the npc? Is it possibly because charB is not put in the gameworld? I don't know

Edited by masternoxx
Link to comment
Share on other sites

ahh... I never thought that Jemane brothers could be exploited like that,,,,

 

XD why you hate argonian that much

 

I have suggestion to avoid invisibility exploit, I have a mod that modify actor behavior on player's invisibility.

it is called Greed Vision (in case you interested you could find it in my Nexus file repository)

as for

 

are you sure ?

just now out of curiosity I tested the script (because when I wrote that script I didn't test it)

scn charAScr
Begin OnDeath
;Once character A dies, character B is spawned. I would like character b to spawn at a map marker at the entrance to town (anvil)
AnvilMapMarkerNEW.PlaceAtMe charB
End

and it did works

maybe there is something missing in your setup ??

Edited by lubronbrons
Link to comment
Share on other sites

Has your CharB NPC been placed in the game? Mine is made in the CS, but not placed in game

 

my code is the same i do have obse latest and cse

 

yes you do the jemane bros quest up until they ask you to take them to wetherleah but then you dont take them there

 

also I used semi-exploits at benarus manor and hackdirt or imperial sewers

Edited by masternoxx
Link to comment
Share on other sites

  • Recently Browsing   0 members

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