The Dink Network

Question for implementing new Keys

October 16th 2003, 10:45 AM
pillbug.gif
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.
October 16th 2003, 10:57 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
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.
October 16th 2003, 03:58 PM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Ooh! Ooh! I know of a *perfect* way to do what you're trying to do.

1) Create a global variable called "&current_weapon" in main.c

2) In *every* weapon/item script, add "&current_weapon = &current_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(&current_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.
October 16th 2003, 04:51 PM
pillbug.gif
Kick ass thats going to save me alota time
October 17th 2003, 07:30 AM
wizardg.gif
Paul
Peasant He/Him United States
 
What about when there's no idem selected? (eg Dink used up the potion or sold the sword he had equiped.)
October 17th 2003, 09:06 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
Uh... don't do that Or have him equip the fist.