| 08-13-2008, 01:57 AM | #1 |
..EDITED.. JASS://////////////////////////////////////////////////////////////////////////////////////// //Effects are changes. All changes are described as an alteration of a subject's //property over time. Time is necessary because the subject cannot be one thing and //another at the same time; also, an object cannot subsequently be something from //something if at one time it was not that new something. //So we have these objects: // 1) the Subject // 2) the Cause // a) the source of the change (affector) // b) the event of the change // 3) the Nature of the change (note: qualitative effects have only 1 'instance', // quantitative effects have many degree-instances. i.e., a stun is // qualitative coz a unit is either stunned or it isnt; a mana loss is // quantative because a unit can have x mana, or x-1 mana, or x+1, mana, // and so on. // Application of qualitative effects involves 'toggling', while application // of quantitative effects involves 'adjustment'.) // a) the object // i) property changed // ii) the quantitative/qualitative change of said property (differential of change) // b) the time that elapsed during the change // //examples: //Some qualitative effects: //'hides', stuns, ownership-change, replacement, pauses, etc. //Some quantitative effects: //a vector effect: target, the moved unit; cause, the pushing/pulling unit/force; object, position; quantity, // scalars of change; time. //a damaging effect: target, the damaged unit; cause, the damaging unit, object, life; quantity, damage amount; // time, (instantaneous or differential). //a stat/property effect: target, altered unit; cause, whatever agent (most likely a unit); object, the field altered; // quantity, quantity of alteration; time, (instantaneous or differential). //////////////////////////////////////////////////////////////////////////////////////// library GeneralLibrary initializer Init globals integer gINT unit gU endglobals /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// scope EffectSystem globals //Constants// private timer gTIM private constant real gR_DurationTimer = 0.05 //General Data// private GeneralData array gEFFECT private integer gINT_CountEffect = 0 //Sub-Data Interfacing// integer array gINT_XStructId integer gINT_CountXStruct string array gSTR_FuncNameStructDestroyer endglobals //=============//General-Type Struct Start//=============// private function gTIMCallback takes nothing returns nothing local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 if gEFFECT[INT_CountEffect].boolOn then call gEFFECT[INT_CountEffect].MainExecute() endif exitwhen INT_CountEffect == gINT_CountEffect endloop endfunction private function gTIMUpdate takes nothing returns nothing if gINT_CountEffect == 1 then call TimerStart(gTIM, gR_DurationTimer, true, function gTIMCallback) elseif gINT_CountEffect == 0 then call PauseTimer(gTIM) endif endfunction struct GeneralData //-----Handlers-----// integer intEffectIndex boolean boolOn integer intTypeId string strFuncNameStart string strFuncNameInterval string strFuncNameEnd real rDuration real rDurationInterval integer intCountInterval integer intMaxCountInterval //input a value of 0 for this to create for a PERMANENT effect static method MainCreate takes integer typeId, string funcNameStart, string funcNameInterval, string funcNameEnd, real durationInterval, integer maxCountInterval returns nothing local GeneralData New = GeneralData.allocate() set gINT_CountEffect = gINT_CountEffect + 1 set New.intEffectIndex = gINT_CountEffect set New.boolOn = true set New.intTypeId = typeId set New.strFuncNameStart = funcNameStart set New.strFuncNameInterval = funcNameInterval set New.strFuncNameEnd = funcNameEnd set New.rDuration = 0.00 set New.rDurationInterval = durationInterval set New.intCountInterval = 0 set New.intMaxCountInterval = maxCountInterval set gEFFECT[gINT_CountEffect] = New call gTIMUpdate() endmethod method UpdateIndexes takes nothing returns nothing local integer INT_CountXStruct = 0 loop set INT_CountXStruct = INT_CountXStruct + 1 if gINT_XStructId[INT_CountXStruct] == .intTypeId then set gINT = .intEffectIndex call ExecuteFunc(gSTR_FuncNameStructDestroyer[INT_CountXStruct]) endif exitwhen INT_CountXStruct == gINT_CountXStruct endloop set gEFFECT[gINT_CountEffect].intEffectIndex = .intEffectIndex set gEFFECT[.intEffectIndex] = gEFFECT[gINT_CountEffect] set gEFFECT[gINT_CountEffect] = 0 set gINT_CountEffect = gINT_CountEffect - 1 endmethod method MainDestroy takes nothing returns nothing //Execute End Function// if .strFuncNameEnd != null then set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameEnd) else endif call .UpdateIndexes() endmethod method MainExecute takes nothing returns nothing if .strFuncNameStart != null and .rDuration == 0.00 and .intCountInterval == 0 then //Execute Start Function// set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameStart) endif set .rDuration = .rDuration + gR_DurationTimer if .rDuration/.rDurationInterval == 1.00 then //Execute Interval Function// if .strFuncNameInterval != null then set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameInterval) endif set .intCountInterval = .intCountInterval + 1 if .intCountInterval == .intMaxCountInterval then call .MainDestroy() endif endif endmethod endstruct //=============//General-Type Struct End//=============// //=============//Sub-Type Structs Start//=============// globals private integer gINT_PauseTypeId private PauseXData array gPAUSE endglobals //Stuns pauses a unit for a duration, works in conjunction with other pauses.// //If boolStack is true then its duration will stack with those of other pauses; if it is false, //its duration will expire independently of those of other pauses. struct PauseXData boolean boolStack boolean boolPaused integer intBuffId integer intBuffLevel unit uTarget static method Create takes boolean stack, integer buffId, integer level, unit source, unit target, real duration returns nothing local PauseXData New = PauseXData.allocate() call GeneralData.MainCreate(PauseXData.typeid, "PauseStart", null, "PauseEnd", duration, 1) set New.boolStack = stack set New.boolPaused = true set New.intBuffId = buffId set New.intBuffLevel = level set New.uTarget = target set gPAUSE[gINT_CountEffect] = New endmethod method Destroy takes nothing returns nothing //Recycle instance; give to instance of highest-value index. set gPAUSE[gINT].boolStack = gPAUSE[gINT_CountEffect].boolStack set gPAUSE[gINT].boolPaused = gPAUSE[gINT_CountEffect].boolPaused set gPAUSE[gINT].intBuffId = gPAUSE[gINT_CountEffect].intBuffId set gPAUSE[gINT].intBuffLevel = gPAUSE[gINT_CountEffect].intBuffLevel set gPAUSE[gINT].uTarget = gPAUSE[gINT_CountEffect].uTarget set gPAUSE[gINT_CountEffect] = 0 endmethod static method UnpauseCheck takes integer effectIndex, unit target returns boolean local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 //First 3 conditions determine if the query gEFFECT is a gPAUSE type that is not that w/c is being checked for. //Last condition determines the desired output of this method: "Is this unit currently paused by another gPAUSE effect?". if INT_CountEffect != effectIndex and gEFFECT[INT_CountEffect].intTypeId == gINT_PauseTypeId and gPAUSE[INT_CountEffect].uTarget == target and gPAUSE[INT_CountEffect].boolPaused then return false endif exitwhen INT_CountEffect == gINT_CountEffect endloop return true endmethod endstruct //Action-ONLY Functions (no struct management here)// function PauseStart takes nothing returns nothing call PauseUnit(gPAUSE[gINT].uTarget, true) endfunction function PauseEnd takes nothing returns nothing local unit U_Target = gPAUSE[gINT].uTarget if PauseXData.UnpauseCheck(gINT, U_Target) then call PauseUnit(U_Target, false) endif set U_Target = null endfunction function PauseDestroy takes nothing returns nothing call gPAUSE[gINT].Destroy() endfunction //=============//Sub-Type Structs End//=============// public function Init takes nothing returns nothing //typeid's for reference by X-structs. set gINT_PauseTypeId = PauseXData.typeid //Initialize X-struct typeid and destroyer-function-name datas. set gINT_CountXStruct = 1 set gINT_XStructId[1] = gINT_PauseTypeId set gSTR_FuncNameStructDestroyer[1] = "PauseDestroy" //GeneralData (Constant Stuff)// set gTIM = CreateTimer() endfunction endscope /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// private function Init takes nothing returns nothing call EffectSystem_Init() endfunction endlibrary ///below outdated///// ok so i made this 'system' it creates "Effects" : triggered buffs AND animations (dummies, effect (fx), lightning, texttags, sound). Effects can have start functions (actions done when they are created), mid-interval functions, and end functions. interval length and amount can be specified. + some minor stuff (sounds that are voices of units will not stack [a unit can say only one thing at a time], sounds that are not voices of untis will; simulated spell steal w/ specifications on good/bad buff targeting; effect pausing; etc) will .evalute() work with struct codes? also, did i designante the functions (startFunc, midFunc, endFunc) properly in the struct? and are they properly listed in the arguements list as 'code myFunc'? JASS:library EffectSystem initializer Init requires GeneralLibrary //////////////////////////////////////////////// ////////==========User Console==========//////// //Effect Creation Functions:// function EffectCreateBuff takes integer abilityId, integer buffId, integer level, player ownerCaster, unit caster, unit target, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData return EffectData.Create(TRUE, gSTR_EffectTypeBuff, FALSE, abilityId, buffId, level, null, ownerCaster, caster, FALSE, null, null, null, null, FALSE, null, target, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) endfunction function CreateEffectAnimUnit takes returns player owner, integer unitId, real x, real y, real facing, boolean killUnitObject, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval string EffectData local unit U_Object = CreateUnit(owner, UnitId, x, y, facing) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, FALSE, 0, 0, 0, gSTR_ObjectTypeUnit, null, U_Object, killUnitObject, null, null, null, null, FALSE, gSTR_TargetTypeLocation, null, x1, y1, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set U_Object = null return null endfunction function CreateEffectAnimFXUnit takes string modelName, unit target, string attachPoint, boolean animTargetAlive, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local effect FX_Object = AddSpecialEffectTarget(modelName, target, attachPoint) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, animTargetAlive, 0, 0, 0, gSTR_ObjectTypeFX, null, null, FALSE, FX_Object, null, null, null, FALSE, gSTR_TargetTypeUnit, target, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set FX_Object = null return null endfunction function CreateEffectAnimFXLocation takes string modelName, real x, real y, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local effect FX_Object = AddSpecialEffect(modelName, x, y) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, FALSE, 0, 0, 0, gSTR_ObjectTypeFX, null, null, FALSE, FX_Object, null, null, null, FALSE, gSTR_TargetTypeLocation, null, x, y, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set FX_Object = null endfunction function CreateEffectAnimLightning takes string modelName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2, code startFunc, code midFunc, code endFunc, real durationInterval, real maxCountInterval returns EffectData local lightning LIGHT_Object = AddLightningEx(modelName, checkVisibility, x1, y1, z1, x2, y2, z2) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, FALSE, 0, 0, 0, gSTR_ObjectTypeLightning, null, null, FALSE, null, LIGHT_Object, null, null, null, FALSE, null, x1, y1, z1, x2, y2, z2, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set LIGHT_Object = null return null endfunction function CreateEffectAnimTextTagLocation takes real age, integer red, integer green, integer blue, integer alpha, real fadepoint, real lifespan, boolean permanent, real x, real y, real z, boolean paused, string text, real height, real xvel, real yvel, boolean visible, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local texttag TT_Object = CreateTextTag() call SetTextTagAge(TT_Object, age) call SetTextTagColor(TT_Object, red, green, blue, alpha) call SetTextTagFadepoint(TT_Object, fadepoint) call SetTextTagLifespan(TT_Object, lifespan) call SetTextTagPermanent(TT_Object, permanent) call SetTextTagPos(TT_Object, x, y, z) call SetTextTagSuspended(TT_Object, paused) call SetTextTagText(TT_Object, text, height) call SetTextTagVelocity(TT_Object, xvel, yvel) call SetTextTagVisibility(TT_Object, visible) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, FALSE, 0, 0, 0, gSTR_ObjectTypeTextTag, null, null, FALSE, null, null, TT_Object, null, FALSE, gSTR_TargetTypeLocation, null, x, y, z, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set TT_Object = null return null endfunction function CreateEffectAnimTextTagUnit takes real age, integer red, integer green, integer blue, integer alpha, real fadepoint, real lifespan, boolean permanent, unit target, real z, boolean paused, string text, real height, real xvel, real yvel, boolean visible, boolean animTargetAlive, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local texttag TT_Object = CreateTextTag() call SetTextTagAge(TT_Object, age) call SetTextTagColor(TT_Object, red, green, blue, alpha) call SetTextTagFadepoint(TT_Object, fadepoint) call SetTextTagLifespan(TT_Object, lifespan) call SetTextTagPermanent(TT_Object, permanent) call SetTextTagPosUnit(TT_Object, target, z) call SetTextTagSuspended(TT_Object, paused) call SetTextTagText(TT_Object, text, height) call SetTextTagVelocity(TT_Object, xvel, yvel) call SetTextTagVisibility(TT_Object, visible) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, animTargetAlive, 0, 0, 0, gSTR_ObjectTypeTextTag, null, null, FALSE, null, null, TT_Object, null, FALSE, gSTR_TargetTypeUnit, target, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set TT_Object = null return null endfunction function CreateEffectAnimSoundLocation takes sound snd, real x, real y, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local sound SND_Object = snd call SetSoundPosition(SND_Object, x, y) call SetSoundVolume(SND_Object, 127) call StartSound(SND_Object) call KillSoundWhenDone(SND_Object) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, FALSE, 0, 0, 0, gSTR_ObjectTypeSound, null, null, FALSE, null, null, null, SND_Object, FALSE, gSTR_TargetTypeLocation, null, x, y, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) set SND_Object = null return null endfunction function CreateEffectAnimSoundUnit takes boolean isVoice, boolean animTargetAlive, sound snd, unit target, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local sound SND_Object = snd if EffectData.ValidateVoiceSound(target) then call AttachSoundToUnit(SND_Object, target) call SetSoundVolume(SND_Object, 127) call StartSound(SND_Object) call KillSoundWhenDone(SND_Object) return EffectData.Create(TRUE, gSTR_EffectTypeAnim, 0, 0, 0, gSTR_ObjectTypeSound, null, null, null, null, SND_Object, isVoice, gSTR_TargetTypeUnit, target, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, startFunc, midFunc, endFunc, durationInterval, maxCountInterval) else return 0 endif set SND_Object = null return null endfunction //Effect Manipulation Functions:// function EffectPause takes EffectData whichEffect, boolean pause returns nothing local integer INT_CountEffect = EffectData.FindEffectIndex(whichEffect) set gEFFECT[INT_CountEffect].boolOn == Not(pause) endfunction function EffectDestroy takes EffectData whichEffect returns nothing local integer INT_CountEffect = EffectData.FindEffectIndex(whichEffect) call gEFFECT[INT_CountEffect].Destroy() endfunction function EffectFindBuff takes unit taster, unit target, integer abilityId, integer level returns EffectData local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 exitwhen gEFFECT[INT_CountEffect].uCaster == caster and gEFFECT[INT_CountEffect].uTarget == target and gEFFECT[INT_CountEffect].intAbilityId == abilityId and gEFFECT[INT_CountEffect].intLevelAbilityCast == level endloop return gEFFECT[INT_CountEffect] endfunction function EffectFindBuffIndex takes unit taster, unit target, integer abilityId, integer level returns EffectData local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 exitwhen gEFFECT[INT_CountEffect].uCaster == caster and gEFFECT[INT_CountEffect].uTarget == target and gEFFECT[INT_CountEffect].intAbilityId == abilityId and gEFFECT[INT_CountEffect].intLevelAbilityCast == level endloop return INT_CountEffect endfunction //Advanced Functions:// function SpellSteal takes unit source, unit target, integer countSpell, boolean goodAllowed, boolean badAllowed returns nothing local integer INT_CountEffect local integer INT_CountSpell = countSpell local boolean BOOL_Cond if goodAllowed and badAllowed then set BOOL_Cond = gEFFECT[INT_CountEffect].uTarget == source elseif goodAllowed and not badAllowed then set BOOL_Cond gEFFECT[INT_CountEffect].uTarget == source and gEFFECT[INT_CountEffect].boolGoodBuff elseif badAllowed and not badAllowed then set BOOL_Cond gEFFECT[INT_CountEffect].uTarget == source and not gEFFECT[INT_CountEffect].boolGoodBuff endif loop set INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 if BOOL_Cond then call UnitRemoveAbility(gEFFECT[INT_CountEffect].uTarget, gEFFECT[INT_CountEffect].intBuffId) set gEFFECT[INT_CountEffect].uTarget = target call UnitAddAbility(target, gEFFECT[INT_CountEffect].intBuffId) endif exitwhen INT_CountEffect == gINT_CountEffect or BOOL_Cond endloop set INT_CountSpell = INT_CountSpell - 1 exitwhen INT_CountSpell == 0 endloop endfunction ////////================================//////// //////////////////////////////////////////////// globals private timer gTIM private constant real gR_DurationTimer = 0.10 private constant string gSTR_EffectTypeBuff = "buff" private constant string gSTR_EffectTypeAnim = "anim" private constant string gSTR_AnimTypeUnit = "unit" private constant string gSTR_AnimTypeFX = "effect" private constant string gSTR_AnimTypeLightning = "lightning" private constant string gSTR_AnimTypeTextTag = "texttag" private constant string gSTR_AnimTypeSound = "sound" private constant string gSTRI_TargetTypeUnit = "unit" private constant string gSTRI_TargetTypeLocation = "location" EffectData array gEFFECT integer gINT_CountEffect = 0 endglobals private function TimerCallback1 takes nothing returns nothing local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 if gEFFECT[INT_CountEffect].boolOn then call gEFFECT[INT_CountEffect].Execute() endif exitwhen INT_CountEffect == gINT_CountEffect endloop endfunction private function UpdateTimer takes nothing returns nothing if gINT_CountEffect == 1 then call TimerStart(gTIM, gR_DurationTimer, TRUE, function TimerCallback1) elseif gINT_CountEffect == 0 then call PauseTimer(gTIM) endif endfunction function interface StartFunc takes integer effectIndex returns nothing function interface MidFunc takes integer effectIndex returns nothing function interface EndFunc takes integer effectIndex returns nothing struct EffectData integer intDataIndex boolean boolOn string strEffectType boolean boolAnimTargetAlive integer intAbilityId integer intBuffId integer intLevelAbilityCast boolean boolGoodBuff player pOwnerCaster string strObjectType unit uObject boolean boolKillUnitObject effect fxObject lightning lightObject texttag ttObject sound sndObject boolean boolIsVoice unit uTarget real rXTarget real rYTarget real rZTarget real rITarget real rJTarget real rKTarget StartFunc startFunc MidFunc midFunc EndFunc endFunc real rDuration real rDurationInterval integer intCountInterval integer intMaxCountInterval static method Create takes boolean on, string effectType, boolean animTargetAlive, integer abilityId, integer buffId, integer level, string objectType, player ownerCaster, unit uObject, boolean killUnitObject, effect fxObject, lightning lightObject, texttag ttObject, sound sndObject, boolean isVoice, unit uTarget, real x, real y, real z, real i, real j, real k, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval returns EffectData local EffectData New = EffectData.allocate() local StartFunc NewStartFunc = startFunc local MidFunc NewMidFunc = midFunc local EndFunc NewEndFunc = endFunc set gINT_CountEffect = gINT_CountEffect + 1 set New.intEffectIndex = gINT_CountEffect set New.boolOn = on set New.strEffectType = effectType set New.boolAnimTargetAlive = animTargetAlive set New.intAbilityId = abilityId set New.intBuffId = buffId set New.intLevelAbilityCast = level set New.boolGoodBuff = (GetOwningPlayer(uTarget) == ownerCaster) set New.strObjectType = objectType set New.pOwnerCaster = ownerCaster set New.uObject = uObject set New.boolKillUnitObject = killUnitObject set New.fxObject = fxObject set New.lightObject = lightObject set New.ttObject = ttObject set New.sndObject = sndObject set New.boolIsVoice = isVoice set New.strTargetType = targetType set New.uTarget = uTarget set New.xTarget = x set New.yTarget = y set New.startFunc = NewStartFunc set New.midFunc = NewMidFunc set New.endFunc = NewEndFunc set New.rDuration = 0.00 set New.rDurationInterval = durationInterval set New.intCountInterval = 0 set New.intMaxCountInterval = maxCountInterval set gEFFECT[gINT_CountEffect] = New if effectType == gSTR_EffectTypeBuff then call UnitAddAbility(uTarget, buffId) endif call New.startFunc.evaluate(New.intEffectIndex) call UpdateTimer() return New endmethod method Destroy takes nothing returns nothing call New.endFunc.evaluate(New.intEffectIndex) if .strEffectType == gSTR_EffectTypeBuff then call UnitRemoveAbility(.uTarget, .intBuffId) else if .strObjectType == gSTR_ObjectTypeUnit then if .boolKillUnitObject then call KillUnit(.uObject) else call RemoveUnit(.uObject) endif elseif .strObjectType == gSTR_ObjectTypeFX then call DestroyEffect(.fxObject) elseif .strObjectType == gSTR_ObjectTypeLightning then call DestroyLightning(.lightObject) elseif .strObjectType == gSTR_ObjectTypeTextTag then call DestroyTextTag(.ttObject) else call StopSound(.sndObject) endif endif set .strEffectType = null set .strObjectType = null set .pOwnerCaster = null set .uObject = null set .fxObject = null set .lightObject = null set .ttObject = null set .sndObject = null set .strTargetType = null set .uTarget = null set .startFunc = null set .midFunc = null set .endFunc = null set gEFFECT[gINT_CountEffect].intEffectIndex = this.intEffectIndex set gEFFECT[this.intEffectIndex] = gEFFECT[gINT_CountEffect] set gEFFECT[gINT_CountEffect] = 0 set gINT_CountEffect = gINT_CountEffect - 1 call UpdateTimer() endmethod method Execute takes nothing returns nothing if OK TO RUN then set .rDuration = .rDuration + gR_DurationTimer if .rDuration/.rDurationInterval == 1.00 then set .intCountInterval = .intCountInterval + 1 set .rDuration = 0.00 call .midFunc.evaluate(.intEffectIndex) if .intCountInterval = .intMaxCountInterval then call .Destroy() endif endif else call .Destroy() endif endmethod static method ValidateVoiceSound takes unit target returns boolean local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 if gEFFECT[INT_CountEffect].gSTR_ObjectType == gSTR_ObjectTypeSound and gEFFECT[INT_CountEffect].boolIsVoice and gEFFECT[INT_CountEffect].uTarget == target then return FALSE endif exitwhen INT_CountEffect == gINT_CountEffect endloop return TRUE endfunction static method FindEffectIndex takes EffectData whichEffect returns indx local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 exitwhen gEFFECT[INT_CountEffect] == whichEffect endloop return INT_CountEffect endmethod endstruct endlibrary |
| 08-13-2008, 06:54 AM | #2 | |
Quote:
The performance difference is really negligible. |
| 08-13-2008, 06:56 AM | #3 |
well i wasted my time it seems |
| 08-13-2008, 10:03 AM | #4 |
You didn't waste you time. However According to Pyrogasm it needs to be improved. You won't get much support here as you saw, you may try to submit it to the resources section. There people will most likely to actually evaluate your spell and help you out. But a friendly warning, don't expect them to be kind, some of them are genius who don't know the meaning of the word "kindness" and although their intention is good, their comments will surely be mean. Meaning they will make you system go trough an intensive fire test. |
| 08-13-2008, 11:02 AM | #5 |
Well, I'll be happy to look through it as soon as you comment your code and explain a bit more detailed how it works. In general, if you want people's comments, make it as easy as possible for them to understand how your system works =) |
| 08-13-2008, 11:16 AM | #6 |
It's not that I think it needs to be improved... I think (and I'm just going to be honest here) that it's useless. Triggers firing even though they don't get past the condition is really not something to worry about at all. |
| 08-13-2008, 11:16 AM | #7 | |
Quote:
|
| 08-13-2008, 12:02 PM | #8 |
Events still fire even when the trigger is disabled. Condition evaluation is very cheap. |
| 09-17-2008, 08:24 AM | #9 |
bump. i edited the initial post. it now pertains to a different subject i don't have hte heart to spam topics... jesus |
| 09-17-2008, 09:25 AM | #10 |
You can't set variables to null after returning, and this is pretty much useless. xe is much better. |
| 09-17-2008, 09:58 AM | #11 |
im not subimitting it. and i better understand what i am making than xe. + itd would, by contingency, probably be more suited to my specific needs than xe is. i am only asking for criticism --_> will it work? |
| 09-17-2008, 04:45 PM | #12 |
JASS:function CreateEffectAnimUnit takes returns player owner, integer unitId, real x, real y, real facing, boolean killUnitObject, code startFunc, code midFunc, code endFunc, real durationInterval, integer maxCountInterval string EffectData Where's the return? And you're missing a comma between maxCountInterval and string EffectData |
| 09-18-2008, 12:11 AM | #13 |
ya i noted all the syntax errors and inconsistencies when i tried to compile it in the trigger editor. besides the syntaxes and the form, i want criticism on how the system works. |
| 09-21-2008, 09:22 AM | #14 |
BUMP: (refer to 1st post for code) changed it a bit. CRITICISM? *i tried to thought of using function interfaces/struct interfaces but i can't get them to work (im not even sure if they're applicable). JASS://////////////////////////////////////////////////////////////////////////////////////// //Effects are changes. All changes are described as an alteration of a subject's //property over time. Time is necessary because the subject cannot be one thing and //another at the same time; also, an object cannot subsequently be something from //something if at one time it was not that new something. //So we have these objects: // 1) the Subject // 2) the Cause // a) the source of the change (affector) // b) the event of the change // 3) the Nature of the change (note: qualitative effects have only 1 'instance', // quantitative effects have many degree-instances. i.e., a stun is // qualitative coz a unit is either stunned or it isnt; a mana loss is // quantative because a unit can have x mana, or x-1 mana, or x+1, mana, // and so on. // Application of qualitative effects involves 'toggling', while application // of quantitative effects involves 'adjustment'.) // a) the object // i) property changed // ii) the quantitative/qualitative change of said property (differential of change) // b) the time that elapsed during the change // //examples: //Some qualitative effects: //'hides', stuns, ownership-change, replacement, pauses, etc. //Some quantitative effects: //a vector effect: target, the moved unit; cause, the pushing/pulling unit/force; object, position; quantity, // scalars of change; time. //a damaging effect: target, the damaged unit; cause, the damaging unit, object, life; quantity, damage amount; // time, (instantaneous or differential). //a stat/property effect: target, altered unit; cause, whatever agent (most likely a unit); object, the field altered; // quantity, quantity of alteration; time, (instantaneous or differential). //////////////////////////////////////////////////////////////////////////////////////// library GeneralLibrary initializer Init globals integer gINT unit gU endglobals /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// scope EffectSystem globals //Constants// private timer gTIM private constant real gR_DurationTimer = 0.05 //General Data// private GeneralData array gEFFECT private integer gINT_CountEffect = 0 //Sub-Data Interfacing// integer array gINT_XStructId integer gINT_CountXStruct string array gSTR_FuncNameStructDestroyer endglobals //=============//General-Type Struct Start//=============// private function gTIMCallback takes nothing returns nothing local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 if gEFFECT[INT_CountEffect].boolOn then call gEFFECT[INT_CountEffect].MainExecute() endif exitwhen INT_CountEffect == gINT_CountEffect endloop endfunction private function gTIMUpdate takes nothing returns nothing if gINT_CountEffect == 1 then call TimerStart(gTIM, gR_DurationTimer, true, function gTIMCallback) elseif gINT_CountEffect == 0 then call PauseTimer(gTIM) endif endfunction struct GeneralData //-----Handlers-----// integer intEffectIndex boolean boolOn integer intTypeId string strFuncNameStart string strFuncNameInterval string strFuncNameEnd real rDuration real rDurationInterval integer intCountInterval integer intMaxCountInterval //input a value of 0 for this to create for a PERMANENT effect static method MainCreate takes integer typeId, string funcNameStart, string funcNameInterval, string funcNameEnd, real durationInterval, integer maxCountInterval returns nothing local GeneralData New = GeneralData.allocate() set gINT_CountEffect = gINT_CountEffect + 1 set New.intEffectIndex = gINT_CountEffect set New.boolOn = true set New.intTypeId = typeId set New.strFuncNameStart = funcNameStart set New.strFuncNameInterval = funcNameInterval set New.strFuncNameEnd = funcNameEnd set New.rDuration = 0.00 set New.rDurationInterval = durationInterval set New.intCountInterval = 0 set New.intMaxCountInterval = maxCountInterval set gEFFECT[gINT_CountEffect] = New call gTIMUpdate() endmethod method UpdateIndexes takes nothing returns nothing local integer INT_CountXStruct = 0 loop set INT_CountXStruct = INT_CountXStruct + 1 if gINT_XStructId[INT_CountXStruct] == .intTypeId then set gINT = .intEffectIndex call ExecuteFunc(gSTR_FuncNameStructDestroyer[INT_CountXStruct]) endif exitwhen INT_CountXStruct == gINT_CountXStruct endloop set gEFFECT[gINT_CountEffect].intEffectIndex = .intEffectIndex set gEFFECT[.intEffectIndex] = gEFFECT[gINT_CountEffect] set gEFFECT[gINT_CountEffect] = 0 set gINT_CountEffect = gINT_CountEffect - 1 endmethod method MainDestroy takes nothing returns nothing //Execute End Function// if .strFuncNameEnd != null then set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameEnd) else endif call .UpdateIndexes() endmethod method MainExecute takes nothing returns nothing if .strFuncNameStart != null and .rDuration == 0.00 and .intCountInterval == 0 then //Execute Start Function// set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameStart) endif set .rDuration = .rDuration + gR_DurationTimer if .rDuration/.rDurationInterval == 1.00 then //Execute Interval Function// if .strFuncNameInterval != null then set gINT = .intEffectIndex call ExecuteFunc(.strFuncNameInterval) endif set .intCountInterval = .intCountInterval + 1 if .intCountInterval == .intMaxCountInterval then call .MainDestroy() endif endif endmethod endstruct //=============//General-Type Struct End//=============// //=============//Sub-Type Structs Start//=============// globals private integer gINT_PauseTypeId private PauseXData array gPAUSE endglobals //Stuns pauses a unit for a duration, works in conjunction with other pauses.// //If boolStack is true then its duration will stack with those of other pauses; if it is false, //its duration will expire independently of those of other pauses. struct PauseXData boolean boolStack boolean boolPaused integer intBuffId integer intBuffLevel unit uTarget static method Create takes boolean stack, integer buffId, integer level, unit source, unit target, real duration returns nothing local PauseXData New = PauseXData.allocate() call GeneralData.MainCreate(PauseXData.typeid, "PauseStart", null, "PauseEnd", duration, 1) set New.boolStack = stack set New.boolPaused = true set New.intBuffId = buffId set New.intBuffLevel = level set New.uTarget = target set gPAUSE[gINT_CountEffect] = New endmethod method Destroy takes nothing returns nothing //Recycle instance; give to instance of highest-value index. set gPAUSE[gINT].boolStack = gPAUSE[gINT_CountEffect].boolStack set gPAUSE[gINT].boolPaused = gPAUSE[gINT_CountEffect].boolPaused set gPAUSE[gINT].intBuffId = gPAUSE[gINT_CountEffect].intBuffId set gPAUSE[gINT].intBuffLevel = gPAUSE[gINT_CountEffect].intBuffLevel set gPAUSE[gINT].uTarget = gPAUSE[gINT_CountEffect].uTarget set gPAUSE[gINT_CountEffect] = 0 endmethod static method UnpauseCheck takes integer effectIndex, unit target returns boolean local integer INT_CountEffect = 0 loop set INT_CountEffect = INT_CountEffect + 1 //First 3 conditions determine if the query gEFFECT is a gPAUSE type that is not that w/c is being checked for. //Last condition determines the desired output of this method: "Is this unit currently paused by another gPAUSE effect?". if INT_CountEffect != effectIndex and gEFFECT[INT_CountEffect].intTypeId == gINT_PauseTypeId and gPAUSE[INT_CountEffect].uTarget == target and gPAUSE[INT_CountEffect].boolPaused then return false endif exitwhen INT_CountEffect == gINT_CountEffect endloop return true endmethod endstruct //Action-ONLY Functions (no struct management here)// function PauseStart takes nothing returns nothing call PauseUnit(gPAUSE[gINT].uTarget, true) endfunction function PauseEnd takes nothing returns nothing local unit U_Target = gPAUSE[gINT].uTarget if PauseXData.UnpauseCheck(gINT, U_Target) then call PauseUnit(U_Target, false) endif set U_Target = null endfunction function PauseDestroy takes nothing returns nothing call gPAUSE[gINT].Destroy() endfunction //=============//Sub-Type Structs End//=============// public function Init takes nothing returns nothing //typeid's for reference by X-structs. set gINT_PauseTypeId = PauseXData.typeid //Initialize X-struct typeid and destroyer-function-name datas. set gINT_CountXStruct = 1 set gINT_XStructId[1] = gINT_PauseTypeId set gSTR_FuncNameStructDestroyer[1] = "PauseDestroy" //GeneralData (Constant Stuff)// set gTIM = CreateTimer() endfunction endscope /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// private function Init takes nothing returns nothing call EffectSystem_Init() endfunction endlibrary |
| 09-21-2008, 01:43 PM | #15 |
Private and public for anything that has anywhere near a generic name. ExecuteFunc is bad, you should pass interfaces instead. |
