• 🏆 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!

How Do You Remove A Unit Through a Text String?

Status
Not open for further replies.
Level 11
Joined
May 10, 2008
Messages
1,001
How Do You Remove A Unit Through a Text String?
Please Help!

Also... Can You Have More Then 1 dialogs at different times? If so please tell me how.. Thank You:grin:
-GeazerGimli2
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
How Do You Remove A Unit Through a Text String?
Ok um that makes completly no sense. Please explain more what you mean by this and maybe why you need it as units and strings are not the least bit simlar.

As for question 2, if you mean button dialogs, then yes but sadly each player can have only 1 at a time (each player can have a different one at the same time as other players).
 
Level 11
Joined
May 10, 2008
Messages
1,001
This is wat i mean

Well What I mean is you know how you can type -name or -ally or anything.. but idk how to -Remove.. (which removes a unit from game completley) Or is there a better way of removing a unit while in game? :eekani:
 
Level 7
Joined
Jul 20, 2008
Messages
377
You can have it set an unit variable for which unit a player has selected most recently and then when the -remove command is issued, remove that unit.
 
Level 11
Joined
May 10, 2008
Messages
1,001
Ye man thx... But is there such this as removing any unit? without being specific? or no?

-Btw... I love that picture on you.. rofl...(Huurka)
 
Level 11
Joined
May 10, 2008
Messages
1,001
When i try to save... The message comes up


Line 2074: Expected Name

function Trig_Kill_Unwanted_Units_Func002002 takes nothing returns nothing
call DoNothing( )
endfunction

function Trig_Kill_Unwanted_Units_Actions takes nothing returns nothing
set bj_wantDestroyGroup = True


Wat would i do? (idk how to work scripts)
 
Level 7
Joined
Jul 20, 2008
Messages
377
When i try to save... The message comes up


Line 2074: Expected Name

function Trig_Kill_Unwanted_Units_Func002002 takes nothing returns nothing
call DoNothing( )
endfunction

function Trig_Kill_Unwanted_Units_Actions takes nothing returns nothing
set bj_wantDestroyGroup = True


Wat would i do? (idk how to work scripts)
Seems to me you're missing an endfunction after the set bj_wantDestroyGroup = true thing.
 
Level 11
Joined
May 10, 2008
Messages
1,001
OOps lol... Wat if i have another Script Already in it? would i put it at the end or in beggining???
And can u tell me wat exactly i should put in there?
Thx Dude :D
 
Level 7
Joined
Jul 20, 2008
Messages
377
JASS:
function Trig_Kill_Unwanted_Units_Func002002 takes nothing returns nothing
call DoNothing( )
endfunction

function Trig_Kill_Unwanted_Units_Actions takes nothing returns nothing
set bj_wantDestroyGroup = true
endfunction

Of course, why the "Do Nothing?"
 
Level 11
Joined
May 10, 2008
Messages
1,001
  • Kill Unwanted Units
    • Events
      • Player - Player 1 (Red) types a chat message containing -Remove as An exact match
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units currently selected by Players) and do (Unit - Remove (Picked unit) from the game)
Aww crap... i messed up i meant to do this one:sad:
 
Level 11
Joined
May 10, 2008
Messages
1,001
function Trig_Kill_Unwanted_Units_Func002002 takes nothing returns nothingcall DoNothing( )endfunctionfunction Trig_Kill_Unwanted_Units_Actions takes nothing returns nothingset bj_wantDestroyGroup = trueendfunction

Do u think u can give me the script though like you did here?
:gg:
 
Level 7
Joined
Jul 20, 2008
Messages
377
Do you want the entire trigger in JASS or just a custom script for removing the typing player's units?
 
Level 7
Joined
Jul 20, 2008
Messages
377
Okay... this is the OCD (obsessive compulsive) way to do it, so bear with me.

JASS:
function Trig_Kill_Unwanted_Units_Actions takes nothing returns nothing
local group tempGroup=CreateGroup()
local unit nextUnit
local player typingPlayer=GetTriggerPlayer()
call GroupEnumUnitsOfPlayer(tempGroup,typingPlayer, null)
loop
set nextUnit=FirstOfGroup(tempGroup)
exitwhen nextUnit==null
call GroupRemoveUnit(tempGroup, nextUnit)
call RemoveUnit(nextUnit)
endloop
call DestroyGroup(tempGroup)
set tempGroup=null
set nextUnit=null
set typingPlayer=null
endfunction
 
Level 11
Joined
May 10, 2008
Messages
1,001
K this is what my scripting code exactly looks like

function B642I takes string s returns integer
local integer idx = StringLength(s)
local integer val = 0
local integer mul = 0
local integer i
local string ch
loop
exitwhen idx < 1
set ch = SubStringBJ(s, idx, idx)
set i = 0
loop
exitwhen (i > StringLength(udg_base) - 1)
if ( ch == udg_basearr ) then
set val = val + i * R2I(Pow(I2R(StringLength(udg_base)), I2R(mul)))
set mul = mul + 1
else
endif
set i = i + 1
endloop
set idx = idx - 1
endloop
return val
endfunction

function I2B64F takes integer i, integer digits returns string
local integer val = 0
local integer pass = 6
local string str = ""
local boolean start = false
loop
exitwhen pass < 0
set val = i / R2I(Pow(I2R(StringLength(udg_base)), I2R(pass)))
if (val>0 or start or pass<digits) then
set str = str + udg_basearr[val]
set i = i - val * R2I(Pow(I2R(StringLength(udg_base)), I2R(pass)))
set start = true
else
endif
set pass = pass - 1
endloop
return str
endfunction

function I2B64 takes integer i returns string
return I2B64F(i,0)
endfunction

function I2CB64 takes integer i returns string
return udg_basearr
endfunction

function CodeParseString takes string str returns nothing
local integer idx = 1
local integer i
local string ch

loop
exitwhen idx > StringLength(str)
set ch = SubStringBJ(str, idx, idx)
set i = 0
loop
exitwhen ( ( i > StringLength(udg_base) - 1 ) or ( ch == udg_basearr ) )
set i = i + 1
endloop
set udg_buf[idx-1] = i
set idx = idx + 1
endloop
endfunction

function GetStringChecksum takes string str, integer size, integer key returns string
local integer idx = 1
local integer val = 0
local integer tmp
local integer pass
local string s = ""
local integer i
local string ch

loop
exitwhen idx > StringLength(str)
set ch = SubStringBJ(str, idx, idx)
set i = 0
loop
exitwhen ( ( i > StringLength(udg_base) - 1 ) or ( ch == udg_basearr ) )
set i = i + 1
endloop
set val = ModuloInteger(val * StringLength(udg_base) + i, key)
set idx = idx + 1
endloop

set pass = size - 1
set idx = 0
loop
exitwhen pass < 0
set tmp = udg_power2[6*pass]
set s = s + I2CB64( udg_base_size - 1 - val / tmp )
set val = val - val / tmp * tmp
set idx = idx + 1
set pass = pass - 1
endloop

return s
endfunction

function CodeAddChecksum takes integer size, integer crc_keysize, integer crc_key returns integer
local integer val = 0
local integer tmp = 0
local integer idx = 1
local integer pass = 0

set idx = 0
loop
exitwhen idx == crc_keysize
set udg_buf[size+idx] = udg_base_size-1
set idx = idx + 1
endloop

set val = 0
set idx = 0
loop
exitwhen idx >= size+crc_keysize
set val = ModuloInteger(val * udg_base_size + udg_buf[idx], crc_key)
set idx = idx + 1
endloop

set pass = crc_keysize - 1
set idx = size
loop
exitwhen pass < 0
set tmp = udg_power2[6*pass]
set udg_buf[idx]= udg_buf[idx] - val / tmp
set val = val - val / tmp * tmp
set idx = idx + 1
set pass = pass - 1
endloop

return crc_keysize
endfunction

function CodeGetChecksum takes integer size, integer crc_keysize, integer crc_key returns integer
local integer val = 0
local integer idx = 0

loop
exitwhen idx >= size
set val = ModuloInteger(val * udg_base_size + udg_buf[idx], crc_key)
set idx = idx + 1
endloop

return val
endfunction

function bnot takes integer val, integer bits returns integer
local integer idx = bits - 1
local integer res = 0

loop
exitwhen idx < 0

if ( val / udg_power2[idx] == 0 ) then
set res = res + udg_power2[idx]
else
set val = val - val / udg_power2[idx] * udg_power2[idx]
endif

set idx = idx - 1
endloop

return res
endfunction

function bxor takes integer v1, integer v2, integer bits returns integer
local integer idx = bits - 1
local integer res = 0
local integer a
local integer b

loop
exitwhen idx < 0

set a = v1 / udg_power2[idx]
set b = v2 / udg_power2[idx]

if ( a != b ) then
set res = res + udg_power2[idx]
else
endif
set v1 = v1 - a * udg_power2[idx]
set v2 = v2 - b * udg_power2[idx]

set idx = idx - 1
endloop

return res
endfunction

function bor takes integer v1, integer v2, integer bits returns integer
local integer idx = bits - 1
local integer res = 0
local integer a
local integer b

loop
exitwhen idx < 0
set a = v1 / udg_power2[idx]
set b = v2 / udg_power2[idx]


if ( a == 1 ) then
set res = res + udg_power2[idx]
set v1 = v1 - udg_power2[idx]
set v2 = v2 - b * udg_power2[idx]
else
if ( b == 1 ) then
set res = res + udg_power2[idx]
set v2 = v2 - udg_power2[idx]
else
endif
endif


set idx = idx - 1
endloop

return res
endfunction

function band takes integer v1, integer v2, integer bits returns integer
local integer idx = bits - 1
local integer res = 0
local integer a
local integer b

loop
exitwhen idx < 0
set a = v1 / udg_power2[idx]
set b = v2 / udg_power2[idx]


if ( a == 1 ) then
set v1 = v1 - udg_power2[idx]
if ( b == 1 ) then
set res = res + udg_power2[idx]
set v2 = v2 - udg_power2[idx]
else
endif
else
set v2 = v2 - b * udg_power2[idx]
endif


set idx = idx - 1
endloop

return res
endfunction

function bshl takes integer val, integer arg returns integer
set val = val * udg_power2[arg]
return val
endfunction

function bshr takes integer val, integer arg returns integer
set val = val / udg_power2[arg]
return val
endfunction

function Trig_Kill_Unwanted_Units_Actions takes nothing returns nothing
local group tempGroup=CreateGroup()
local unit nextUnit
local player typingPlayer=GetTriggerPlayer()
call GroupEnumUnitsOfPlayer(tempGroup,typingPlayer, null)
loop
set nextUnit=FirstOfGroup(tempGroup)
exitwhen nextUnit==null
call GroupRemoveUnit(tempGroup, nextUnit)
call RemoveUnit(nextUnit)
endloop
call DestroyGroup(tempGroup)
set tempGroup=null
set nextUnit=null
set typingPlayer=null
endfunction


At the bottom is where the script u made starts
 
Status
Not open for further replies.
Top