
Posts
2,789
Respect
230Add +1
Forum Rank
King of the Zombies
Primary Group
Community Daedra
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;
// V1
// TODO:
// -try to fix closest node issue where AI would just run off and get killed.
// -increase responsiveness of the AI
// -add easy AI customization
// -fix trigger if statement bug
main()
{
// The max amount of "drones"
level.friendly_limit = 2;
// the cost of the trigger
level.h_cost = 1000;
// how many seconds until the AI move to a new node
level.drone_wait = 2;
level.ally = GetSpawnerTeamArray( "allies");
level.a_trigger = Getent("helper_trig","targetname");
thread drone_update();
thread trig_setup();
}
trig_setup()
{
level.a_trigger SetHintString( "Press F to buy a Friend [cost: " + level.h_cost + "]" );
while(isdefined(level.a_trigger) && isdefined(level.h_cost) )
{
player = get_players();
level.a_trigger waittill("trigger", player);
// there are three possible outcomes for when the player uses the trigger
if(player.score >= level.h_cost && level.friendlies.size != level.friendly_limit)
{
thread drone_spawn();
thread drone_move(player);
player maps\_zombiemode_score::minus_to_player_score( level.h_cost );
}
if(player.score >= level.h_cost && level.friendlies.size == level.friendly_limit)
{
player iprintln("You cannot buy anymore allies at this time!");
}
if(player.score < level.h_cost)
{
player maps\_zombiemode_perks::play_no_money_perk_dialog();
}
wait(1);
}
}
drone_spawn()
{
// spawns the AI array
for(i = 0; i < level.ally.size; i++)
{
level.ally[i] StalingradSpawn();
}
}
drone_move(player)
{
// moves the AI to the player
while(1)
{
if(isdefined(level.friendlies) )
{
for(i = 0; i < level.friendlies.size; i++)
{
nodes = GetAllNodes();
new_nodes = getClosest( player.origin, nodes );
level.friendlies[i] SetGoalNode( new_nodes );
}
}
wait(level.drone_wait);
}
}
drone_update()
{
// updates the array, needed for the if limit check
while(1)
{
level.friendlies = GetAISpeciesArray( "allies", "all" );
wait(.1);
}
}dd now i have to say it xD this script its actually interesting
btw get all nodes gets an array of the nodes, doesnt it?
maybe because you didnt looped through it thats why the ai just runs randomly