The current stage of things is:
The physics entity comes to an absolute rest, due to "phent_enable".
But it cannot be initiated when being hit.
Code:
var stosskraft=900000;
var weapons_type;
var cigweight=5;
var colaweight=10;
Define mySpeed, my.skill2;
Define myoldpos, my.skill5;// not vacant: skill1-16 + to: flag1
Define bounce_on,skill8;
Define bounce_handle,skill9;
Define bouncesounddelay,skill10;
Define dampfaktor,skill11;
Define dampmax,skill12;
Define soundtype, skill13;
string cigboxstr=<cig_box.mdl>;
string canstr=<can.mdl>;
var colfric=35;
var colelastmin=100;
var group_id=1;
sound funnyprall1=<blechplump.wav>;
sound funnyprall2=<blechhell1.wav>;
sound funnyprall3=<dumpf3.wav>;
sound funnyprall4=<kartonhell1.wav>;
var test16=50;
function ph_bounce_event
{
if (EVENT_TYPE == EVENT_block){my.bounce_on=1;}
if (EVENT_TYPE==EVENT_friction) {my.bounce_on=2;my.flag1=off;// enabling physics again
// if(you==camdummie or other){phent_addcentralforce(you.speed)
}
}
FUNCTION play_abprall()
{
phent_getvelocity(my, mySpeed, nullvector);
temp=vec_length(mySpeed);
if(my.bouncesounddelay==1){return;}
if(temp<50){if(my.bounce_on==1){my.flag1=on;}return;}
//if(my.bouncesounddelay==1||temp<50){return;}
my.bouncesounddelay=1;
temp=vec_dist(my.x,camera.x);
if(my.bounce_on==1) {if(my.soundtype==1){my.bounce_handle=ent_playsound(my,funnyprall3,max(1000-temp/3,0));}
if(my.soundtype==2){my.bounce_handle=ent_playsound(my,funnyprall1,max(1000-temp/3,0));}
}
if(my.bounce_on==2) {if(my.soundtype==1){my.bounce_handle=ent_playsound(my,funnyprall4,max(1000-temp/3,0));}
if(my.soundtype==2){my.bounce_handle=ent_playsound(my,funnyprall2,max(1000-temp/3,0));}
}
sleep(0.2);
my.bouncesounddelay=0;
}
var physics_gravity[3];
FUNCTION handle_weapon_physics()
{
group_id+=1;
if(weapons_type==1) {my.soundtype=1;
phent_settype(my,PH_RIGID, PH_BOX);phent_setgroup( my, group_id);
phent_setmass(my,colaweight/2,PH_box);
phent_setfriction(my,colfric);phent_setelasticity(my,40,colelastmin*2);
my.dampfaktor=45;
my.dampmax=60;
}
if(weapons_type==2) {my.soundtype=2;
phent_settype(my,PH_RIGID, PH_POLY);phent_setgroup( my, group_id);
phent_setmass(my,colaweight,PH_POLY);
phent_setfriction(my,colfric);phent_setelasticity(my,50,colelastmin);
my.dampfaktor=3;
my.dampmax=50;
}
phent_setdamping(my,my.dampfaktor,75);
physics_gravity.z=-600;//0
ph_setgravity (physics_gravity);
ph_setcorrections(50000,0.05);//60000,0.01
phent_enable(my,0);
var t;
my.pan=camera.pan+90+t%360;
while(key_ctrl==0)
///////// HIER ENT_MOVE benutzen, um eindringen in wand zu verhindern
{temp.x = screen_size.x/2;
temp.y = screen_size.y/2;
temp.z = 130;
vec_for_screen(temp,CAMERA);
vec_set(my.x,temp);
my.pan=camera.pan+90+t%360;
wait(1);
t+=10*time;
}
phent_enable(my,1);
phent_setmaxspeed( my, 5000, 1000);
my.enable_friction=on;
my.enable_block=on;
//my.enable_touch=on;
my.event=ph_bounce_event;
physics_gravity.z=-600;
ph_setgravity (physics_gravity);
vec_set(temp,nullvector);
if(weapons_type==1){temp.x=stosskraft/2;}
if(weapons_type==2){temp.x=stosskraft;}
vec_rotate(temp,camera.pan);
phent_addcentralforce( my, temp );
temp=random(800);
phent_addtorquelocal(my, vector(400-temp,400-temp,400-temp));
while(1)
{
if(my.flag1==off)
{
phent_enable( my, 1);
vec_for_vertex(temp,my,2);//rotation mit eingbezogen
phent_getvelocity(my, mySpeed, temp);
temp=vec_length(myspeed);
if(temp>1000){phent_setdamping(my, my.dampmax, 75);}
else {phent_setdamping(my, my.dampfaktor, 25);}
//
//if(temp<test16){phent_setfriction(my,100);}// auf impact warten
//else{phent_setfriction(my,colfric);}
//
if(my.bounce_on>0) {
play_abprall();
}
my.bounce_on=0;
}
else{phent_enable( my, 0);}
wait(1);
}
}
FUNCTION CREATE_WEAPON()
{
temp.x = screen_size.x/2;
temp.y = screen_size.y/2;
temp.z = 100;
vec_for_screen(temp,CAMERA);
if(key_1==1){weapons_type=1;ent_create(cigboxstr,temp,handle_weapon_physics);}
if(key_2==1){weapons_type=2;ent_create(canstr,temp,handle_weapon_physics);}
}
///////////////////////
on_1=CREATE_WEAPON;
on_2=CREATE_WEAPON;