if(ringcounters[RING_RED] > 0){ //If the Red Ring is active
for(int i = 1; i <= Screen->NumLWeapons(); i ++){ //Cycle through all the LWeapons on the screen
lweapon wpn;
wpn = Screen->LoadLWeapon(i); //Load the LWeapon.
if(wpn->Misc[RING_RED_MISC_VARIABLE] == 0){ //Check to see if the LWeapon has been marked already.
wpn->Damage *= 2; //Multiply the amount of damage caused by 2.
wpn->Misc[RING_RED_MISC_VARIABLE] = 1; //Mark the LWeapon
}
}
ringcounters[RING_RED] ++; //Increment the counter
if(ringcounters[RING_RED] > RING_RED_DURATION){ //If the Red Ring buff has worn off, deactive this routine
ringcounters[RING_RED] = 0; //Reset the counter
}
}
I've been trying to multiply the amount of damage that a Sword LWeapon deals by 2 in this script and it seems to have no effect. I can confirm that this code is working because it modifies the damage of other LWeapons, including Sword Beam LWeapons.
I'm pretty sure you can't do anything to sword weapons whatsoever. If you want to change how much damage it's doing, you gotta do it to the itemdata itself.
I think the easier thing to do in this situation would be to give the player and identical looking sword that deal double damage when he collects the red ring, and then silently remove it when the red ring counter drops to zero.
You can attempt to change the damage of a sword, as a global effect, but it isn't reliable.
If you trace the damage, you can determine if the value is being sent through to the weapon, but again,. what I found is that the damage changes generally affect the beams, but not the sword blade, making the attempt fruitless. I can give you all the code for how this works (or doesn't work, in practice), if you want to play with it, and try to find another solution...however...
It is, in fact, what I was originally intending to do in LoE; but it was terribly broken, and in the end, it was just a better solution to re-script swords entirely. (I posted that elsewhere on the forum.)
In your situation, you;d be better off making identical looking swords, and doing this:
//Set first sword to level 1, and the double power to identical settings with 2x power at L2.
//Set second sword to L3, and identical item with double power to L4.
//Set third sword to L5 and identical item with double power to L6.
//Set fourth sword to L7 and identical item withdoubl power to L8.
//If allowing theplayer to select multiple swords, place duplicate items on the subscreen in identical places.
//Global Item Constants
const int DOUBLE_POWER = 18; //Set to item that doubles power.
const int FIRST_SWORD_DOUBLED = 143; //Set to double power item that looks like third sword.
const int SECOND_SWORD_DOUBLED = 144; //Set to double power item that looks like second sword.
const int THIRD_SWORD_DOUBLED = 145; //Set to double power item that looks like third sword.
const int FOURTH_SWORD_DOUBLED = 146; //Set to double power item that looks like fourth sword.
//Global Arrays and Array Constants
const int FISRT_SWORD = 1;
const int SECOND_SWORD = 2;
const int THIRD_SWORD = 3;
const int FOURTH_SWORD = 4;
bool swordsOwned[5]={false, false, false, false, false}; //Five, to make using them easier, so that sword levels start at 1.
void doubleSwords(){
if ( Link->Item[DOUBLE_POWER] == true ) {
if ( swordsOwned[1] == true && Link->Item[FIRST_SWORD_DOUBLED] == false){
Link->Item[I_SWORD1] = false;
Link->Item[FIRST_SWORD_DOUBLED] = true;
}
if ( swordsOwned[2] == true && Link->Item[SECOND_SWORD_DOUBLED] == false) {
Link->Item[I_SWORD2] = false;
Link->Item[SECOND_SWORD_DOUBLED] = true;
}
if ( swordsOwned[3] == true && Link->Item[THIRD_SWORD_DOUBLED] == false ){
Link->Item[I_SWORD3] = false;
Link->Item[THIRD_SWORD_DOUBLED] = true;
}
if ( swordsOwned[4] == true && Link->Item[FOURTH_SWORD_DOUBLED] == false ){
Link->Item[I_SWORD4] = false;
Link->Item[FOURTH_SWORD_DOUBLED] = true;
}
}
else if ( Link->Item[DOUBLE_POWER] == false ) {
if ( Link->Item[FIRST_SWORD_DOUBLED] == true ) {
Link->Item[FIRST_SWORD_DOUBLED] == false;
}
if ( Link->Item[SECOND_SWORD_DOUBLED] == true ) {
Link->Item[SECOND_SWORD_DOUBLED] == false;
}
if ( Link->Item[THIRD_SWORD_DOUBLED] == true ) {
Link->Item[THIRD_SWORD_DOUBLED] == false;
}
if ( Link->Item[FOURTH_SWORD_DOUBLED] == true ) {
Link->Item[FOURTH_SWORD_DOUBLED] == false;
}
if ( swordsOwned[1] == true && Link->Item[I_SWORD1] == false ) {
Link->Item[I_SWORD1] = true;
}
if ( swordsOwned[2] == true && Link->Item[I_SWORD2] == false ) {
Link->Item[I_SWORD2] = true;
}
if ( swordsOwned[3] == true && Link->Item[I_SWORD3] == false ) {
Link->Item[I_SWORD3] = true;
}
if ( swordsOwned[4] == true && Link->Item[I_SWORD4] == false ) {
Link->Item[I_SWORD4] = true;
}
}
}
// Set as pick-up script on swords. Speciy the nornal sword level, 1, 2, 3, or 4 as D0.
// The nornal magical sword is the third sword, and thus, D0 for that item would be set to '3'.
// This sets the array values so that doubled swords are only enabled if the player has the doubling item.
item script swordPickUp{
void run(int level){
swordsOwned[level] = true;
}
}
global script activeSample{
void run(){
while(true){
doubleSwords();
Waitdraw();
Waitframe();
}
}
}
In essence, you have two swords for each normal sword in your game. One with nornal power, and one with double-power. If Link has the double-power item, the function checks to see if he has the correct swords, and if he does, it gives him the double-power versions--that you will need to place on the subscreen to identical positions to the normal versions, for both cannot co-exist the way that I set this up--and the effect would be invisible to the player.
The array is there as a handy way to check to see if items are true, or should be set to true, when restoring lower-power items. The function checks the array, to see if an item was true in the past, and if so, restores it when Link deactivates the item with the doubling effect. (This, is assuming that you intend this to be a limited effect.)
Update: 22nd July 2014; fixed a few code errors. I wrote that using an Android, via VNC to a remote machine, and managed to have a few typos.