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

Generating random node usage through script

broken avatar :(
Created 11 years ago
by DidUknowiPwn
0 Members and 1 Guest are viewing this topic.
2,961 views
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Current code for lukkie's Target Practice request.

Code Snippet
Plaintext
/*******************************************************************
Challenge - Target Practice
Objective: Test your skills here! Shoot all the teddy's to win.
----
*******************************************************************/
roomTargetPractice(player)
{
level endon("end_game");
level endon("room_tp_end");

//DUKIP - Set the player before starting the TP.
player tpSetupPlayer();
level thread tpStartup(player);
level thread challengeSetTimer(30, player, "target_practice");
}

tpStartup(player)
{
level endon("end_game");
level endon("room_tp_end");
tpEnts = GetEntArray("room_tp_bears", "targetname");
level.challenge_teddy_hit = 0;
level.challenge_total_teddy = tpEnts.size;
//fix this
level.tp_angles_vector = (90, 0, 0);
//play some sound/fx?
//countdown 3-2-1-go!
array_thread(tpEnts, ::tpMain);
}

tpMain()
{
level endon("end_game");
level endon("room_tp_end");
self thread tpDamageFeedback();
self thread tpMovementThink();
}

tpDamageFeedback()
{
level endon("end_game");
level endon("room_tp_end");
self SetCanDamage(true);
self waittill( "damage", damage, attacker );
self SetCanDamage(false);
level.challenge_teddy_hit++;
//DUKIP - make sure to in _zombiemode -> add_sound( "ding", "sound_alias" );
//self play_sound_on_ent("ding");
//play some feather fx (or maybe the bear will already do it).
self Hide();
self.is_active = false;

if(level.challenge_teddy_hit >= level.challenge_total_teddy)
level thread tpCleanup(attacker);
}

tpCleanup(player)
{
level endon("end_game");
level endon("room_tp_end");

level thread tpReset();
level thread giveChallengeAward(player, "target_practice");
tpEnts = GetEntArray("room_tp_bears", "targetname");
for(i = 0; i < tpEnts.size; i ++)
{
tpEnts[i] Show();
tpEnts[i] SetOrigin(tpEnts[i].original_pos);
}
}

tpMovementThink()
{
level endon("end_game");
level endon("room_tp_end");

self.original_pos = self.origin;
self.moving_to_node = undefined;
self.is_active = true;

while(true && self.is_active)
{
goToNode = tpSelectNode(self);
if(IsDefined(goToNode))
{
self.moving_to_node = true;
goToNode.is_active = true;
self MoveTo(goToNode.origin, 1, 0.05, 0.05);

self waittill("movedone");

self.moving_to_node = false;
goToNode.is_active = false;
continue;
}

wait 0.05;
}
}

tpSelectNode(ent)
{
level endon("end_game");
level endon("room_tp_end");

while(self.moving_to_node)
wait 0.05;

originalTPNodes = GetEntArray("room_tp_nodes", "targetname");
filterNodes = tpGenerateFilteredNodes(originalTPNodes);

goodNodes = array_exclude(originalTPNodes, filterNodes);
//DUKIP - Need to generate node based on 1x1 away.
//So fix asap.
theNode = tpSelectRandomNode(goodNodes);

return theNode;
}

tpSelectRandomNode(nodes)
{
nodes = array_randomize(nodes);
goodNode = undefined;
while(true)
{
if(goodNode)
break;
for(i = 0; i <= nodes.size; i++)
{
coinflip = cointoss();
if(coinflip) //go up
{
coinflip = cointoss();
if(coinflip) //go left
{

}
else //go right
{

}
}
else //go down
{
coinflip = cointoss();
if(coinflip) //go left
{

}
else //go right
{

}
}
}
}
return goodNode;
}

tpGenerateFilteredNodes(nodes)
{
inUseNodes = [];
for(i = 0; i < nodes.size; i++)
{
if(nodes[i].is_active)
inUseNodes[inUseNodes.size] = nodes[i];
}
return inUseNodes;
}

tpSetupPlayer()
{
level endon("end_game");
level endon("room_tp_end");

self AllowStand(true);
self AllowCrouch(false);
self AllowProne(false);
self AllowSprint(false);
self SetMoveSpeedScale(0);

self SetPlayerAngles(level.tp_angles_vector);
self thread giveTPRandomWeapon();
self thread tpReEnableMovement();
}

giveTPRandomWeapon()
{
level endon("end_game");
level endon("room_tp_end");
self endon("death");
self endon("disconnect");

primaryWeapons = self GetWeaponsListPrimaries();
weaponToGive = maps\_zombiemode_weapons::treasure_chest_ChooseRandomWeapon(self);
self GiveWeapon(weaponToGive);
self GiveMaxAmmo(weaponToGive);
self SwitchToWeapon(weaponToGive);
self DisableOffhandWeapons();
self DisableWeaponCycling();

//DUKIP - Modified function from T6, script resumes when one of these 4 notifies are received.
waittill_any_ents_four( level, "room_tp_end", level, "end_game", self, "fake_death", self, "player_downed" );
self thread reEnableWeapons(weaponToGive, primaryWeapons[0]);
}

tpReEnableMovement()
{
level endon("end_game");
level endon("room_tp_end");

waittill_any_ents_four( level, "room_tp_end", level, "end_game", self, "fake_death", self, "player_downed" );

if(maps\_laststand::player_is_in_laststand())
{
self SetMoveSpeedScale(1);
return;
}

self AllowStand(true);
self AllowCrouch(true);
self AllowProne(true);
self AllowSprint(true);
self SetMoveSpeedScale(1);

}
Current issue is starting from tpSelectNode(ent), so I'm trying to select a random node (entity) within a certain radius (probably 24 units) I haven't implemented the distance checks and stuff yet because I can't think of a proper method to select a new node in tpSelectRandomNode(nodes). The point being that the node has to be a certain units away and is accessible, anyone got any ideas?
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
Couldn't you just add and remove the possible ents from an array based off of the distance and when it was last used? Haven't really looked at code but I don't see why that wouldn't work.
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Couldn't you just add and remove the possible ents from an array based off of the distance and when it was last used? Haven't really looked at code but I don't see why that wouldn't work.
I could haven't thought about really. I've never messed with 3d/vector stuff so I wouldn't know how to use distance functionality yet.
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 could haven't thought about really. I've never messed with 3d/vector stuff so I wouldn't know how to use distance functionality yet.

You've never used distance before?  :o
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
You've never used distance before?  :o
Nah I think I'll just have to gut it until I can figure it out later.
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
Can you get all the nodes and check distance2D, and add to an array if you can see them with a DamageConeTrace, and then randomize array and take the 0-th one?

Edit: 24 units? Isn't that like a foot in front of the player? Would go 2400 prob...?
Last Edit: February 27, 2015, 02:40:31 pm by MakeCents

 
Loading ...