So, I’m currently trying to build my first custom weapon. I’ve scoured the forum for examples, which has helped alot. Other examples, that were mentioned often, but only lead to 404 errors/no longer accessable links such as for a Zodiac Weapon tutorial frequently mentioned…
Here is my current script:
if (playertouchsme) {
toweapons Weapons/MC-LightSaber;
hidelocal;
set Weapons/MC-LightSaber;
}
if(weaponfired){
this.on=(this.on+1)%2;
if(this.on == 1){
setplayerprop #P2,Lightsaber_MultiColor.gif;
replaceani idle,Lightsaber_MultiColor_Idle;
replaceani sword,Lightsaber_MultiColor_Attack;
replaceani walk,Lightsaber_MultiColor_Walk;
}
else{
setplayerprop #P2,sword1.png;
replaceani Lightsaber_MultiColor_Idle,Lightsaber_MultiColor_Idle;
replaceani Lightsaber_MultiColor_Attack,sword;
replaceani Lightsaber_MultiColor_Walk,walk;
}
}
Here’s the test result:
Player starts. (weaponIDLE animation already shows)
Player walks to weapon NPC to touch & obtain weapon. (weaponWALK animation keeps running even after releasing direction keys.)
Player obtains weapons, presses D to unsheathe the weapon. (No unsheathing animation yet, will create after the rest of the script is fixed.)
Player presses S to attack. (weaponATTACK animation works, then returns to regular IDLE animation instead of weaponIDLE.)
Player walks in any given direction, after the direction key is released the weaponWALK animation continues.
I guess what I’m trying to fix is a key release trigger(?) to change the weaponWALK animation to weaponIDLE upon said key release(directional keys).
I believe the key release trigger should go inside “if(this.on=(this.on+1)%2;” underneath the replaceani commands, but this is where I’m getting myself confused.
I may just have a few wires crossed in the conditional branch also, which is why I’m asking for some corrections with the logic.
I’m trying to figure out how to perform a keyrelease command: if (keyreleased) (?)
I can’t seem to locate it in the commands.rtf. I’ve found the keypressed flag, but no keyrelease type flag. Any ideas?
*I understand that this base question has been asked alot on here, but the references I’ve tried to locate again, seem to no longer exist.