Gamestudio Links
Zorro Links
Newest Posts
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
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 (NnamueN, Akow, 1 invisible), 1,421 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Changing Particle Direction? #234569
11/03/08 16:25
11/03/08 16:25
Joined: Oct 2008
Posts: 22
S
SamstaUK Offline OP
Newbie
SamstaUK  Offline OP
Newbie
S

Joined: Oct 2008
Posts: 22
If you apply the action "tornado" to an entity, then that entity will turn into a tornado. The problem is that the tornado twists clockwise, but it is supposed to twist anti-clockwise. I have tried changing some values but they didn't affect anything.

Here is the code if you want to try and test it.

Quote:

bmap tornado_bmap = <sprite.tga>;
bmap small_bmap = <particle.tga>;

function tornado_particles;
function small_particle;
function destoyed_object_event;

var flying_objects[100];//max 100
var nbr_flying_obj=0;

entity* tornado_ent;

function tornado_sprite()
{
var distance;
var distance_add;
var max_alpha = 40;
my.facing = on;
my.transparent=on;
my.alpha=0;
my.passable = on;
my.unlit=on;
my.light=on;
my.red=70;
my.green=50;
my.blue=30;
while(my.skill3 == 0)
{
wait(1);
}
distance_add=random(0.7);
while(1)
{
distance + = distance_add*time;
my.skill2 + = my.skill1 * time;
you = ptr_for_handle(my.skill3);

if(abs(my.z-your.z)>1000)
{
my.alpha-=0.5*time;
if(my.alpha < 0){wait(1);ent_remove(me);return;}
}
else
{
my.alpha = min(my.alpha+time,max_alpha);
}
my.x = sin(my.skill2)*distance + you.x+20*sin(my.z+your.pan);
my.y = cos(my.skill2)*distance + you.y+20*sin(my.z+your.pan);
my.z += random(5)*time;
if(total_ticks%5<1)//all 5 ticks
{
my.scale_x += 0.002;
my.scale_y += 0.002;
}
if(random(40)>39.9)
{
effect(tornado_particles,2,my.x,nullvector);
}
my.roll + = my.skill1*time;
wait(1);
}
}

function move_tornado
{
var jerry;
jerry = int(random(100));
var middle[3];
var position[3];
var new_pos[3];
new_pos.x=random(5)-2.5;
new_pos.y=random(5)-2.5;
my.passable=on;
wait(-10);
my.passable=off;
vec_set(middle,my.x);
while(1)
{
if(random(10)>9.9)//new dir
{
new_pos.x=random(jerry)-(jerry/2);
new_pos.y=random(jerry)-(jerry/2);
}
position.x += (new_pos.x-position.x)*0.1*time;
position.y += (new_pos.y-position.y)*0.1*time;
c_move(me,nullvector,vector(position.x*time,position.y*time,0),ignore_maps + ignore_push + glide);
c_rotate(me,vector(5*time,0,0),ignore_passable + ignore_maps + ignore_push);
wait(1);
}
}

function tornado_paritcle_func
{
if(my.skill_a==1)
{
my.alpha+=time;
if(my.alpha>5)
{
my.skill_a=0;
}
}
else
{
my.alpha-=time;
}
my.size += 20*time;
my.x = your.x - 10*sin(total_ticks);
my.y = your.y - 10*cos(total_ticks);
effect(small_particle,1,vector(my.x+50-random(100),my.y+50-random(100),my.z+50-random(100)),vector(0,0,-0.125));
if(my.alpha<0)
{
my.lifespan=0;
}
}


function tornado_particles
{
my.bmap = tornado_bmap;
my.function=tornado_paritcle_func;
my.transparent=on;
my.size = 200;
my.alpha=0;
my.skill_a=1;
my.red=20;
my.green=10;
my.blue=5;
}

function small_particle_func
{
my.alpha-=time;
my.x = your.x +50-random(100);
my.y = your.y +50-random(100);
if(my.alpha<0)
{
my.lifespan=0;
}
}

function small_particle
{
my.size=0.5;
my.function = small_particle_func;
my.red=20;
my.green=10;
my.blue=0;
my.bmap = small_bmap;
my.streak=on;
my.move=on;
my.transparent = on;
}

function dust_func
{
my.alpha-=time;
my.size+=time;
if(my.alpha<0)
{
my.lifespan=0;
}
}

function dust
{
my.size = you.scale_x*50;
my.function = dust_func;
my.bmap = tornado_bmap;
my.vel_x = 4-random(8);
my.vel_y = 4-random(8);
my.vel_z = random(1);
my.move = on;
my.transparent = on;
my.alpha=40;
my.red=40;
my.green=25;
my.blue=12.5;
}

function fall_down_event
{
if(event_type==event_block||event_type==event_impact)
{
vec_scale(bounce,0.3);
if(vec_length(bounce)<1)
{
my.event=null;
}
vec_Set(my.skill2,bounce);
}
}

function fall_down(ent)
{
me=ent;
my.passable = off;
my.enable_block = on;
my.enable_impact = on;
my.event = fall_down_event;
var position[3];
vec_Set(my.skill2,vector(tornado_ent.x-my.x,tornado_ent.y-my.y,0));
vec_normalize(my.skill2,5);
my.skill4 = 5;
my.skill1/=36;
while(1)
{
my.skill4 -= 0.5*time;
c_move(me,nullvector,my.skill2,glide);
if(vec_length(my_speed)<1&&my.skill4<-5)
{
my.tilt%=360;
my.tilt -= my.tilt*0.1;
if(my.tilt<1)
{
my.skill1 = random(360);
my.event = destoyed_object_event;
return;
}
}
else
{
c_rotate(me,vector(my.skill1*time,my.skill1*time,0),ignore_passable);
}
wait(1);
}
}

function control_flying_object
{
var i;
while(1)
{
i=0;
while(i<nbr_flying_obj)
{
you=flying_objects[i];
your.z += 16*time;
your.x = (tornado_ent.x-fsin(2*tornado_ent.pan+your.skill1,your.skill1/2));
your.y = (tornado_ent.y-fcos(2*tornado_ent.pan+your.skill1,your.skill1/2));
your.pan += your.skill1/360;
your.tilt += your.skill1/360;
if(abs(tornado_ent.z-your.z)>1000)
{
fall_down(you);
flying_objects[i]=flying_objects[nbr_flying_obj-1];
flying_objects[nbr_flying_obj-1]=0;
nbr_flying_obj-=1;
}
i+=1;
}
wait(1);
}
}



action tornado()
{
var edward;
edward = random(1.5);
tornado_ent = me;
my.nofog = 1;
my.push = 10;
//my.passable = on;
my.invisible = on;
//move_me here^^
move_tornado();
wait(1);
c_setminmax(me);
while(1)
{
you = ent_create("sprite.tga",my.x,tornado_sprite);
you.skill1 = random(10)+2;
you.skill2 = random(360);
you.scale_x = edward; //0.125
you.scale_y = you.scale_x;
you.skill3 = handle(my);
effect(dust,1,my.x,nullvector);
wait(-random(0.2));
}
}

function destoyed_object_event
{
if(nbr_flying_obj<100)
{
my.event = null;
wait(1);
flying_objects[nbr_flying_obj]=me;
nbr_flying_obj+=1;
my.passable = on;
}
}

action destroy_object()
{
my.skill1 = random(360);//for the position in the storm...
my.enable_push=on;
my.event = destoyed_object_event;
wait(1);
c_setminmax(me);
}

/*function main
{
fps_max=75;
level_load("tornado.wmb");
wait(3);
randomize();
control_flying_object();
while(1)
{
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;
temp.x = (key_w-key_s+mickey.z/10)*15*time;
temp.y = (key_a-key_d)*15*time;
temp.z = 0;
vec_rotate(temp,camera.pan);
vec_add(camera.x,temp);
wait(1);
}
}*/


//set the model you will be using for the spawned entity
string spawnEntity = "tornado.mdl";
//
//
//set the distance from the target entity you want to spawn to
var spawnDistance = 30;
//
//

entity* funnelEntity;

action funnel
{
funnelEntity = me;
my.invisible=on;
//MOVEMENT CODE OF THE MODEL
}

function spawnTheThing()
{
//get outta here if there aint no target entity in the game
if(funnelEntity == NULL)
{
return;
}

//set temp to the vector of the target entity
vec_set(temp.x, funnelEntity);

//this is the same idea used in a 3rd Person Camera
//it will place the spawned entity behind the target entity
//taking the rotation of the target entity into account
temp.x = funnelEntity.x - spawnDistance * cos(funnelEntity.pan);
temp.y = funnelEntity.y - spawnDistance * sin(funnelEntity.pan);

//set spawnEntityAction to NULL if you do not want to asign it a function
ent_create(spawnEntity,temp.x,tornado);
}

on_z = spawnTheThing();


Re: Changing Particle Direction? [Re: SamstaUK] #234598
11/03/08 20:18
11/03/08 20:18
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
change

your.pan += your.skill1/360;
your.tilt += your.skill1/360;

to

your.pan -= your.skill1/360;
your.tilt -= your.skill1/360;

Re: Changing Particle Direction? [Re: TechMuc] #234628
11/03/08 22:38
11/03/08 22:38
Joined: Oct 2008
Posts: 22
S
SamstaUK Offline OP
Newbie
SamstaUK  Offline OP
Newbie
S

Joined: Oct 2008
Posts: 22
I've done that, it still rotates in the same direction. :S

Re: Changing Particle Direction? [Re: SamstaUK] #234650
11/03/08 23:55
11/03/08 23:55
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
hey, in
Code:
function move_tornado

try changing
Code:
c_rotate(me,vector(5*time,0,0),ignore_passable + ignore_maps + ignore_push);
to
Code:
c_rotate(me,vector( -5*time,0,0),ignore_passable + ignore_maps + ignore_push);


Re: Changing Particle Direction? [Re: MrGuest] #234763
11/04/08 16:28
11/04/08 16:28
Joined: Oct 2008
Posts: 22
S
SamstaUK Offline OP
Newbie
SamstaUK  Offline OP
Newbie
S

Joined: Oct 2008
Posts: 22
I've tried both of those, still didn't work?? Thanks for the help though!


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