///////////////////////////////
//includes
#include <acknex.h> //contains all the predefined structures
#include <default.c> //mouse and controls predefined
//#include "mtlFX.c" //material & shaders
///////////////////////////////
//global variables
STRING* strLevel = "Gtest.WMB";
STRING* strModel = "agent.MDL";
ENTITY* entAgent[1000];
var run_percentage;
var agent_count = 0;
var mygravity;
int no_of_agents = 100;
//action for walk animation of entity
action entity_walk()
{
var walk_percentage;
var move_result;
var pan_count = 0;
var speed_down = 0;
VECTOR vFeet;
vec_for_min(vFeet,me);
wait(1);
while(1)
{
pan_count = 0;
c_move (my, nullvector, vector(0,0,10), IGNORE_PASSABLE);
c_move (my, vector(7 * time_step, 0, 0), nullvector, IGNORE_PASSABLE);
c_move (my, nullvector, vector(0,0,-10), IGNORE_PASSABLE);
//walk animation sequence
ent_animate(me,"walk",walk_percentage, ANM_CYCLE);
//collision detection and resolution
if (event_type == EVENT_ENTITY)
{
me.pan = random(360);
pan_count += 1;
wait(1);
}
//
// if(trace_hit != 0)
// {
//
// me.pan = random(360);
// pan_count += 1;
// wait(1);
//
// }
//
walk_percentage += 4 * time_step;
wait(1);
}
}
//funtion to load entities
function load_entity()
{
randomize();
var ran_pos_x, ran_pos_y;
var i, j;
for(i=0; i<no_of_agents; i++)
{
wait(1);
ran_pos_x = random(3000)-1710;
ran_pos_y = random(3000)-1642;
//create entity
entAgent[i] = ent_create(strModel, vector(ran_pos_x,ran_pos_y,-240), entity_walk);
agent_count +=1;
//scale entity
entAgent[i].scale_x = 2;
entAgent[i].scale_y = 2;
entAgent[i].scale_z = 2;
entAgent[i].pan = random(360);
//setting bounding box to tight fit for better collision detection0
//wait(1);
c_setminmax(entAgent[i]);
//set shadows on
set(entAgent[i], SHADOW);
}
}
//main function
function main()
{
//800x600 screen resolution
video_mode = 6;
//1-fullscreen, 2-window mode
video_screen = 2;
//mouse mode
mouse_mode = 1;
max_entities = 1000;
//loading level
level_load(strLevel);
wait(2);
//call function to create agent
load_entity();
}