Monday, 2024-05-20, 3:57 AM


Main
Registration
Login
Welcome Guest | RSS  
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 2 of 2
  • «
  • 1
  • 2
Forum moderator: JonNny, Hanky  
Clan NgO Forums » Discussions » Flood Dimension » Question to the teacher. :) (Some questions)
Question to the teacher. :)
Darkt3mpl3rDate: Sunday, 2008-12-21, 5:27 PM | Message # 16
Sergeant
Group: Administrators
Messages: 35
Reputation: 4
Status: Offline
I can. send me the code you already done and I'll fix it.

 
TheCheeseLoverDate: Friday, 2009-01-16, 11:06 PM | Message # 17
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
function TestMe takes real x0, real y0, real radius, real angle, real scale, real z, real delay, real duration, string modelName returns integer
return 30
endfunction

unction Trig_explosion_Actions takes nothing returns nothing
local string s = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
call TestMe(0, 0, 100, 10, 10, 100, 0.01, 1, s)
endfunction

Added (2009-01-11, 3:28 Am)
---------------------------------------------
Hi!

I ''debuged''! Check my new code:

function cheese takes unit u ,real z returns nothing
call UnitAddAbilityBJ( 'Amrf', u )
call SetUnitFlyHeightBJ( u, z, 200.00 )
endfunction

function thunder takes unit u, string s returns nothing
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
call AddSpecialEffectTargetUnitBJ( "origin", u, s )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call TriggerSleepAction( 0.50 )
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction

function Trig_explosion_Actions takes nothing returns nothing
local string s = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
local unit u = GetTriggerUnit()
call cheese( u, 1000 )
call thunder( u, s)
endfunction

And can you teach me how to use timer please?

Thanks!

Added (2009-01-16, 11:06 Pm)
---------------------------------------------
Can you answer to my questions please?


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Sunday, 2009-01-11, 3:29 AM
 
Darkt3mpl3rDate: Saturday, 2009-01-17, 9:22 PM | Message # 18
Sergeant
Group: Administrators
Messages: 35
Reputation: 4
Status: Offline
Well sure I can help you understanding the usage of timers.

Read through this tutorial, which includes all your needs.

If you still have any questions reply in this thread.


 
TheCheeseLoverDate: Saturday, 2009-01-17, 11:41 PM | Message # 19
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Thanks for the tutorial.

I just read the top and I will read the bottom later. But I have a question: I saw the first comment and it's was writted:

''Timers shouldn't be destroyed but recycled, really. It saves us of all the esoteric things about when to set timers to null.''

Does this mean I should always recycle it ( set t = null ) or I can destroy it ( call DestroyTimer(t) )?

Added (2009-01-17, 11:26 Pm)
---------------------------------------------
OMG!

I have no JASS error. BUT! when the timer is done, I have an acces violation ( that is the name in french ).

I think in english it's violation acces something like that. And I don't know why I have this stupid thing ( that close my wc3 ).

Can you help me? There is my code:

function cheese takes unit u ,real z returns nothing
call UnitAddAbilityBJ( 'Amrf', u )
call SetUnitFlyHeightBJ( u, z, 200.00 )
endfunction

function thunder takes unit u, string s returns nothing
local timer t = GetExpiredTimer()
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
call AddSpecialEffectTargetUnitBJ( "origin", u, s )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
call TriggerSleepAction( 0.50 )
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call DestroyTimer( t)
set t = null
endfunction

function Trig_explosion_Actions takes nothing returns nothing
local string s = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
local unit u = GetTriggerUnit()
local timer t = CreateTimer()
call TimerStart( t, 0.50, FALSE, function thunder)
call cheese( u, 1000 )

set t = null
endfunction

Added (2009-01-17, 11:41 Pm)
---------------------------------------------
Woot. Sorry for the triple post, but I started a new trigger and i had no error with the timer. So question 2 is done.


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Saturday, 2009-01-17, 10:56 PM
 
FireeyeDate: Sunday, 2009-01-18, 3:19 PM | Message # 20
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
The main problem with timers are, that you can not use the 'takes' keyword for the target function therefore a callback always takes nothing and returns nothing. (This is the reason why you get that crash)
Therefore you most likely need globals.
I rewrote your functions to work proper (at least they should, long time since i switched to vJASS).
You need 5 globals variables, you can create them with the variable Editor of Blizzard.
They need the following options:
type / [options] / name
unit array TargetUnit
string array TargetEffect
integer array CurrentCycle
integer CurrentSlot
timer CallbackTimer

The script i wrote looks like this:

Code
function cheese takes unit u ,real z returns nothing
     call UnitAddAbility(u,'Amrf')
     call SetUnitFlyHeight( u, z, 200.00 )
     call UnitRemoveAbility(u,'Amrf')
endfunction

function thunder_callback takes nothing returns nothing
     local integer i = 0
     //looping through all global values
     loop
         exitwhen i >= udg_CurrentSlot
         //Creating + Destroy the wanted effect on unit x
         call DestroyEffect(AddSpecialEffectTarget(udg_TargetEffect[i],udg_TargetUnit[i],"origin"))
         //Checking for max cycle limit of each array slot
         if udg_CurrentCycle[i] >= 10 then
             //If hit switching it with newer array slot and reducing the max slot by 1 (overwritting old values)
             set udg_CurrentSlot = udg_CurrentSlot - 1
             set udg_TargetUnit[i] = udg_TargetUnit[udg_CurrentSlot]
             set udg_TargetEffect[i] = udg_TargetEffect[udg_CurrentSlot]
             set udg_CurrentCycle[i] = udg_CurrentCycle[udg_CurrentSlot]
         else
             //If the array slot got at least 1 cycle left, increasing it's Cycle Counter by 1 and going to the next array slot
             set udg_CurrentCycle[i] = udg_CurrentCycle[i] + 1
             set i = i + 1             
         endif
     endloop
     //Checking for array slots ammount
     if udg_CurrentSlot == 0 then
         //When there are no slots available, stop timer from running again
         call PauseTimer(udg_CallbackTimer)
     endif
endfunction

function thunder takes unit u, string s returns nothing
     //Assigning values to globals variables for callback
     set udg_TargetUnit[udg_CurrentSlot] = u
     set udg_TargetEffect[udg_CurrentSlot] = s
     set udg_CurrentCycle[udg_CurrentSlot] = 1
     //Your other function
     call cheese(u,1000)
     //Increasing global integer for next free array slot
     set udg_CurrentSlot = udg_CurrentSlot + 1
     //Your other function
     call cheese(u,1000)
function Trig_NewTrigger_Conditions takes nothing returns boolean
      
     return  
endfunction

function Trig_NewTrigger_Actions takes nothing returns nothing
      
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_NewTrigger takes nothing returns nothing
     set gg_trg_NewTrigger = CreateTrigger()
     //call TriggerRegister__(gg_trg_NewTrigger, )
     call TriggerAddCondition(gg_trg_NewTrigger, Condition(function Trig_NewTrigger_Conditions))
     call TriggerAddAction(gg_trg_NewTrigger, function Trig_NewTrigger_Actions)
endfunction

     //Checking if assigned value is first in row
     if udg_CurrentSlot == 1 then
         //If so, starting Callback
         call TimerStart(udg_CallbackTimer,.5,true,function thunder_callback)
     endif
endfunction

function ExampleUsage takes nothing returns nothing
     //Passing arguments to creation function
     call thunder(GetTriggerUnit(),"Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl")
endfunction

I'll give a more detailed explanation when i got time.


 
TheCheeseLoverDate: Tuesday, 2009-02-03, 1:55 AM | Message # 21
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Question 1: Can we call more than 2 times a function? biggrin thats all.

Yay I have a signature. You suck. :D
 
FireeyeDate: Tuesday, 2009-02-03, 2:01 AM | Message # 22
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
You can call a function as often as you want to, as long as the function is above the function calling it.
Or hitting the OP Limit, but the OP Limit is something you won't hit unless you write some insane long functions.




Message edited by Fireeye - Tuesday, 2009-02-03, 2:02 AM
 
TheCheeseLoverDate: Friday, 2009-02-06, 4:33 AM | Message # 23
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Can you tell me the better thing for make a spell MUI and can you tell me how use it please?

Yay I have a signature. You suck. :D
 
Clan NgO Forums » Discussions » Flood Dimension » Question to the teacher. :) (Some questions)
  • Page 2 of 2
  • «
  • 1
  • 2
Search:

Clan NgO © 2024Powered by uCoz