Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 4 1 2 3 4
Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185593
03/02/08 20:33
03/02/08 20:33
Joined: Aug 2005
Posts: 312
Sweden
tindust Offline
Senior Member
tindust  Offline
Senior Member

Joined: Aug 2005
Posts: 312
Sweden
About the turning entity, I assumed you has assigned an action to it, it would not work without one. Anyway, here is a small action that you need to assign to the entity that is going to turn toward you. You can actually assign it to look at any other entity. The "you" pointer has to be assigned to whatever is going to be looked at. Also, the version of Game Studio is important. Prior to 6.4 "time" was used to correct the time factor for different computers. After that, it was changed to "time_factor". Look it up on a newer manual. (Found in the download area).

Edit: I included a line if(mouse_middle) just to give the option of starting the turn by mouse input. Remove it when it is not needed any more.

This action code works:

Code:
action a_turner
{
var original_direction[3];
var new_direction[3];
var pan_difference;
var pan_direction;
var turnspeed = 4;

while(1) // action goes on forever or entity is removed
{
// Check angles
you = player; // or whatever is going to be turned toward
vec_set(original_direction,my.pan);
vec_set(temp,your.pos);
vec_sub(temp,my.pos);
vec_to_angle(new_direction,temp);

if(mouse_middle)
{
// Turn if needed
if(abs(original_direction.pan - new_direction.pan) > 1) // only turn if not looking toward player (within +/- x degrees)
{
pan_difference = (360-new_direction.x) - (360-original_direction.x);
if(pan_difference < 0)
{
pan_direction = 1;
}
else
{
pan_direction = -1;
}

while(abs(my.pan - new_direction.x) > turnspeed)
{
my.pan += pan_direction * turnspeed; // adjust angle increment by multiplying with turnspeed

if(abs(my.pan - new_direction.pan) < turnspeed)
{
my.pan - new_direction.pan
}

// edited: added to ensure end to panning

wait(-time_step*0.01); // adjust step speed by multiplying with 0.01 .. 100
wait(1);

// (use time instead of time_step in Game Studio prior to 6.8)

}
}
}
wait(1);
}
}



cheers,
tindust

Last edited by tindust; 03/03/08 00:33.
Re: 144655 entities instead of 5 entities... [Re: tindust] #185594
03/03/08 13:02
03/03/08 13:02
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
Now the entities only use pan and do nothing other...

I post my currently action, which controls the enemies. All functions will describe in the comments:

Code:
action enemy_flight
{
wait(1);
var timer;
my.enable_entity = on;
my.enable_block = on;
var block_;
var my_pos[3];
my.moving = 1;
my.enemy_health = 2;
var you_pos[3];
var save_pos[3];
var save_id;
rolling_kind = int(random(3))+1;
if(int(random(2))+1 == 1) //set the rotating kind (pan or tilt)
{
rolling_dir = -1;
}
else
{
rolling_dir = 1;
}
if(enemy_nr[1] == 0) //set the pointer
{
enemy_nr[1] = my;
my.saving = 1;
}
else
{
if(enemy_nr[2] == 0)
{
enemy_nr[2] = my;
my.saving = 2;
}
else
{
if(enemy_nr[3] == 0)
{
enemy_nr[3] = my;
my.saving = 3;
}
else
{
if(enemy_nr[4] == 0)
{
enemy_nr[4] = my;
my.saving = 4;
}
else
{
if(enemy_nr[5] == 0)
{
enemy_nr[5] = my;
my.saving = 5;
}
}
}
}
}
npc_shoot_enemy(); //shooting function (the enemy shoots between 1 and 5 seconds)
while(me)
{
if(my.which_rocket == 1) //scan, which rocket has defeated him (the rocket set the skill)
{
str_cpy(scan_str,sc_8);
scan_.red = 255;
scan_.green = 0;
scan_.blue = 0;
my.which_rocket = 0;
}
while(my.klicked != 1) //random to choose the friend to kill
{
save_id = int(random(5))+1;
if(friend_nr[save_id] == 1)
{
break;
}
my.klicked = 1;
sleeper_();
wait(1);
}
friend1 = null;
friend1 = friend_nr[save_id]; //set the chosed friend in this pointer
if(block_ != 1)
{
if(friend1) //HERE IS THE PROBLEM (looking to the friend to kill him with the random shoots)
{
my.skill40 = 1;
vec_set(you_pos,friend1.x);
vec_set(temp,you_pos);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);
}
else
{
my.skill40 = 0;
my.klicked = 0;
}
}
if(friend1) //if the enemy is too near at the friend, he rotating
{
if(vec_dist(my.x,friend1.x) < 200) || (block_ != 0) || (event_type == event_block) || (event_type == event_entity) //the same, but by objects
{
my.pan += 5 * time;
block_ = 1;
}
if(vec_dist(my.x,friend1.x) > 500) || (event_type == null)
{
block_ = 0;
}
}
my_pos.x = enemy_speed*time; //flying speed
timer += 1;
move_mode = ignore_passable + ignore_passents + glide;
ent_move(my_pos,nullvector); //moving
if(my.enemy_health <= 1) && (timer > 5) //if enemy is short before exploding, a smoke-effect is behind him
{
if(int(random(3)) == 0)
{
effect(effect_splitter,1,my.x,normal);
}
randomize();
if(int(random(3)) == 0)
{
effect(effect_splitter2,1,my.x,normal);
}
randomize();
if(int(random(3)) == 0)
{
effect(effect_splitter3,1,my.x,normal);
}
randomize();
timer = 0;
}
else
{
if(my.enemy_health < 1) //exploding
{
effect(effect_splitter,350,my.x,normal);
effect(effect_splitter2,50,my.x,normal);
effect(effect_splitter3,50,my.x,normal);
effect(effect_explo,1000,my.x,normal);
ent_create("expl2+16.pcx",my.x,explo2);
ent_create("expl2+16.pcx",my.x,explo2);
ent_create("expl2+16.pcx",my.x,explo2);
ent_create("expl2+16.pcx",my.x,explo3);
//ent_create("ring.mdl",my.x,ring2);
wait(1);
str_cpy(scan_str,sc_9);
scan_.red = 255;
scan_.green = 0;
scan_.blue = 0;
enemy_nr[my.saving] = 0;
enemy_count -= 1;
ent_remove(me);
break;
}
}
wait(1);
}
}



Re: 144655 entities instead of 5 entities... [Re: JokeSpeaker] #185595
03/07/08 18:54
03/07/08 18:54
Joined: Mar 2007
Posts: 151
JokeSpeaker Offline OP
Member
JokeSpeaker  Offline OP
Member

Joined: Mar 2007
Posts: 151
sry, but I are stupid to write a script with the wished function...

Page 4 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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