My custom made spell damage function

Coding Help

13 years
edited 13 years
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
1
function Spelldamage_Func003C takes unit Target returns boolean
2
    if ( not ( IsUnitType(Target, UNIT_TYPE_HERO) == true ) ) then
3
        return false
4
    endif
5
    return true
6
endfunction
7
8
function Spelldamage_Func004C takes unit Target, unit Caster returns boolean
9
    if ( not ( udg_spellarmor[GetConvertedPlayerId(GetOwningPlayer(Target))] > udg_spellpenetration[GetConvertedPlayerId(GetOwningPlayer(Caster))] ) ) then
10
        return false
11
    endif
12
    return true
13
endfunction
14
15
function Spelldamage_Func007Func001C takes unit Caster, unit Target returns boolean
16
    if ( not ( ( GetRandomInt(1, 40) + GetHeroStatBJ(bj_HEROSTAT_INT, Caster, true) ) <= ( GetRandomInt(1, 35) + GetHeroStatBJ(bj_HEROSTAT_INT, Target, true) ) ) ) then
17
        return false
18
    endif
19
    return true
20
endfunction
21
22
function Spelldamage_Func007C takes unit Target returns boolean
23
    if ( not ( IsUnitType(Target, UNIT_TYPE_HERO) == true ) ) then
24
        return false
25
    endif
26
    return true
27
endfunction
28
29
function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns bolean
30
local real spelldamage; tempspellarmor
31
local bolean
32
    set spelldamage = ( basedamage + udg_spelldamagebonus[GetConvertedPlayerId(GetOwningPlayer(Caster))] * udg_spelldamagebonuspercent[GetConvertedPlayerId(GetOwningPlayer(udg_FSCaster))])
33
    if ( Spelldamage_Func003C( Target ) ) then
34
        set tempspellarmor = udg_spellarmor[GetConvertedPlayerId(GetOwningPlayer(Target))]
35
    else
36
    endif
37
    if ( Trig_Spelldamage_Func004C( Target, Caster ) ) then
38
        set tempspellarmor = tempspellarmor - udg_spellpenetration[GetConvertedPlayerId(GetOwningPlayer(Caster))]
39
        set spelldamage = ( spelldamage * ( 1 - ( ( tempspellarmor * 0.06 ) / ( 1 + ( 0.06 * tempspellarmor ) ) ) ) )
40
    else
41
    endif
42
    set tempspelldamage = (( tempspelldamage - udg_spellreduction[GetConvertedPlayerId(GetOwningPlayer(Target))]* ( 1 - udg_spelldamagereductionpercent[GetConvertedPlayerId(GetOwningPlayer(Target) )) )
43
    if ( Trig_Spelldamage_Func007C( Caster, Target ) ) then
44
        if ( Trig_Spelldamage_Func007Func001C( Target ) ) then
45
            set tempdamage = ( udg_FSSheepdealsdamage * 0.50 )
46
            set SDsave = true
47
        else
48
            set save = false
49
        endif
50
    else
51
    endif
52
    call UnitDamageTargetBJ( udg_FSCaster, udg_FSSheepDealsTarget, udg_FSSheepdealsdamage, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL )
53
    return SDsave
54
endfunction

13 years
(I saw a small error in the end of the code, but that is not the problem, so pls ignore it)
13 years
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
1
function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns bolean
2
   local real spelldamage; tempspellarmor
3
   local bolean


it should be:

Code (jass) Select
1
function Spelldamage_Actions takes unit Target, unit Caster, real basedamage returns boolean //you made a typo :P
2
   local real spelldamage //unfortunately jass doesn't support multiple declarations in one statement :(
3
   local real tempspellarmor
4
   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.
13 years
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
13 years
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
1
library CustomSpellDamage
2
   // insert you code HERE :D
3
endlibrary


Tell me what kind of errors you get and screenshot if possible. We'll learn to debug your code.
13 years
edited 13 years
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)
13 years
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. )
13 years
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"
13 years
edited 13 years
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?
13 years
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?
13 years
edited 13 years
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.