UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: DeletedUser on December 26, 2020, 06:48:48 pm

Title: how to script a choice of choosing between 2 triggers.
Post by: DeletedUser on December 26, 2020, 06:48:48 pm
heres the logic im trying to achieve-

https://imgur.com/EM1JFbm (https://imgur.com/EM1JFbm)
Title: Re: how to script a choice of choosing between 2 triggers.
Post by: GabeTheGreat on December 26, 2020, 07:19:47 pm
heres the logic im trying to achieve-

https://imgur.com/U2XD5W0 (https://imgur.com/U2XD5W0)
Actually, what are you trying to do here, you're psuedo code is not really specific and what do you mean by "lot"?
Title: Re: how to script a choice of choosing between 2 triggers.
Post by: DeletedUser on December 27, 2020, 09:14:08 am
heres a vid of what im trying to do. its what ive done so far. i just need to sort the [select] bit out now. which is why i need 2 trigs to remain active and the player can choose from 1 of the 2 & depending on which one they choose depends on whether the script 'proceeds' or returns to start.

https://www.youtube.com/watch?v=RMqpV22urvs&ab_channel=PhilGibson (https://www.youtube.com/watch?v=RMqpV22urvs&ab_channel=PhilGibson)

heres the code i have written also-

```

Code Snippet
Plaintext
gun_machine()

{

    zombie_ppsh = getEnt("zombie_ppsh","targetname"); //zombie_ppsh

    zombie_mg42 = getEnt("zombie_mg42","targetname"); //zombie_mg42

    zombie_cymbal_monkey = getEnt("zombie_cymbal_monkey","targetname"); //zombie_cymbal_monkey

    zombie_ppsh hide();

    zombie_mg42 hide();

    zombie_cymbal_monkey hide();

   

    trig = getEnt("gun_machine_trig", "targetname");

    trig setHintString("Press X to browse gun catalogue");

    trig setCursorHint("HINT_NOICON");

   

    pistol = getEnt("pistol", "targetname"); //buy weapon

    melee = getEnt("melee", "targetname"); //cycle thru weapons

   

    trig waittill ("trigger", player);

    zombie_ppsh show();

    trig setHintString("PPSH - [Cost 100] 'Shoot' to buy, OR 'Melee' to see next weapon");

   

        while(1)

        {    

            melee waittill ("trigger", player);

           

                zombie_ppsh hide();

                zombie_mg42 show();

               

                trig setHintString("MG42 - [Cost 100] 'Shoot' to buy, OR 'Melee' to see next weapon");

           

            melee waittill ("trigger", player);

           

                zombie_mg42 hide();

                zombie_cymbal_monkey show();

               

                trig setHintString("MONKEY's - [Cost 100] 'Shoot' to buy, OR 'Melee' to see next weapon");

           

            melee waittill ("trigger", player);

           

                zombie_cymbal_monkey hide();

                zombie_ppsh show();

               

                trig setHintString("PPSH - [Cost 100] 'Shoot' to buy, OR 'Melee' to see next weapon");

        }


        while(1)

        {    

            pistol waittill ("trigger", player);

       

            if (player.score >= 100)

            {

                primariesList = player getWeaponsListPrimaries(); //checks how many weapons player has

               

                if( primariesList.size >= 2 ) // ok, you have bla bla, ill now proceed accordingly

                {

                    iPrintLnBold ("Sorry. Both Weapon Slots Filled Already!"); // should only see this if i have 2(+) weapons

                }

                   

                else

                {

                    player maps\_zombiemode_score::minus_to_player_score( 100 );

                    player giveWeapon("zombie_ppsh");

                    player switchToWeapon("zombie_ppsh");

                    player giveStartAmmo("zombie_ppsh");

                    player giveMaxAmmo("zombie_ppsh");

                    iPrintLnBold("PPSH Acquired");

                }

            }

           

            else

            {

                iPrintLnBold("Insuficient Funds Available");

            }

        }


    while(1)

    {    

        pistol waittill ("trigger", player);

   

        if (player.score >= 100)

        {

            primariesList = player getWeaponsListPrimaries();

           

            if( primariesList.size >= 2 )

            {

                iPrintLnBold ("Sorry. Both Weapon Slots Filled Already!");

            }

               

            else

            {

                player maps\_zombiemode_score::minus_to_player_score( 100 );

                player giveWeapon("zombie_mg42");

                player switchToWeapon("zombie_mg42");

                player giveStartAmmo("zombie_mg42");

                player giveMaxAmmo("zombie_mg42");

                iPrintLnBold("MG42 Acquired");

            }

        }

       

        else

        {

            iPrintLnBold("Insuficient Funds Available");

        }

    }

   

    while(1)

    {    

        pistol waittill ("trigger", player);

   

        if (player.score >= 100)

        {

            primariesList = player getWeaponsListPrimaries();

           

            if( primariesList.size >= 2 )

            {

                iPrintLnBold ("Sorry. Both Weapon Slots Filled Already!");

            }

               

            else

            {

                player maps\_zombiemode_score::minus_to_player_score( 100 );

                player giveWeapon("zombie_cymbal_monkey");

                player switchToWeapon("zombie_cymbal_monkey");

                player giveStartAmmo("zombie_cymbal_monkey");

                player giveMaxAmmo("zombie_cymbal_monkey");

                iPrintLnBold("MONKEY's Acquired");

            }

        }

       

        else

        {

            iPrintLnBold("Insuficient Funds Available");

        }

    }

}
```

Double Post Merge: December 27, 2020, 09:19:11 am

Actually, what are you trying to do here, you're psuedo code is not really specific and what do you mean by "lot"?
this is what i mean by "lot" https://imgur.com/4gBsbWw (https://imgur.com/4gBsbWw)
there are 2 weapons and monkeys in the machine. so 3 "lots" of trigs & each "lot" containing 2 trigs. 1 to cycle to next weapon & 1 to select a weapon.
Title: Re: how to script a choice of choosing between 2 triggers.
Post by: GabeTheGreat on December 27, 2020, 12:13:59 pm
heres a vid of what im trying to do. its what ive done so far. i just need to sort the [select] bit out now. which is why i need 2 trigs to remain active and the player can choose from 1 of the 2 & depending on which one they choose depends on whether the script 'proceeds' or returns to start.
Can I see how you have it setup in Radiant? Also, add me on discord: LilGabe#2429
Title: Re: how to script a choice of choosing between 2 triggers.
Post by: gympie6 on December 30, 2020, 11:53:05 pm
You need to thread the methods to achieve your goal.
you know...
self thread Test1();
self thread Test2();
self thread Test3();

Like a crossway where you can task your workers to do stuff for you.
Title: Re: how to script a choice of choosing between 2 triggers.
Post by: DeletedUser on December 31, 2020, 02:53:04 pm
You need to thread the methods to achieve your goal.
you know...
self thread Test1();
self thread Test2();
self thread Test3();

Like a crossway where you can task your workers to do stuff for you.
like you mentiond before-

"I don't know which way you want
you can loop through an array of triggers and thread it to one method
or you can get a few entities like I have here and thread those"

im currently trying out- "you can loop through an array of triggers and thread it to one method".

issue im having is even tho i can choose between 1 or the other trig. in order to get weapon 2 i 1st Have to get weapon1. i can cycle thru the 3 functions with no problem. it just wont let me get access to another other weapon until weapon1 trig has been activated. so even tho i can choose. i still have to also use both trigs to proceed to acquiring weapon2 from func2. i tried endon & notify. which i got it working. (to killt the function i mean by 'working'. not the script). but i need to call on each func at the end so terminating the func is no good here. as both trigs are within a loop and i have a break; outside of both trigs, but inside the loop. i thought that by selecting any trig it would then break out of the loop, therefore forgetting about the other trig and then proceed to func2();. but this isnt the case