3 registered members (NnamueN, Akow, 1 invisible),
1,421
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Changing Particle Direction?
#234569
11/03/08 16:25
11/03/08 16:25
|
Joined: Oct 2008
Posts: 22
SamstaUK
OP
Newbie
|
OP
Newbie
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. 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]
#234650
11/03/08 23:55
11/03/08 23:55
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
hey, in try changing c_rotate(me,vector(5*time,0,0),ignore_passable + ignore_maps + ignore_push); to c_rotate(me,vector( -5*time,0,0),ignore_passable + ignore_maps + ignore_push);
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|