Little problem.
| |
Fireeye | Date: Sunday, 2009-02-15, 11:12 PM | Message # 16 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| 14. a static method call would look like : StructName.MethodName() while a method name looks this way variable.MethodName() So basically a static method is a method call without the need to have any variable of that kind. 15. that's due to the difference between static method and method. When i use static method i don't have any reference to the struct so i've to allocate one to use it. But with method i call it with a reference to a struct, therefore i can use the "." syntax it's basically the same as if i would write "dat." inside the calling function 16. the function .allocate() is the "REAL" creation function of a struct, other than .create() you can NOT call it outside the struct. 17. they're already "private" due the fact they're in a private struct, if i would make them private i wouln't be able to reference to them outside the struct. 18.In this case yes, they're the caster, the target, the damage/sec, the time left and the effect attached to the target unit. But i guess you're still misunderstanding the concept of MUI, MUI doesn't just mean all datas are local in more likely means you store an information save from being overwritten till you don't need it anymore.
|
|
| |
TheCheeseLover | Date: Sunday, 2009-02-15, 11:31 PM | Message # 17 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| Yes, I still misunderstanding. I need more exemples for understand I am a visual boy. 19: Why do we write some times: ''dat.''. 20: Can you give me an exemple of when you call the caster and other variables in OnCast. Thanks!!!
Yay I have a signature. You suck. :D
|
|
| |
Fireeye | Date: Monday, 2009-02-16, 1:20 AM | Message # 18 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| 19. We use dat. for methods or variables inside a struct, we need the dat. to know what struct you want to access. However INSIDE a method we don't need it anymore cause we're calling the method for the struct variable dat 20. I call them in the example i wrote with .create(), it basically is just a simple function call, you could also write it this way (remove the create method). In the OnCast you only assign all needed values for callback. Code function OnCast takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() //Spell code (assigned values directly in the create function) set dat.caster = GetTriggerUnit() set dat.target = GetSpellTargetUnit() set dat.dps = 150.00 + 50.00 * GetUnitAbilityLevel(GetTriggerUnit(),'A000') set dat.TimeLeft = 2 + .5 * GetUnitAbilityLevel(GetTriggerUnit(),'A000') set dat.TargetEffect = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Doom\\DoomTarget.mdl",GetSpellTargetUnit(),"origin") //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 I basically use methods to make code more readable and clear.
Message edited by Fireeye - Monday, 2009-02-16, 1:21 AM |
|
| |
TheCheeseLover | Date: Monday, 2009-02-16, 2:43 AM | Message # 19 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| WHOOHOO! thanks! I will make spell with this. I think i will have some questions too. We need to celebrate this with a little gift! HMM! reputation? Yea reputation! So I added you a little gift. You will never know what it is! NOOOOO!!!! Sorry I can't add you more reputation. It's said: You already increased his reputation. Added (2009-02-16, 2:43 Am) --------------------------------------------- Hi again! 21: Why do you put .0 and not 0.00 for a real? Exemple: real dps = .0
Yay I have a signature. You suck. :D
Message edited by TheCheeseLover - Monday, 2009-02-16, 2:40 AM |
|
| |
Fireeye | Date: Monday, 2009-02-16, 2:57 AM | Message # 20 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| 21. doesn't matter due it's the same, but less to type ^^
|
|
| |
TheCheeseLover | Date: Tuesday, 2009-02-17, 4:12 AM | Message # 21 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| HI! 22: What does it mean the '' return d '' ? 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 23: Can you explain me what is a global please and do we need to call it? 24: How can we know OnDestroy will affect wich methode? 25: What is different between those library: library intializer Init, library Nothing. 26: How can we call a OnDestroy methode?
Yay I have a signature. You suck. :D
Message edited by TheCheeseLover - Tuesday, 2009-02-17, 5:16 AM |
|
| |
Fireeye | Date: Tuesday, 2009-02-17, 1:48 PM | Message # 22 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| 22. When you use the .create() method of a struct, you need to return a variable of that kind, in this case it is "local WhatEverStruct d" 23. Globals are variables which can be called from any function and not just the function declaring a value for it. 24. Manuals, no really MANUALS. There are quite some nice things in the Jass Helper Manual. You'll find e.g. the OnDestroy method there. 25. The extension "intializer " let you declare a function within the library you want to be executed when the maps loads, so basically it's like making a new trigger in the editor and modify it, but with this way you don't need to create new triggers. You basically could put all things into the map header even though the overview would get lost. 26. The method OnDestroy is called when you use the command .destroy() on a struct variable.
Message edited by Fireeye - Tuesday, 2009-02-17, 1:49 PM |
|
| |
TheCheeseLover | Date: Friday, 2009-03-06, 1:05 AM | Message # 23 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| Hi again! I don't know why but I am getting an error because I am putting dat. before a variables. And I need the dat.. It's said: dat is not of a type that allows . syntax Code private function knockback takes nothing returns nothing if dat.tr > 100 then call PauseTimer(dat.tt) else call DoNothing() endif call SetUnitPositionLoc( dat.target, PolarProjectionBJ(dat.target, 5.00, ( AngleBetweenPoints(GetUnitLoc(dat.target), GetUnitLoc(dat.caster)) - 180.00 )) ) set dat.tr = dat.tr + 1 endfunction private function WindWave takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() //Spell code (assigned values directly in the create function) set dat.target = GetSpellTargetUnit() set dat.tr = null call TimerStart(tt, 0.03, TRUE, function knockback) //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 fu nction Trig_WIND_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_WIND_Conditions ) ) call TriggerAddAction(tr, function WindWave) endfunction Can you help me plz?
Yay I have a signature. You suck. :D
Message edited by TheCheeseLover - Friday, 2009-03-06, 1:10 AM |
|
| |
Fireeye | Date: Sunday, 2009-03-08, 10:39 PM | Message # 24 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| You didn't declare any struct with the name dat in that function, also you don't need the Code else call DoNothing() part, DoNothing() is propably the most useless function ever made by Blizzard, you'll never need it due it has no usage. Furthermore you're leaking 3 locations in this function.
|
|
| |
TheCheeseLover | Date: Friday, 2009-03-13, 4:24 AM | Message # 25 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| Thanks! The leaks are not a problem because this is just a test. Code private function knockback takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() if dat.tr > 100 then call PauseTimer(dat.tt) else endif call SetUnitPositionLoc( dat.target, PolarProjectionBJ(GetUnitLoc(dat.target), 5.00, ( AngleBetweenPoints(GetUnitLoc(dat.target), GetUnitLoc(dat.caster)) - 180.00 )) ) set dat.tr = dat.tr + 1 endfunction Do I need to allocate it like this?: local WhatEverStruct dat = WhatEverStruct.create() Added (2009-03-13, 4:24 Am) ---------------------------------------------
Code scope WhatEverSpell initializer Init private struct WhatEverStruct //all struct variables unit caster = null unit target = null string dummy = null group picked = null group gdum = null real tr = .0 real TimeLeft = 0.00 string effect1 = null timer tt = 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.tr = 0.00 set d.TimeLeft = 2 + 0.50 * GetUnitAbilityLevel(GetTriggerUnit(),'A000') set d.effect1 = null set d.tt = CreateTimer() return d endmethod //Destroy function method onDestroy takes nothing returns nothing set .effect1 = null set .caster = null set .target = null set .tr = .0 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 //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 //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
private function knockback takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() if dat.tr > 100 then call PauseTimer(dat.tt) else endif call SetUnitPositionLoc( dat.target, PolarProjectionBJ(GetUnitLoc(dat.target), 5.00, ( AngleBetweenPoints(GetUnitLoc(dat.target), GetUnitLoc(dat.caster)) - 180.00 )) ) set dat.tr = dat.tr + 1 endfunction private function WindWave takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() //Spell code (assigned values directly in the create function) set dat.target = GetSpellTargetUnit() set dat.tr = 0.00 call TimerStart(dat.tt, 0.03, TRUE, function knockback) //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_WIND_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_WIND_Conditions ) ) call TriggerAddAction(tr, function WindWave) endfunction endscope Does the variable dat.TimeLeft is the max time of the trigger?
Yay I have a signature. You suck. :D
Message edited by TheCheeseLover - Tuesday, 2009-03-10, 4:01 AM |
|
| |
Fireeye | Date: Wednesday, 2009-03-18, 3:50 PM | Message # 26 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| Why the "hell" do you create another timer, when you could do ALL instances in the callback function i provided? Just insert your code directly after Code exitwhen i == struct_init //Setting global struct to local for preventing OP Limit Hit set dat = GlobalStruct[i] and you're fine. for the duration of the knockback, you can easily use the TimeLeft variable provided in the struct...
|
|
| |
TheCheeseLover | Date: Thursday, 2009-03-19, 2:50 AM | Message # 27 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| First, the other timer is for my test. Now I am confuse, do I need to write my code after what you said or in this function: Code private function WindWave takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() //Spell code (assigned values directly in the create function) set dat.target = GetSpellTargetUnit() set dat.tr = 0.00 call TimerStart(dat.tt, 0.03, TRUE, function knockback) //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
Yay I have a signature. You suck. :D
|
|
| |
Fireeye | Date: Thursday, 2009-03-19, 3:28 PM | Message # 28 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| Code scope WhatEverSpell initializer Init private struct WhatEverStruct //all struct variables unit caster = null unit target = null real TimeLeft = 0.00 real angle = .0 //Create functions static method create takes nothing returns WhatEverStruct local WhatEverStruct d = WhatEverStruct.allocate() set d.caster = GetTriggerUnit() set d.target = GetSpellTargetUnit() set d.angle = Atan2(GetUnitY(d.target)-GetUnitY(d.caster),GetUnitX(d.target)-GetUnitX(d.caster)) set d.TimeLeft = 3 return d endmethod //Destroy function method onDestroy takes nothing returns nothing set .caster = null set .target = 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() //Bound check private real MinX = GetRectMinX(bj_mapInitialPlayableArea) private real MaxX = GetRectMaxX(bj_mapInitialPlayableArea) private real MinY = GetRectMinY(bj_mapInitialPlayableArea) private real MaxY = GetRectMaxY(bj_mapInitialPlayableArea) endglobals
private function Callback takes nothing returns nothing local WhatEverStruct dat local integer i = 0 local real x = .0 local real y = .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 //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 //Spell code set x = GetUnitX(dat.target) set y = GetUnitY(dat.target) if x > MinX and x < MaxX and y > MinY and y < MaxY then call SetUnitX(dat.target,x+5*Cos(dat.angle)) call SetUnitY(dat.target,y+5*Sin(dat.angle)) endif //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 private function WindWave takes nothing returns nothing local WhatEverStruct dat = WhatEverStruct.create() //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
private function WIND_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 WIND_Conditions)) call TriggerAddAction(tr,function WindWave) endfunction endscope
Message edited by Fireeye - Thursday, 2009-03-19, 3:32 PM |
|
| |
TheCheeseLover | Date: Saturday, 2009-03-28, 2:05 PM | Message # 29 |
![TheCheeseLover](/avatar/00/00/016804.gif) Sergeant
Group: Users
Messages: 22
Status: Offline
| THX! Lol, I am posting from the school. Added (2009-03-28, 2:05 Pm) --------------------------------------------- Code UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean 1:What means the boolean attack and the boolean ranged? 2: Code scope Telekinesis initializer Init
private function Trig_Telekinesis_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A000' ) ) then return false endif return true endfunction
private struct Telekinesis //all struct variables unit caster = null unit target = null real TimeLeft = 0.00 real angle = .0 //Create functions static method create takes nothing returns WhatEverStruct local Telekinesis d = Telekinesis.allocate() set d.caster = GetTriggerUnit() set d.target = GetSpellTargetUnit() set d.angle = Atan2(GetUnitY(d.target)-GetUnitY(d.caster),GetUnitX(d.target)-GetUnitX(d.caster)) set d.TimeLeft = 3 return d endmethod //Destroy function method onDestroy takes nothing returns nothing set .caster = null set .target = null endmethod endstruct
globals //Struct array for storage private Telekinesis array GlobalStruct //Integer for max used Array slot private integer struct_init = 0 //Callback Timer private timer CallbackTimer = CreateTimer() //Bound check private real MinX = GetRectMinX(bj_mapInitialPlayableArea) private real MaxX = GetRectMaxX(bj_mapInitialPlayableArea) private real MinY = GetRectMinY(bj_mapInitialPlayableArea) private real MaxY = GetRectMaxY(bj_mapInitialPlayableArea) endglobals
private function Trig_Telekinesis_Actions takes nothing returns nothing local Telekinesis dat local integer i = 0 local real x = .0 local real y = .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 //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 //Spell code set x = GetUnitX(dat.target) set y = GetUnitY(dat.target) if x > MinX and x < MaxX and y > MinY and y < MaxY then call SetUnitX(dat.target,x+5*Cos(dat.angle)) call SetUnitY(dat.target,y+5*Sin(dat.angle)) endif //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
//=========================================================================== private function InitTrig_Telekinesis takes nothing returns nothing set gg_trg_Telekinesis = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Telekinesis, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Telekinesis, Condition( function Trig_Telekinesis_Conditions ) ) call TriggerAddAction( gg_trg_Telekinesis, function Trig_Telekinesis_Actions ) endfunction endscope I don't know why the endscope can not find the scope.
Yay I have a signature. You suck. :D
Message edited by TheCheeseLover - Saturday, 2009-03-28, 3:00 PM |
|
| |
Fireeye | Date: Friday, 2009-04-03, 0:33 AM | Message # 30 |
![Fireeye](/avatar/93/867657.jpg) Private
Group: Moderators
Messages: 16
Status: Offline
| 1. When you set the boolean attack to true, it will be counted as attack (victim may attack source), however if the target is out of sight and ranged is false, the target will not attack the source, due the fact it won't have sight. In short: attack == Count as attack, ranged == Provides sight to target unit 2. No idea, found only 1 error, rename "private function InitTrig_Telekinesis takes nothing returns nothing " into "private function Init takes nothing returns nothing" to fix it.
|
|
| |
|