UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: whippytrout on February 03, 2014, 01:20:44 am

Title: I need help spawning different zombie variants
Post by: whippytrout on February 03, 2014, 01:20:44 am
Hey guys I need a little help with something. I have two zombie models from black ops that work great but I want the player to be able to choose in-game which zombie model will spawn. I created two triggers in my map, each one activates the zombie rounds start, but  I also want it to select the zombies model itself. For example if i choose trigger_1 then round 1 will start and moon zombies will spawn and start attacking. On the other hand if I choose trigger_2 then the round will start but hazmat zombies will spawn. It will be up to the player which kind of zombies will spawn. As of now the zombie models are being randomly set in my char_ger_honorguard_zombies.gsc. Any help would be appreciated.
Title: Re: I need help spawning different zombie variants
Post by: YaPh1l on February 03, 2014, 10:02:57 am
Well, instead of checking for a random number, check for a level variable that you set according to which trigger the player used.

- Phil.
Title: Re: I need help spawning different zombie variants
Post by: whippytrout on February 04, 2014, 12:37:56 am
I know that's the part I'm having trouble figuring out. I have a trig in place but I dont know how to setup the script. Right now I have a simple line that chooses a random int and spawns random zombies but I want to be able to choose what zombie model is going to be used by using a trigger in game. How would I set up a loop or statement to achieve this goal? Here is a look at what I have:
       
Code Snippet
Plaintext
 self.num_bodies = 10;
self.bodie = randomint(self.num_bodies);   // I was thinking I can change this to something but IDK
if(self.bodie == 0)
{
self setModel("bo2_c_zom_dlc0_zom_sol_body1");
self.headModel = "bo2_c_zom_dlc0_zom_head3";
self attach("bo2_c_zom_dlc0_zom_head3", "", true);
         }
if(self.bodie == 1)
{
self setModel("bo2_c_zom_dlc0_zom_solciv_body1");
self.headModel = "bo2_c_zom_dlc0_zom_head4";
self attach("bo2_c_zom_dlc0_zom_head4", "", true);
}
..... so on and so on
Title: Re: I need help spawning different zombie variants
Post by: YaPh1l on February 04, 2014, 12:55:17 am
As I've already said
check for a level variable that you set according to which trigger the player used
That's all you need to do.
In your trigger, set something like
Code Snippet
Plaintext
// Obviously a different number for every trigger
level.zombie_variant = 4;
And in your character file, just check for that variable set by the trigger.

- Phil.
Title: Re: I need help spawning different zombie variants
Post by: whippytrout on February 04, 2014, 01:51:27 am
I'm not sure if this is correct but I made my triggers with KVP's of:
Code Snippet
Plaintext
targetname: hazmat_trig
zombie_variant: 1
and
Code Snippet
Plaintext
targetname: prisoner_trig
zombie_variant: 2
then in my character gsc I have
Code Snippet
Plaintext
main()
{

trig = getEnt("hazmat_trig", "targetname");
trig2 = getEnt("prisoner_trig", "targetname");

trig UseTriggerRequireLookAt();
trig sethintstring("Press F to Pickup Orb");
trig waittill ("trigger");
trig delete();

                trig2 UseTriggerRequireLookAt();
trig2 sethintstring("Press F to activate block");
trig2 waittill ("trigger");
trig2 delete();

if(level.zombie_variant == 1)
{
self setModel("bo1_c_zom_cosmo_scientist_body");
self attach("bo1_c_zom_cosmo_scientist_head2", "", true);
}

if(level.zombie_variant == 2)
{
self setModel("bo2_c_zom_inmate_body2");
self attach("bo2_c_zom_zombie_hellcatraz_head", "", true);
}

self.voice = "german";

}

Now the weird thing is that when I activate the trigger the game starts lagging every 5 seconds like its running an infinte loop or something, zombies dont spawn and I get bones errors if I use the second trigger. But the zombie variants worked before. I also need to mention that I dont know have the start round trigger in the game get due to I dont know how to link the start rounds trigger to each of these triggers so that it selects the zombie model then starts the round. If I can do that then it might fix it if I'm even doing this right. But that trigger is in _zombiemode and looks like this:
Code Snippet
Plaintext
round_start()
{
activate_trig = getent ("start_rounds", "targetname");
activate_trig waittill ("trigger");
.....ect
}
Title: Re: I need help spawning different zombie variants
Post by: daedra descent on February 04, 2014, 02:44:25 am
Code Snippet
Plaintext
main()
{
   
    trig = getEnt("hazmat_trig", "targetname");
    trig2 = getEnt("prisoner_trig", "targetname");

        trig UseTriggerRequireLookAt();
        trig sethintstring("Press F to Pickup Orb");
        trig waittill ("trigger");
        trig delete();

                trig2 UseTriggerRequireLookAt();
        trig2 sethintstring("Press F to activate block");
        trig2 waittill ("trigger");
        trig2 delete();

// the following are the spawners - each one needs to be seperate for this to work, or apart of an array if there are alot of them
// also, i think it would be better to specify each variant with a switch/case statement than an if statement for the same reasons

level.zombie_variant_1 = getEntarray("zombie_variant_1", "targetname");
level.zombie_variant_2 = getEntarray("zombie_variant_2", "targetname");
       
        if(isdefined(level.zombie_variant_1) )
        {
            self setModel("bo1_c_zom_cosmo_scientist_body");
            self attach("bo1_c_zom_cosmo_scientist_head2", "", true);
        }
       
        if(isdefined(level.zombie_variant_2) )
        {
            self setModel("bo2_c_zom_inmate_body2");
            self attach("bo2_c_zom_zombie_hellcatraz_head", "", true);
        }
   
    // self.voice = "german"; an actors voice is declared by their spawner type(Aly/Axis)
   
}

Don't know if it works or not, worth a try i suppose.
Title: Re: I need help spawning different zombie variants
Post by: YaPh1l on February 04, 2014, 09:19:10 am
I'm not sure if this is correct but I made my triggers with KVP's of:
No, I haven't said you should put a KVP anywhere. Do not, I repeat, NOT do any trigger code in your character file.
Why? Because this is what you just did: Your code waits until both triggers are hit. Then deletes them. This runs everytime a zombie tries to spawn. You see the problem?
In your character code, you only check for the level variable.
In your trigger code, you set it. That's it.
If you want your trigger to start the round too, just wait on a level notify in round_start(),
Code Snippet
Plaintext
level waittill("start_rounds");
and notify it when one of your character triggers is hit.
Code Snippet
Plaintext
level notify("start_rounds");

- Phil.
Title: Re: I need help spawning different zombie variants
Post by: whippytrout on February 05, 2014, 12:16:19 am
Thanks that makes sense. I have been trial and error testing this for about an hour and one trigger works great, it starts the rounds and spawns the right zombie but the other one dont even work. It just displays a hand and nothing happens if you click it. Here is my code maybe you can see what I'm doing wrong:

Code Snippet
Plaintext
start_zombies()
{

trig = getEnt("hazmat_trig", "targetname");
trig2 = getEnt("cell_trig", "targetname");
level.zombie_variant = 0;

if(isdefined(trig))
  {
trig SetCursorHint("HINT_NOICON");
      trig SetHintString("Press & Hold &&1 to Pickup Orb");
      while(1)
      {
trig waittill("trigger", user);
        if( is_player_valid(user))
        {
user playsound( "cha_ching" );
    level.zombie_variant = 1;
level notify("start_rounds");
    trig delete();
trig2 delete();
}
  }
  }

 
if(isdefined(trig2))
  {
trig2 SetCursorHint("HINT_NOICON");
      trig2 SetHintString("Press & Hold &&1 to Read Book");
      while(1)
      {
trig2 waittill("trigger", user);
        if( is_player_valid(user))
        {
user playsound( "cha_ching" );
    level.zombie_variant = 2;
level notify("start_rounds");
    trig delete();
trig2 delete();
}
  }
  }
 
}
Title: Re: I need help spawning different zombie variants
Post by: jjbradman on February 05, 2014, 04:33:51 am
maybe because theres any statemente refering to trig2 except for the delete part lol
Title: Re: I need help spawning different zombie variants
Post by: YaPh1l on February 05, 2014, 09:23:52 am
You have one function running. It checks and waits for the first trigger to be pressed. Then deletes both. Then it checks if the second trigger is still there... You see?
You need two threaded functions, one for every trigger.

- Phil.
Title: Re: I need help spawning different zombie variants
Post by: whippytrout on February 05, 2014, 03:45:37 pm
Thanks YaPh1l I got it working now. You sure know your stuff, you helped me out and I learned something at the same time. I appreciate your help.