• 🏆 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] cannot test a map

Status
Not open for further replies.
Level 4
Joined
May 21, 2015
Messages
70
is there something wrong with my code cannot semm to test it when i try to test(F9) in the WE, using JNGP, tried saving the map then manually opening through warcraft but no luck (this just a test because I'm still learning JASS right now) does anyone know what might be the problem?
map initialization trigger is present btw its a trigger which means i created a trigger then convert to custom text, erase all then paste this code.

JASS:
function Slash_Action takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local location position = GetUnitLoc(caster)
local group g = CreateGroup()
local unit temp
local integer count = 5
   call GroupEnumUnitsInRangeOfLoc(g, position, 600.0, null)
loop
set temp = FirstOfGroup(g)
exitwhen temp == null or count == 0
  if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
  set temp_loc = GetUnitLoc(temp)
  call SetUnitPositionLoc(caster, temp_loc)
  call UnitDamageTarget(caster, temp, 100.0, true, false, ATTACK_TYPE_CHAOS, null)
  set count = count - 1
  endif
  call GroupRemoveUnit(g, temp)
  endloop
   set position = null
   set g = null
   set temp = null
   set temp_loc = null
   endfunction

function Slash_Trigger takes nothing returns nothing
   local trigger gg_trg_Slash = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
   call TriggerAddCondition(gg_trg_Slash,Condition(function Slash_Condition))
   call TriggerAddAction(gg_trg_Slash, function Slash_Action)
endfunction
 
Last edited:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

You forgot to define one of the last two parameters in your statement. It should throw you the error, btw, when you try to save the map. Doesn't it?

Also use [code=jass] tags instead of [CODE]. :p
 
Level 4
Joined
May 21, 2015
Messages
70
thanks for encouragement, btw do I need to put this script on the map "icon"-thing on the top left corner of the trigger editor?? oh another thing It doesn't give error (don't know whats wrong with JNGP [cannpt even syntax check]) I just click Test Map (F9) then it just go to the warcraft's opening (where you can see "Single Player")
 
Uhm no. I think you mean the trigger header. Normal triggers should not be moved there.

You can place help functions there, and it will be ensured that the normal jass triggers you create will be able to use those help functions. ( a JASS statement can only call a function which is defined above the calling function)
So for example maths forumlas etc, that you would need in multiple triggers, could be placed there in theory.
 
Level 4
Joined
May 21, 2015
Messages
70
now now I found it but again I'm new to JASS to don't really understand what it meant
ARGUMETNS JASS.PNG
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Damage type and weapon type parameter or argument is missing in that function.

JASS:
call UnitDamageTarget(caster,temp,100,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_MAGIC,null)
// This should work
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
^ Check again my previous post above

Edit: JNGP should already shows you the needed parameters of a function when your typing or atleast go inside the 'Function List'

Also you can use the constants of weapon type instead of a null.
 
Last edited:
Level 20
Joined
Aug 13, 2013
Messages
1,696
It should have a prefix called InitTrig_ for initialization function of JASS to recognize.
( vJASS have initializers itself )
JASS:
function InitTrig_Trigger_Name takes nothing returns nothing
// Initialize stuffs and
// create a trigger, register an event and add conditions or actions
// preload for optional
endfunction
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
If you want to make an iniaialization function that doesn't use the default InitTrig_ function you can do (and I would highly recommend doing it this way):
JASS:
library YourLibrary initializer ThisFunctionGetsCalledOnMapInit
    //Put whatever you want here

    private function ThisFunctionGetsCalledOnMapInit takes nothing returns nothing
        //All these get called at map init
    endfunction
endlibrary
 
Status
Not open for further replies.
Top