Create Unit Problem

Vulcansurge

Ultra Cool Member
Reaction score
27
HEre is my code:

Code:
//===========================================================================
//                              AQUIRE SHIPS
//===========================================================================
function Trig_ShipAquireJASS_Actions takes nothing returns nothing
  local unit um=GetManipulatingUnit()
  local integer i=GetItemTypeId(GetManipulatedItem())
  local player pl=GetOwningPlayer(um)
  local location pt=GetUnitLoc(um)
  local integer l=0
  local integer n=0
  local integer array it
  local integer array ut
  local integer array ua
  local unit array up
    set it[1]='I001'
    set it[2]='I000'
    set it[3]='I002'
    set it[4]='I005'
    set it[5]='I008'
    set it[6]='I007'
    set it[7]='I006'
    set ut[1]='H000'
    set ut[2]='H001'
    set ut[3]='H003'
    set ut[4]='H002'
    set ut[5]='H00F'
    set ut[6]='H004'
    set ut[7]='H005'
    set ua[1]=10
    set ua[2]=6
    set ua[3]=8
    set ua[4]=6
    set ua[5]=1
    set ua[6]=3
    set ua[7]=5
  loop
    set l=l+1
    if (i==it[l]) then
      loop
        set n=n+1
        call CreateNUnitsAtLoc(1,ut[l],pl,pt,100)
        set up[n]=GetLastCreatedUnit()
        exitwhen n==ua[l]
      endloop
      set n=0
    endif
    exitwhen (i==it[l])
  endloop
endfunction
//===========================================================================
function InitTrig_ShipAquireJASS takes nothing returns nothing
    set gg_trg_ShipAquireJASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ShipAquireJASS, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_ShipAquireJASS, function Trig_ShipAquireJASS_Actions )
endfunction

I know its messy, things need to be fixed and im new at this. This code it used to make little ships at the position of a hero when he aquires a specfic item. But they dont get created...
 

PurgeandFire

zxcvmkgdfg
Reaction score
508
Can't you just use a boolexpr and a condition function for it to check it, or even an if/then/else?
Simply create your condition then do this:
Code:
local boolexpr <var> = (function ( Condition function thingy))
//Something like that//
Then do an if var = true then... I think that should work, don't forget to destroy it afterwards! :D
If you need me to go into further detail, I'll do that later cuz I have to go to sleep. :)
 

Chocobo

White-Flower
Reaction score
409
Code:
//===========================================================================
//                              AQUIRE SHIPS
//===========================================================================
function Trig_ShipAquireJASS_Actions takes nothing returns nothing
  local unit um=GetTriggerUnit()
  local integer i=GetItemTypeId(GetManipulatedItem())
  local integer l=0
  local integer n=0
  local integer array it
  local integer array ut
  local integer array ua
  local unit array up //really used?
    set it[1]='I001'
    set it[2]='I000'
    set it[3]='I002'
    set it[4]='I005'
    set it[5]='I008'
    set it[6]='I007'
    set it[7]='I006'
    set ut[1]='H000'
    set ut[2]='H001'
    set ut[3]='H003'
    set ut[4]='H002'
    set ut[5]='H00F'
    set ut[6]='H004'
    set ut[7]='H005'
    set ua[1]=10
    set ua[2]=6
    set ua[3]=8
    set ua[4]=6
    set ua[5]=1
    set ua[6]=3
    set ua[7]=5
    loop
        set l=l+1
        if (i==it[l]) then
            loop
                set n=n+1
                set up[n]=CreateUnit(GetOwningPlayer(um),ut[l],GetUnitX(um),GetUnitY(um),100) [B]//ut = NULL[/B]
                exitwhen n==ua[l]
            endloop
        set n=0
        endif
    exitwhen (i==it[l])
    endloop
    set um=null
endfunction

(nvm)
 

Chocobo

White-Flower
Reaction score
409
No that hasnt seemed to work... What the problem.

lets see one by one the actions :

- All is initialized
- Loop starts
- l = 1
- if GetItemTypeId(GetManipulatedItem())==it[1]
- then loops
- n = 1
- set up[1] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 1==10
- loops again
- n = 2
- set up[2] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 2==10
- loops again
- n = 3
- set up[3] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 3==10
- loops again
- n = 4
- set up[4] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 4==10
- loops again
- n = 5
- set up[5] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 5==10
- loops again
- n = 6
- set up[6] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 6==10
- loops again
- n = 7
- set up[7] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'H000',...)
- exitwhen 7==10
- loops again
- n = 8
- set up[8] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),H000,...)
- exitwhen 8==10
- loops again
- n = 9
- set up[9] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),H000,...)
- exitwhen 9==10
- loops again
- n = 10
- set up[10] = CreateUnit(GetOwningPlayer(GetTriggerUnit()),H000,...)
- exitwhen 10==10
- endloops
- n = 0
- exitwhen GetItemTypeId(GetManipulatedItem())=='I001'
- loops from begin.. but exitwhen l = 6, then = 8, = 6, = 1, = 3, = 5.
.. and so on

You sure you wrote the correct unitIds?
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
We need a rule that requires all triggers to have descriptive variable names...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top