Linken Posted January 20, 2017 Posted January 20, 2017 I'm sure you all know, if we go into the console and type in npc spawn jedi_random, we'll get a Jedi npc that's "different" every single time. I tried following a similar formula. Calling an NPC file [name]_random, and calling the subsequent npcs [name]_[type] , but it didn't work. Is it possible to make a random npc file aside from jedi_random? Cerez likes this
Solution JaceSolarisVIII Posted January 20, 2017 Solution Posted January 20, 2017 This also needs to be supported in the code. In the code add the following in. NPC _spawn.cpp static void NPC_Spawn_f(void) after Jedi_random add if ( !Q_stricmp( "jedi_random", NPCspawner->NPC_type ) ) {//special case, for testing NPCspawner->NPC_type = NULL; NPCspawner->spawnflags |= 4; SP_NPC_Jedi( NPCspawner ); } else if ( !Q_stricmp( "sith_random", NPCspawner->NPC_type ) ) {//special case, for testing NPCspawner->NPC_type = NULL; NPCspawner->spawnflags |= 4; SP_NPC_Sith( NPCspawner ); } else { NPC_Spawn( NPCspawner, NPCspawner, NPCspawner ); } then after void SP_NPC_Jedi( gentity_t *self) add a variation of this void SP_NPC_Sith( gentity_t *self) { if(!self->NPC_type) { if ( self->spawnflags & 4 ) {//random! int sanityCheck = 20; //just in case while ( sanityCheck-- ) { switch( Q_irand( 0, 11 ) ) { case 0: self->NPC_type = "Sith1"; break; case 1: self->NPC_type = "Sith2"; break; case 2: self->NPC_type = "Sith3"; break; case 3: self->NPC_type = "Sith4"; break; case 4: self->NPC_type = "Sith5"; break; case 5: self->NPC_type = "Sith6"; break; case 6: self->NPC_type = "Sith7"; break; case 7: self->NPC_type = "Sith8"; break; case 8: self->NPC_type = "Sith9"; break; case 9: self->NPC_type = "Sith10"; break; case 10: self->NPC_type = "Sith11"; break; case 11: default://just in case self->NPC_type = "Sith12"; break; } if ( strstr( self->NPC_type, g_char_model->string ) != NULL ) {//bah, we're using this one, try again continue; } break; //get out of the while } } else if ( self->spawnflags & 2 ) { self->NPC_type = "RebornFencer"; } else if ( self->spawnflags & 1 ) { self->NPC_type = "RebornForceUser"; } else { if ( !Q_irand( 0, 2 ) ) { self->NPC_type = "RebornRodian"; } else if ( Q_irand( 0, 1 ) ) { self->NPC_type = "RebornTrandoshan"; } else { self->NPC_type = "RebornWeequay"; } } } SP_NPC_spawner( self ); } then you need to make a npc file to match the names of the npc,c you have created .like this Sith1 { playerModel cultist2 customSkin brown saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd cultist1 sndcombat cultist2 sndextra cultist3 sndjedi cultist1 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith2 { playerModel cultist3 customSkin red saber reborn_new weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd cultist1 sndcombat cultist2 sndextra cultist3 sndjedi cultist1 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith3 { playerModel chiss saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 1 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 1 FP_LIGHTNING 1 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 1 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd reborn1 sndcombat reborn2 sndextra reborn1 sndjedi reborn2 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith4 { playerModel rosh_penin saber shadowtrooper weapon WP_SABER saberStyle 3 health 500 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd rosh_boss sndextra rosh_boss sndcombat rosh_boss sndjedi rosh_boss dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith5 { playerModel alora saber Tavion weapon WP_SABER sabercolor red saberStyle 1 saberStyle 2 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 1 FP_PUSH 3 FP_PULL 2 FP_TELEPATHY 0 FP_GRIP 1 FP_LIGHTNING 2 FP_RAGE 0 FP_PROTECT 2 FP_ABSORB 2 FP_DRAIN 2 FP_SEE 2 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_ALORA sex female snd alora sndcombat alora sndextra alora sndjedi alora dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith6 { playerModel tavion saber tavion saberColor red weapon WP_SABER saberStyle 5 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 1 FP_SPEED 0 FP_PUSH 3 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 2 FP_RAGE 0 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 2 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank commander reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_TAVION sex female snd tavion sndextra tavion sndcombat tavion sndjedi tavion dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith7 { playerModel desann weapon WP_SABER saber Desann saberColor red saberStyle 4 altFire 1 health 500 FP_HEAL 2 FP_LEVITATION 3 FP_SPEED 0 FP_PUSH 3 FP_PULL 2 FP_GRIP 3 FP_LIGHTNING 2 FP_SEE 2 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 forceRegenRate 50 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 scale 135 height 78 crouchheight 42 width 18 playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_DESANN yawSpeed 120 walkSpeed 55 runSpeed 200 earshot 2048 visrange 4096 vigilance 1 movetype "walk" snd desann sndextra desann sndcombat desann sndjedi desann dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith8 { playerModel reborn2 customSkin boss saber RebornMaster weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 1 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 1 FP_LIGHTNING 1 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 1 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd reborn1 sndcombat reborn2 sndextra reborn1 sndjedi reborn2 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith9 { playerModel rodian saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd rodian1 sndcombat rodian1 sndextra rodian1 sndjedi rodian1 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith10 { playerModel trandoshan saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd trandoshan1 sndcombat trandoshan1 sndextra trandoshan1 sndjedi trandoshan1 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith11 { playerModel reborn customSkin acrobat saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd reborn1 sndcombat reborn2 sndextra reborn1 sndjedi reborn2 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } Sith12 { playerModel reborn customSkin fencer saber reborn weapon WP_SABER saberStyle 2 saberStyle 1 altFire 1 health 200 FP_HEAL 3 FP_LEVITATION 2 FP_SPEED 0 FP_PUSH 2 FP_PULL 1 FP_TELEPATHY 0 FP_GRIP 0 FP_LIGHTNING 0 FP_RAGE 0 FP_PROTECT 1 FP_ABSORB 2 FP_DRAIN 0 FP_SEE 1 FP_SABERTHROW 2 //npc,s never get more than 2 because they spam it. FP_SABER_DEFENSE 5 FP_SABER_OFFENSE 5 rank captain reactions 5 aim 5 move 5 aggression 5 evasion 5 intelligence 5 hfov 160 vfov 160 yawSpeed 120 walkSpeed 50 runSpeed 170 earshot 2048 visrange 4096 vigilance 1 movetype "walk" playerTeam TEAM_ENEMY enemyTeam TEAM_PLAYER class CLASS_REBORN snd reborn1 sndcombat reborn2 sndextra reborn1 sndjedi reborn2 dismemberProbHead 95 dismemberProbArms 95 dismemberProbLegs 95 dismemberProbHands 0 dismemberProbWaist 95 } this or a variation of this will allow you to create a new random npc spawn list. Cerez and GamingPrince83 like this
kwenga Posted January 20, 2017 Posted January 20, 2017 As far as I know, You would have to make a new npc file. jedi_random.npc (assets1.pk3\ext_data\npcs\) has several models written in it, which makes that file different from other npc files. It's not difficult. Just copy random npc file, name it whatever-you-want, open it (use notepad or other txt editor), delete everything inside. You have a blank npc file. Open other files of your choice, copy whatever is inside them, paste it all to your blank file (don't mess up txt formating). Every time you use /npc spawn whatever-you-want, game should use one of your npcs. Remember to put your file back to assets1.pk3\ext_data\npcs, or create your own pk3 file with appropriate directory. EDIT: Or do what @@JaceSolarisVIII said.
Linken Posted January 20, 2017 Author Posted January 20, 2017 This also needs to be supported in the code. In the code add the following in. NPC _spawn.cpp static void NPC_Spawn_f(void) after Jedi_random add if ( !Q_stricmp( "jedi_random", NPCspawner->NPC_type ) ) {//special case, for testing NPCspawner->NPC_type = NULL; NPCspawner->spawnflags |= 4; SP_NPC_Jedi( NPCspawner ); } else if ( !Q_stricmp( "sith_random", NPCspawner->NPC_type ) ) {//special case, for testing NPCspawner->NPC_type = NULL; NPCspawner->spawnflags |= 4; SP_NPC_Sith( NPCspawner ); } else { NPC_Spawn( NPCspawner, NPCspawner, NPCspawner ); } then after void SP_NPC_Jedi( gentity_t *self) add a variation of this void SP_NPC_Sith( gentity_t *self) { if(!self->NPC_type) { if ( self->spawnflags & 4 ) {//random! int sanityCheck = 20; //just in case while ( sanityCheck-- ) { switch( Q_irand( 0, 11 ) ) { case 0: self->NPC_type = "Sith1"; break; case 1: self->NPC_type = "Sith2"; break; case 2: self->NPC_type = "Sith3"; break; case 3: self->NPC_type = "Sith4"; break; case 4: self->NPC_type = "Sith5"; break; case 5: self->NPC_type = "Sith6"; break; case 6: self->NPC_type = "Sith7"; break; case 7: self->NPC_type = "Sith8"; break; case 8: self->NPC_type = "Sith9"; break; case 9: self->NPC_type = "Sith10"; break; case 10: self->NPC_type = "Sith11"; break; case 11: default://just in case self->NPC_type = "Sith12"; break; } if ( strstr( self->NPC_type, g_char_model->string ) != NULL ) {//bah, we're using this one, try again continue; } break; //get out of the while } } else if ( self->spawnflags & 2 ) { self->NPC_type = "RebornFencer"; } else if ( self->spawnflags & 1 ) { self->NPC_type = "RebornForceUser"; } else { if ( !Q_irand( 0, 2 ) ) { self->NPC_type = "RebornRodian"; } else if ( Q_irand( 0, 1 ) ) { self->NPC_type = "RebornTrandoshan"; } else { self->NPC_type = "RebornWeequay"; } } } SP_NPC_spawner( self ); } then you need to make a npc file to match the names of the npc,c you have created .like this Ok, one question, where's NPC_spawn.cpp at? I'm working outside of OpenJK EDIT: Found NPC_Spawn.c, that doesn't have any mention of jedi_random in it.
GamingPrince83 Posted January 20, 2017 Posted January 20, 2017 Ok, one question, where's NPC_spawn.cpp at? I'm working outside of OpenJK EDIT: Found NPC_Spawn.c, that doesn't have any mention of jedi_random in it.Use the search function in Visual studio! :-)
JaceSolarisVIII Posted January 21, 2017 Posted January 21, 2017 Ok, one question, where's NPC_spawn.cpp at? I'm working outside of OpenJK EDIT: Found NPC_Spawn.c, that doesn't have any mention of jedi_random in it. NPC_spawn.c is for multiplayer , you need to find NPC_spawn.ccp. This is for singleplayer. make sure the names in the NPC file match the ones in the code. I used sith1 - sith12 in my example just to keep it simple. Just to clarify : The NPC file is for ext/npc,s assets and it must match the NPC_spawn.cpp code to work correctly.
Linken Posted January 22, 2017 Author Posted January 22, 2017 NPC_spawn.c is for multiplayer , you need to find NPC_spawn.ccp. This is for singleplayer. make sure the names in the NPC file match the ones in the code. I used sith1 - sith12 in my example just to keep it simple. Just to clarify : The NPC file is for ext/npc,s assets and it must match the NPC_spawn.cpp code to work correctly. Alright, didn't want to do this, gotta ask the noob question. Where is it? How do I access it?
JaceSolarisVIII Posted January 22, 2017 Posted January 22, 2017 Do you have access to the code? Openjk is the best way to go.I use Visual studio 2012 with the SerenityJediEngine, but Openjk is easier to work with and more readily available.The SerenityJediEngine is way more complicated than Openjk and has less people using it. So I suggest using Openjk, that's if its just small changes you want to make. Probably best to use Visual studio 2015 also but I'm no expert on which version is the best. I'm sure more knowledgeable people can help you with that one. You could then just copy/paste the code example I posted and edit it for your own purposes.
Linken Posted January 23, 2017 Author Posted January 23, 2017 Do you have access to the code? Openjk is the best way to go.I use Visual studio 2012 with the SerenityJediEngine, but Openjk is easier to work with and more readily available.The SerenityJediEngine is way more complicated than Openjk and has less people using it. So I suggest using Openjk, that's if its just small changes you want to make. Probably best to use Visual studio 2015 also but I'm no expert on which version is the best. I'm sure more knowledgeable people can help you with that one. You could then just copy/paste the code example I posted and edit it for your own purposes. I have Visual, as for access to the code, I got what I got from the SDK (which apparently doesn't include sp code ). Is there anyway to get access through base itself?
JaceSolarisVIII Posted January 24, 2017 Posted January 24, 2017 I have Visual, as for access to the code, I got what I got from the SDK (which apparently doesn't include sp code ). Is there anyway to get access through base itself? you will need this to have any success with your plan: https://github.com/JACoders/OpenJK this page may also help: https://jkhub.org/topic/7551-fork-megathread/
Linken Posted January 24, 2017 Author Posted January 24, 2017 you will need this to have any success with your plan: https://github.com/JACoders/OpenJK this page may also help: https://jkhub.org/topic/7551-fork-megathread/ Thank you very much Jace, I really appreciate all of your help.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now