My custom made spell damage function

Coding Help

Hello friends! I am completely new at jass (and programing overall) so perhaps this is a little to big step for me, but I am trying to create my own damaging system and thought that it should be easier to use a pre-made function in the map-script that I could call that does the math that every spell uses. (yes, it requires one more "call"/spell, but it simplifies things and helps me get an understanding of jass). Now, this script is basically a bunch of GUI-actions and conditions that I have modified. But I just seems to get a whole bunch of error-messages on compiling. Any help?
(the first line with error (function Spelldamage_actions...) seems to be line 414)
Code (jass) Select
function Spelldamage_Func003C takes unit Target returns boolean
    if ( not ( IsUnitType(Target, UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Spelldamage_Func004C takes unit Target, unit Caster returns boolean
    if ( not ( udg_spellarmor[GetConvertedPlayerId(GetOwningPlayer(Target))] > udg_spellpenetration[GetConvertedPlayerId(GetOwningPlayer(Caster))] ) ) then
        return false
    endif
    return true
endfunction

function Spelldamage_Func007Func001C takes unit Caster, unit Target returns boolean
    if ( not ( ( GetRandomInt(1, 40) + GetHeroStatBJ(bj_HEROSTAT_INT, Caster, true) ) <= ( GetRandomInt(1, 35) + GetHeroStatBJ(bj_HEROSTAT_INT, Target, true) ) ) ) then
        return false
    endif
    return true
endfunction

function Spelldamage_Func007C takes unit Target returns boolean
    if ( not ( IsUnitType(Target, UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns bolean
local real spelldamage; tempspellarmor
local bolean
    set spelldamage = ( basedamage + udg_spelldamagebonus[GetConvertedPlayerId(GetOwningPlayer(Caster))] * udg_spelldamagebonuspercent[GetConvertedPlayerId(GetOwningPlayer(udg_FSCaster))])
    if ( Spelldamage_Func003C( Target ) ) then
        set tempspellarmor = udg_spellarmor[GetConvertedPlayerId(GetOwningPlayer(Target))]
    else
    endif
    if ( Trig_Spelldamage_Func004C( Target, Caster ) ) then
        set tempspellarmor = tempspellarmor - udg_spellpenetration[GetConvertedPlayerId(GetOwningPlayer(Caster))]
        set spelldamage = ( spelldamage * ( 1 - ( ( tempspellarmor * 0.06 ) / ( 1 + ( 0.06 * tempspellarmor ) ) ) ) )
    else
    endif
    set tempspelldamage = (( tempspelldamage - udg_spellreduction[GetConvertedPlayerId(GetOwningPlayer(Target))]* ( 1 - udg_spelldamagereductionpercent[GetConvertedPlayerId(GetOwningPlayer(Target) )) )
    if ( Trig_Spelldamage_Func007C( Caster, Target ) ) then
        if ( Trig_Spelldamage_Func007Func001C( Target ) ) then
            set tempdamage = ( udg_FSSheepdealsdamage * 0.50 )
            set SDsave = true
        else
            set save = false
        endif
    else
    endif
    call UnitDamageTargetBJ( udg_FSCaster, udg_FSSheepDealsTarget, udg_FSSheepdealsdamage, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL )
    return SDsave
endfunction

(I saw a small error in the end of the code, but that is not the problem, so pls ignore it)
Hi rvonsonsnadtz and welcome to www.wc3jass.com :) I hope you feel at home here :D

I took the freedom of modifying your first post so we can read properly the code.

Hmm, it seems that you have a bad declaration here:

Code (jass) Select
function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns bolean
   local real spelldamage; tempspellarmor
   local bolean


it should be:

Code (jass) Select
function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns boolean //you made a typo :P
   local real spelldamage //unfortunately jass doesn't support multiple declarations in one statement :(
   local real tempspellarmor
   local boolean b // you forgot to define a variable name


One question, Do you want to use vJASS or you want to keep in normal jass?? vJASS would made this system easier to read.
Thank u man! Got myself a face-palm when u told me I hade a typo-error.
I would like to use vJass, but when I downloaded the NewGen-pack from this site and ran this perticular map, all my GUI-triggers returned errors, so I kinda abandoned that idea.. But if you belive that it would simplify things that much for me, then perhaps I should give it a shot?
Btw, just cause I'm curious, are Jass based on any "normal" programming-language and, in that case, which one? xP
Quote from: rvonsonsnadtz on October 11, 2012, 06:18:34 PM
Thank u man! Got myself a face-palm when u told me I hade a typo-error.
I would like to use vJass, but when I downloaded the NewGen-pack from this site and ran this perticular map, all my GUI-triggers returned errors, so I kinda abandoned that idea.. But if you belive that it would simplify things that much for me, then perhaps I should give it a shot?
Don't fear this pack :) In fact it's safer to debug and it will help you in your coding learning a lot. Just you need to start little by little with your own challenges as you're doing right now :D

QuoteBtw, just cause I'm curious, are Jass based on any "normal" programming-language and, in that case, which one? xP


According to this article, it's based on turing and delphi, for me it looks more like VB, but in general it's a verbose language, so it makes it relatively easy to understand.

Meanwhile let's do this: Download JNGP to start with vJASS at once, do the fixers I pointed out and finally let's do this thing: Putting your code inside a library. Example:

Code (jass) Select
library CustomSpellDamage
   // insert you code HERE :D
endlibrary


Tell me what kind of errors you get and screenshot if possible. We'll learn to debug your code.
Erhmm! ^^'
I can't see any thing special about the JNGP WE.. None of the new drop-down-menus that should exist do I see. (I downloaded the JNGP 5d if that is any relevant, the 5e seems to be impossible to download for the moment) I have tried to follow a install-tutorial, but there is no syntax highlighting or any other of the JNGP features.. I ran the we.bat and it says it fails to find the wc3-directory. Now, I didn't install the wc3 for this computer cause I have lost the cd:s, I just copied it from my other computer. If that is the problem, then is there a way to fix this, that doesn't include reinstalling it?

EDIT: I think I fixed the path-issue, but the .bat still returns a Registry Key error, is this error returned due to the missing cd-key (it seems like the cd-key isn't stored in the normal Wc3 folder, so whatever key I used wouldn't follow, but since I haven't really cared about battle.net for this game and the game itself have been running flawlessly, so I didn't care about the cd-key.
Edit2: I might have found a solution to my problems, I return again if it doesn't work.
EDIT3: Ok, the problems should be solved, It does atleast find the right path BUT.. it still tells me a registry error and then open something that looks like a normal WE 1.21. (I have tried a registry-program, and a keychanger, but it didn't work) I tried running the bat as a administrator and the weird thing was that it didn't find the exehack.exe cause it started looking in the system32-folder.. I really got no clue what the error is for the moment.. (I got a windows7 64bit if that is any relevant)
Still not functioning, this is the message I get when running the we.bat

(The last message is Press any key to continue, which will terminate the cmd-window. )
What kind of problem did you have downloading JNGP from this site?

I'll check the installation again just in case there's something wrong with it.

Meanwqhile try to start the WE using "NewGen WE.exe"
Error downloading the JNGP-file: Well, to start, my antivirus (Microsoft Security Essentials) warns me of the adress I am directed to after I click the download-button. When I click the Ignore and Continue - option, I get into a page with letters like this: 7z¼¯'ùžÛT&â•6J÷u>núI-CeRqÍl=÷Z£ýu[Xq_²ú½‹UÙzÊ@#'DÔ/ç'úYl²ÎrÜ©(•4ÒCO´òpZ@ÍË'ܵÃc"Ä¢t®€f S9...±W®ÄÙÔ`áåmÛ›–†õʃUݱ™,,VVÄgø3 .¢óÙEKSlRH@ D©Û{*G 5 ù2»ic4àŠòª˜íMë¿Ëz6˜Î`Õ_)[ÃD»"­û²)gfØOþg$Ìö‰<\Èú§8˜ÒÇ_/õä)>`‰EWá«U]ˆv?©2·oÄ­®žåsÒ Õ6|ެxda鹇°ÇTÊ$âÆ©•¬BfÖÐA +xæâ<®Öb€Äcî'{on "7–¼ø¶Œçö'l· –<íau¯†ð]:‹/ö«ÐÓŒJX~Wê*Ñê.ñà=Úöhô¬Ò—hÓŒ±½¿r1ÛX4P üs*¶Ë]'P!¢!,"ØŠÃ8•©8"Ú?wãTT븃&ãš‹È7 ~àÓ3ù—‡qùûß"ËwL‹7W¶":Í"æxÞž7,,˜c‹¸Eå÷§ö+å‡N­ú†µihmûµ TÓ}0U D2—¯!²¨Ù®\‡ÖP\'"*3U...ùÎô,˜©;€´›Ëü&çƒÝØñ¶WžK é6nY*ò 'u"Y/;öì™ý...¾4@Éî*heÈOg»...ä}ûOjGc* N¨&xâD¬îmÀü‡,,¹•èL‰$ç?* Z9Û½ÁÛ6¤;«ájù†ûKšˆ|50£Ákª¢ÚNy©ïœGÒÎðûÃkâøõ¾‹õ0Âädy,"™ACÝ™Õ~´|vÂ,—'Ó7C*µ...)íÞËÍAB³æ\x'5.5Ž´•mdjß9yœg] ÈAVœ«¨YŠºýu\× )ÔQâ,ÔÑÏÚzÕ63Yé&ê=3±!é«Í9?0Tcp{]Rsße†öͪHËW²JÑ#ÇçìÕùîóˆL7¾‰$zäA¡²-1"séitè_Þð,î-C%§Š•ùÛÞ¯ÈìtëE© þ¶...ï–þ±}V®\&º£®o4"bK³Ȳ/гí!ìÁ>» 0èG{œ¿´¾‰mËöÿ0SƒdVÛ‡V/ò3Ó÷ŠtCgÕnòóÇý¸'¥'­ZMK†DÂ$5úRŽœcm\õÕÖ·d£ûdÒØŒ³Ì³=•¸Aµ`ß[j"­Øë*¿?£)Óu//–Џ9ShØÂ¢MºS,,ïã2?ß²º«^ŝ©Í†ã¿sÜ8eÍ,H°vJ­¬¼.ÐûoÞxöâ'Dn¡3 LÛ(7ƒÓXÉпA郻¾øp5þCÿt,5âÁ?1ŠËÁhöäuGM¡ò޼7DöN‹ßíÑ9­T×e/7§™µeï‡ÓÈ?m¦ELéh£2Ô¿ó#v~b3ˆŽÚçÛÛæÇ–£[ø}/ éz,,PSS÷@æ6¿ˆ ƒzÐiî©e@óoˆµDlÉqƒB¯õ›;tÃEBµ\;(HPã|ß'È¡>P...|öAšK%u.
This continues for a very long time, just increasing more and more. If I scroll a huge amount downward, a strange line starts to appear on the letters, but otherwise, it looks kinda much the same.

The NewGen WE is the one I tested to start with, and I have tested it about every time after I ran the .bat - file.

I use wc3 1.25 for the moment, I hope that isn't the problem?

Edit: About the download issue, could the fact that I am running InternetExplorer 64bit be a problem (the JNGP 5d was possible to download, after som fix with the SmartScreen Filter, but 5e won't even start downloading)
Edit2: I fixed the code and the functions seems to work as intended. I wait with the JNGP and stays with the regular WE in the meantime. However, since want to use a trigger-based attack-damage system, using a timer and boolean to determine if cooldown is active or not (I ignore the cooldown-part for computer-players since they normally don't stop-attack-stop-attack). However, it feels like a 12x10 numbers of booleans and timers will take it's toll on the performance together with everything else. Any suggestions?
QuoteError downloading the JNGP-file: Well, to start, my antivirus (Microsoft Security Essentials) warns me of the adress I am directed to after I click the download-button. When I click the Ignore and Continue - option, I get into a page with letters like this: .....

This continues for a very long time, just increasing more and more. If I scroll a huge amount downward, a strange line starts to appear on the letters, but otherwise, it looks kinda much the same.

The NewGen WE is the one I tested to start with, and I have tested it about every time after I ran the .bat - file.

I use wc3 1.25 for the moment, I hope that isn't the problem?
Do you have 7z installed in your pc??



QuoteEdit: About the download issue, could the fact that I am running InternetExplorer 64bit be a problem (the JNGP 5d was possible to download, after som fix with the SmartScreen Filter, but 5e won't even start downloading)
I'd suggest to use firefox, it's nicer and safer :)
QuoteEdit2: I fixed the code and the functions seems to work as intended. I wait with the JNGP and stays with the regular WE in the meantime. However, since want to use a trigger-based attack-damage system, using a timer and boolean to determine if cooldown is active or not (I ignore the cooldown-part for computer-players since they normally don't stop-attack-stop-attack). However, it feels like a 12x10 numbers of booleans and timers will take it's toll on the performance together with everything else. Any suggestions?
Hmm, you can use hastables to store the cooldowns values and one timer that checks units times. But why you need to store the cooldowns?
Yes, I have 7z installed ^^

I kinda like internet explorer in this newer edition ^^' But it could be the 64bit-editions fault. Shall try a 32bit- webbbrowser and see if it works (perhaps Firefox or Opera, Chrome is also an alternative)

I need to stop the stop/attack/stop/attack etc. bug with "Unit is attacked"-triggers. And using a buff to check for a real attack is not a alternative I like, since the first attack won't happen, since the trigger is activated before the attack is made. (I am using a script-based attack-damage system too, since I have some other modifiers more than just plain armor and attackbonus, and I have to keep count on damage done for certain events)

EDIT1!: Ok, fixed a 32bits browser, and now the 5e works and it works without error. I will try and use this now.