Monday, 2024-05-20, 1:20 AM


Main
Registration
Login
Welcome Guest | RSS  
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 3
  • 1
  • 2
  • 3
  • »
Forum moderator: JonNny, Hanky  
Clan NgO Forums » Discussions » Flood Dimension » Little problem.
Little problem.
TheCheeseLoverDate: Saturday, 2009-02-14, 3:34 AM | Message # 1
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
HI! smile

I have a little problem (NO!!! you are serious!). First: I have JassNewGenPack. When I am making globals and struck or I am importing glabals and struck, I can't test my map. Exemple: I go in warcraft, I go in 1 player and I click on my map. When I am doing the same thing like my exemple, warcraft try to start it but it come back at the same place than before.

Can you help me please??? sad

Added (2009-02-14, 3:34 Am)
---------------------------------------------
NVM!!!

Yay I found how to test it correctly. And Fireeye, you made an error when you tryed to help me in the thread: ??? text macro ???.

Code
library WhatEverSpell initializer Init    
        struct WhatEverStruct    
            //all struct variables    
        endstruct    

        globals    
            //Struct array for storage    
            private WhatEverStruct array GlobalStruct    
            //Integer for max used Array slot    
            private integer struct_init = 0    
            //Callback Timer    
            private timer CallbackTimer = CreateTimer()    
        endglobals    

        private function Callback takes nothing returns nothing    
            local WhatEverStruct dat    
            local integer i = 0    
            //Looping through all structs    
            loop    
                exitwhen i == struct_init    
                //Setting global struct to local for preventing OP Limit Hit    
                set dat = GlobalStruct[i]    
                if DestroyStruct then    
                    //Destroying struct if wanted    
                    call dat.destroy()    
                    //Decreasing max slot and switch structs    
                    set struct_init = struct_init - 1    
                    set GlobalStruct[i] = GlobalStruct[struct_init]    
                else    
                    //Checking for next struct    
                    set i = i + 1    
                endif    
            endloop    
            if struct_init == 0 then    
                call PauseTimer(CallbackTimer)    
            endif    
        endfunction    

        private function OnCast takes nothing returns nothing    
            local WhatEverStruct dat = WhatEverStruct.create()    
            //Spell Code    
            //or whatever    
            //Saving struct to global + increasing max slot    
            set GlobalStruct[struct_init] = dat    
            set struct_init = struct_init + 1    
            if struct_init == 1 then    
                call TimerStart(CallbackTimer,.03,true,function Callback)    
            endif    
        endfunction    

        private function Init takes nothing returns nothing    
            //Whatever init function    
        endfunction    
endlibrary

The error: if DestroyStruct then

PS: I don't know what is wrong but the JAssNewGenPack said its was that.

Question 2: What is the OP limit?


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Saturday, 2009-02-14, 3:41 AM
 
FireeyeDate: Saturday, 2009-02-14, 3:06 PM | Message # 2
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
if DestroyStruct then means the same as
if (Some Boolean == true) then
I just wanted to express that you'll need a boolean condition to declare when a struct should get destroyed.
2: The OP Limit is also called Operation Limit. Every action in wc3 takes a specific amount of operations (don't know how to express it better so i'll stay with operations), however due to the limit of operations of every wc3 thread it can happen that VERY long scripts get aborted due to that limit.
But you can by-pass the limit to a certain amount with the help of ExecuteFunc(), however it's nothing you have to be aware of unless you're trying to write some insane encryption scripts, etc.




Message edited by Fireeye - Saturday, 2009-02-14, 3:07 PM
 
TheCheeseLoverDate: Saturday, 2009-02-14, 5:26 PM | Message # 3
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Thanks.

But why do I get an error when I save? ( If DestroyStruct )

Error information: Line 73: Undeclared variable to DestroyStruct


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Saturday, 2009-02-14, 5:29 PM
 
FireeyeDate: Saturday, 2009-02-14, 6:57 PM | Message # 4
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
Because there's no boolean variable called DestroyStruct, it's a replacement for the condition you want at the moment when the struct should be destroyed.

 
TheCheeseLoverDate: Saturday, 2009-02-14, 8:47 PM | Message # 5
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Thanks!!!

Question 3: Do I need to insert the private struct trigger in my spell triggers or I keep it like that?

Queston 4: Do I need to use privates variables or locals variables in my spell triggers, when I use your MUI system?

Code
library WhatEverSpell initializer Init  
      struct WhatEverStruct  
          //all struct variables  
          private real flyingheight = 50
          private real flyingheightspeed = 50
          private real addition = 50
          private unit caster = GetTriggerUnit()
      endstruct  

      globals  
          //Struct array for storage  
          private WhatEverStruct array GlobalStruct  
          //Integer for max used Array slot  
          private integer struct_init = 6000  
          //Callback Timer  
          private timer CallbackTimer = CreateTimer()
          private boolean DestroyStruct = TRUE
      endglobals  

      private function Callback takes nothing returns nothing  
          local WhatEverStruct dat  
          local integer i = 0  
          //Looping through all structs  
          loop  
              exitwhen i == struct_init  
              //Setting global struct to local for preventing OP Limit Hit  
              set dat = GlobalStruct[i]  
              if DestroyStruct then  
                  //Destroying struct if wanted  
                  call dat.destroy()  
                  //Decreasing max slot and switch structs  
                  set struct_init = struct_init - 1  
                  set GlobalStruct[i] = GlobalStruct[struct_init]  
              else  
                  //Checking for next struct  
                  set i = i + 1  
              endif  
          endloop  
          if struct_init == 0 then  
              call PauseTimer(CallbackTimer)  
          endif  
      endfunction  

      private function OnCast takes nothing returns nothing  
          local WhatEverStruct dat = WhatEverStruct.create()
          //Spell code
              call SetUnitFlyHeightBJ( caster, flyingheight, flyingheightspeed )
          //or whatever  
          //Saving struct to global + increasing max slot  
          set GlobalStruct[struct_init] = dat  
          set struct_init = struct_init + 1  
          if struct_init == 1 then  
              call TimerStart(CallbackTimer,.03,true,function Callback)  
          endif  
      endfunction  
       
      function Trig_CACA_Conditions takes nothing returns boolean
     if ( not ( GetSpellAbilityId() == 'A000' ) ) then
         return false
     endif
     return true
endfunction

      private function Init takes nothing returns nothing  
          //Whatever init function  
              set gg_trg_CACA = CreateTrigger(  )
     call TriggerRegisterAnyUnitEventBJ( gg_trg_CACA, EVENT_PLAYER_UNIT_SPELL_EFFECT )
     call TriggerAddCondition( gg_trg_CACA, Condition( function Trig_CACA_Conditions ) )
     call TriggerAddAction( gg_trg_CACA, function OnCast)
      endfunction  
endlibrary

I made this with your code. BUT!!! i have some problems. First: can you tell me what isnt good in the trigger please? 2: I put my private variables in the library and when I try to use them, I get an error.

Can you help me please?

biggrin Thanks Mister VJASS


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Saturday, 2009-02-14, 9:52 PM
 
FireeyeDate: Saturday, 2009-02-14, 10:34 PM | Message # 6
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
1. leave struct_init to 0 due it'll get increased for every instance by 1 and decreased by 1 when a spell instance is over.
Also you destroy the struct after the first literation, if you don't want any over time effect there's no need for any sort of MUI try.

2. you can not use the private keyword for struct variables, but you can make the struct itself private.

When i got my Syntax Highlighter back i'll post an optimized version, however what do you want to do with this spell?




Message edited by Fireeye - Saturday, 2009-02-14, 10:36 PM
 
TheCheeseLoverDate: Saturday, 2009-02-14, 10:47 PM | Message # 7
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Thanks.

I want to make my first MUI and JASS( with VJASS too ) simple spell. A windwave that will knockback some guys.

3: What is the difference between a private variable and a local variable?

4: What do I need to put in struct WhatEverStruct? My MUI variables? My local variables?

5: I put the struct WhatEverStruct in a private struct like this: private struct WhatEverStruct. Does it will change something?


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Saturday, 2009-02-14, 10:59 PM
 
FireeyeDate: Sunday, 2009-02-15, 0:56 AM | Message # 8
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
3. the difference between local and private is:
local will only be accessable for the function declared in, furthermore they won't get overwritten when a new instance appears
private is a vJASS extension, declaring a variable only being callable inside a library / struct (also vJASS)

4. you need to put into the struct the things your need to "recall", e.g. the target unit, maybe caster, position, speed, etc.

5. private struct WhatEverStruct will result into something like this -> WhatEverSpell_WhatEverStructX (X is a random number generated new each time you save, so you can not access it from outside the function)
Also this allows you to use the samy library again without having the struct colliding.


 
TheCheeseLoverDate: Sunday, 2009-02-15, 1:49 AM | Message # 9
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
THANKS!!!

Re 4: Can you give me an exemple of ''recall'' please?

(You are much more active than Darkt3mpl3r )

biggrin


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Sunday, 2009-02-15, 1:49 AM
 
FireeyeDate: Sunday, 2009-02-15, 1:59 AM | Message # 10
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
e.g. you want the caster to deal the target 120 dmg over 3 secs (40 dmg/sec), then you need to store:
the caster
the target
the damage/sec
and how much time already elapsed


 
TheCheeseLoverDate: Sunday, 2009-02-15, 2:02 AM | Message # 11
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
I know that but I mean an exemple in a trigger please. smile

6: What is a scope?

PS: I added you some thing magic!


Yay I have a signature. You suck. :D
 
FireeyeDate: Sunday, 2009-02-15, 5:52 PM | Message # 12
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
6: Scope is basically the same as a library but i can not be required by other scopes/librarys.
Gonna write an example when i got time today.


 
TheCheeseLoverDate: Sunday, 2009-02-15, 9:08 PM | Message # 13
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Ok thanks!

7: Can you explain me what is a struct please?

8: What is different between a function and a private function?

9: What is different between a public struct and a struct?

10: What is a private data?

11: What is a local data?

Added (2009-02-15, 8:11 Pm)
---------------------------------------------
OMG!

I hate when I don't understand. Tell me if its not correct please. So, in the private struct WhatEverStruct, I need to put a private variable: exemple: private string gg. And after, if I write local string gg in the function OnCast, the gg string will be MUI.

Code
library WhatEverSpell initializer Init             
                 private struct WhatEverStruct             
                     //all struct variables
                      
                     private string gg
                      
                 endstruct             

                            
                            
                 g  lobals             
                     /   /Struct array for storage             
                     private WhatEverStruct array GlobalStruct             
                     //Integer for max used Array slot             
                     private integer struct_init = 0            
                     //Callback Timer             
                     private timer CallbackTimer = CreateTimer()            
                     private boolean DestroyStruct = TRUE            
                 endglobals             

                            
                            
                 private function Callback takes nothing returns nothing             
                     local WhatEverStruct dat             
                     local integer i = 0             
                     //Looping through all structs             
                     loop             
                         exitwhen i == struct_init             
                         //Setting global struct to local for preventing OP Limit Hit             
                         set dat = GlobalStruct[i]             
                         if DestroyStruct then             
                             //Destroying struct if wanted             
                             call dat.destroy()             
                             //Decreasing max slot and switch structs             
                             set struct_init = struct_init - 1             
                             set GlobalStruct[i] = GlobalStruct[struct_init]             
                         else             
                             //Checking for next struct             
                             set i = i + 1             
                         endif             
                     endloop             
                     if struct_init == 0 then             
                         call PauseTimer(CallbackTimer)             
                     endif             
                 endfunction             

                            
                            
                f      unction  OnCast takes nothing returns nothing             
                     local WhatEverStruct dat = WhatEverStruct.create()            
                     //Spell code
                     //or whatever             
                     //Saving struct to global + increasing max slot             
                     set GlobalStruct[struct_init] = dat             
                     set struct_init = struct_init + 1             
                     if struct_init == 1 then             
                         call TimerStart(CallbackTimer,.03,true,function Callback)             
                     endif             
                 endfunction             
                             
                             
                             
                 f      uncti on Trig_CACA_Conditions takes nothing returns boolean            
                if ( not ( GetSpellAbilityId() == 'A000' ) ) then            
                    return false            
                endif            
                return true            
endfunction            

                  function Init takes nothing returns nothing             
                     //Whatever init function             
                      
                         set gg_trg_CACA = CreateTrigger(  )            
                call TriggerRegisterAnyUnitEventBJ( gg_trg_CACA, EVENT_PLAYER_UNIT_SPELL_EFFECT )            
                call TriggerAddCondition( gg_trg_CACA, Condition( function Trig_CACA_Conditions ) )            
                call TriggerAddAction( gg_trg_CACA, function OnCast)            
                 endfunction             
endlibrary

Added (2009-02-15, 9:08 Pm)
---------------------------------------------
12: What is a private constant function?

13: What is a method and a method onDestroy?


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Sunday, 2009-02-15, 9:09 PM
 
FireeyeDate: Sunday, 2009-02-15, 9:13 PM | Message # 14
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
7. A Struct is basically several variables with array done parallel to hold all informations, you could do the same thing as the structs are doing without vJASS but it's such a giant amount of work not being worth to make it in normal JASS.

8. A normal function can be called outside a library / scope, the name will not be changed.
A private function can not be called outside a library / scope, due the name will be changed with a random number + scope name.

9. A public struct will have it's name changed but it can be called outside the library / scope, other than private.
A normal struct will not have it's name changed, it can be called outside the library /scope too.

10. A private data is a global variable inside the library / scope using the keyword private, therfore it can not be changed from outside the library / scope.

11. A local data can only be used within the function it is declared, if you have another function with the same name it'll not contain the same information (in most case) as function #1.

---EDIT---
This would be basically an example of how to use:
It's a simple written DPS spell (not tested...)

Code
library WhatEverSpell initializer Init                
       private struct WhatEverStruct                
           //all struct variables
           unit caster = null
           unit target = null
           real dps = .0
           real TimeLeft = .0
           effect TargetEffect = null
           //Create functions
           static method create takes nothing returns WhatEverStruct
               local WhatEverStruct d = WhatEverStruct.allocate()
               set d.caster = GetTriggerUnit()
               set d.target = GetSpellTargetUnit()
               set d.dps = 150.00 + 50.00 * GetUnitAbilityLevel(GetTriggerUnit(),'A000')
               set d.TimeLeft = 2 + .5 * GetUnitAbilityLevel(GetTriggerUnit(),'A000')
               set d.TargetEffect = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Doom\\DoomTarget.mdl",d.target,"origin")
               return d
           endmethod
           //Destroy function
           method onDestroy takes nothing returns nothing
               call DestroyEffect(.TargetEffect)
               set .caster = null
               set .target = null
               set .dps = .0
               set .TimeLeft = .0
               set .TargetEffect = null
           endmethod
       endstruct                
                   
       globals                
           //Struct array for storage                
           private WhatEverStruct array GlobalStruct                
           //Integer for max used Array slot                
           private integer struct_init = 0               
           //Callback Timer                
           private timer CallbackTimer = CreateTimer()               
       endglobals                

       private function Callback takes nothing returns nothing                
           local WhatEverStruct dat                
           local integer i = 0                
           //Looping through all structs                
           loop                
               exitwhen i == struct_init                
               //Setting global struct to local for preventing OP Limit Hit                
               set dat = GlobalStruct[i]                
               if dat.TimeLeft < .03 then      
                   call UnitDamageTarget(dat.caster,dat.target,dat.dps*dat.TimeLeft,true,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
                   /  /Destroying struct if wanted                
                   call dat.destroy()                
                   //Decreasing max slot and switch structs                
                   set struct_init = struct_init - 1                
                   set GlobalStruct[i] = GlobalStruct[struct_init]                
               else            
                   //Doing all actions if you don't want to destroy the struct
                   set dat.TimeLeft = dat.TimeLeft - .03
                   call UnitDamageTarget(dat.caster,dat.target,dat.dps*.03,true,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
                   /  /Checking for next struct                
                   set i = i + 1                
               endif                
           endloop    
           //Checking if any struct is assigned
           if struct_init == 0 then                
               call PauseTimer(CallbackTimer)                
           endif                
       endfunction                

       function  OnCast takes nothing returns nothing                
           local WhatEverStruct dat = WhatEverStruct.create()               
           //Spell code (assigned values directly in the create function)
           //Saving struct to global + increasing max slot                
           set GlobalStruct[struct_init] = dat                
           set struct_init = struct_init + 1      
           //Starting Callback Timer
           if struct_init == 1 then                
               call TimerStart(CallbackTimer,.03,true,function Callback)                
           endif                
       endfunction                
                        
       function Trig_CACA_Conditions takes nothing returns boolean               
           return GetSpellAbilityId() == 'A000'            
       endfunction               

       private function Init takes nothing returns nothing                
           //Whatever init function                
           local trigger tr = CreateTrigger(  )               
           call TriggerRegisterAnyUnitEventBJ(tr, EVENT_PLAYER_UNIT_SPELL_EFFECT )               
           call TriggerAddCondition(tr, Condition( function Trig_CACA_Conditions ) )               
           call TriggerAddAction(tr, function OnCast)               
       endfunction                
endlibrary

---EDIT 2---
12: The keyword constant will NOT have any effect unless you use a map optimizer, if you use it and function got the keyword constant that function will be inlined into the calling function, therefore saving space and a bit execution time.

13: A method basically is a function for structs, not more not less.
The method onDestroy is a function which will be called when you destroy a struct, so you can easily remove effects, etc.




Message edited by Fireeye - Sunday, 2009-02-15, 9:37 PM
 
TheCheeseLoverDate: Sunday, 2009-02-15, 10:13 PM | Message # 15
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
14: What is a statistic method?

15: Why do you put ''.'' and ''d'' some times before a variables?

16: Can you explain me what is that please? local WhatEverStruct d = WhatEverStruct.allocate()

17: Why did you don't put ''private'' or ''local'' before those variables?

unit caster = null
unit target = null
real dps = .0
real TimeLeft = .0
effect TargetEffect = null

18: So in your exemple, I need to use those MUI variables in the OnCast function:

set d.caster
set d.target
set d.dps
set d.TimeLeft
set d.TargetEffect


Yay I have a signature. You suck. :D
 
Clan NgO Forums » Discussions » Flood Dimension » Little problem.
  • Page 1 of 3
  • 1
  • 2
  • 3
  • »
Search:

Clan NgO © 2024Powered by uCoz