Question for implementing new Keys
I want weapons to have second functions and im kinda stumped on how to do this. I was thinking having a script for a new key(key123.c) that when you press it does the alternative fucntion for the weapon, but how to do this is where im stumped. Should I put all the code for the alternative functions in the script for the Key or should I have various scripts for the differnt items and the function and have the key script spawn them when the approriate item is equip?
I think the Spawning might Crap out and putting all the code in one script might be messy.
I think the Spawning might Crap out and putting all the code in one script might be messy.
I think having various scripts (one for each item) would make it more managable, certainly if you have lots of code for each item. You could use spawn(); (to run a script) or external(); (to run a proc) to run it. You could also have a proc for each item and use external to run them from that script.
Ooh! Ooh! I know of a *perfect* way to do what you're trying to do.
1) Create a global variable called "¤t_weapon" in main.c
2) In *every* weapon/item script, add "¤t_weapon = ¤t_script;" in the arm function.
3) In *every* weapon/item script, add a new function called 'alt' or 'altuse' or whatever you want. It is imperative that you create it in *every* weapon/item, even those that don't have alternative modes, otherwise it will cause problems.
4) Then in key123.c or whatever, do this code:
void main(void)
{
run_script_by_number(¤t_weapon,"altuse");
kill_this_task();
}
Replacing 'altuse' with whatever function name you chose in step 3.
And that's it. Nice and neat code, no checking to see if which weapon is armed, etc.
1) Create a global variable called "¤t_weapon" in main.c
2) In *every* weapon/item script, add "¤t_weapon = ¤t_script;" in the arm function.
3) In *every* weapon/item script, add a new function called 'alt' or 'altuse' or whatever you want. It is imperative that you create it in *every* weapon/item, even those that don't have alternative modes, otherwise it will cause problems.
4) Then in key123.c or whatever, do this code:
void main(void)
{
run_script_by_number(¤t_weapon,"altuse");
kill_this_task();
}
Replacing 'altuse' with whatever function name you chose in step 3.
And that's it. Nice and neat code, no checking to see if which weapon is armed, etc.
What about when there's no idem selected? (eg Dink used up the potion or sold the sword he had equiped.)