Anyone can help me with Jass?

Vetadors

New Member
Reaction score
1
I am trying to create a Maze map and i want to create a trigger like that;

Trigger
Events
Unit - A unit enters in a terrain of type <gen>
Conditions
(Unit-type of (Entering unit)) Equal to Peasant
Actions
Unit - Kill (Entering unit)

But i know the only solution of that is to create a Jass trigger! And i dont understand how to use the Jass... If anyone know how to use jass, please can you say me the code for this trigger?? :(
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Which terrain type is it that you want to kill units on when they enter? What player(s) control the hostile creeps etc? Do you have a respawn point?
 

CaptDeath

New Member
Reaction score
103
you can create that kinda trigger w/o jass
just
type <gen>
needs to be the name of a rect
make a rect br pressing r in world editor
 

Charapanga

New Member
Reaction score
46
Why don't you get NewGen and Convert it to custom text
Its in the Edit thingy that stretches down...

for that it would be something like
JASS:
function TrigTrigger_Conditions takes nothing returns boolean 
    return GetUnitTypeId(GetEnteringUnit()) == &#039;hpea&#039;
endfunction

function TrigTrigger_Actions takes nothing returns nothing
    call KillUnit(GetEnteringUnit())
endfunction

function InitTrig_Trigger takes nothing returns nothing
    set gg_trg_Trigger = CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_Trigger, gg_rct_in_a_terrain_of_type)
    call TriggerAddCondition(gg_trg_Trigger, Condition(function TrigTrigger_Conditions))
    call TriggerAddAction(gg_trg_Trigger, function TrigTrigger_Actions)
endfunction


its freehand, untested
 

Vetadors

New Member
Reaction score
1
Which terrain type is it that you want to kill units on when they enter? What player(s) control the hostile creeps etc? Do you have a respawn point?

I dont have any respawn point. I just want to kill the peasant (hero) in my game when he enter in a terrain of type; Ice, Poison or Lava
 

darkbeer

Beer is Good!
Reaction score
84
.... unless you want to do millions of rects use a periodic timer, thats what all maze maps do( at least the ones i know of)

would look like this:

Code:
Events - Every 0.04 seconds
Actions - 
set TempGroup = Units in Playable Map area matching unit is a hero <-- wahtever you need here
Unit Group - For TempGroup do actions 
  - set TempPoint = Position of Picked unit
  - if (Terrain type at TempPoint) Gleich XXX then <-- use  an OR for multiple terrain types
        -- Unit - kill Picked unit
  - Custom script: call RemoveLocaiton(udg_TempPoint)
Custom script: call DestroyGroup(udg_TempGroup)
 

Vetadors

New Member
Reaction score
1
Why don't you get NewGen and Convert it to custom text
Its in the Edit thingy that stretches down...

for that it would be something like
JASS:
function TrigTrigger_Conditions takes nothing returns boolean 
    return GetUnitTypeId(GetEnteringUnit()) == &#039;hpea&#039;
endfunction

function TrigTrigger_Actions takes nothing returns nothing
    call KillUnit(GetEnteringUnit())
endfunction

function InitTrig_Trigger takes nothing returns nothing
    set gg_trg_Trigger = CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_Trigger, gg_rct_in_a_terrain_of_type)
    call TriggerAddCondition(gg_trg_Trigger, Condition(function TrigTrigger_Conditions))
    call TriggerAddAction(gg_trg_Trigger, function TrigTrigger_Actions)
endfunction


its freehand, untested

I have put your Jass but its say "Trigger 'Jass' has been disabled due to error." when i test the map.
 

darkbeer

Beer is Good!
Reaction score
84
It does.

you only need NewGen for vJass, but seriously you just converted his trigger and added a rect ...

take a look at my post above.
 

Vetadors

New Member
Reaction score
1
.... unless you want to do millions of rects use a periodic timer, thats what all maze maps do( at least the ones i know of)

would look like this:

Code:
Events - Every 0.04 seconds
Actions - 
set TempGroup = Units in Playable Map area matching unit is a hero <-- wahtever you need here
Unit Group - For TempGroup do actions 
  - set TempPoint = Position of Picked unit
  - if (Terrain type at TempPoint) Gleich XXX then <-- use  an OR for multiple terrain types
        -- Unit - kill Picked unit
  - Custom script: call RemoveLocaiton(udg_TempPoint)
Custom script: call DestroyGroup(udg_TempGroup)

I have do your trigger but its say du to error because you have type a error on "- Custom script: call RemoveLocaiton(udg_TempPoint)" I have modified your error to "Location" but still due to error...
 

Azlier

Old World Ghost
Reaction score
461
RemoveLocation

Typos will not be tolerated by JASS! Unacceptable!

Well... there goes my 666 post count.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
This could be maybe what you're looking for:

Just make sure to create those variables in the variable editor with those exact names.

JASS:
//Requires the following variables:
//
//GlobalN - integer variable
//GlobalUnit - unit array variable
//GlobalTimer - timer array variable
//
//Make sure you have these variables created with those exact names for this to work.

function KillUnitOnTerrain_TerrainType takes real x, real y returns boolean
    //Replace the rawcodes with the ones you have in your map if they do not work.
    if (GetTerrainType(x, y) == &#039;Cpos&#039;) or (GetTerrainType(x, y) == &#039;Nice&#039;) or (GetTerrainType(x, y) == &#039;Dlav&#039;) then
        return true
    endif
    
    return false
endfunction

function KillUnitOnTerrain_CreepPlayer takes nothing returns player
    return Player(12)    //The player owning creeps on your map, Player(0) equal to player 1 red, Player(12) equal to neutral hostile.
endfunction

function KillUnitOnTerrain_Respawn takes nothing returns boolean
    return true    //Set to true if players shall revive.
endfunction

//If there is no respawn, ignore the rest of the functions.

function KillUnitOnTerrain_RespawnTime takes nothing returns real
    return 5.    //Time in seconds that it takes for units to revive.
endfunction

function KillUnitOnTerrain_RespawnX takes nothing returns real
    return -222.    //The X value of the respawn point.
endfunction

function KillUnitOnTerrain_RespawnY takes nothing returns real
    return 280.    //The Y value of the respawn point.
endfunction

//Do not edit anything below here.

function KillUnitOnTerrain_RespawnFunc takes nothing returns nothing
    local integer i = udg_GlobalN
    loop
        exitwhen i &lt;= 0
        if (GetExpiredTimer() == udg_GlobalTimer<i>) then
            call ReviveHero(udg_GlobalUnit<i>, KillUnitOnTerrain_RespawnX(), KillUnitOnTerrain_RespawnY(), true)
            if (GetLocalPlayer() == GetOwningPlayer(udg_GlobalUnit<i>)) then
                call SelectUnit(udg_GlobalUnit<i>, true)
            endif
            
            set udg_GlobalUnit<i> = udg_GlobalUnit[udg_GlobalN]
            set udg_GlobalTimer<i> = udg_GlobalTimer[udg_GlobalN]
            set udg_GlobalN = udg_GlobalN - 1
        endif
        
        set i = i - 1
    endloop
endfunction

function KillUnitOnTerrain_GroupFilter takes nothing returns boolean
    local unit u = GetFilterUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    if KillUnitOnTerrain_TerrainType(x, y) and (GetOwningPlayer(u) != KillUnitOnTerrain_CreepPlayer()) and (GetWidgetLife(u) &gt; .405) then
        call KillUnit(u)
        if KillUnitOnTerrain_Respawn() then
            set udg_GlobalN = udg_GlobalN + 1
            set udg_GlobalUnit[udg_GlobalN] = u
            
            call TimerStart(udg_GlobalTimer[udg_GlobalN], KillUnitOnTerrain_RespawnTime(), false, function KillUnitOnTerrain_RespawnFunc)
        endif
    endif
    
    set u = null
    
    return false
endfunction

function KillUnitOnTerrain_Callback takes nothing returns nothing
    local group g = CreateGroup()
    
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Filter(function KillUnitOnTerrain_GroupFilter))
    call DestroyGroup(g)
    
    set g = null
endfunction

function InitTrig_KillUnitOnTerrain takes nothing returns nothing
    call TimerStart(CreateTimer(), 0.03125, true, function KillUnitOnTerrain_Callback)
endfunction</i></i></i></i></i></i>
 

Vetadors

New Member
Reaction score
1
I do your Jass and i got a error;

Its say " The Trigger 'Jass' must have an initialization fonction called 'InitTrig_Jass' "

So i put 'InitTrig_Jass' in the trigger but after that, its say "'1 Compile error' Expected end of line"
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Is the trigger named exactly like this: KillUnitOnTerrain

Nothing additional, it must be named exactly like that.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top