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

[JASS] Fake Units imitat Ulti (Help)

Status
Not open for further replies.
Level 8
Joined
Mar 23, 2007
Messages
302
Hi, i did a Jassed spell for a Unit (Hero:Sniper).It is a Combination with another one. Spell: create a Illusion (in this case its the standart Human Priest ('hmpr')).
This one is fine. The ultimate is the problem. I worked with JassCraft if its important to know.
What is the ultimate supposed to do?
it has a casting time of 3 seconds and deals 999999.00 dmg (simply kills).
when the Sniper uses the Ultimate the Priests should act like him.
they should wait the same time, reveal like the sniper for the attacked enemy and then play the animation like the sniper does.

JASS:
function Trig_Imitate_Ultimate_Conditions takes nothing returns boolean
 return (GetUnitTypeId(GetSpellAbilityUnit()) == 'H00C' and GetSpellAbilityId() == 'A023')
endfunction

function Trig_Imitate_Ultimate_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local player Tp = GetOwningPlayer(target)
local location Ploc = GetUnitLoc(GetEnumUnit())
local location Cloc = GetUnitLoc(caster)
local group myGroup = GetUnitsInRectAll(GetPlayableMapRect())
local group g = CreateGroup()
local unit fake
local fogmodifier fog
local real R = 512            
local integer Type = 'hmpr'                 
    call GroupAddGroup(myGroup, g)
loop
    set fake = FirstOfGroup(g)
    exitwhen fake == null
    if ( GetUnitTypeId(fake) == Type ) then
        call PauseUnit(  fake,true)
        call SetUnitFacingToFaceUnitTimed( fake, target, 0 )
        call CreateFogModifierRadiusLoc(  Tp , FOG_OF_WAR_VISIBLE, Ploc, R,true,true )
        set fog = GetLastCreatedFogModifier()                                          
        call TriggerSleepAction( 3.00 )
        call SetUnitAnimation( fake, "attack" )
        call TriggerSleepAction( 1.00 )
        call PauseUnit(  fake,false )
        call DestroyFogModifier( fog )
    endif
    call GroupRemoveUnit(g, fake)
endloop
    call DestroyGroup(g)
    call CreateFogModifierRadiusLoc(  Tp , FOG_OF_WAR_VISIBLE, Cloc, R,true,true )
 set fog = GetLastCreatedFogModifier()
    call TriggerSleepAction( 4.00 )
    call DestroyFogModifier( fog )
endfunction

i just cant find the wrong part y.y.
and yes i will remove the leaks as far as i got this work.
thx for the Help.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
When using CreateFogModifierLoc you cannot retrieve the modifier via GetLastCreatedFogModifier, because it is a native and it doesn't store the modifier in bj_lastCreatedFogModifier variable (which GetLastCreatedFogModifier returns, btw). Why don't you just do this:

set fog = CreateFogModifierRadiusLoc(...)?

It saves you a bit of space and it actually works (which is important, afaik :p).

Now, here we have a problem:

local location Ploc = GetUnitLoc(GetEnumUnit())

GetEnumUnit?? Don't you mean target or something? GetEnumUnit will return null in this case, because no unit is "picked".

Where do you damage the unit?

There's a 4 second wait after each loop, I hope you're aware of that.

Where's the problem anyways? What seems to go wrong?
 
Level 8
Joined
Mar 23, 2007
Messages
302
Thx for pointing out this wrong parts, i fixed them instantly.
But does this Kind of "picking every unit" prevent me from using Waits?
cuz then i would remove the casting time.

The Damage is in the Spell in the Object editor.
lets see i will try it out without Waits.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
What did you want with that GetEnumUnit (Picked Unit, in GUI)? I want to help you, but I don't know what exactly do you want.

But does this Kind of "picking every unit" prevent me from using Waits?

No no, ForGroup prevents you from using waits. If you want to wait 3 seconds (or whatever you want) and then do an action on all units in group, than you should add the wait before the loop, and then loop through the group (with no waits). Otherwise it will do an action to a unit from the group, wait 4 seconds, do the same thing to the next unit, wait 4 seconds and so on.
 
Level 8
Joined
Mar 23, 2007
Messages
302
Ok i reworked the whole thing, hope you understand it no better.

JASS:
globals
 unit udg_target
endglobals
_
function Trig_Imitate_Ultimate_Conditions takes nothing returns boolean
 return (GetUnitTypeId(GetSpellAbilityUnit()) == 'H00C' and GetSpellAbilityId() == 'A023')
endfunction
_
function DoUnit takes nothing returns nothing 
local unit fake=GetEnumUnit() 
local unit target = udg_target
call PauseUnit( fake,true )
call SetUnitFacingToFaceUnitTimed( fake, target, 0 )
call PolledWait( 3.00 ) 
call SetUnitAnimation( fake, "attack" ) 
call PauseUnit( fake,false ) 
set fake= null   
set target = null            
endfunction
_
function CheckUnit takes nothing returns boolean
 return GetUnitTypeId(GetEnumUnit()) == 'hmpr'
endfunction                                                                    
_
function DoUnit2 takes nothing returns nothing
 call ExecuteFunc("DoUnit")
endfunction   
_
function Trig_Immitate_Ultimate_Actions takes nothing returns nothing
    set udg_target = GetSpellTargetUnit()
    call ForGroup(GetUnitsInRectMatching(GetPlayableMapRect(),Condition(function CheckUnit)),function DoUnit2) 
endfunction
_
//===========================================================================
_
function InitTrig_Immitate_Ultimate takes nothing returns nothing
    set gg_trg_Immitate_Ultimate = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Immitate_Ultimate, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Immitate_Ultimate, Condition( function Trig_Imitate_Ultimate_Conditions ) )
    call TriggerAddAction( gg_trg_Immitate_Ultimate, function Trig_Immitate_Ultimate_Actions )
endfunction

this whole trigger seems to be fine when i check it in JassCraft, but when i import it into the map, hounderts of errors appears.
like: somthing is expecte but not needed oO.

the _ are only cosmetics for better look

the more strange thing is that in the same time when i save my map
it shows some errors BUT it shows me that everything is fine and no errors found ... oO
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Your globals block can cause errors, if you don't have Jass NewGen Pack.

I don't know what had caused so much errors, you probably did something stupid, like import the code in a wrong trigger, or in a trigger that is not named Immitate Ultimate. The reason I think that has happened is that your trigger's substring is "Immitate" (with double m), but your actions/conditions function's substring is "Imitate" (with single m).

Why don't you just loop through a group if you want waits, instead of using slow ExecuteFunc function.

Btw, I don't know why _ makes the code look better, it's just confusing :)
 
Level 8
Joined
Mar 23, 2007
Messages
302
ok i fixed the mm m problem , and deleted the globals (i created it with variable editor) and it works now fine... this is strange i have WE NewGen that one from Vexorian, so how to create globals then within a trigger?

it is for sure now that the globals cause this error. i just dont know why.

for the _ i want the functions to have a empty line in between and this does not work with simple <space>.

THX Silvenon i have no longer the problems with the JassChecker.

EDIT: nothing happens oO...
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
If you have Jass NewGen Pack from Vexorian, then you can create globals like that and there shouldn't be any errors in it. If you have NewGen, but it still returns the error there, then maybe you have cracked wc3.

for the _ i want the functions to have a empty line in between and this does not work with simple <space>.

I still don't get this one. Can't you just leave a normal empty line between them? Or if you want to separate them so much, you can make something like this:

JASS:
function Func1 takes nothing returns nothing
endfunction
//=========================================
function Func2 takes nothing returns nothing
endfunction


That's how blizzard does it and it returns no error, unlike _.

It does nothing??

Try checking if you did some mistake in the condition:

JASS:
function Trig_Imitate_Ultimate_Conditions takes nothing returns boolean
    return (GetUnitTypeId(GetSpellAbilityUnit()) == 'H00C' and GetSpellAbilityId() == 'A023')
endfunction


Try putting a call BJDebugMsg("msg") in the actions function to check if the trigger even runs.

Are you sure 'hmpr' is the right rawcode?

I'm not sure if SetUnitFacingToFaceUnitTimed function even works, there are some issues with turning the units, it apparently doesn't work for some lame bug.

Those would be all the possibilities why nothing is happening.

Btw, you're using a global, that means the spell's not MUI, I hope you're aware of that.
 
Level 8
Joined
Mar 23, 2007
Messages
302
ok i reCreated the whole thing again and this time it worked.
all the Human priests Turned to the target and played their animation.
and the target died... (after a mysterious time, it looks strange but it works).
so here is the new Code:
JASS:
function Trig_Sniper_attack_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A01Z' and GetUnitTypeId(GetTriggerUnit()) == 'H00C'
endfunction

function UnitFilter takes nothing returns boolean
return (GetUnitTypeId(GetEnumUnit()) == 'hmpr') and ( IsUnitIllusion(GetTriggerUnit()) == true )
endfunction

function WaitNFace takes nothing returns nothing
    if ( UnitFilter() ) then
        call SetUnitMoveSpeed( GetEnumUnit(), 0.00 )
        call SetUnitFacingToFaceUnitTimed( GetEnumUnit(), GetSpellTargetUnit() , 0 )
    endif
endfunction

function Anima takes nothing returns nothing
   if ( UnitFilter() ) then
        call SetUnitAnimation( GetEnumUnit(), "Spell Attack" )
    endif
endfunction

function Reset takes nothing returns nothing
    if ( UnitFilter() ) then
        call ResetUnitAnimation( GetEnumUnit() )
        call SetUnitMoveSpeed( GetEnumUnit(), GetUnitDefaultMoveSpeed(GetEnumUnit()) )
    endif
endfunction

function Trig_Sniper_attack_Actions takes nothing returns nothing
local unit S = GetTriggerUnit()
local unit T = GetSpellTargetUnit()
    call SetUnitMoveSpeed(S, 0.00 )
    call SetUnitFacingToFaceUnitTimed( S, T, 0 )
    call ForGroup( GetUnitsInRectAll(GetPlayableMapRect()) , function WaitNFace )
    call TriggerSleepAction( 2 )
    call ForGroup( GetUnitsInRectAll(GetPlayableMapRect()) , function Anima )
    call SetUnitAnimation( S, "Attack" )
    call TriggerSleepAction( 0.86 )
    call KillUnit( T )
    call ResetUnitAnimation( T )
    call ResetUnitAnimation( S )
    call SetUnitMoveSpeed( S, GetUnitDefaultMoveSpeed(S) )
    call ForGroup( GetUnitsInRectAll(GetPlayableMapRect()) , function Reset )
set S = null
set T = null   
endfunction

And now the Illusion creating spell.

JASS:
function Trig_Create_Copy_Snipeee_Actions takes nothing returns nothing
local player P = GetOwningPlayer(GetSpellAbilityUnit())
local location L = GetUnitLoc(GetSpellAbilityUnit())
local unit U
local item I
local unit C = GetTriggerUnit()
if ( GetSpellAbilityId() == 'A022') then
    call CreateNUnitsAtLoc( 1, 'h011', P , L , 0 )
set U = GetLastCreatedUnit()
    call UnitApplyTimedLife(U,'BTLF',1)
    call UnitAddAbility( U ,'A00G')
    call UnitAddItemByIdSwapped( 'I01T', U )
set I = GetLastCreatedItem()
    call UnitUseItemTarget( U, I, C )
endif
set P = null
call RemoveLocation(L)
set L = null
endfunction

I hope u could help me to link that 2 triggers, so that the Imitation only affects Illusions of the Owning player of the sniper. And that the Illusion-creating-spell create some illusions.... all what happens when i trigger the illusion creating is that it says "no place for the unit".
I wonder if you could help me improving this trigger, cuz i tried it with Grouping the units but it doesnt worked.

i should do a Demo map and send it to u?

and NO i dont have a cracked WC3 nor a cracked WE :zip:
 
Status
Not open for further replies.
Top