O Ilusionista
Captain 100K
I am using Bloodbane's "keymove" to control an Entity which Black Widow spawns on her hyper move (the sniper aim) and it works for the player 1.
But if the player 2 uses Black Widow and uses that move, the aim won't move and can't be controlled by player 2 - but player 1 can controls it, even if he is not Black Widow.
Here is the code.
This also happens with the shoot. I am using BB's "keyint" function to tell the sniper aim entity to go to another animation once I press "A":
@cmd keyint "ANI_FREESPECIAL2" 0 "A" 0 0
And it works only with the first player too, and prevents P2 of shooting.
Here is the original function:
From what I see, it gets the playerindex to determine who will gonna control it. But since the entity isn't a player, I think the engine doesn't knows who should controls it. Should the code be changed to get the Parent, instead of the playerindex?
Thanks.
But if the player 2 uses Black Widow and uses that move, the aim won't move and can't be controlled by player 2 - but player 1 can controls it, even if he is not Black Widow.
Here is the code.
Code:
void keymove(float V)
{// Move hero if direction button is pressed
void self = getlocalvar("self");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
float xdir = 0;
float zdir = 0;
if (playerkeys(iPIndex, 0, "moveleft")){// Left is pressed?
xdir = -V;
} else if(playerkeys(iPIndex, 0, "moveright")){// Right is pressed?
xdir = V;
}
if(playerkeys(iPIndex, 0, "moveup")){// Up is pressed?
zdir = -V/2;
} else if(playerkeys(iPIndex, 0, "movedown")){// Down is pressed?
zdir = V/2;
}
changeentityproperty(self, "velocity", xdir, zdir);
}
This also happens with the shoot. I am using BB's "keyint" function to tell the sniper aim entity to go to another animation once I press "A":
@cmd keyint "ANI_FREESPECIAL2" 0 "A" 0 0
And it works only with the first player too, and prevents P2 of shooting.
Here is the original function:
Code:
void keyint(void Ani, int Frame, void Key, int Hflag, int Limit)
{// Change current animation if proper key is pressed or released provided HP is more than limit
void self = getlocalvar("self");
void Health = getentityproperty(self,"health");
int iPIndex = getentityproperty(self,"playerindex"); //Get player index
void iRKey;
if (Key=="U"){ //Up Required?
iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
}
if (Key=="D"){ //Down Required?
iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
}
if (Key=="J"){ //Jump Required?
iRKey = playerkeys(iPIndex, 0, "jump"); // "Jump"
}
if (Key=="A"){ //Attack Required?
iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
}
if (Key=="S"){ //Special Required?
iRKey = playerkeys(iPIndex, 0, "special"); // "Special"
}
if (Key=="A2"){ //Attack2 Required?
iRKey = playerkeys(iPIndex, 0, "attack2"); // "Attack2"
}
if (Key=="UJ"){ //Up and Jump Required?
iRKey = playerkeys(iPIndex, 0, "moveup", "jump"); // "Up" + "Jump"
}
if (Hflag==1){ //Not holding the button case?
iRKey = !iRKey; //Take the opposite condition
}
if ((Health > Limit)&&iRKey){
changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
changeentityproperty(self, "animpos", Frame);
if (Key=="UJ"){
// This is copy of dethrown
changeentityproperty(self, "attacking", 0);
changeentityproperty(self, "damage_on_landing", 0);
changeentityproperty(self, "projectile", 0);
}
}
}
From what I see, it gets the playerindex to determine who will gonna control it. But since the entity isn't a player, I think the engine doesn't knows who should controls it. Should the code be changed to get the Parent, instead of the playerindex?
Thanks.