void main()
{
snow();
}
void snow()
{//Simulates a "Snow" effect
void self = getlocalvar("self");
void anim = getentityproperty(self, "animationID");
void type = getentityproperty(self, "type");
int pIndex = getentityproperty(self, "playerindex");
float speed = getentityproperty(self, "speed");
float rspeed = getentityproperty(self, "running", "speed"); //GET CURRENT RUNNING SPEED
float xDir = getentityproperty(self, "xdir");
float zDir = getentityproperty(self, "zdir");
int a = getentityproperty(self,"a"); //Get bomb's altitude
float xRate = 0.03;
float zRate = 0.03;
float walk = 3;
float run = 6.5;
float accel = 0.06;
float raccel = 0.1;
//DEBUG INFO ONLY, ERASE WHEN ALL TESTS ARE DONE
//drawstring(50, 144, 1, "speed___"+ speed);
//drawstring(50, 244, 0, "xdir___"+ xDir);
//drawstring(50, 344, 0, "zdir___"+ zDir);
//drawstring(50, 444, 0, "xvar___"+ getlocalvar("xVel"+self));
// drawstring(50, 544, 0, "zvar___"+ getlocalvar("zVel"+self));
// drawstring(50, 644, 0, "att___"+ getentityproperty(self,"a"));
// drawstring(50, 684, 0, "run___"+ getentityproperty(self, "running", "speed") );
//SAVE CURRENT VELOCITY WHILE NOT IN IDLE ANIMATION
if( anim != openborconstant("ANI_IDLE")){
//USED ONLY FOR PLAYERS, DETECT KEYS PRESSED
if(type == openborconstant("TYPE_PLAYER")){
//PRESSING RIGHT??
if( playerkeys(pIndex, 0, "moveright") ){
setlocalvar("xVel"+self, xDir);
setlocalvar("rxVel"+self, xDir);
//INCREASE SPEED WHILE MOVING
if(speed < walk){changeentityproperty(self, "speed", speed+accel);}
if(rspeed < run ){changeentityproperty(self, "running", rspeed+raccel);}
}
//PRESSING LEFT??
if( playerkeys(pIndex, 0, "moveleft") ){
setlocalvar("xVel"+self, xDir);
setlocalvar("rxVel"+self, xDir);
//INCREASE SPEED WHILE MOVING
if(speed < walk){changeentityproperty(self, "speed", speed+accel);}
if(rspeed < run ){changeentityproperty(self, "running", rspeed+raccel);}
}
//PRESSING DOWN??
if( playerkeys(pIndex, 0, "movedown") ){
setlocalvar("zVel"+self, zDir);
//INCREASE SPEED WHILE MOVING
if(speed < walk){changeentityproperty(self, "speed", speed+accel);}
if(rspeed < run ){changeentityproperty(self, "running", rspeed+raccel);}
}
//PRESSING UP??
if( playerkeys(pIndex, 0, "moveup") ){
setlocalvar("zVel"+self, zDir);
//INCREASE SPEED WHILE MOVING
if(speed < walk){changeentityproperty(self, "speed", speed+accel);}
if(rspeed < run ){changeentityproperty(self, "running", rspeed+raccel);}
}
}
//USED ONLY FOR ENEMIES, DETECT ANIMATIONS
if(type == openborconstant("TYPE_ENEMY")){
//TRYING TO MOVE??
if( anim == openborconstant("ANI_WALK") || anim == openborconstant("ANI_BACKWALK") || anim == openborconstant("ANI_RUN") ){
setlocalvar("xVel"+self, xDir);
setlocalvar("rxVel"+self, xDir);
setlocalvar("zVel"+self, zDir);
//INCREASE SPEED WHILE MOVING
if(speed < walk){changeentityproperty(self, "speed", speed+accel);}
if(rspeed < run ){changeentityproperty(self, "running", rspeed+raccel);}
}
}
}
else
{
//APPLY THE PREVIOUS SAVED VELOCITY AND DECREASE GRADUALLY WHILE IN IDLE ANIMATION
//MOVING RIGHT IN X AXIS??
if(getlocalvar("xVel"+self) > 0 ){
changeentityproperty(self, "velocity", getlocalvar("xVel"+self));
setlocalvar("xVel"+self, getlocalvar("xVel"+self)-xRate);
setlocalvar("rxVel"+self, getlocalvar("rxVel"+self)-xRate);
changeentityproperty(self, "speed", getentityproperty(self, "speed")/1.015);
changeentityproperty(self, "running", getentityproperty(self, "running","speed")/8);
}
//MOVING LEFT IN X AXIS??
if(getlocalvar("xVel"+self) < 0){
changeentityproperty(self, "velocity", getlocalvar("xVel"+self));
setlocalvar("xVel"+self, getlocalvar("xVel"+self)+xRate);
setlocalvar("rxVel"+self, getlocalvar("rxVel"+self)-xRate);
changeentityproperty(self, "speed", getentityproperty(self, "speed")/1.015);
changeentityproperty(self, "running", getentityproperty(self, "running","speed")/8);
}
//MOVING DOWN IN Z AXIS??
if(getlocalvar("zVel"+self) > 0){
changeentityproperty(self, "velocity", NULL(), getlocalvar("zVel"+self));
setlocalvar("zVel"+self, getlocalvar("zVel"+self)-zRate);
setlocalvar("rxVel"+self, getlocalvar("rxVel"+self)-xRate);
changeentityproperty(self, "speed", getentityproperty(self, "speed")/1.015);
changeentityproperty(self, "running", getentityproperty(self, "running","speed")/8);
}
//MOVING UP IN Z AXIS??
if(getlocalvar("zVel"+self) < 0 ){
changeentityproperty(self, "velocity", NULL(), getlocalvar("zVel"+self));
setlocalvar("zVel"+self, getlocalvar("zVel"+self)+zRate);
setlocalvar("rxVel"+self, getlocalvar("rxVel"+self)-xRate);
changeentityproperty(self, "speed", getentityproperty(self, "speed")/1.015);
changeentityproperty(self, "running", getentityproperty(self, "running","speed")/8);
}
}
}