Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,209 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Aum 54, Dungeon creator #295373
10/24/09 20:59
10/24/09 20:59
Joined: Mar 2009
Posts: 42
Dominican Republic
keilyn3d Offline OP
Newbie
keilyn3d  Offline OP
Newbie

Joined: Mar 2009
Posts: 42
Dominican Republic
what I need to change for make the dugeon creator work? this don't work with the A7.7 or 7.8.
(I don't mean convert it to Lite-c).

this is the code from aum 54 but it not work (the level is not created):

Click to reveal..

////////////////////////////////////////////////////////////////////////////////////////
// "#" = wall
// " " = floor
// "p" = player
// "s" = spider
// "f" = finish
////////////////////////////////////////////////////////////////////////////////////////

var video_mode = 8; // 1024x768
var video_depth = 32; // 32 bit mode
var video_screen = 2; // start in full screen mode

var level_handle; // handle for the level data file
var level_size_x;
var level_size_y;
var lines_index;
var all_placed = 0; // will be set to 1 as soon as the entire level is created
var starting_position;
var char_index;
var floor_coords;
var players_health = 100;
var player_spotted = 0; // will alarm all the spiders as soon as the first spider sees the player

////////////////////////////////////////////////////////////////////////////////////////

sound beep_sound = <beep.wav>;

////////////////////////////////////////////////////////////////////////////////////////

string bigroom_wmb = <bigroom.wmb>;
string wall_wmb = <wall.wmb>;
string floor_wmb = <floor.wmb>;
string player_mdl = <player.mdl>;
string spider_mdl = <spider.mdl>;
string finish_mdl = <finish.mdl>;

string level_chars[900]; // stores the characters, the level can have up to 30 x 30 = 900 blocks
string line_characters[30]; // a level must have a maximum number of 30 blocks on x and y
string temp_string[30];
string empty_space = " "; // 30 empty spaces
string current_character = " "; // empty space

////////////////////////////////////////////////////////////////////////////////////////

function read_level_data();
function make_static();
function finish_action();
function players_action();
function spider_action();
function spider_event();

////////////////////////////////////////////////////////////////////////////////////////

function main()
{
randomize(); // initialize the random number generator
all_placed = 0; // the level elements aren't placed at this point
level_load(bigroom_wmb); // load the level
wait (3); // wait until the level is loaded
read_level_data(); // read the level elements
while (player == null) {wait (1);} // wait until the player model is created
while (1)
{
camera.x = player.x - 300; // place the camera 300 quants below the player on the x axis
camera.y = player.y;
camera.z = 1000; // and 1000 quants above the player on the z axis
camera.tilt = -60; // look down at the player
if (mouse_left == on) {camera.arc -= 2 * time;} // zoom in or out using the left / right mouse buttons
if (mouse_right == on) {camera.arc += 2 * time;}
if (mouse_middle == on) {camera.arc = 60;} // press the middle mouse button to restore the default zoom factor
camera.arc = min (max (camera.arc, 40), 100); // limit camera.arc to 40..100
wait (1);
}
}

function read_level_data()
{
vec_set (starting_position, nullvector);
level_handle = file_open_read("level01.dat"); // open the level file
level_size_x = file_var_read(level_handle); // read the level size on x
level_size_y = file_var_read(level_handle); // and on y
starting_position.x -= (30 - level_size_x) * 64 / 2; // a floor piece has 64 quants
starting_position.y -= (30 - level_size_y) * 64 / 2; // a floor piece has 64 quants
lines_index = 0;
while (lines_index < level_size_y)
{
file_str_read(level_handle, line_characters); // here we get the lines that create the level (horizontally)
str_cat(level_chars, line_characters);
if (str_len(line_characters) < level_size_x) // if this line is shorter than level_size_x
{
str_cpy(temp_string, empty_space); // we copy some spaces in temp_string
str_trunc(temp_string, (30 - level_size_x)); // first we cut this line to the standard level_size_x
str_trunc(temp_string, (level_size_x - str_len(line_characters))); // now we've got some space to add to the end of the line
str_cat(level_chars, temp_string); // and we do that in order to keep the same length for all the lines in the level
}
lines_index += 1;
}
file_close(level_handle); // close the file
// here I've got all the elements stored in level_chars; if a level has 3 lines and 3 rows (for example) the string stores the elements this way
// "## . @### " -> it puts all the level elements that are useful at the beginning of the string
// all the lines have the same length (I have added spaces at the end of the shorter lines)
// now we have to split them in lines / rows again and read / create them in the "real" world
// so we will read only the first level_size_x * level_size_y characters in the string
char_index = 0;
vec_set (floor_coords, starting_position); // we want to change floor_coords without altering starting_position
floor_coords.z = 0;
while (char_index < (level_size_x * level_size_y))
{
str_cpy(current_character, level_chars);
if (str_cmp(current_character, " ") == 1) // floor?
{
starting_position.z = 0;
ent_create(floor_wmb, starting_position, make_static);
}
if (str_cmp(current_character, "#") == 1) // wall?
{
starting_position.z = 54;
ent_create(wall_wmb, starting_position, make_static);
}
if (str_cmp(current_character, "p") == 1) // player? (we create the player and the floor below it)
{
starting_position.z = 0;
ent_create(floor_wmb, starting_position, make_static);
starting_position.z += 64;
player = ent_create(player_mdl, starting_position, players_action);
}
if (str_cmp(current_character, "s") == 1) // spider? (we create the spider and the floor below it)
{
starting_position.z = 0;
ent_create(floor_wmb, starting_position, make_static);
starting_position.z += 64;
ent_create(spider_mdl, starting_position, spider_action);
}
if (str_cmp(current_character, "f") == 1) // finish? (we create the flag and the floor below it)
{
starting_position.z = 0;
ent_create(floor_wmb, starting_position, make_static);
starting_position.z += 64;
ent_create(finish_mdl, starting_position, finish_action);
}
char_index += 1;
str_clip(level_chars, 1); // remove the 1st character from level_chars and so on
starting_position.x += 64; // offset on x
if ((char_index % (level_size_x)) == 0) // line finished? draw another line
{
starting_position.x -= 64 * level_size_x;
starting_position.y -= 64;
}
}
// all the level blocks are placed here
all_placed = 1; // all the level elements are placed here
}

function make_static()
{
my.dynamic = off; // increases the frame rate, especially if we've got a bigger level
}

function finish_action()
{
while (vec_dist (player.x, my.x) > 50) {wait (1);} // wait until the player comes close to the flag
exit; // you should load the 2nd level here
}

function players_action()
{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
while (players_health == 100) // as long as the player is alive
{
my.pan += 6 * (key_cul - key_cur) * time; // rotate the player using the cursor left and cursor right keys
vec_set (temp.x, my.x); // copy player's position to temp
movement_speed.x = 5 * (key_cuu - key_cud) * time; // move the player the using cursor up and cursor down keys
movement_speed.y = 0; // don't move sideways
movement_speed.z = 0; // nor vertically
c_move (my, movement_speed.x, nullvector, glide); // move the player
if ((key_cuu == off) && (key_cud == off)) // if the player isn't moving
{
ent_animate(my, "stand", anim_percentage, anm_cycle); // play its "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, anm_cycle); // then play its "walk" animation
}
anim_percentage += 5 * time; // 5 = animation speed
wait (1);
}
while (players_health > 0) // animate the player for its "death" animation
{
ent_animate(my, "death", 100 - players_health, anm_cycle); // play the "death" animation
wait (1);
}
my.passable = on;
}

function spider_action()
{
var anim_percentage; // animation percentage
var movement_speed; // movement speed
var spider_antenna; // detects the environment type in front of the spider
var distance_covered = 0; // stores the distance covered by the spider in the last frame
my.skill10 = my.z; // store the initial height of the spider in skill10
my.scale_x = 0.7; // make the spider a bit smaller, play with this value
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
my.enable_entity = on; // the spider is sensitive to impact with other entities and level blocks
my.enable_impact = on;
my.enable_block = on;
my.event = spider_event; // this is the event function for the spider
while (player_spotted == 0) // stand still until you see the player
{
c_trace (my.x, player.x, ignore_me + use_box); // trace from the spider to the player
if (you == player) // the player is visible
{
player_spotted = 1; // get out of this while loop; alert all the other spiders
}
ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation until you see the player
anim_percentage += 15 * time; // 15 = animation speed
sleep (0.1);
}
movement_speed.x = 3 * time;
movement_speed.y = 0; // don't move sideways
movement_speed.z = 0; // nor vertically
while (1)
{
spider_antenna.x = my.x + 15 * cos(my.pan); // the spider_antenna variable detects the environment and
spider_antenna.y = my.y + 15 * sin(my.pan); // it is placed 15 quants in front of the spider
spider_antenna.z = my.z;
if (content(spider_antenna) == content_solid) // a wall is in front of the spider
{
my.skill40 = my.pan;
my.skill41 = 88 + random(4);
if (random(1) > 0.5)
{
while (my.pan < my.skill40 + my.skill41) // then rotate for 88...92 degrees to get out of there
{
my.pan += 3 * time;
wait (1);
}
}
else
{
while (my.pan > my.skill40 - my.skill41) // then rotate for -88...-92 degrees to get out of there
{
my.pan -= 3 * time;
wait (1);
}
}
}
else // the road is clear
{
ent_animate(my, "run", my.skill20, anm_cycle); // play the "run" animation
my.skill20 += 10 * time;
distance_covered = c_move (my, movement_speed.x, nullvector, ignore_passable | glide); // move the spider
if (distance_covered < 0.1) // got stuck or moving too slow? (0.1 = experimental value, prevents the spiders from moving too slow)
{
movement_speed.x *= -1; // reverse the movement direction
movement_speed.x *= 0.5; // halve the movement speed when walking backwards
my.skill40 = my.pan;
my.skill41 = 88 + random(4);
if (random(1) > 0.5)
{
while (my.pan < my.skill40 + my.skill41) // rotate 88...92 degrees
{
my.pan += 5 * time;
ent_animate(my, "run", my.skill20, anm_cycle); // play the "run" animation
my.skill20 -= 10 * time;
c_move (my, movement_speed.x, nullvector, ignore_passable | glide); // move the spider
wait (1);
}
}
else
{
while (my.pan > my.skill40 - my.skill41) // rotate -88...-92 degrees
{
my.pan -= 5 * time;
ent_animate(my, "run", my.skill20, anm_cycle); // play the "run" animation
my.skill20 -= 10 * time;
c_move (my, movement_speed.x, nullvector, ignore_passable | glide); // move the spider
wait (1);
}
}
movement_speed.x = 3 * time; // restore the initial movement_speed
}
}
my.z = my.skill10; // restore the initial height
wait (1);
}
}

function spider_event()
{
if ((event_type == event_entity) && (you == player)) // collided with the player?
{
my.event = null; // don't trigger the same event several times - the player will die anyway
while (players_health > 10) // play with this value until you are happy with the "death" animation
{
players_health -= 2 * time; // the player dies, "2" controls the "death" animation speed
wait (1);
}
}
}



Re: Aum 54, Dungeon creator [Re: keilyn3d] #295390
10/24/09 22:37
10/24/09 22:37
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
what does it do? or does it not do?

I apologize, as I do not have time to go through all the code there ATM. If you can narrow it down a bit, it would be easier for us all.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: Aum 54, Dungeon creator [Re: Nowherebrain] #295396
10/24/09 23:41
10/24/09 23:41
Joined: Mar 2009
Posts: 42
Dominican Republic
keilyn3d Offline OP
Newbie
keilyn3d  Offline OP
Newbie

Joined: Mar 2009
Posts: 42
Dominican Republic
this code is for read an level from a text file, but the level appear empty.
the engine don't show any error, only appear empty.
This code work in old versions of A7 but no in 7.7 or 7.8.

Re: Aum 54, Dungeon creator [Re: keilyn3d] #295532
10/25/09 21:11
10/25/09 21:11
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
Do you have a player in the level? Make sure that it includes the "player = my;" line of code in its action.

Re: Aum 54, Dungeon creator [Re: George] #295535
10/25/09 21:44
10/25/09 21:44
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
I "assume" it does, or there would be an empty pointer...player* is used in main() for the camera.....I am making an assumption here...again...I have not thoroughly gone through the code.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: Aum 54, Dungeon creator [Re: Nowherebrain] #295549
10/26/09 00:59
10/26/09 00:59
Joined: Mar 2009
Posts: 42
Dominican Republic
keilyn3d Offline OP
Newbie
keilyn3d  Offline OP
Newbie

Joined: Mar 2009
Posts: 42
Dominican Republic
yes, The code works without problems in the olds A7 but no in 7.7 or 7.8, I think that something have changed in the engine.

Re: Aum 54, Dungeon creator [Re: keilyn3d] #295598
10/26/09 13:41
10/26/09 13:41
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
Some of the old C-Script keywords are removed progressively from the newer A7 engine versions. Your best bet would be to convert the code to lite-C.

Re: Aum 54, Dungeon creator [Re: George] #295624
10/26/09 15:54
10/26/09 15:54
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Talk about absent minded, I did not even look at it as if it were C-script....I just assume that everything is lite-c now a days....anyway...
check the manual for "obsolete syntax". it should show you migration tips, as well as a listing of all the commands/keywords that are obsolete and or replaced....

-Justin


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: Aum 54, Dungeon creator [Re: Nowherebrain] #295804
10/27/09 18:45
10/27/09 18:45
Joined: Mar 2009
Posts: 146
USA
P
paracharlie Offline
Member
paracharlie  Offline
Member
P

Joined: Mar 2009
Posts: 146
USA
Here is my attempt to convert this to lite-c. I have invalid arguments error in read_level_data. If someone wants to help figure out what the problem is.

Code:
////////////////////////////////////////////////////////////////////////////////////////
// "#" = wall
// " " = floor
// "p" = player
// "s" = spider
// "f" = finish
////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>


var level_handle; // handle for the level data file
var level_size_x;
var level_size_y;
var lines_index;
var all_placed = 0; // will be set to 1 as soon as the entire level is created
VECTOR starting_position;
var char_index;
VECTOR floor_coords;
var players_health = 100;
var player_spotted = 0; // will alarm all the spiders as soon as the first spider sees the player

////////////////////////////////////////////////////////////////////////////////////////

SOUND* beep_sound = "beep.wav";

////////////////////////////////////////////////////////////////////////////////////////

STRING* bigroom_wmb = "bigroom.wmb";
STRING* wall_wmb = "wall.wmb";
STRING* floor_wmb = "floor.wmb";
STRING* player_mdl = "player.mdl";
STRING* spider_mdl = "spider.mdl";
STRING* finish_mdl = "finish.mdl";

STRING* level_chars[900]; // stores the characters, the level can have up to 30 x 30 = 900 blocks
STRING* line_characters[30]; // a level must have a maximum number of 30 blocks on x and y
STRING* temp_string[30];
STRING* empty_space = "#30"; // 30 empty spaces
STRING* current_character = " "; // empty space

////////////////////////////////////////////////////////////////////////////////////////

function read_level_data();
function make_static();
function finish_action();
function players_action();
function spider_action();
function spider_event();

////////////////////////////////////////////////////////////////////////////////////////

function main()
{
	video_mode = 8; // 1024x768
   video_depth = 32; // 32 bit mode
   video_screen = 1; // start in full screen mode
	random_seed(0); // initialize the random number generator
	all_placed = 0; // the level elements aren't placed at this point
	level_load(bigroom_wmb); // load the level
	wait (3); // wait until the level is loaded
	read_level_data(); // read the level elements
	while (player == NULL) {wait (1);} // wait until the player model is created
	while (1)
	{
		camera.x = player.x - 300; // place the camera 300 quants below the player on the x axis
		camera.y = player.y;
		camera.z = 1000; // and 1000 quants above the player on the z axis
		camera.tilt = -60; // look down at the player
		if (mouse_left == 1) {camera.arc -= 2 * time_step;} // zoom in or out using the left / right mouse buttons
		if (mouse_right == 1) {camera.arc += 2 * time_step;}
		if (mouse_middle == 1) {camera.arc = 60;} // press the middle mouse button to restore the default zoom factor
		camera.arc = minv (maxv (camera.arc, 40), 100); // limit camera.arc to 40..100
		wait (1);
	}
}

function read_level_data()
{	
	vec_set (starting_position, nullvector);
	level_handle = file_open_read("level01.dat"); // open the level file
	level_size_x = file_var_read(level_handle); // read the level size on x
	level_size_y = file_var_read(level_handle); // and on y
	starting_position.x -= (30 - level_size_x) * 64 / 2; // a floor piece has 64 quants 
	starting_position.y -= (30 - level_size_y) * 64 / 2; // a floor piece has 64 quants 
	lines_index = 0;
	while (lines_index < level_size_y)
	{	
		file_str_read(level_handle, line_characters); // here we get the lines that create the level (horizontally)
		str_cat(level_chars, line_characters);
		if (str_len(line_characters) < level_size_x) // if this line is shorter than level_size_x
		{
			str_cpy(temp_string, empty_space); // we copy some spaces in temp_string
			str_trunc(temp_string, (30 - level_size_x)); // first we cut this line to the standard level_size_x
			str_trunc(temp_string, (level_size_x - str_len(line_characters))); // now we've got some space to add to the end of the line 
			str_cat(level_chars, temp_string); // and we do that in order to keep the same length for all the lines in the level
		}
		lines_index += 1;
		wait(1);
	}		
	file_close(level_handle); // close the file
	// here I've got all the elements stored in level_chars; if a level has 3 lines and 3 rows (for example) the STRING* stores the elements this way
	// "## . @###                                " -> it puts all the level elements that are useful at the beginning of the STRING*
	// all the lines have the same length (I have added spaces at the end of the shorter lines)
	// now we have to split them in lines / rows again and read / create them in the "real" world
	// so we will read only the first level_size_x * level_size_y characters in the STRING*
	char_index = 0;
	vec_set (floor_coords, starting_position); // we want to change floor_coords without altering starting_position
	floor_coords.z = 0;
	while (char_index < level_size_x * level_size_y)
	{
		str_cpy(current_character, level_chars);
		if (str_cmp(current_character, " ") == 1) // floor?
		{
			starting_position.z = 0;
			ent_create(floor_wmb, starting_position, make_static);
		}
		if (str_cmp(current_character, "#") == 1) // wall?
		{
			starting_position.z = 54;
			ent_create(wall_wmb, starting_position, make_static);
		}
		if (str_cmp(current_character, "p") == 1) // player? (we create the player and the floor below it)
		{
			starting_position.z = 0;
			ent_create(floor_wmb, starting_position, make_static);
			starting_position.z += 64;
			player = ent_create(player_mdl, starting_position, players_action);
		}
		if (str_cmp(current_character, "s") == 1) // spider? (we create the spider and the floor below it)
		{
			starting_position.z = 0;
			ent_create(floor_wmb, starting_position, make_static);
			starting_position.z += 64;
			ent_create(spider_mdl, starting_position, spider_action);
		}
		if (str_cmp(current_character, "f") == 1) // finish? (we create the flag and the floor below it)
		{
			starting_position.z = 0;
			ent_create(floor_wmb, starting_position, make_static);
			starting_position.z += 64;
			ent_create(finish_mdl, starting_position, finish_action);
		}
		char_index += 1;
		str_clip(level_chars, 1); // remove the 1st character from level_chars and so on
		starting_position.x += 64; // offset on x
		if ((char_index % (level_size_x)) == 0) // line finished? draw another line
		{
			starting_position.x -= 64 * level_size_x;
			starting_position.y -= 64;
		}
		wait(1);
	}
	// all the level blocks are placed here
	all_placed = 1; // all the level elements are placed here
}

function make_static()
{
	my.emask &= ~DYNAMIC; // increases the frame rate, especially if we've got a bigger level
}

function finish_action()
{
	while (vec_dist (player.x, my.x) > 50) {wait (1);} // wait until the player comes close to the flag
	sys_exit("bye...bye"); // you should load the 2nd level here
}

function players_action()
{
	VECTOR temp[3];
	VECTOR movement_speed[3];
	var anim_percentage; // animation percentage	
	while (players_health <= 0) // as long as the player is alive
	{
		my.pan += 6 * (key_cul - key_cur) * time_step; // rotate the player using the cursor left and cursor right keys
		vec_set (temp.x, my.x); // copy player's position to temp
		movement_speed.x = 5 * (key_cuu - key_cud) * time_step; // move the player the using cursor up and cursor down keys
		movement_speed.y = 0; // don't move sideways
		movement_speed.z = 0; // nor vertically
		c_move (my, movement_speed, nullvector, GLIDE); // move the player
		if ((key_cuu == 0) && (key_cud == 0)) // if the player isn't moving
		{
			ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play its "stand" animation
		}
		else // the player is moving?
		{ 
			ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // then play its "walk" animation
		}
		anim_percentage += 5 * time_step; // 5 = animation speed
		wait (1);
	}
	while (players_health > 0) // animate the player for its "death" animation
	{
		ent_animate(my, "death", 100 - players_health, ANM_CYCLE); // play the "death" animation
		wait (1);
	}
	set(my, PASSABLE);
}

function spider_action()
{
	var anim_percentage; // animation percentage
	VECTOR movement_speed[3]; // movement speed
	VECTOR spider_antenna[3]; // detects the environment type in front of the spider
	var distance_covered = 0; // stores the distance covered by the spider in the last frame
	my.skill10 = my.z; // store the initial height of the spider in skill10
	my.scale_x = 0.7; // make the spider a bit smaller, play with this value
	my.scale_y = my.scale_x;
	my.scale_z = my.scale_x;
	my.emask |= ENABLE_ENTITY | ENABLE_IMPACT | ENABLE_BLOCK; // the spider is sensitive to impact with other entities and level blocks
	//my.enable_impact = on;
	//my.enable_block = on;
	my.event = spider_event; // this is the event function for the spider
	while (player_spotted == 0) // stand still until you see the player
	{
		c_trace (my.x, player.x, IGNORE_ME + USE_BOX); // trace from the spider to the player
		if (you == player) // the player is visible
		{
			player_spotted = 1; // get out of this while loop; alert all the other spiders
		}
		ent_animate(my, "stand", anim_percentage, ANM_CYCLE); // play the "stand" animation until you see the player
		anim_percentage += 15 * time_step; // 15 = animation speed
		wait (-0.1);
	}
	movement_speed.x = 3 * time_step;
	movement_speed.y = 0; // don't move sideways
	movement_speed.z = 0; // nor vertically
	while (1)
	{
		spider_antenna.x = my.x + 15 * cos(my.pan); // the spider_antenna variable detects the environment and 
		spider_antenna.y = my.y + 15 * sin(my.pan); // it is placed 15 quants in front of the spider
		spider_antenna.z = my.z;
		if (content(spider_antenna) == 1) // a wall is in front of the spider
		{
			my.skill40 = my.pan;
			my.skill41 = 88 + random(4);
			if (random(1) > 0.5)
			{
				while (my.pan < my.skill40 + my.skill41) // then rotate for 88...92 degrees to get out of there
				{
					my.pan += 3 * time_step;
					wait (1);
				}
			}
			else
			{
				while (my.pan > my.skill40 - my.skill41) // then rotate for -88...-92 degrees to get out of there
				{
					my.pan -= 3 * time_step;
					wait (1);
				}
			}
		}
		else // the road is clear 
		{
			ent_animate(my, "run", my.skill20, ANM_CYCLE); // play the "run" animation
			my.skill20 += 10 * time_step; 
			distance_covered = c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE | GLIDE); // move the spider
			if (distance_covered < 0.1) // got stuck or moving too slow? (0.1 = experimental value, prevents the spiders from moving too slow)
			{
				movement_speed.x *= -1; // reverse the movement direction
				movement_speed.x *= 0.5; // halve the movement speed when walking backwards
				my.skill40 = my.pan;
				my.skill41 = 88 + random(4);
				if (random(1) > 0.5)
				{
					while (my.pan < my.skill40 + my.skill41) // rotate 88...92 degrees
					{
						my.pan += 5 * time_step;
						ent_animate(my, "run", my.skill20, ANM_CYCLE); // play the "run" animation
						my.skill20 -= 10 * time_step; 
						c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE | GLIDE); // move the spider
						wait (1);
					}
				}
				else
				{
					while (my.pan > my.skill40 - my.skill41) // rotate -88...-92 degrees
					{
						my.pan -= 5 * time_step;
						ent_animate(my, "run", my.skill20, ANM_CYCLE); // play the "run" animation
						my.skill20 -= 10 * time_step; 
						c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE | GLIDE); // move the spider
						wait (1);
					}
				}
				movement_speed.x = 3 * time_step; // restore the initial movement_speed
			}
		}
		my.z = my.skill10; // restore the initial height
		wait (1);
	}
}

function spider_event()
{
	if ((event_type == EVENT_ENTITY) && (you == player)) // collided with the player?
	{
		my.event = NULL; // don't trigger the same event several times - the player will die anyway
		while (players_health > 10) // play with this value until you are happy with the "death" animation
		{
			players_health -= 2 * time_step; // the player dies, "2" controls the "death" animation speed
			wait (1);
		}
	}
}





Last edited by paracharlie; 10/27/09 20:38. Reason: Fixed Vectors

A8 Commercial
Re: Aum 54, Dungeon creator [Re: paracharlie] #295806
10/27/09 19:37
10/27/09 19:37
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline
Serious User
Nowherebrain  Offline
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
first "VECTOR" is already an array length of 3 [x,y,z]
so...
VECTOR some_vec[3]; //is wrong

var some_vec[3]; //could be used
VECTOR some_vec; //is correct

I have not sorted through all of it though, I will let George respond....I'm just cluttering up the thread...I want to help, I just don't have the time.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Page 1 of 2 1 2

Moderated by  George 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1