wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 05-25-2010, 08:49 AM   #1
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default Trigger-based movement?

Hi
So, in some maps, units are not moving normally. For example: Warlock or Hungry Hungry Fellhounds. They start slow, but their speed increases as they go. Also, when they are ordered to go in the opposite direction, they don't turn right away, but slide a while in the direction they were going at first, because of momentum.
It's like they're on ice or some slick surface.

Do you know what I mean? I usually suck at explaining things, so if it's not clear, just tell and I'll try to specify.

So, how would I do something like that? You don't have to write the whole thing, it'll be enough if you just explain the basic logic behind it.
Thanks for any reply!
__________________
.

(lol, a hole in there, damn I fail :C )

Last edited by rednek : 05-25-2010 at 09:55 AM.
rednek is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 05-25-2010, 09:27 AM   #2
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

Sorry, grammar nazi intervention:

because of friction
should be:
because of momentum, as there is a lack of friction.

Are you looking for real code for this, or are you looking for a GUI workaround?
Bribe is offline   Reply With Quote
Old 05-25-2010, 10:00 AM   #3
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default

Grammar fixed~

The real code is allright with me, if you can post it that is :)

But it should be enough if you just explain the system it works on, and I'll code it myself :D
__________________
.

(lol, a hole in there, damn I fail :C )
rednek is offline   Reply With Quote
Old 05-25-2010, 11:10 AM   #4
TheKid
User
 
TheKid's Avatar
 
Join Date: Mar 2009
Posts: 195

TheKid will become famous soon enough (37)TheKid will become famous soon enough (37)

Default

If they change directions suddenly do they still slide?
__________________
TheKid is offline   Reply With Quote
Old 05-25-2010, 11:10 AM
TheKid
This message has been deleted by TheKid.
Old 05-25-2010, 11:22 AM   #5
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default

Yes, that's the point :P
__________________
.

(lol, a hole in there, damn I fail :C )

Last edited by rednek : 05-25-2010 at 11:22 AM.
rednek is offline   Reply With Quote
Old 05-25-2010, 05:31 PM   #6
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

Collapse JASS:
scope Momentum initializer Init
    
globals
    group Group=CreateGroup()
    hashtable hash=InitHashtable()
    unit EnumUnit
endglobals
    
    private function SlipLoop takes nothing returns nothing
        local string Order
        local integer id
        local integer i
        local real f
        
        set EnumUnit=GetEnumUnit()
        set Order=OrderId2String(GetUnitCurrentOrder(EnumUnit))
        set id=GetHandleId(EnumUnit)
        set i=LoadInteger(hash,id,0)+1
        call SaveInteger(hash,id,0,i)
        
        if Order!="attack" and Order!="stop" and Order!="holdposition" then
            call SaveReal(hash,id,i*2,GetUnitFacing(EnumUnit)*bj_DEGTORAD)
            call SaveBoolean(hash,id,i*2+1,true)
        else
            call SaveBoolean(hash,id,i*2+1,false)
        endif
        
        if i>40 and LoadBoolean(hash,id,(i-40)*2) then
            set f=LoadReal(hash,id,(i-40)*2)
            
            call SetUnitX(EnumUnit,GetWidgetX(EnumUnit)+5*Cos(f))
            call SetUnitY(EnumUnit,GetWidgetY(EnumUnit)+5*Sin(f))
        endif
        call RemoveSavedReal(hash,id,(i-40)*2)
        call RemoveSavedBoolean(hash,id,(i-40)*2+1)
    endfunction
    
    private function SlipEnum takes nothing returns nothing
        call ForGroup(Group,function SlipLoop)
    endfunction
    
    private function Add2 takes nothing returns nothing
        if not IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) then
            call GroupAddUnit(Group,GetFilterUnit())
        endif
    endfunction
    private function Add takes nothing returns nothing
        if not IsUnitType(GetTriggerUnit(),UNIT_TYPE_STRUCTURE) then
            call GroupAddUnit(Group,GetTriggerUnit())
        endif
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t=CreateTrigger()
        call GroupEnumUnitsInRect(Group,bj_mapInitialPlayableArea,Filter(function Add2))
        call TimerStart(CreateTimer(),0.035,true,function SlipEnum)
        
        call TriggerRegisterEnterRectSimple(t,bj_mapInitialPlayableArea)
        call TriggerAddCondition(t,Condition(function Add))
    endfunction
    
endscope

Last edited by Bribe : 05-25-2010 at 05:32 PM.
Bribe is offline   Reply With Quote
Old 05-25-2010, 06:57 PM   #7
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default

Thanks! That's a little more than I hoped for : D

I still don't get some parts of it though
Collapse JASS:
call SetUnitX(EnumUnit,GetWidgetX(EnumUnit)+5*Cos(f))
__________________
.

(lol, a hole in there, damn I fail :C )
rednek is offline   Reply With Quote
Old 05-25-2010, 07:10 PM   #8
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

That sets the x-coordinate of the unit (to slide it) and the one below it sets the y-coordinate. The math is polar projection math, and the unit slides in the direction it was facing 1.5 seconds prior.
Bribe is offline   Reply With Quote
Old 05-25-2010, 10:21 PM   #9
0zyx0
Perfectionist noob
 
0zyx0's Avatar
 
Join Date: Mar 2009
Posts: 255

0zyx0 will become famous soon enough (38)0zyx0 will become famous soon enough (38)

Default

I believe a vector-based approach would be better for this, because of versatility, realism, and speed. Just store a velocity vector for each unit, and have an acceleration depending on the user's input. At least that's how I would have done it. And the relatively slow hashtable calls could be replaced by array + unit indexing. That is, if speed is an issue.
__________________
My new signature - Now easier to understand than ever!
0zyx0 is offline   Reply With Quote
Old 05-25-2010, 11:54 PM   #10
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default

Shouldn't be a problem, since I only have like 6 units moving on the map.

Anyway, I've got a different problem!
Now that the units are moving like this, they can't use any abilities! It's because they need some time to cast them, and their cast is disrupted when I change their location.

They fixed this in Warlock somehow, does anyone know how?
Also, should I create a new thread? :D

edit: nah, since I asked already... Or dunno, I'll create a new thread if I wont get answered in this one :S
__________________
.

(lol, a hole in there, damn I fail :C )

Last edited by rednek : 05-25-2010 at 11:56 PM.
rednek is offline   Reply With Quote
Old 05-26-2010, 04:50 AM   #11
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

SetUnitX and SetUnitY shouldn't disrupt channeling spells; that's only SetUnitPosition that does that I thought??
Bribe is offline   Reply With Quote
Old 05-26-2010, 08:01 AM   #12
TheKid
User
 
TheKid's Avatar
 
Join Date: Mar 2009
Posts: 195

TheKid will become famous soon enough (37)TheKid will become famous soon enough (37)

Default

That is correct.
__________________
TheKid is offline   Reply With Quote
Old 05-26-2010, 09:06 AM   #13
rednek
",:..:,"
 
rednek's Avatar
 
Join Date: May 2006
Posts: 236

Submissions (11)

rednek will become famous soon enough (61)rednek will become famous soon enough (61)rednek will become famous soon enough (61)

Default

Tested - Hmmm, it really does not.
Damn, must be something different

edit: fixed - it was facing angle... -.-
__________________
.

(lol, a hole in there, damn I fail :C )

Last edited by rednek : 05-26-2010 at 10:01 AM.
rednek is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:42 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services