Why does this spell make my map not work?

Status
Not open for further replies.
Level 22
Joined
Feb 3, 2009
Messages
3,292
Well bellow is the code, and yes this is the trigger causing it, because if i disable it, then map works again. But i really need to make this my trigger work :/
+rep for solutions

JASS:
globals
location array p
endglobals
// function for group conditions
function Group_Con takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
endfunction
// function for group actions 
function Group_Act takes nothing returns nothing
call SetUnitPositionLoc(GetEnumUnit(), p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
endfunction
// function for trigger conditions
function Teleport_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00B' 
endfunction
// function for trigger actions
function Teleport_Actions takes nothing returns nothing
local unit x = GetTriggerUnit()
local location px = GetUnitLoc(x)
local group g = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(x), Condition(function Group_Con))
local real delay = 1.6 - ((GetUnitAbilityLevel(x, 'A00B') * 0.5))
local string e = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
// End of locals, start of main code.
set p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetSpellTargetLoc()
call TriggerSleepAction(delay)
call AddSpecialEffectLoc(e , px)
call ForGroup( g, function Group_Act )
// Nulling variables
set x = null
call RemoveLocation(p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
call RemoveLocation(px)
call DestroyGroup(g)
endfunction
//===========================================================================
function InitTrig_Teleport takes nothing returns nothing
   local trigger Teleport = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( Teleport, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( Teleport, Condition( function Teleport_Conditions ) )
    call TriggerAddAction( Teleport, function Teleport_Actions )
endfunction
 
Declaring public globals like that is a very bad idea, especially with such a generic name (p).
Assuming you have JNGP you should be using vJass.

JASS:
scope Teleport initializer onInit

    globals
        private location array p
    endglobals
    // function for group conditions
    private function Group_Con takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
    endfunction
    // function for group actions
    function Group_Act takes nothing returns nothing
        call SetUnitPositionLoc(GetEnumUnit(), p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
    endfunction
    // function for trigger conditions
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00B'
    endfunction
    // function for trigger actions
    private function Actions takes nothing returns nothing
        local unit x = GetTriggerUnit()
        local location px = GetUnitLoc(x)
        local group g = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(x), Condition(function Group_Con))
        local real delay = 1.6 - ((GetUnitAbilityLevel(x, 'A00B') * 0.5))
        local string e = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
        // End of locals, start of main code.
        set p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetSpellTargetLoc()
        call TriggerSleepAction(delay)
        call AddSpecialEffectLoc(e , px)
        call ForGroup( g, function Group_Act )
        // Nulling variables
        set x = null
        call RemoveLocation(p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
        call RemoveLocation(px)
        call DestroyGroup(g)
    endfunction

    private function onInit takes nothing returns nothing
        local trigger Teleport = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( Teleport, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( Teleport, Condition( function Conditions ) )
        call TriggerAddAction( Teleport, function Actions )
    endfunction
endscope

This could still be optimized a lot more. Also, if you don't have JNGP you cannot declare globals like you are.
 
Last edited:
Level 22
Joined
Feb 3, 2009
Messages
3,292
Declaring public globals like that is a very bad idea, especially with such a generic name (p).
Assuming you have JNGP you should be using vJass.


JASS:
scope Teleport initializer onInit
 
    globals
        private location array p
    endglobals
    // function for group conditions
    private function Group_Con takes nothing returns boolean
        return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
    endfunction
    // function for group actions
    function Group_Act takes nothing returns nothing
        call SetUnitPositionLoc(GetEnumUnit(), p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
    endfunction
    // function for trigger conditions
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00B'
    endfunction
    // function for trigger actions
    private function Actions takes nothing returns nothing
        local unit x = GetTriggerUnit()
        local location px = GetUnitLoc(x)
        local group g = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(x), Condition(function Group_Con))
        local real delay = 1.6 - ((GetUnitAbilityLevel(x, 'A00B') * 0.5))
        local string e = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl"
        // End of locals, start of main code.
        set p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetSpellTargetLoc()
        call TriggerSleepAction(delay)
        call AddSpecialEffectLoc(e , px)
        call ForGroup( g, function Group_Act )
        // Nulling variables
        set x = null
        call RemoveLocation(p[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
        call RemoveLocation(px)
        call DestroyGroup(g)
    endfunction
 
    private function onInit takes nothing returns nothing
        local trigger Teleport = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( Teleport, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( Teleport, Condition( function Conditions ) )
        call TriggerAddAction( Teleport, function Actions )
    endfunction

This could still be optimized a lot more. Also, if you don't have JNGP you cannot declare globals like you are.


Yes i do have JNGP, but simply don't know how to fully use vJASS like Scopes, Library, the tutorials were to hard for me, expecialy that this spell is only MPI because of the Globals variable, don't know how to make vJASS MUI.

EDIT: It gives me a error: The Trigger Teleport must have an initilization function called InitTrig_Teleport.
Any ideas ?
EDIT2: It gives another error: Missing endscope
 
Status
Not open for further replies.
Top