UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Only three or four array values work?

broken avatar :(
Created 12 years ago
by daedra descent
0 Members and 1 Guest are viewing this topic.
3,061 views
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Only three or four of my array values work, and i don't know why. If i switch the order the ones that are in the front three or four work, while the rest don't.

code:

Code Snippet
Plaintext
level.random = randomint(level.rm.size);

if(level.random == 1 && iscurrent != level.rm[0])
{
level.powerup = level.rm[0];
iscurrent = level.powerup;
}
if(level.random == 2 && iscurrent != level.rm[1])
{
level.powerup = level.rm[1];
iscurrent = level.powerup;
}
if(level.random == 3 && iscurrent != level.rm[2])
{
level.powerup = level.rm[2];
iscurrent = level.powerup;
}
if(level.random == 4 && iscurrent != level.rm[3])
{
level.powerup = level.rm[3];
iscurrent = level.powerup;
}
if(level.random == 5 && iscurrent != level.rm[4])
{
level.powerup = level.rm[4];
iscurrent = level.powerup;
}
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
I have no idea what this is for but the code looks overcomplicated. Give more context, you dont even show your declaration of level.rm.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 16 June 2013
Last active: 4 years ago
Posts
1,005
Respect
Forum Rank
Zombie Colossus
Primary Group
Mapper
My Groups
More
My Contact & Social Links
More
Signature
Hey if you had tons of fun on playing my maps please DONATE :)

play ESTATE now, and claim your mansion back from the undead!
×
jei9363's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Mapper Has released one or more maps to the UGX-Mods community.
jei9363's Contact & Social Linksjayingardiajei9363jei9363
level.random tested for 1,2,3,4,5

possible outcomes of randomint(level.rm.size);

0,1,2,3,4



Post Merge: April 30, 2014, 02:30:02 am
dont know whats going on here but change to this

Code Snippet
Plaintext
level.random = randomint(level.rm.size);


if(level.random == 0 && iscurrent != level.rm[0])
{
level.powerup = level.rm[0];
iscurrent = level.powerup;
}
if(level.random == 1 && iscurrent != level.rm[1])
{
level.powerup = level.rm[1];
iscurrent = level.powerup;
}
if(level.random == 2 && iscurrent != level.rm[2])
{
level.powerup = level.rm[2];
iscurrent = level.powerup;
}
if(level.random == 3 && iscurrent != level.rm[3])
{
level.powerup = level.rm[3];
iscurrent = level.powerup;
}
if(level.random == 4 && iscurrent != level.rm[4])
{
level.powerup = level.rm[4];
iscurrent = level.powerup;
}
Last Edit: April 30, 2014, 02:35:50 am by jei9363
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I have no idea what this is for but the code looks overcomplicated. Give more context, you dont even show your declaration of level.rm.

I suppose that would help, xD

Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;


main()
{
level.trigger = getent("powerup_machine","targetname");
level.rp = getent("random_model","targetname");

level.rm = [];
level.rm[level.rm.size] = "zombie_bomb";
level.rm[level.rm.size] = "zombie_carpenter";
level.rm[level.rm.size] = "zombie_ammocan";

level.rm[level.rm.size] = "zombie_skull";
level.rm[level.rm.size] = "zombie_x2_icon";


level.wait_time = 5;

level.trigger_cost = 100; // change this later

level thread start_randomize();

level thread trigger_setup();
}
trigger_setup()
{
while(1)
{
player = get_players();

level.trigger SetHintString( "Press F to activate random powerup machine[cost: " + level.trigger_cost + "]" );

level.trigger waittill("trigger", player);

if(isdefined(level.trigger) && player.score >= level.trigger_cost)
{
// rp_test();
player maps\_zombiemode_score::minus_to_player_score( level.trigger_cost );
player magic_init();
}
if(isdefined(level.trigger) && player.score < level.trigger_cost)
{
iprintln("Not Enough Money!");
player maps\_zombiemode_perks::play_no_money_perk_dialog();
}
wait(1);
}
}
magic_init()
{
rand = undefined;
level.cycles = 15;

model_cycle();

if(level.powerup == "zombie_ammocan")
{
maps\_zombiemode_powerups::full_ammo_powerup( "null" );
}
else if(level.powerup == "zombie_skull")
{
maps\_zombiemode_powerups::insta_kill_powerup( "null" );
}
else if(level.powerup == "zombie_carpenter")
{
players = get_players();
maps\_zombiemode_powerups::start_carpenter( players[0].origin );
}
else if(level.powerup == "zombie_bomb")
{
players = get_players();
maps\_zombiemode_powerups::nuke_powerup("null");
}
else if(level.powerup == "zombie_2x_icon")
{
maps\_zombiemode_powerups::double_points_powerup("null");
}
}
model_cycle()
{
cm = 0;
level.powerup = undefined;
iscurrent = current_watch();

while(cm != level.cycles)
{
level.random = randomint(level.rm.size);

if(level.random == 1 && iscurrent != level.rm[0])
{
level.powerup = level.rm[0];
iscurrent = level.powerup;
}
if(level.random == 2 && iscurrent != level.rm[1])
{
level.powerup = level.rm[1];
iscurrent = level.powerup;
}
if(level.random == 3 && iscurrent != level.rm[2])
{
level.powerup = level.rm[2];
iscurrent = level.powerup;
}
if(level.random == 4 && iscurrent != level.rm[3])
{
level.powerup = level.rm[3];
iscurrent = level.powerup;
}
if(level.random == 5 && iscurrent != level.rm[4])
{
level.powerup = level.rm[4];
iscurrent = level.powerup;
}
iprintln("Current Powerup: " + level.powerup);
level.rp setmodel( level.powerup );
cm++;
wait(.7);
}
}
start_randomize()
{
while(1)
{
// level.random = Randomint(level.rm.size);
wait(.1);
}
}
current_watch()
{
while(1)
{
last_powerup = level.powerup;
return last_powerup;
wait(.7);
}
}



The iscurrent is to stop the powerup from showing up twice, but it doesn't work.

level.random tested for 1,2,3,4,5

possible outcomes of randomint(level.rm.size);

0,1,2,3,4



Post Merge: April 30, 2014, 02:30:02 am
dont know whats going on here but change to this

Code Snippet
Plaintext
level.random = randomint(level.rm.size);


if(level.random == 0 && iscurrent != level.rm[0])
{
level.powerup = level.rm[0];
iscurrent = level.powerup;
}
if(level.random == 1 && iscurrent != level.rm[1])
{
level.powerup = level.rm[1];
iscurrent = level.powerup;
}
if(level.random == 2 && iscurrent != level.rm[2])
{
level.powerup = level.rm[2];
iscurrent = level.powerup;
}
if(level.random == 3 && iscurrent != level.rm[3])
{
level.powerup = level.rm[3];
iscurrent = level.powerup;
}
if(level.random == 4 && iscurrent != level.rm[4])
{
level.powerup = level.rm[4];
iscurrent = level.powerup;
}

Treyarch commented in the box function that its from 1-value, but i tried this anyway and it didn't work.

Post Merge: April 30, 2014, 03:51:15 am
NVM! i fixed it!

The issue was

Code Snippet
Plaintext
level.random = randomint(level.rm.size);

randomint does one less than the actual size, in which case is 4. This caused the last powerup to not be registered. I fixed it by doing this:

Code Snippet
Plaintext
level.random = randomint(level.rm.size + 1);

HOWEVER, the iscaused still isn't working. Could someone help me out with that?
Last Edit: April 30, 2014, 03:51:16 am by daedra descent
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
The iscurrent is to stop the powerup from showing up twice, but it doesn't work.
You only ever store the most recent one, to make sure you don't pick it again right afterwards. However, the iteration after that, it can be picked again, as iscurrent now holds the new last powerup.
Also:
start_randomize() is currently useless.
current_watch() is useless, too.
model_cycle() could be made a lot shorter.

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
You only ever store the most recent one, to make sure you don't pick it again right afterwards. However, the iteration after that, it can be picked again, as iscurrent now holds the new last powerup.
Also:
start_randomize() is currently useless.
current_watch() is useless, too.
model_cycle() could be made a lot shorter.

- Phil.

The issue is that it will randomly select the same powerup 2, 3, or even 4 times before randomizing again.

I have got rid of the unneeded functions, but what would i use to make model_cycle() shorter?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I have got rid of the unneeded functions, but what would i use to make model_cycle() shorter?

Can you use a for loop since the only thing different between the if statements is the number?

Code Snippet
Plaintext
    for(i=0;i<5;i++){
        if(level.random == i+1 && iscurrent != level.rm[i])
        {
            level.powerup = level.rm[i];
            iscurrent = level.powerup;
        }
    }
               

instead of
Code Snippet
Plaintext
		if(level.random == 1 && iscurrent != level.rm[0])
{
level.powerup = level.rm[0];
iscurrent = level.powerup;
}
if(level.random == 2 && iscurrent != level.rm[1])
{
level.powerup = level.rm[1];
iscurrent = level.powerup;
}
if(level.random == 3 && iscurrent != level.rm[2])
{
level.powerup = level.rm[2];
iscurrent = level.powerup;
}
if(level.random == 4 && iscurrent != level.rm[3])
{
level.powerup = level.rm[3];
iscurrent = level.powerup;
}
if(level.random == 5 && iscurrent != level.rm[4])
{
level.powerup = level.rm[4];
iscurrent = level.powerup;
}
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
When RandomInt() returns the same value a second time, your code doesn't do anything. Meaning that it will just keep the previous one for this cycle.

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
When RandomInt() returns the same value a second time, your code doesn't do anything. Meaning that it will just keep the previous one for this cycle.

- Phil.

So how do i make sure it doesn't give the same value twice? Do i need to use a different function for randomizing the model?
Last Edit: May 01, 2014, 11:46:30 am by daedra descent
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
So how do i make sure it doesn't give the same value twice?
Well, change your logic so that it handles this case properly. That's the challenge of programming.
Commonly, if you want a random number, but exclude a specific one in the range, you generate random numbers, until you get one that is not equal to the one you don't want.
You could also be using a randomized array in your case.
Etc. etc.

- Phil.

 
Loading ...