I need some JASS help

Dryvnt

New Member
Reaction score
10
Hey all! Before i start to address what i need help for, i first wanna say for all that remember me, that the first time i was here, i failed, bigtime... But now i am back and i have learned abit more patience, gotten more writing skills and simply, gotten smarter :thup:

So heres my problem, i am making this spell, that i need to use local variables for. But the problem is i FAIL at JASS, but i tried, but the spell wont work :banghead:. The spell is going to go like this

1. I cast the spell on an enemy
2. A dummy unit spawns and cast's a lookalike spell (without a new dummy unit ofc)

Here's my code

JASS:
function Trig_Main_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Main_Func002001003 takes nothing returns boolean
    return ( GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetSpellAbilityUnit()) )
endfunction

function Trig_Main_Func002A takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit victim = GetSpellTargetUnit()
    local location targetpoint = GetSpellTargetLoc()
    local unit dummy
    call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(caster), targetpoint, 0.00 )
    set dummy = GetLastCreatedUnit()
    call UnitAddAbilityBJ( 'A000', dummy )
    call SetUnitAbilityLevelSwapped( 'A000', dummy, GetUnitAbilityLevelSwapped('A001', caster) )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", victim )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', dummy )
endfunction

function Trig_Main_Actions takes nothing returns nothing
    local location targetpoint = GetSpellTargetLoc()
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(500.00, targetpoint, Condition(function Trig_Main_Func002001003)), function Trig_Main_Func002A )
endfunction

//===========================================================================
function InitTrig_Main takes nothing returns nothing
    set gg_trg_Main = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Main, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Main, Condition( function Trig_Main_Conditions ) )
    call TriggerAddAction( gg_trg_Main, function Trig_Main_Actions )
endfunction
 

Faust

You can change this now in User CP.
Reaction score
123

chobibo

Level 1 Crypt Lord
Reaction score
48
Optimize your code:
-learn vjass
-inline code when necessary
-Use native functions whenever you can
-All dynamic handles must be nulled after use

I recommend the "Collected jass lessons" tutorial.
 

Dryvnt

New Member
Reaction score
10
Explains hardly what's the problem.

But I already found some errors:
JASS:
    local unit victim = GetSpellTargetUnit()
    local location targetpoint = GetSpellTargetLoc()


So the spell is targeted on ground or unit? o_O
The location is for making the dummy unit at the right point, while the victim is gonna get hit by the dummy units spell :rolleyes:

But even with your recommended fix, it wont work. I have my EVIL thoughts on the
JASS:
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", victim )
 

Faust

You can change this now in User CP.
Reaction score
123
The location is for making the dummy unit at the right point, while the victim is gonna get hit by the dummy units spell :rolleyes:

But even with your recommended fix, it wont work. I have my EVIL thoughts on the
JASS:
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", victim )

Why would you order the lastcreatedunit if you set it to a variable?
 

Dryvnt

New Member
Reaction score
10
Why would you order the lastcreatedunit if you set it to a variable?

Oh my! I didn't see that! But it still didnt fix it :/... Tell me if you need map to see if i missed some info

Edit:
Added the map, so you might see if i made something wrong with the dummy unit or something with the spell's stats or stuff :p
 

Attachments

  • Spreading Dark.w3x
    18.4 KB · Views: 115

Expelliarmus

Where to change the sig?
Reaction score
48
Found your error(s)
Start with GUI
Code:
Main Copy
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spreading Evil 
    Actions
        Unit Group - Pick every unit in (Units within 500.00 of (Target point of ability being cast) matching[B] (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))[/B] and do (Actions)
            Loop - Actions
                Unit - Create 1 Peasant for (Owner of (Triggering unit)) at (Target point of ability being cast) facing 0.00 degrees
                Unit - Add Spreading Evil Dummy  to (Last created unit)
                Unit - Set level of Spreading Evil Dummy  for (Last created unit) to (Level of Spreading Evil  for (Triggering unit))
                [B]Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)[/B]
                Unit - Add a 2.00 second Generic expiration timer to (Last created unit)

- Matching Condition errors?
- You ordered Chain Lightning when the spell was based on Stormbolt
- You used Target Unit of Ability Being Cast which again shoots Stormbolt to target unit based on the number of people around it. (This is what you want?)
- Spreading Evil Dummy had mana cost

JASS:
JASS:
function Trig_Main_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Main_Func002001003 takes nothing returns boolean
    //return ( GetOwningPlayer(GetEnumUnit()) != GetOwningPlayer(GetSpellAbilityUnit()) ) // again filter error?
      return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Main_Func002A takes nothing returns nothing
    //local unit caster = GetSpellAbilityUnit() // use triggering unit instead 
    local unit caster = GetTriggerUnit()
    local unit victim = GetSpellTargetUnit()
    local location targetpoint = GetSpellTargetLoc()
    local unit dummy = CreateUnitAtLoc( GetOwningPlayer(caster), 'hooo', targetpoint, 0.00 )
    //set dummy = CreateUnitAtLoc( GetOwningPlayer(caster), 'hooo', targetpoint, 0.00 ) // you can combine them
    call UnitAddAbilityBJ( 'A000', dummy )
    call SetUnitAbilityLevelSwapped( 'A000', dummy, GetUnitAbilityLevelSwapped('A001', caster) )
    //call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", victim ) // you can use dummy variable
    call IssueTargetOrderBJ(dummy, "thunderbolt", victim)
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', dummy )
endfunction

function Trig_Main_Actions takes nothing returns nothing
    local location targetpoint = GetSpellTargetLoc()
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(500.00, targetpoint, Condition(function Trig_Main_Func002001003)), function Trig_Main_Func002A )
    call RemoveLocation(targetpoint) //leaks
    set targetpoint = null //leaks
endfunction

//===========================================================================
function InitTrig_Main takes nothing returns nothing
    set gg_trg_Main = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Main, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Main, Condition( function Trig_Main_Conditions ) )
    call TriggerAddAction( gg_trg_Main, function Trig_Main_Actions )
endfunction

- Your spell casts shockwave to the target as many times as the number of units around the target.
- Look at GUI problems

- You can remove the BJ/ Optimize the code yourself (when you start to learn JASS, this will be a good example to start from)
 

Faust

You can change this now in User CP.
Reaction score
123
Give the dummy's ability 9999999999999 casting range.
 

Dryvnt

New Member
Reaction score
10
Wierd

This is wierd, the GUI version works, have i done something wrong in the JASS? :(

GUI
Code:
Main Copy
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spreading Evil 
    Actions
        Unit Group - Pick every unit in (Units within 500.00 of (Target point of ability being cast) matching (((Owner of (Matching unit)) is an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
            Loop - Actions
                Unit - Create 1 Peasant for (Owner of (Triggering unit)) at (Target point of ability being cast) facing 0.00 degrees
                Unit - Set level of Spreading Evil Dummy  for (Last created unit) to (Level of Spreading Evil  for (Casting unit))
                Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
                Unit - Add a 2.00 second Generic expiration timer to (Last created unit)

JASS
JASS:
function Trig_Main_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Main_Func002001003 takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Trig_Main_Func002A takes nothing returns nothing
    local location targetpoint = GetSpellTargetLoc()
    local unit caster = GetTriggerUnit()
    local unit victim = GetEnumUnit()
    local unit dummy = CreateUnitAtLoc( GetOwningPlayer(caster), 'hooo', targetpoint, 0.00 )
    call SetUnitAbilityLevelSwapped( 'A000', dummy, GetUnitAbilityLevelSwapped('A001', caster) )
    call IssueTargetOrderBJ( dummy, "thunderbolt", victim )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', dummy )
endfunction

function Trig_Main_Actions takes nothing returns nothing
    local location targetpoint = GetSpellTargetLoc()
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(500.00, GetSpellTargetLoc(), Condition(function Trig_Main_Func002001003)), function Trig_Main_Func002A )
    call RemoveLocation(targetpoint)
    set targetpoint = null
endfunction

//===========================================================================
function InitTrig_Main takes nothing returns nothing
    set gg_trg_Main = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Main, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Main, Condition( function Trig_Main_Conditions ) )
    call TriggerAddAction( gg_trg_Main, function Trig_Main_Actions )
endfunction


What am i doing wrong?
 

saw792

Is known to say things. That is all.
Reaction score
280
Did you add the CreateUnitAtLoc() line yourself? Because normally custom unit codes start with 'h000' not 'hooo'.
 

Dryvnt

New Member
Reaction score
10
Did you add the CreateUnitAtLoc() line yourself? Because normally custom unit codes start with 'h000' not 'hooo'.

Well... I thought that was the problem but no :(... I still think its something with that line... Because it doesent spawn a dummy unit

But since the GUI version works, should i just stick to that? Or should i try and fix the JASS ?
 

Viikuna

No Marlo no game.
Reaction score
265
Btw.
You dont have to create Dummy unit for stun everytime someone gets stunned. Just use one global dummy all the time. You just need to set spells casting time and unit animation times to 0. And use SetUnitX /SetUnitY to move dummy to the right place.


EDIT.

I made this WarStomp copy, as a small Jass tutorial for my friend
You might learn something from it too.

JASS:
scope WarStomp initializer init
//====================================================================================
//ASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDA
//==================================================================================
globals
            private constant integer ABILITY_ID = 'A000'
            private constant integer DEALERS_HAND = 'A001'
            private constant integer DEALER_ID = 'n000'
            private constant real AOE = 250.0
            private constant real DAMAGE = 25.0
            private constant string EFFECT_PATH = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"

//====================================================================================
//ASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDASDASDASDASDASDASDASDDDDASD
//====================================================================================    
    private group TempG = CreateGroup()
    private unit TempU
    private filterfunc F
    private unit Dealer
endglobals

private function Filtteri takes nothing returns boolean
    return IsUnitAlly(GetFilterUnit(),GetOwningPlayer(TempU)) == false and GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

private function YesWeCan takes nothing returns nothing
     local unit u = GetTriggerUnit()
     local real x = GetUnitX(u)
     local real y = GetUnitY(u)
     local integer level = GetUnitAbilityLevel(u,ABILITY_ID)
     local unit target
     local player p = GetOwningPlayer(u)
     set TempU = u
     call GroupEnumUnitsInRange(TempG,x,y,AOE,F)
     call DestroyEffect(AddSpecialEffect(EFFECT_PATH,x,y))
     call SetUnitAbilityLevel(Dealer,DEALERS_HAND,level)
     loop
         set target = FirstOfGroup(TempG)
         exitwhen target == null
         set x = GetUnitX(target)
         set y = GetUnitY(target)
         call SetUnitX(Dealer,x)
         call SetUnitY(Dealer,y)
         call IssueTargetOrder(Dealer,"thunderbolt",target)
         call UnitDamageTarget(u,target,DAMAGE*level,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
         call GroupRemoveUnit(TempG,target)
     endloop
     set u = null
     set p = null
endfunction

private function CanWeStomp takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function CanWeStomp))
    call TriggerAddAction(t,function YesWeCan)
    set F = Filter(function Filtteri)
    set Dealer = CreateUnit(Player(13),DEALER_ID,0.0,0.0,0.0)
endfunction

endscope


And sometimes it is good to have WarStomp without terrain deformation, since normal WarStomp can desync with GetLocationZ.
 

saw792

Is known to say things. That is all.
Reaction score
280
Umm I think you missed what I was saying. Replace 'hooo' with 'h000'.
 

Dryvnt

New Member
Reaction score
10
Umm I think you missed what I was saying. Replace 'hooo' with 'h000'.

I have done that... But it didnt work, then after importing into another map, it worked... So well, thank you guys for all your help! :D Wish i could give you +rep :rolleyes:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top