HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Range Increase/Decrease using WEU mid game

01-31-2006, 12:52 AM#1
Keyser_Salsa
Hi, so i'm making a map where each unit comes with a few "guns" in their inventory. Selecting one of these items will "equip" the weapon. So for example, a sniper comes with a shotgun and sniper rifle in their inventory. A shotgun's range is say 400 and the rifle is 800. A player's current weapon is stored as a string value in the variable curWeapon array. I've set it up so in the instance a new weapon is selected the trigger uses advanced upgrades to decrease the unit's range depending on that player's curWeapon value. The trigger then "equips" the new weapon by increasing the units range to the new value and such using advanced triggers.

So here's the problem... I optimize everything and boot up the map. Get my unit which has a base range of 0, i select the shotgun and range is increased to 400, everything works as it should. The problem is when i try to switch to another weapon it's as if the trigger never executes the decrease range action, it just keeps iexecuting the increase range action. So if i had a shotgun (range 400) equiped and tried to switch to my rifle it changes my range to 1200, not 800. Now i know my conditioinal in the if-then is correct, and the actions decrease range actions should run... It may be something with the upgrade sets that i just don't get (like why are there 2 sets for each race that do the same thing?) but there is no documentation i can find on the matter. Here's the code from my map that illustrates switching to shotgun from a "nail gun."

Any help is appreciated, thanks.



Code:
function Trig_SBS_Copy_Conditions takes nothing returns boolean
    if ( not ( GetItemTypeId(GetManipulatedItem()) == 'I001' ) ) then
        return false
    endif
    return true
endfunction

function Trig_SBS_Copy_Func003001 takes nothing returns boolean
    return ( udg_weaponArray[udg_curPlayer] == "sbs" )
endfunction

function Trig_SBS_Copy_Func005C takes nothing returns boolean
    if ( not ( udg_weaponArray[udg_curPlayer] == "nail_gun" ) ) then
        return false
    endif
    return true
endfunction

function Trig_SBS_Copy_Actions takes nothing returns nothing
    call SetItemCharges( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I001'), ( GetItemCharges(GetItemOfTypeFromUnitBJ(GetTriggerUnit(), 'I001')) + 1 ) )
    set udg_curPlayer = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
    if ( Trig_SBS_Copy_Func003001() ) then
        return
    else
        call DoNothing(  )
    endif
    call UnitAddAbilityBJ( 'A000', GetTriggerUnit() )
    if ( Trig_SBS_Copy_Func005C() ) then
        call UnitRemoveAbilityBJ( 'A002', GetTriggerUnit() )
        call ChangeDamage( GetTriggerUnit(), false, 1 )
        call ChangeRange( GetOwningPlayer(GetTriggerUnit()), false, 6, 500 )
        call ChangeAttackRate( GetOwningPlayer(GetTriggerUnit()), false, 6, 0.10 )
    else
    endif
    call TriggerSleepAction( 0.10 )
    call ChangeDamage( GetTriggerUnit(), true, 1 )
    call ChangeRange( GetOwningPlayer(GetTriggerUnit()), true, 0, 500 )
    call ChangeAttackRate( GetOwningPlayer(GetTriggerUnit()), true, 0, 1.00 )
    set udg_weaponArray[udg_curPlayer] = "sbs"
endfunction

//===========================================================================
function InitTrig_SBS_Copy takes nothing returns nothing
    set gg_trg_SBS_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SBS_Copy, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( gg_trg_SBS_Copy, Condition( function Trig_SBS_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_SBS_Copy, function Trig_SBS_Copy_Actions )
endfunction
01-31-2006, 01:51 AM#2
Vexorian
Why did you post the trigger as image instead of just using the "Copy as text" option and then [trigger] tags?

And why did you convert the same trigger to JASS and posted it too?
01-31-2006, 02:02 AM#3
Keyser_Salsa
1. first post, didn't know
2. thought it would help

does it really matter..
01-31-2006, 02:14 AM#4
PCPharaoh
1. Don't use WEU. It just confuses things.
2.
Trigger:
Unit - Set (Picked unit) acquisition range to ((Current acquisition range of (Triggering unit)) + 400.00)
should work. Give the unit a 999999 range, and then set acquisition range to ...
01-31-2006, 02:37 AM#5
BBDino
Does that even actually work?
01-31-2006, 02:45 AM#6
Keyser_Salsa
nah, changing the acquisition range with a max range doesn't work , anyone know why what i was doing originally isn't working??
01-31-2006, 05:45 AM#7
Extrarius
How come the inside of the if statement refers to "Undead Upgrade Set 2" and then after the if statement you refer to "Human Upgrade Set 1"?
01-31-2006, 07:34 AM#8
Anitarf
This thing uses upgrades? Isn't it so upgrades can't be unlearned?
01-31-2006, 08:22 AM#9
Keyser_Salsa
ok so basically all i want to do is increase and decrease range in some cases mid game, is it hard coded so that the range attribute can't be modified mid game or what..

Extrarius: i got bored and just started messing around, then posted here
01-31-2006, 12:52 PM#10
Jacek
Well, for sure it can be modified using Long Rifles and Improved Bows upgrade. I never use WEU triggers, they just make map unopenable by normal WE.
01-31-2006, 12:59 PM#11
Azazel_
One inefficient but working way to reduce your range would be a trigger as follows :

Event - A unit is attacked
Condition - Attacking Unit equals to (MyUnit)

Actions
If ( (range reduction active) and (distance between attacking unit and attacked unit > (range threshold of reduced range) ) then
- call IssueImmediateOrder( MyUnit, "stop" )
endif

========================================

This does what you want and can be written under 2 minutes. However, it is process heavy and produces weird behavior if the unit is in between the attacker's acquisition range and short range threshold (it will just stand there). A better solution would be the Orc - Chaos Orc ability that switches unit type.
01-31-2006, 01:08 PM#12
Jacek
That wouldn't work. If you order to attack enemy who is far away, using your trigger: your unit will come into range (unit range) try to attack, but stop. So right-clicking and ordering attack would be strange, you will have to manually enter the attack range.