|
Post by BeasTie on Dec 16, 2012 22:36:58 GMT -5
Breaking melee weapons by robovine
For my mod, I'm trying to make non-throwing weapons break randomly after you hit somebody with it. Like, you have a glass bottle which you hit the enemy over the head with. Either it smashes into pieces so you can't use it again, or you get lucky and it stays intact.
Simply using changeentityproperty(self,weapon,0) makes characters change, but they are unable to move afterwards. If they get hit by an opponent, they drop the weapon that they originally had.
Is there some other property that I should change to make the character lose the weapon permanently?
The function I used, basically DC's weap001 function with randomness:
void weapbreak(int chance) { // --- 1-in-chance chance of weapon breaking after being used if (rand() % chance == 0) { void vSelf = getlocalvar("self"); //Get calling entity. int iMap = getentityproperty(vSelf, "map"); //Get current remap. int iWep = 0; //weapon index 0 == unarmed?
if ((iWep) && (iMap)){ //If requested model is not default and a remap is being used, record remap. setglobalvar("iMap" + vSelf, iMap); } changeentityproperty(vSelf, "weapon", iWep, 0); //Switch to desired model. changeentityproperty(vSelf, "map", getglobalvar("iMap" + vSelf)); //Defeat weapon remap bug by forcing a switch back to remap. } }
by robovine
|
|