Russia is over. The end.
Bester
So I finished the creature spawning console command even though the prefab names for most creatures in game aren't known yet. I'll see about it tomorrow, there should be a way to export them. For now, the only names known are the file names starting with "cre_" in assetbundles\prefabs\objectbundle
It's not really useful atm, but IE games had such commands to unblock bugged quests etc, so it may become useful some day. You can spawn an NPC and then make him join your party for example. The usual "console fun".
Anyway, the command spawns a creature, places it on the ground under your cursor, then the creature gets the same rotation that your main character has at the moment. Then it either makes the creature hostile or friendly depending on the parameter that you pass. If it's hostile, it'll start fighting you. Then it'll center the camera on the creature. It'll also spam your console with some info that may come in handy once modding really takes off (if ever). The code may serve as a sort of modding tutorial/example, I suppose.
BSC creaturename bool (0 for friendly, 1 for hostile)
So for example to spawn a friendly "Obsidian Wurm" (it's an animal companion), you type:
BSC cre_wurm_obsidian_pet 0
For a hostile druid cat:
BSC cre_druid_cat01 1
Code:
If you wanna play with it, here's the patched dll: https://dl.dropboxusercontent.com/u/62420848/patch4.zip
It's not really useful atm, but IE games had such commands to unblock bugged quests etc, so it may become useful some day. You can spawn an NPC and then make him join your party for example. The usual "console fun".
Anyway, the command spawns a creature, places it on the ground under your cursor, then the creature gets the same rotation that your main character has at the moment. Then it either makes the creature hostile or friendly depending on the parameter that you pass. If it's hostile, it'll start fighting you. Then it'll center the camera on the creature. It'll also spam your console with some info that may come in handy once modding really takes off (if ever). The code may serve as a sort of modding tutorial/example, I suppose.
BSC creaturename bool (0 for friendly, 1 for hostile)
So for example to spawn a friendly "Obsidian Wurm" (it's an animal companion), you type:
BSC cre_wurm_obsidian_pet 0
For a hostile druid cat:
BSC cre_druid_cat01 1
Code:
Code:
//INJECT THIS METHOD INTO THE "SCRIPTS" CLASS
static void BSC(string param1, string param2)
{
if (GameState.s_playerCharacter.IsMouseOnWalkMesh()) // checks if mouse cursor is on the navmesh
{
if (param2 == "1")
Console.AddMessage("Attempting to spawn a hostile: " + param1, UnityEngine.Color.yellow);
else
Console.AddMessage("Attempting to spawn a friendly: " + param1, UnityEngine.Color.yellow);
UnityEngine.GameObject besterCreature; // creates an empty game object
besterCreature = GameResources.LoadPrefab<UnityEngine.GameObject>(param1, true); // instantiates a prefab
if (besterCreature != null)
{
Console.AddMessage("Spawned successfully: "+besterCreature.name, UnityEngine.Color.green);
besterCreature.transform.position = GameInput.WorldMousePosition; //it's a raycast (it gives you the coordinates of the ground under your cursor)
besterCreature.transform.rotation = GameState.s_playerCharacter.transform.rotation; // takes the rotation from the player and assigns it to the creature... can do the same with position if you want
Console.AddMessage("Coordinates: X = "+besterCreature.transform.position.x+" Z = "+besterCreature.transform.position.z);
if (besterCreature.GetComponent<Faction>() != null){
Console.AddMessage("Default relationship to player: "+besterCreature.GetComponent<Faction>().RelationshipToPlayer);
Console.AddMessage("Default team: "+besterCreature.GetComponent<Faction>().CurrentTeamInstance);
}
if (besterCreature.GetComponent<AIPackageController>() != null)
Console.AddMessage("Default AI: "+besterCreature.GetComponent<AIPackageController>().AIPackage);
if (besterCreature.GetComponent<InstanceID>() != null)
Console.AddMessage("GUID: "+besterCreature.GetComponent<InstanceID>().Guid);
Console.AddMessage("Now transforming the creature.", UnityEngine.Color.cyan);
bool isHostile = false;
if (param2 == "1")
isHostile = true;
if (isHostile == false)
{
if (besterCreature.GetComponent<Faction>() != null)
{
besterCreature.GetComponent<Faction>().RelationshipToPlayer = Faction.Relationship.Neutral; // simply modifying the relationshipToPlayer isn't enough, you need to change the team as well
besterCreature.GetComponent<Faction>().CurrentTeamInstance = Team.GetTeamByTag("player"); // it's just the first friendly team I found... if you want to see other teams, you can write a method to print them all, cause they're in a private field
}
if (besterCreature.GetComponent<AIPackageController>() != null)
{
besterCreature.GetComponent<AIPackageController>().ChangeBehavior(AIPackageController.PackageType.DefaultAI); // some creatures might come without AI, which would make them always stand idly.
besterCreature.GetComponent<AIPackageController>().InitAI(); // the creature might have already started attacking the player if it was initially hostile, so we relaunch its AI
}
}
else
{
if (besterCreature.GetComponent<Faction>() != null)
{
besterCreature.GetComponent<Faction>().CurrentTeamInstance = Team.GetTeamByTag("monster");
besterCreature.GetComponent<Faction>().RelationshipToPlayer = Faction.Relationship.Hostile;
}
if (besterCreature.GetComponent<AIPackageController>() != null)
{
besterCreature.GetComponent<AIPackageController>().ChangeBehavior(AIPackageController.PackageType.DefaultAI);
besterCreature.GetComponent<AIPackageController>().InitAI();
}
}
if (besterCreature.GetComponent<Faction>() != null)
{
Console.AddMessage("New relationship to player: "+besterCreature.GetComponent<Faction>().RelationshipToPlayer);
Console.AddMessage("New Team: "+besterCreature.GetComponent<Faction>().CurrentTeamInstance);
}
if (besterCreature.GetComponent<AIPackageController>() != null)
Console.AddMessage("New AI: "+besterCreature.GetComponent<AIPackageController>().AIPackage);
CameraControl.Instance.FocusOnPoint(besterCreature.transform.position); // centers the camera on the creature
}
else
Console.AddMessage("Failed to spawn "+param1+" - probably bad naming.", UnityEngine.Color.red);
}
else
Console.AddMessage("Mouse is not on walkmesh, move mouse elsewhere and try again.", UnityEngine.Color.red);
}
If you wanna play with it, here's the patched dll: https://dl.dropboxusercontent.com/u/62420848/patch4.zip
Last edited: