Jump to content

Photo

ZScript can't set the damage of a Sword LWeapon?

Bug? Sword LWeapon ZScript Damage

  • Please log in to reply
3 replies to this topic

#1 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 17 July 2014 - 02:51 AM

    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.



#2 Moosh

Moosh

    Tiny Little Questmaker

  • ZC Developers

Posted 17 July 2014 - 03:06 AM

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.



#3 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 17 July 2014 - 02:13 PM

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.

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 19 July 2014 - 02:45 AM

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:
 

 
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.

Edited by ZoriaRPG, 21 July 2014 - 08:09 PM.




Also tagged with one or more of these keywords: Bug?, Sword, LWeapon, ZScript, Damage

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users