• 🏆 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!

[JASS] Jass Errors?

Status
Not open for further replies.
Level 3
Joined
Sep 3, 2004
Messages
50
Every now and then (off and on) I look into learning JASS and sometimes use JASS for things gui can't do. Course now I'm having problems and I need soultions. It seems like it would be a few simple mistakes I made somewhere but I'm not familar enough with JASS yet to figure it out.

JASS:
function Trig_Blade_Damager_Actions takes nothing returns nothing
    local point BleedPositioner[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource()))]=GetUnitLoc(GetTriggeringUnit())
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', GetOwningPlayer(GetEventDamageSource()), BleedPositioner[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource()))], GetUnitLoc(GetTriggerUnit()) )
    local unit Bleeder[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource())) = GetLastCreatedUnit()
    //call TriggerSleepAction( 0.01 )
    call IssueTargetOrderBJ( Bleeder[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource())), "acidbomb", GetTriggerUnit() )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', Bleeder[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource())) )
    call DestroyUnit(Bleeder[GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
    call RemoveLocation(BleedPositioner[GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource()))])
    call ConditionalTriggerExecute( gg_trg_Dameage_Clear )
endfunction

//===========================================================================
function InitTrig_Blade_Damager takes nothing returns nothing
    set gg_trg_Blade_Damager = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Blade_Damager, function Trig_Blade_Damager_Actions )
endfunction

(note: The wait trigger is left off intentionally right now, don't worry bout that)

First post on this new Hive Site rather than the old WC3sear.ch

First time noticing the "JASS classroom" which looks interesting. Might need to enroll soon heh heh.
 
Level 11
Joined
Oct 13, 2005
Messages
233
The "Jass Classroom" is no longer being used. I'd like to say that you need much more experience with Jass, but at least you're trying. First off, I'd like to point out that 'point' is know as a location and also, that local variable needs a name (otherwise, how will you refer to it). Second, all local variables must be defined before doing anything else. That means you can't make a local variable, call some functions, and then make another. Third, here's how arrays are used:
JASS:
local location array myLocation
// Note that you can't make an array and set a value for it on the same line
   set myLocation[index] = value
// I'm sure you already know how to use arrays
Now, why do you need array variables? It's not like in GUI where the variables are the same throughout the map, so you don't need all that player-specific stuff. Think of local variables as a completely new variable being made each time the function is run, and can only be accessed from within that specific function.

After you get the hang with all of that, you'll need to stop using all those BJ functions GUI uses by default. For instance, CreateUnit or CreateUnitAtLoc should be used instead of CreateNUnitsAtLoc, which will mean that you can't (and shouldn't) use GetLastCreatedUnit().

If you need somewhere to go for learning more Jass, take a look at the link in my signature for a good sized Jass tutorial.
 
Level 3
Joined
Sep 3, 2004
Messages
50
JASS:
function Trig_Blade_Damager_Conditions takes nothing returns boolean
    if GetUnitTypeId(GetEventDamageSource()) == 'o001'  then
        return true
    endif
    return false
endfunction

function Trig_Blade_Damager_Actions takes nothing returns nothing
    local location BleedPosition = GetUnitLoc(GetTriggerUnit())
    local unit bleed1
    local unit bleed2=GetTriggerUnit()
    call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', GetOwningPlayer(GetEventDamageSource()), BleedPosition, GetUnitLoc(bleed2) )
    call TriggerSleepAction( 0.01 )
    set bleed1 = GetLastCreatedUnit()
    call IssueTargetOrderBJ( bleed1, "acidbomb", bleed2)
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', bleed1 )
    call RemoveLocation(BleedPosition)
    set bleed1=null
    set bleed2=null
    call ConditionalTriggerExecute( gg_trg_Dameage_Clear )
endfunction

//===========================================================================
function InitTrig_Blade_Damager takes nothing returns nothing
    set gg_trg_Blade_Damager = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Blade_Damager, Condition( function Trig_Blade_Damager_Conditions ) )
    call TriggerAddAction( gg_trg_Blade_Damager, function Trig_Blade_Damager_Actions )
endfunction

I managed to fix it up mostly. It works the same way the gui version worked....which beats the purpose of why I wanted it to convert it to jass in the first place.

As this is triggered, the lag increases dramatically until it crashes. Meaning there is a leak somewhere? Hmm....any ideas anyone?

btw, I didn't do those other things you said wyrm like changing createnunits to createunit since you said you can't use last created unit with it. You then specified no repalcement that would suit it....
 
Level 11
Joined
Oct 13, 2005
Messages
233
I'm pretty sure I did. Anyways, here's what you would do:
JASS:
 set <unit_variable> = CreateUnit(parameters here)

You can also change:
JASS:
function Trig_Blade_Damager_Conditions takes nothing returns boolean
if GetUnitTypeId(GetEventDamageSource()) == 'o001' then
return true
endif
return false
endfunction

// Changes to:

function Trig_Blade_Damager_Conditions takes nothing returns boolean
 return GetUnitTypeId(GetEventDamageSource()) == 'o001'
endfunction

Also, there's no need for the wait (unless you need some kind of pause). I don't know what the trigger you're executing does; that might cause the lag.
 
Level 3
Joined
Sep 3, 2004
Messages
50
What goes in the CreateUnit()

What I got is....

set bleed1 = CreateUnit(GetOwningPlayer(GetEventDamageSource()),'h000', GetLocationX(BleedPosition), GetLocationY(BleedPosition),

Jass Editor says that function CreateUnit takes arguments player id, integer unitid, real x, real y, and real face

What is "real face"?

BleedPosition leaks since you forgot to set it to null at the end of its use.

There is a call RemoveLocation(BleedPosition) in there. Doesn't that prevent it from leaking or do I need to set it to null?
 
Status
Not open for further replies.
Top