• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help to fix the script

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys does any one know how to fix this script?
The error is Expected: ''takes''

Here's the script http://www.hiveworkshop.com/forums/pastebin.php?id=xhp9v8

This line is causing the error

JASS:
function AfterDamageEvent EQUAL to 1.00 takes unit source, unit target, boolean b, real amount, boolean attack, boolean ranged, attacktype a, damagetype d, weapontype w returns boolean
    local integer ptype = udg_PDD_damageType
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
That seems super mega wrong.

Either it's some vjass stuff that I don't know about, or whoever made that function don't know the basics of jass syntax.

A function looks like:
JASS:
function NAME takes ARGUMENTS returns VARIABLE TYPE
//stuff
endfunction

EQUAL to 1.00
Remove that and it will compile.

edit: if you use JNGP 2.0 you can try to switch JassHelper.
235738620bd8be9401fae6ddf136eb88.png
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hmmmmm.... okay I'll stick with the PDD system since a lot of my imported stuff use that system, Bribe told me that, with PDD you have to use custom script to Get/Set the widget life, so he wouldn't trust that to work 100% in GUI. DamageEngine will do the job with more security. That's why I imported his Damage Engine too. Thanks for time man.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Hey again jon, I think I've isolated the problem. There were variable clashes in that script that I've now sorted through:

JASS:
//Physical Damage Detection plugin for Damage Engine 3.
//
//A few important notes:
//- Spell reduction is handled multiplicatively in DamageEngine, instead of additively like in PDD.
//- Just like in PDD, make sure you've modified the Runed Bracers item to remove the Spell Damage Reduction ability
//- Move any UnitDamageTargetEx calls to an "AfterDamageEvent Equal to 1.00" trigger
//- You do not need custom Get/Set-Unit(Max)Life functions, but I included them for ease of import.
//
//I will add more disclaimers, tips or fixes if anyone runs into issues!
function GetUnitLife takes unit u returns real
    return GetWidgetLife(u)
endfunction

function SetUnitLife takes unit u, real r returns nothing
    call SetWidgetLife(u, r)
endfunction

function GetUnitMaxLife takes unit u returns real
    return GetUnitState(u, UNIT_STATE_MAX_LIFE)
endfunction

function UnitDamageTargetEx takes unit source, unit target, boolean b, real amount, boolean attack, boolean ranged, attacktype a, damagetype d, weapontype w returns boolean
    local integer ptype = udg_PDD_damageType
    //To keep this functioning EXACTLY the same as it does in PDD, you need to move it
    //to an AfterDamageEvent Equal to 1.00 trigger. It's up to you.
    if ptype != udg_PDD_CODE then
        set udg_PDD_damageType = udg_PDD_CODE
        call UnitDamageTarget(source, target, amount, attack, ranged, a, d, w)
        call TriggerEvaluate(udg_ClearDamageEvent)
        set udg_PDD_damageType = ptype
        return true
    endif
    return false
endfunction

function PDD_OnDamage takes nothing returns boolean
    //cache previously-stored values in the event of recursion.
    local unit source = udg_PDD_source
    local unit target = udg_PDD_target
    local real amount = udg_PDD_amount
    local integer typ = udg_PDD_damageType

    //set variables to their event values.
    set udg_PDD_source = udg_DamageEventSource
    set udg_PDD_target = udg_DamageEventTarget
    set udg_PDD_amount = udg_DamageEventAmount

    //Extract the damage type from what we already have to work with.
    if udg_IsDamageSpell then
        set udg_PDD_damageType = udg_PDD_SPELL
    elseif udg_PDD_damageType != udg_PDD_CODE then
        set udg_PDD_damageType = udg_PDD_PHYSICAL
    endif

    //You can delete the next few lines if you have already modified your runed bracers
    //ability to 1.67 instead of removing it from the item:
    if udg_IsDamageSpell and IsUnitType(udg_PDD_target, UNIT_TYPE_HERO) and UnitHasItemOfTypeBJ(udg_PDD_target, 'brac') then
        set udg_PDD_amount = udg_PDD_amount * 0.67
    endif

    //Fire PDD event.
    set udg_PDD_damageEventTrigger = 0.00
    set udg_PDD_damageEventTrigger = 1.00

    //Hey, this works and I'm really happy about that!
    set udg_DamageEventAmount = udg_PDD_amount

    //reset things just in case of a recursive event.
    set udg_PDD_damageEventTrigger = 0.00
    set udg_PDD_source = source
    set udg_PDD_target = target
    set udg_PDD_amount = amount
    set udg_PDD_damageType = typ
    set source = null
    set target = null
    return false
endfunction

function InitTrig_DamageEvent takes nothing returns nothing
    set udg_PDD_PHYSICAL = 0
    set udg_PDD_SPELL = 1
    set udg_PDD_CODE = 2
    set udg_PDD_damageEvent = CreateTrigger()
    call TriggerRegisterVariableEvent(udg_PDD_damageEvent, "udg_DamageModifierEvent", EQUAL, 1.00)
    call TriggerAddCondition(udg_PDD_damageEvent, Filter(function PDD_OnDamage))
endfunction
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
Yeheyyy...... its okay now guys, I'll change my triggers right away!

Must spread rep around first before giving it to Bribe again XD
 
Status
Not open for further replies.
Top