Help with Code

Shadow

TH.net Regular
Reaction score
23
Hey was learning the basics of vJass but its been 6 months since I last learned it :)

Need some help removing a unit.

Code:
 scope SunQuan initializer onInit
 
public function ChangeOwner takes nothing returns nothing
    call KillUnit(GetTriggerUnit())
    call SetUnitOwner(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit()), true)
    call SetUnitOwner(GateSpawns_GateCaptain[1], GetOwningPlayer(GetTriggerUnit()), false)
endfunction
 
private function Conditions takes nothing returns boolean
    call ForGroup(armies_Army[1], function ChangeOwner)
    call ForGroup(armies_Army[2], function ChangeOwner)
   
        return false
endfunction
 
private function onInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call CreateUnit(Player(13), 'H006', -5950, 4400, 270)
    call TriggerRegisterUnitInRange(t, CreateUnit(Player(13),'ncop',-6000,4270,90),100,null)
    call TriggerAddCondition(t,Condition(function Conditions))
    endfunction
endscope

Need to remove the unit created in this line

Code:
call TriggerRegisterUnitInRange(t, CreateUnit(Player(13),'ncop',-6000,4270,90),100,null)

After its happened (units entered range) so I assume i'd put it in here

Code:
public function ChangeOwner takes nothing returns nothing
    call KillUnit(GetTriggerUnit())
    call SetUnitOwner(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit()), true)
    call SetUnitOwner(GateSpawns_GateCaptain[1], GetOwningPlayer(GetTriggerUnit()), false)
endfunction

I think i'd have to somehow set the unit to a variable then use the
RemoveUnit function. But how do I set I know its like "set unit t ="
 
I don't have WC3 installed but I remember some...
RegisterUnitInRange will fire when a unit comes in range, the unit that came in range will be the triggering unit.
To remove the unit created here
JASS:
call TriggerRegisterUnitInRange(t, CreateUnit(Player(13),'ncop',-6000,4270,90),100,null)

A global variable should be created for it:
JASS:
// this is not the whole trigger, just the changed parts.
globals
private unit mainUnit//this is the 'registered' unit
endglobals
 
public function ChangeOwner takes nothing returns nothing
call KillUnit(GetTriggerUnit())
call SetUnitOwner(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit()), true)
call SetUnitOwner(GateSpawns_GateCaptain[1], GetOwningPlayer(GetTriggerUnit()), false)
call RemoveUnit(mainUnit)// remove the original unit
set mainUnit=null// remove something... long time since w3 days -_-
endfunction
 
private function onInit takes nothing returns nothing
local trigger t =CreateTrigger()
call CreateUnit(Player(13),'H006',-5950,4400,270)
set mainUnit=CreateUnit(Player(13),'ncop',-6000,4270,90)//set the global unit
call TriggerRegisterUnitInRange(t,mainUnit,100,null)// register global unit
call TriggerAddCondition(t,Condition(function Conditions))
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    I mean I don't really like the government. But I would also prefer to have one than... not have any government. Like we need to have police forces and national welfare systems, but I don't think the cop that is pulling you over for speeding is the same cop that should also be responding to active terror events.
  • The Helper The Helper:
    I am talking about federal.
  • The Helper The Helper:
    State and local elections I believe in when it comes to governing. Of course the military
  • The Helper The Helper:
    Federal should do military
  • The Helper The Helper:
    The federal government should do the military not the police. I hope Trump gets rid of the income tax
  • The Helper The Helper:
    I hold no hope of Trump getting rid of income tax though.
  • jonas jonas:
    Trump is a wildcard, but in the end, it's the republican party that makes the laws, Trump can only do exec orders
  • jonas jonas:
    I don't think the Republicans will get rid of income tax, at most lower it a little, mostly for people with 6 figures+. But that's just my opinion
  • The Helper The Helper:
    one can dream
  • Ghan Ghan:
    FairTax would be nice.
  • Ghan Ghan:
    But the electorate would have to demand it and vote people in to do it.
  • Ghan Ghan:
    Government spending, foreign policy, and the southern border are all bigger issues than the income tax right now I'd say.
  • The Helper The Helper:
    For you those are the bigger issues. Cannabis legalization and get rid of Income tax are mine.
  • Ghan Ghan:
    We have so much cannabis up here in Oklahoma. Can't go a block without running into 3 dispensaries. xD
  • The Helper The Helper:
    if the demand is there
  • jonas jonas:
    I think the biggest issue in USA is how divided the country has become
  • Ghan Ghan:
    There's a big split happening in fundamental values that is very worrisome.
  • jonas jonas:
    I think there's always been a split in values. But now there's a split in what reality is. No matter whom you ask, they think a third of the country is insane and wants to destroy the country
  • The Helper The Helper:
    pretty big split
  • The Helper The Helper:
    Happy Saturday!
    +1
  • V-SNES V-SNES:
    Happy Saturday!
    +1
  • The Helper The Helper:
    Dont forget to check out the list of all the recipes on the site at the Recipe Index - I am about to take Ghan up on the offer of making that a site :) https://www.thehelper.net/threads/main-recipes-menu-recipes-index-version-2-0.189517/
  • The Helper The Helper:
    We should add that as part of site navigation
  • Varine Varine:
    I just don't think Trump actually understands how the government works. I'm not going to pretend like I can understand the entirety of government but in my industry he kind of caused massive fucking issues. Tarriffs and the international counters had a pretty significant impact on what I do, it was actually kind of interesting to see though. I live in Idaho so I'm not really concerned with it, it'll be R pretty much the entire way down. We do have ranked choice on our ballot this year though and I DO really care about that. But if we are going to have a federal government we kind of need income tax. They could abolish it and tax states I guess, but then states are just going to raise income taxes. It's not really viable without a very significant and holistic overhaul of how the federal government works, and that isn't something I would expect Trump to do.
  • Varine Varine:
    I don't expect Harris to do it either. I want to see wealth and church taxes, but those also aren't things I'm going to hold my breath for.

      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