Hello,
The warp and cheat band has a function that causes an NPC to spawn when you use it. However, I browsed the script and found nothing indicating an NPC file for spawning. What I wanted to know is what lines I need to put into a script to make it spawn something, and then attach it to an armband item.
Thanks if any of you can help.
The warp and cheat band has a function that causes an NPC to spawn when you use it. However, I browsed the script and found nothing indicating an NPC file for spawning. What I wanted to know is what lines I need to put into a script to make it spawn something, and then attach it to an armband item.
You usually use the CreateObject() script function for this. It can be used to create other types of objects (items, placeables etc) than creatures/NPCs as well. You use it like:
void main() {
location lDestination = Location(Vector(0.0, 0.0, 0.0), 0.0);
object oNew = CreateObject(OBJECT_TYPE_CREATURE, "template", lDestination);
}
0.0 is the X coordinate in the world to spawn the creature at, 0.0 is the Y coordinate, 0.0 is the direction the creature should face when spaned (0-359 degree angle), the OBJECT_TYPE_CREATURE constant is used to spawn creatures and NPCs (there are other OBJECT_TYPE_ constants to spawn other object types) and "template" is the name of the .UTC file, without the file extension, of the template to spawn the creature from.
(You can't affect the Z-coordinate, or elevation, of creatures and NPCs in the game world, so I left that out above. The third number in the vector sets that otherwise, if you spawn placeables and the like.)
If you don't know the exact coordinates where the creature should be spawned and just want to spawn it right next to the player you can use GetLocation() instead to get the coordinates of an existing object in the game world, like:
void main() {
location lDestination = GetLocation(GetFirstPC());
object oNew = CreateObject(OBJECT_TYPE_CREATURE, "template", lDestination);
}
Great, thanks. Can any of you now tell me how I would attach it to an armband or some other item that spawns the NPC I want when used? Man, I wish I was better at this, so I wouldn't have to bug you guys.
Great, thanks. Can any of you now tell me how I would attach it to an armband or some other item that spawns the NPC I want when used? Man, I wish I was better at this, so I wouldn't have to bug you guys.
Scripts fired from armbands are technically "spells" (along with force powers, grenades, rockets, medkits, stims etc), so you'll have to add a new line to the spells.2da file for your armband. On this line you set the name of your script in the impactscript column.
Then, in the UTI template of your armband you add an Activate Item property and set the Subtype field to the line number of the row you just added to spells.2da, and the Value field to Unlimited uses. This will make the armband trigger the spell when you activate it, which fired the impact script.
General tip: Have a look at what others have done with armband mods while looking through this spells.2da tutorial (
http://www.lucasforums.com/showthread.php?t=130898).
With the script, I keep getting this thing about a syntax error and if I play around with it I get this thing below:
"To many arguments specified in call to GetFirstPC"
"Required argument missing in GetLocation"
I have the script just as you have it, with the NPC's file name (without extension) in place. What am I doing wrong?
Try copy/pasting stoffe's script while only editing what's in between quotation marks.
Yeah, that worked. Thanks.