NPC as an Item
-
Dementedsnake
- Layman

- Posts: 2
- Joined: Tue Jun 02, 2009 3:04 am
NPC as an Item
Greetings. I have a sort-of simple problem I'd like help with. Without using an mods or programs other than Tribunal and Bloodmoon, I'm trying to either script or mash up elements from the Construction Set to make a friendly NPC that I can carry around in my inventory. Essentailly, I plan to use a burden spell on them and turn them into a magic turret that I can carry around with me. So, is this possible? It seems easy enough, I just can't script. Thanks for any help or ideas.
Re: NPC as an Item
not to answer your original question but i think to be fair to the spirit of the game an NPC item should weigh as much as the NPC. say 150.
i'm basing this on when i played baldurs gate. you could pick up a dead body but it weighed 100. in baldurs gate it was harder to increase your strength (no enchanting) so i think for mw 150 would be fairer.
and although i know absolutely zip about scripting, would this work?
to pick up:
1) change location of npc to somewhere they can't move (i.e. an underground location),
2) create icon to prepresent NPC in inventory.
to put down:
1) change location of npc to somewhere near player. maybe an equivalent of fixme could be done on the NPC to stop them getting stuck in scenery,
2) remove icon from inventory.
just my thoughts - good luck
i'm basing this on when i played baldurs gate. you could pick up a dead body but it weighed 100. in baldurs gate it was harder to increase your strength (no enchanting) so i think for mw 150 would be fairer.
and although i know absolutely zip about scripting, would this work?
to pick up:
1) change location of npc to somewhere they can't move (i.e. an underground location),
2) create icon to prepresent NPC in inventory.
to put down:
1) change location of npc to somewhere near player. maybe an equivalent of fixme could be done on the NPC to stop them getting stuck in scenery,
2) remove icon from inventory.
just my thoughts - good luck
It's a fine line, but someone has to walk it.
Life - the straightest road possible, with as many turns as possible
There's no such thing as an honest politician.
Life - the straightest road possible, with as many turns as possible
There's no such thing as an honest politician.
-
Dementedsnake
- Layman

- Posts: 2
- Joined: Tue Jun 02, 2009 3:04 am
Changed from NPC to Item (for now)
Actually, I only wanted to use an NPC because I thought objects couldn't cast spells. Since yesterday, I've made an item (tall torch) that rapidly flings spells at the player. There are two problems though, I can't get the the thing to fire at anyone other than "player" and I'm having trouble with the timing of the spells. It fires so fast that after a minute, it'll crash the game.
Apparently, I need a second object to mark targets for the torch to cast at (if I want it to cast on anyone but me), and haven't figured out the right coding for 'GetSecondsPassed' to make it fire once every second as opposed to once every frame. I might have some luck by scripting the torch to be my companion. But right now, I'm working on using 'GetDistance' and 'GetTarget'.
Essentially, I'm trying to make a magical turret that will automatically cast at any target (Either me, an NPC/Creature attacking me, or anyone in range). There are a lot of little details I've already (mostly) worked out for each type of turret (I have Fire, Frost, Healing, Paralyzing, Teleporting, etc.) but I need help with targeting and timing.
Any code monkeys out there feel like helping?
EDIT: Oh, and since I'm using a tiki torch, I can already pick it up and move it around without needed extra codes.
Apparently, I need a second object to mark targets for the torch to cast at (if I want it to cast on anyone but me), and haven't figured out the right coding for 'GetSecondsPassed' to make it fire once every second as opposed to once every frame. I might have some luck by scripting the torch to be my companion. But right now, I'm working on using 'GetDistance' and 'GetTarget'.
Essentially, I'm trying to make a magical turret that will automatically cast at any target (Either me, an NPC/Creature attacking me, or anyone in range). There are a lot of little details I've already (mostly) worked out for each type of turret (I have Fire, Frost, Healing, Paralyzing, Teleporting, etc.) but I need help with targeting and timing.
Any code monkeys out there feel like helping?
EDIT: Oh, and since I'm using a tiki torch, I can already pick it up and move it around without needed extra codes.
reminds me of a mod for oblivion where a sword floats around as your companion and fights for you. wish i could remember it's name. also reminds me of diablo where you sometimes came across flying scimitars.
anyway, i'm guessing the way the oblivion mod works is to simply create an NPC companion that is permanently invisible that holds the sword. if you're not doing it that way then how is this turret going to "be" with the player? does the player have to wield it, wear it or will it autonomously follow them around?
i know this is for morrowind but if you ever want to look at the code for oblivion mods it should be easy. i've seen the TES editor for morrowind all over the place free and legal to download so same must be true for the oblivion version. then find the mod that does a bit of what you want, load it up and find out how they did it. although much oblivion scripting code will be different the logic will be there and some of the methods will be similar and/or portable.
anyway, i'm guessing the way the oblivion mod works is to simply create an NPC companion that is permanently invisible that holds the sword. if you're not doing it that way then how is this turret going to "be" with the player? does the player have to wield it, wear it or will it autonomously follow them around?
i know this is for morrowind but if you ever want to look at the code for oblivion mods it should be easy. i've seen the TES editor for morrowind all over the place free and legal to download so same must be true for the oblivion version. then find the mod that does a bit of what you want, load it up and find out how they did it. although much oblivion scripting code will be different the logic will be there and some of the methods will be similar and/or portable.
It's a fine line, but someone has to walk it.
Life - the straightest road possible, with as many turns as possible
There's no such thing as an honest politician.
Life - the straightest road possible, with as many turns as possible
There's no such thing as an honest politician.
Your problem isn't as easy as you might think. The timer is no problem, here's some script that would make a timer work: (if you already have a script, just use the float declaration, the "If" statement and the set timer1 should be put somewhere near the end of the script)
Begin turretscript
float timer1
if ( timer1 >= 1 )
;comment: here's where you will have problems, the target ID has to be specific
cast "whateverSpell" "target"
set timer1 to 0
endIf
set timer1 to ( timer1 + GetSecondsPassed )
End turretscript
You could have the turret fire at a predetermined object, and use area effect spells, but... How do you convince your enemy to sand near the target object? also, these kinds of spells fired by objects rather than NPCs are supposed to be "touch" range spells in order to work properly.
I think your first notion of haveing an NPC would be far easier to make work.
You could take an object (be sure to change the id), either a misc or activator so you can add a script, then write a script (attached to that object) so that when you drop the object (OnPCDrop ) the NPC is ploaced near you ( PlaceAtPC ) then teleported ("NPCID"->positioncell X,Y,Z, )to a cell you create or your home (interior cells work much betterthan exterior) when you pick up the object ( OnPCAdd ). If you made the object heavy, it would then simulate carrying the NPC.
Of course the NPC will need to have the AIFollow package in order to have him attack your enemies. A bonus would be to put in the script "set companion to 1" (without quotes) and then you could also use the NPC as a storage container as well if you attach that script to him.
Begin turretscript
float timer1
if ( timer1 >= 1 )
;comment: here's where you will have problems, the target ID has to be specific
cast "whateverSpell" "target"
set timer1 to 0
endIf
set timer1 to ( timer1 + GetSecondsPassed )
End turretscript
You could have the turret fire at a predetermined object, and use area effect spells, but... How do you convince your enemy to sand near the target object? also, these kinds of spells fired by objects rather than NPCs are supposed to be "touch" range spells in order to work properly.
I think your first notion of haveing an NPC would be far easier to make work.
You could take an object (be sure to change the id), either a misc or activator so you can add a script, then write a script (attached to that object) so that when you drop the object (OnPCDrop ) the NPC is ploaced near you ( PlaceAtPC ) then teleported ("NPCID"->positioncell X,Y,Z, )to a cell you create or your home (interior cells work much betterthan exterior) when you pick up the object ( OnPCAdd ). If you made the object heavy, it would then simulate carrying the NPC.
Of course the NPC will need to have the AIFollow package in order to have him attack your enemies. A bonus would be to put in the script "set companion to 1" (without quotes) and then you could also use the NPC as a storage container as well if you attach that script to him.

