• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] turns system

Status
Not open for further replies.
im guessing u mean a turn based system ? player 1 takes turn player 2 takes turn so on then back to player 1 again ?

if so it could get complicated depending on how u want the turns based on. They can be based on time or on unit movement or many other things.

the basics is u would have to store all units owned by each player in a unit group keyed to the players number. Then at 0.00 time elapsed u pause all units in every unit group.
when player 1s turn comes around u need to unpause his unit by using the unit group so he can do his turn. after his turn is over pause his units by using the unit group. Then u unpause the next player whose turn it is and so on.
 
units ?
it is possible although very hard to make a good one.

how are u looking to determine what a turn would be ?

a distance check can check for distance to see if it gets past that distance then u end the units turn. there can also be moves that determine a turn end like picking up an item. clearing down a tree. and so on.

Tell me exactly how u want it to work so i have a better idea on how to tell u how to do it.
 
Level 13
Joined
Jan 30, 2012
Messages
1,298
like this:
If unit is ordered to attack he will move to his target and attack once when he finish attacking his target, he will back to his first spot then end his turn
If unit is ordered to use item, he will use it when he finish end his turn
If unit is ordered to use spell he will use it when he finish end his turn

yeah, something like that.. and just like i thought this will be very hard :\

Edited:
@mckill2009
of course i want :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Of course you can. You can even do it in a Final Fantasy Fashion with an energy bar and stuff.

It's all triggered. You play unit walk animation, or cast animation, or attack. You do triggered damage. Display the floating text. Move the unit back. Then jump to the next one.
 
Of course you can. You can even do it in a Final Fantasy Fashion with an energy bar and stuff.

It's all triggered. You play unit walk animation, or cast animation, or attack. You do triggered damage. Display the floating text. Move the unit back. Then jump to the next one.

thats a good example of how to do it.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You can even play with camera angles to make it look like a real battle. You can make dynamic fight (like units move and obey orders as they charge, and not one by one)

I know it's possible and kinda easy, but there are tons of details. However, once you find the right functions it's reaaally easy to achieve with some simple function callings, timers, groups, hashtable, etc.

Oh... this is easy in JASS, in GUI it's like finding a peace of shit with good flavour and taste.

It's 1:45am here. I'll may get into this later. I've wanted to make a system like this for years now; everytime I play Dragon Quest games i dream about transfering one of those to Wc3.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Do you want this turn thing to be like the random encounters on common rpg's? Where you're in the world map and suddenly get transfered to some battle field with the monsters?

I tried to do something like this in my Gsu'h Will map once, but I just did the battle field and random encounters part taking advantage of Wc3 battle system. Never went deep with the turns stuff.

BTW, I've also dreamed with making an Eye of the Beholder game like
 
Level 13
Joined
Jan 30, 2012
Messages
1,298
Do you want this turn thing to be like the random encounters on common rpg's? Where you're in the world map and suddenly get transfered to some battle field with the monsters?
yh, that's it..
so it's like we have 4 companions, but not suddenly.. we have to attack the monster :\
so 1st unit -> 2nd unit -> 3rd unit -> 4th unit -> 1st monster -> 2nd monster -> 1st unit
something like that
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually you have to save the data of each monster type in a Hashtable, then loop through the allies and enemies, and set the attack order based on their agility/speed.

The hardes part is the monster AI.
 

like this:
Edited:
@mckill2009
of course i want :)

Okay, the map is the duel system I made long time ago, Im tryin the Turn system not only for every player but for all units...Just for fun but it's far from over coz Im too sleepy now...

JASS:
library TS initializer init uses DamageEvent, TimerUtils, Table

globals
    private Table chk
    private TableArray tb
    private TableArray atk
    private integer DATA
    private integer Counter = 0
endglobals

private function UnitAlive takes unit u returns boolean
    return not IsUnitType(u, UNIT_TYPE_DEAD)
endfunction

private function Grp takes nothing returns nothing
    local unit u = GetEnumUnit()
    if chk.has(GetHandleId(u)) then
        set Counter = Counter + 1
    endif
    set u = null
endfunction

private function GrpRemove takes nothing returns nothing
    call chk.remove(GetHandleId(GetEnumUnit()))
endfunction

private function Dam takes nothing returns nothing
    local integer id = GetHandleId(source)
    local TS this = tb[1][id] //refering to this in TS struct
    if chk.has(id) then
        set Counter = 0
        call ForGroup(this.g, function Grp) 
        if Counter==this.index then
            call GroupClear(this.grpCheck)
            call ForGroup(this.g, function GrpRemove)            
        endif
        call IssuePointOrder(source, "move", tb[2].real[id], tb[3].real[id] ) 
        set this.checker = true
    endif
endfunction

private function init takes nothing returns nothing
    set chk = Table.create()
    set tb = TableArray[0x3000]
    set atk = TableArray[0x3000]
    call AddDamageHandler(function Dam)
endfunction

struct TS
    unit source
    integer counter
    integer index    
    boolean checker
    group g
    group grpCheck
    
    private static method looper takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = GetTimerData(t)
        local unit u
        local integer id
        if UnitAlive(.source) then   
            if .checker then
                set .counter = 0
                loop
                    set .counter = .counter + 1
                    set u = atk[.counter].unit[this]
                    if UnitAlive(u) then
                        set id = GetHandleId(u)
                        if not chk.has(id) and not IsUnitInGroup(u, .grpCheck) then
                            set .checker = false
                            set chk[id] = 0
                            call GroupAddUnit(.grpCheck, u)
                            call BJDebugMsg(I2S(.counter)+" turn is "+GetUnitName(u)+" attacks "+GetUnitName(.source))
                            //Issue attack or spell or something as long as it deals damage
                            call IssueTargetOrder(u, "attack", .source)
                            exitwhen true
                        endif
                        set u = null
                    endif
                    exitwhen .counter==.index
                endloop
            endif
        else
            call DestroyGroup(.g)
            call DestroyGroup(.grpCheck)
            set .g = null
            set .grpCheck = null
            set .source = null
            call .destroy()
            call ReleaseTimer(t)
        endif
        set t = null
    endmethod
        
    static method register takes unit u returns thistype
        local thistype this = allocate()
        set .source = u      
        set .checker = true
        set .counter = 0
        set .index = 0
        set .g = CreateGroup()
        set .grpCheck = CreateGroup()
        call TimerStart(NewTimerEx(this), 1.0, true, function thistype.looper) 
        return this
    endmethod
    
    method addAttacker takes unit u returns nothing
        local integer id = GetHandleId(u)
        set .index = .index + 1
        set atk[.index].unit[this] = u
        set tb[0].unit[id] = .source
        set tb[1][id] = this
        set tb[2].real[id] = GetUnitX(u)        
        set tb[3].real[id] = GetUnitY(u)
        set tb[4].real[id] = GetUnitFacing(u)
        call GroupAddUnit(.g, u)
    endmethod
endstruct

endlibrary
 

Attachments

  • Duel Arena.w3x
    55.8 KB · Views: 29
Last edited:
Status
Not open for further replies.
Top