PDA

View Full Version : [Support] Orbit - Invoker



Schm0ftie
06-27-2011, 05:42 PM
Hey guys,

some of you know that I am currently work on a hero, called
Crystal Enchanter, which is basicly a Invoker port. I have
already finished the orb system and started with working at
the abilities that can be created. Currently I want to add
the visual orbs, since they aren't visible around the hero at
the moment. I tried to use a state and refresh it every times
a new orb is set. But my problem is that a state loses his
proxy on refresh. Trying to expire the state before re applying
it seems not to work too (idea was to put the delete orbits
thing in <onexpired>. Maybe you guys have ideas how to
make it. The main problem is that I need to delete old orbits
and spawn new one, every time the player changes the orbs.

I hope someone has a good idea, else I would leave the visual
as it is know, only visible on the ability buttons and do the rest
of the abilities.

For those who want to look into the state, there is the code.



<state
name="State_Crystal_Enchanter_Orbs"
icon="ability_04/icon.tga"
allowtransfer="false"
ishidden="false"
>

<oninflict>
<printvalue label="ORBIT STATE REFRESHED" value="" />
<!-- A orb was activated, new orbs have to be spawn -->
<setaccumulator value="0" />
<setcharges a="0" />

<!-- Get current orbs -->
<pushability name="Ability_Crystal_Enchanter1" />
<setent0 entity="stack_entity" />
<pushentityproxy entity="ent0" />
<changeaccumulator entity="stack_entity" b="0" op="add" />
<setvar0 a="result" />

<pushability name="Ability_Crystal_Enchanter2" />
<setent1 entity="stack_entity" />
<pushentityproxy entity="ent1" />
<changeaccumulator entity="stack_entity" b="0" op="add" />
<setvar1 a="result" />

<pushability name="Ability_Crystal_Enchanter3" />
<setent2 entity="stack_entity" />
<pushentityproxy entity="ent2" />
<changeaccumulator entity="stack_entity" b="0" op="add" />
<setvar2 a="result" />

<evaluate a="var0" b="var1" op="add" />
<evaluate a="result" b="var2" op="add" />
<setvar3 a="result" />

<!-- Get current number of active orbs -->
<addcharges entity="ent0" count="0" />
<changeaccumulator b="result" op="add"/>
<addcharges entity="ent1" count="0" />
<changeaccumulator b="result" op="add" />
<addcharges entity="ent2" count="0" />
<changeaccumulator b="result" op="add" />

<printvalue label="Accumulator - active orbs" value="accumulator" />
<!-- ################################################# -->
<!-- Only ONE orb active, only ONE needs to be spawned -->
<!-- ################################################# -->
<compare a="accumulator" b="1" op="eq">

<!-- One orb active -->
<compare a="var0" b="1" op="eq">

<!-- Red orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="1" op="eq">

<!-- Green orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="1" op="eq">

<!-- Blue orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>
</compare>

<!-- ################################################## #### -->
<!-- Only TWO orbs are active, only TWO needs to be spawned -->
<!-- ################################################## #### -->
<compare a="accumulator" b="2" op="eq">

<!-- 1 Orb is already active, activate another one -->
<!-- Get the orb that is at position 1 -->

<compare a="var0" b="1" op="eq">

<!-- Red orb is at position 1 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="1" op="eq">

<!-- Green orb is at position 1 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="1" op="eq">

<!-- Blue orb is at position 1 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<!-- Get the orb that is at position 2 -->
<!-- Check if one orb is activated twice -->
<compare a="var3" b="3" op="eq">

<!-- 2 different orbs are active -->
<compare a="var0" b="2" op="eq">

<!-- Red Orb is at position 2 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="2" op="eq">

<!-- Green Orb is at position 2 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="2" op="eq">

<!-- Blue Orb is at position 2 -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>
</compare>

<else>

<!-- Two orbs of the same type are active -->
<compare a="var0" b="1" op="eq">

<!-- Two red orbs are active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="1" op="eq">

<!-- Two green orbs are active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="1" op="eq">

<!-- Two blue orbs are active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>
</else>
</compare>

<!-- ################################################## ###### -->
<!-- all THREE orbs are active, all THREE needs to be spawned -->
<!-- ################################################## ###### -->
<compare a="accumulator" b="3" op="eq">

<!-- Three orbs are active -->
<!-- First orb -->
<compare a="var0" b="1" op="eq">

<!-- Red orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="1" op="eq">

<!-- Green orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="1" op="eq">

<!-- Blue orb is active, spawn it -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="120"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<!-- Second orb -->
<compare a="var0" b="2" op="eq">

<!-- Red is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var1" b="2" op="eq">

<!-- Green is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var2" b="2" op="eq">

<!-- Blue is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<!-- Check if second orb is set -->
<compare a="charges" b="1" op="ne">

<!-- Second orb isn't set yet -->
<!-- IMPORTANT: Var0,Var1 and Var2 will be used here for another purpose -->
<!-- They no longer contaion the position of the first orb -->
<pushentityproxy entity="ent0" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="result" />

<pushentityproxy entity="ent1" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="result" />

<pushentityproxy entity="ent2" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="result" />

<compare a="var0" b="2" op="eq">

<!-- Red orb is at position two -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var1" b="2" op="eq">

<!-- Green orb is at position two -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<compare a="var2" b="2" op="eq">

<!-- Blue orb is at position three -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="240"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>
</compare>

<!-- Third orb -->
<setcharges a="0" />
<compare a="var0" b="3" op="eq">

<!-- Red is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var1" b="3" op="eq">

<!-- Green is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var2" b="3" op="eq">

<!-- Blue is active -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<!-- Check if third orb is set -->
<compare a="charges" b="1" op="ne">

<!-- Third orb isn't set yet -->
<!-- IMPORTANT: Var0,Var1 and Var2 will be used here for another purpose -->
<!-- They no longer contaion the position of the first orb -->
<pushentityproxy entity="ent0" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="result" />

<pushentityproxy entity="ent1" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="result" />

<pushentityproxy entity="ent2" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="result" />

<compare a="var0" b="3" op="eq">

<!-- Red orb is at position two -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var1" b="3" op="eq">

<!-- Green orb is at position two -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<compare a="var2" b="3" op="eq">

<!-- Blue orb is at position three -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
<addcharges />
</compare>

<!-- IF the 3rd orb isn't set yet it has to be 3 orbs of one type -->
<compare a="charges" b="1" op="ne">

<addcharges entity="ent0" count="0" />
<compare a="result" b="3" op="eq">

<!-- Red is active 3 times -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Red"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<addcharges entity="ent1" count="0" />
<compare a="result" b="3" op="eq">

<!-- Green is active 3 times -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Green"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>

<addcharges entity="ent2" count="0" />
<compare a="result" b="3" op="eq">

<!-- Blue is active 3 times -->
<spawnprojectile
name="Projectile_Crystal_Enchanter_Orb_Blue"
source="source_entity"
target="source_entity"
orbitstartingtheta="360"
proxy="this_proxy_entity"
pushentity="true"
/>
<setproxy entity="this_entity" target="stack_entity" />
</compare>
</compare>
</compare>
</compare>
<printdebuginfo />
</oninflict>

<onexpired>
<!-- Remove all existing orbs -->
<compare a="accumulator" b="3" op="eq">

<pushentityproxy entity="this_proxy_entity" />
<printdebuginfo />
<pushentityproxy entity="stack_entity" />
<printdebuginfo />
<kill target="stack_entity" />
<pushentityproxy entity="this_proxy_entity" />
<printdebuginfo />
<kill target="stack_entity" />
<kill target="this_proxy_entity" />
<printdebuginfo />
<printvalue label="3 PROXY" value="accumulator" />
</compare>

<else>
<compare a="accumulator" b="2" op="eq">
<printdebuginfo />
<pushentityproxy entity="this_proxy_entity" />
<printdebuginfo />
<kill target="stack_entity" />
<kill target="this_proxy_entity" />
<printvalue label="2 PROXY" value="accumulator" />
</compare>

<else>
<printdebuginfo />
<kill target="this_proxy_entity" />
<printvalue label="1 PROXY" value="accumulator" />
</else>
</else>
</onexpired>
</state>

Schm0ftie
06-28-2011, 07:25 AM
Source Code Ability:

<ability
name="Ability_Crystal_Enchanter1"

icon="icon.tga"
statuseffecttooltip=""

anim="ability_1"
casttime="0"
castactiontime="0"

maxlevel="7"
requiredlevel="1,3,5,7,9,11,13"

actiontype="target_self"
casteffecttype="Superior Magic"

manacost=""
cooldowntime="500"
cooldowntype="summon_orb"

maxcharges="3"
strength="2,4,6,8,10,12,14"
healthregenpercharge="1,2,3,4,5,6,7"

>
<onlearn>
<applystate name="State_Crystal_Enchanter1" duration="-1" pushentity="true" />
<setproxy entity="this_entity" target="stack_entity" />

<!-- Used to let other abilities access the current level of this ability -->
<setaccumulator entity="this_proxy_entity" value="1" />
</onlearn>

<onupgrade>

<!-- Used to let other abilities access the current level of this ability -->
<changeaccumulator entity="this_proxy_entity" b="1" op="add" />
</onupgrade>

<onimpact>
<expirestate target="source_entity" name="State_Crystal_Enchanter_Orbs" />
<!-- Get number of active orbs -->
<pushability name="Ability_Crystal_Enchanter2" />
<setent0 entity="stack_entity" />
<addcharges entity="ent0" count="0" />
<setvar0 a="result" />

<pushability name="Ability_Crystal_Enchanter3" />
<setent1 entity="stack_entity" />
<addcharges entity="ent1" count="0" />
<setvar1 a="result" />

<!-- Check if already 3 orbs are active -->
<evaluate a="var0" b="var1" op="add" />
<evaluate a="result" b="charges" op="add" />
<compare a="result" b="3" op="ne">

<!-- Check how many orbs are active -->
<evaluate a="var0" b="var1" op="add" />
<setvar3 a="result" b="charges" op="add" />

<compare a="var3" b="1" op="eq">

<!-- Only one orb is active -->
<!-- Is this orb already active? -->
<compare a="charges" b="1" op="eq">

<!-- This orb is active -->
<setcharges entity="this_proxy_entity" a="2" />
<printvalue label="Charges on State" value="result" />
</compare>
<else>
<setaccumulator value="2" />
</else>
<addcharges />
</compare>

<compare a="var3" b="0" op="eq">

<!-- No orb is active -->
<setaccumulator value="1" />
<addcharges />
</compare>

<compare a="var3" b="2" op="eq">
<printvalue label="Two orbs are active" value="var3" />
<!-- Two orbs are active -->
<!-- Is this orb active? -->
<compare a="charges" b="0" op="gt">
<printvalue label="Charges > 0" value="charges" />
<!-- Is this orb active once? -->
<compare a="charges" b="1" op="eq">

<!-- It is active once! -->
<setcharges entity="this_proxy_entity" a="3" />
</compare>

<else>

<!-- It is active twice! -->
<setcharges entity="this_proxy_entity" a="2" />
</else>
</compare>

<else>

<!-- It is not active -->
<setaccumulator value="3" />
</else>
<addcharges />
</compare>
</compare>

<else>

<!-- Check if this orb is already active -->
<compare a="charges" b="0" op="ne">

<!-- Store current charges in var2. -->
<!-- Check how many orbs of this type are active -->
<setvar2 a="charges" />

<!-- 1 orb active of [Q] -->
<compare a="var2" b="1" op="eq">

<!-- Compare if this orb is the oldest one -->
<!-- Store current order number in var3 -->
<setvar3 a="accumulator" />
<compare a="var3" b="1" op="eq">

<!-- var3 will be used here for other things. -->
<!-- It no longer stores the current order number! -->
<setaccumulator value="2" />
<setcharges entity="this_proxy_entity" a="3" />
<addcharges />

<changeaccumulator entity="ent0" b="0" op="add" />
<setvar2 a="result" />

<changeaccumulator entity="ent1" b="0" op="add" />
<setvar3 a="result" />

<compare a="var0" b="0" op="eq">

<!-- No orbs of [W] active -->
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="2" />
<setaccumulator entity="ent1" value="1" />
<setcharges entity="ent1" a="1" />
</compare>

<compare a="var1" b="0" op="eq">

<!-- No orbs of [E] active -->
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="2" />
<setaccumulator entity="ent0" value="1" />
<setcharges entity="ent0" a="1" />
</compare>

<compare a="var0" b="var1" op="eq">

<!-- One orb of [W] and one of [E] are active -->
<!-- Compares their order number and change it -->
<compare a="var2" b="var3" op="gt">
<setaccumulator entity="ent0" value="1" />
<setaccumulator entity="ent1" value="0" />
<setcharges entity="ent1" a="0" />
</compare>

<else>
<setaccumulator entity="ent0" value="0" />
<setaccumulator entity="ent1" value="1" />
<setcharges entity="ent0" a="0" />
</else>
</compare>

</compare>

<!-- Compare if this orb is at the middle position -->
<compare a="var3" b="2" op="eq" >

<!-- var3 will be used here for other things. -->
<!-- It no longer stores the current order number! -->
<setaccumulator value="1" />
<setcharges entity="this_proxy_entity" a="3" />

<changeaccumulator entity="ent0" b="0" op="add" />
<setvar2 a="result" />

<changeaccumulator entity="ent1" b="0" op="add" />
<setvar3 a="result" />

<compare a="var0" b="0" op="eq">

<!-- No orbs of [W] active -->
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="0" />
<setcharges entity="ent1" a="1" />
<setaccumulator entity="ent1" value="2" />
</compare>

<compare a="var1" b="0" op="eq">

<!-- No orbs of [E] active -->
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="0" />
<setcharges entity="ent0" a="1" />
<setaccumulator entity="ent0" value="2" />
</compare>

<compare a="var0" b="var1" op="eq">

<!-- One orb of [W] and one of [E] are active -->
<!-- Compares their order number and change it -->
<compare a="var2" b="var3" op="gt">
<setaccumulator entity="ent0" value="2" />
<setaccumulator entity="ent1" value="0" />
<setcharges entity="ent1" a="0" />
</compare>

<else>
<setaccumulator entity="ent0" value="0" />
<setaccumulator entity="ent1" value="2" />
<setcharges entity="ent0" a="0" />
</else>
</compare>
<addcharges />
</compare>

<!-- Compare if this orb is at the 3rd position -->
<compare a="var3" b="3" op="eq">

<!-- var3 will be used here for other things. -->
<!-- It no longer stores the current order number! -->
<setaccumulator value="2" />
<setcharges entity="this_proxy_entity" a="3" />

<changeaccumulator entity="ent0" b="0" op="add" />
<setvar2 a="result" />

<changeaccumulator entity="ent1" b="0" op="add" />
<setvar3 a="result" />

<compare a="var0" b="0" op="eq">

<!-- No orbs of [W] active -->
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="0" />
<setcharges entity="ent1" a="1" />
<setaccumulator entity="ent1" value="1" />
</compare>

<compare a="var1" b="0" op="eq">

<!-- No orbs of [E] active -->
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="0" />
<setcharges entity="ent0" a="1" />
<setaccumulator entity="ent0" value="1" />
</compare>

<compare a="var0" b="var1" op="eq">

<!-- One orb of [W] and one of [E] are active -->
<!-- Compares their order number and change it -->
<compare a="var2" b="var3" op="gt">
<setaccumulator entity="ent0" value="1" />
<setaccumulator entity="ent1" value="0" />
<setcharges entity="ent1" a="0" />
</compare>

<else>
<setaccumulator entity="ent0" value="0" />
<setaccumulator entity="ent1" value="1" />
<setcharges entity="ent0" a="0" />
</else>
</compare>
<addcharges />
</compare>
</compare>

<!-- 2 orbs active of [Q] -->
<compare a="var2" b="2" op="eq">

<!-- Check if [W] or [E] is active and get its order number -->
<!-- var2 will be used here for other things. -->
<!-- It no longer stores the current charges! -->
<changeaccumulator entity="ent0" b="0" op="add" />
<setvar2 a="result" />

<changeaccumulator entity="ent1" b="0" op="add" />
<setvar3 a="result" />

<compare a="var2" b="0" op="ne">

<!-- [W] is active -->
<compare a="var2" b="1" op="eq">

<!-- [W] is the oldest one -->
<setaccumulator entity="ent0" value="0" />
<setcharges entity="ent0" a="0" />
<setaccumulator value="1" />
<setcharges entity="this_proxy_entity" a="2" />
<addcharges />
</compare>

<compare a="var2" b="2" op="eq">

<!-- [W] is at the middle position -->
<setaccumulator entity="ent0" value="1" />
<setaccumulator value="2" />
<setcharges entity="this_proxy_entity" a="3" />
</compare>

<compare a="var2" b="3" op="eq">

<!-- [W] is at the third position -->
<setaccumulator entity="ent0" value="2" />
<setaccumulator value="1" />
<setcharges entity="this_proxy_entity" a="3" />
</compare>
</compare>

<else>

<!-- [E] is active -->
<compare a="var3" b="1" op="eq">

<!-- [E] is the oldest one -->
<setaccumulator entity="ent1" value="0" />
<setcharges entity="ent1" a="0" />
<setaccumulator value="1" />
<setcharges entity="this_proxy_entity" a="2" />
<addcharges />
</compare>

<compare a="var3" b="2" op="eq">

<!-- [E] is at the middle position -->
<setaccumulator entity="ent1" value="1" />
<setaccumulator value="2" />
<setcharges entity="this_proxy_entity" a="3" />
</compare>

<compare a="var3" b="3" op="eq">

<!-- [E] is at the third position -->
<setaccumulator entity="ent1" value="2" />
<setaccumulator value="1" />
<setcharges entity="this_proxy_entity" a="3" />
</compare>
</else>
</compare>

<!-- 3 orbs active of [Q] -->
<compare a="var2" b="3" op="eq" />

</compare>

<!-- No orbs of [Q] active -->
<else>

<!-- Store the order position of the orbs -->
<changeaccumulator entity="ent0" b="0" op="add" />
<setvar2 a="result" />

<changeaccumulator entity="ent1" b="0" op="add" />
<setvar3 a="result" />

<!-- Check if one orb type [W] or [E] is active three times -->
<compare a="var0" b="3" op="eq">

<!-- [W] is active 3 times -->
<!-- Remove 1 x [W] and add 1 x [Q] -->
<setaccumulator entity="ent0" value="1" />
<setcharges entity="ent0" a="2" />
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="2" />
<addcharges />
<setaccumulator value="3" />
</compare>

<compare a="var1" b="3" op="eq">

<!-- [E] is active 3 times -->
<!-- Remove 1 x [E] and add 1 x [Q] -->
<setaccumulator entity="ent1" value="1" />
<setcharges entity="ent1" a="2" />
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="2" />
<addcharges />
<setaccumulator value="3" />
</compare>

<compare a="var0" b="2" op="eq">

<!-- [W] is active 2 times and [E] once -->
<!-- check order position of [E] -->
<compare a="var3" b="3" op="eq">

<!-- [E] is at the last position -->
<setaccumulator entity="ent0" value="1" /> <!-- Set position of [W] to 1 -->
<removecharge entity="ent0" /> <!-- Remove one charge from [W] (one [W] is pushed out) -->
<pushentityproxy entity="ent0" /> <!-- Prepare to change the position of the 2nd [W] -->
<setcharges entity="stack_entity" a="0" /> <!-- Set position of 2nd [W] to 0 (it does not exist anymore) -->
<setaccumulator entity="ent1" value="2" /> <!-- Set position of [E] to 2 -->
<setaccumulator value="3" /> <!-- Set position of new added [Q] to 3 -->
<addcharges /> <!-- Add one charge to [Q] -->
</compare>

<compare a="var3" b="2" op="eq">
<printvalue label="E at 2" value="var3" />
<!-- [E] is at the middle position -->
<setaccumulator entity="ent0" value="2" />
<setcharges entity="ent0" a="1" />
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="0" />
<setaccumulator entity="ent1" value="1" />
<setaccumulator value="3" />
<addcharges />
</compare>

<compare a="var3" b="1" op="eq">
<printvalue label="E at 1" value="var3" />
<!-- [E] is at the first position -->
<setaccumulator entity="ent0" value="1" />
<pushentityproxy entity="ent0" />
<setcharges entity="stack_entity" a="2" />
<setcharges entity="ent1" a="0" />
<setaccumulator entity="ent1" value="0" />
<setaccumulator value="3" />
<addcharges />
</compare>
</compare>

<compare a="var1" b="2" op="eq">
<printvalue label="E x 2 - W x 1" value="var1" />
<!-- [E] is active 2 times and [W] once -->
<!-- check order position of [W] -->
<compare a="var2" b="3" op="eq">
<printvalue label="W at 3" value="var3" />
<!-- [W] is at the last position -->
<setaccumulator entity="ent1" value="1" />
<setcharges entity="ent1" a="1" />
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="0" />
<setaccumulator entity="ent0" value="2" />
<setaccumulator value="3" />
<addcharges />
</compare>

<compare a="var2" b="2" op="eq">
<printvalue label="W at 2" value="var3" />
<!-- [W] is at the middle position -->
<setaccumulator entity="ent1" value="2" />
<setcharges entity="ent1" a="1" />
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="0" />
<setaccumulator entity="ent0" value="1" />
<setaccumulator value="3" />
<addcharges />
</compare>

<compare a="var2" b="1" op="eq">
<printvalue label="W at 1" value="var3" />
<!-- [W] is at the first position -->
<setaccumulator entity="ent1" value="1" />
<pushentityproxy entity="ent1" />
<setcharges entity="stack_entity" a="2" />
<setcharges entity="ent0" a="0" />
<setaccumulator entity="ent0" value="0" />
<setaccumulator value="3" />
<addcharges />
</compare>
</compare>
</else>
</else>

<applystate name="State_Crystal_Enchanter_Orbs" target="source_entity" continuous="true" />

<!-- Debugging Area -->
<!--
<printvalue label="############# Debugging: Red #############" value="" />
<printvalue label="" value="" />
<printvalue label="Red Orbs" value="" />
<printvalue label="Active Orbs" value="charges" />
<printvalue label="Orb Position A" value="accumulator" />
<addcharges entity="this_proxy_entity" count="0" />
<printvalue label="Orb Position B" value="result" />
<printvalue label="" value="" />

<printvalue label="Green Orbs" value="" />
<addcharges entity="ent0" count="0" />
<printvalue label="Active Orbs" value="result" />
<changeaccumulator entity="ent0" b="0" op="add" />
<printvalue label="Orb Position A" value="result" />
<pushentityproxy entity="ent0" />
<addcharges entity="stack_entity" count="0" />
<printvalue label="Orb Position B" value="result" />
<printvalue label="" value="" />

<printvalue label="Blue Orbs" value="" />
<addcharges entity="ent1" count="0" />
<printvalue label="Active Orbs" value="result" />
<changeaccumulator entity="ent1" b="0" op="add" />
<printvalue label="Orb Position A" value="result" />
<pushentityproxy entity="ent1" />
<addcharges entity="stack_entity" count="0" />
<printvalue label="Orb Position B" value="result" />
<printvalue label="" value="" />
-->
</onimpact>



</ability>

tojooko
06-29-2011, 05:50 AM
Ok, so as I said my idea is based on states. Obviously we must create 3 states for orbs (let's call them State1,State2,State3).
There is maximum of 3 states same time, and we'll give them order by creating singly linked list.

So, let's focus on abilities. All that it must do is to add new state to list and remove 1st element

Some code (not full :P)

ability1.entity


<ability
name="Ability_Test1"

icon="/heroes/pyromancer/ability_03/icon.tga"
anim="ability_4"

casttime="0"
castactiontime="0"

maxlevel="4"
requiredlevel="1,2,3,4"

actiontype="target_self"
targetscheme=""

casteffecttype="SuperiorMagic"
casteffect=""

manacost="0"
cooldowntime="500"


frontqueue="true"
inheritmovement="true"
noninterrupting="true"
>

<onimpact>
<!-- Load variables -->
<pushability name="Ability_Invoke"/> <!-- 4th ability -->
<setent0 entity="stack_entity"/>
<popentity />

<pushentityproxy entity="ent0"/> <!-- get 1st state -->
<setent1 entity="stack_entity"/>

<compare a="stack_entity" b="0" op="le"> <!-- is it 1st state applied? (For some unknown reasons it must be stack_entity instead of ent1-->
<applystate name="State1" continuous="true" target="this_owner_entity" pushentity="true" stack="true"/>
<setproxy entity="ent0" target="stack_entity"/> <!-- Add new state to list -->

</compare>
<else>
<popentity /> <!-- clear stack -->
<pushentityproxy entity="ent1"/> <!-- get 2nd state from 1st state proxy-->
<setent2 entity="stack_entity"/>

<compare a="stack_entity" b="0" op="eq"> <!-- is it 2nd state applied? -->
<applystate name="State1" continuous="true" target="this_owner_entity" pushentity="true" stack="true"/>
<setproxy entity="ent1" target="stack_entity"/> <!-- Add new state to list -->

</compare>
<else>
<popentity /> <!-- clear stack -->
<pushentityproxy entity="ent2"/> <!-- get 3rd state -->
<setent3 entity="stack_entity"/>

<compare a="stack_entity" b="0" op="eq"> <!-- is it 3rd state applied? -->
<applystate name="State1" continuous="true" target="this_owner_entity" pushentity="true" stack="true"/>
<setproxy entity="ent2" target="stack_entity"/> <!-- Add new state to list -->

</compare>
<else>
<!-- Update list -->
<applystate name="State1" continuous="true" target="this_owner_entity" pushentity="true" stack="true"/>
<setproxy entity="ent3" target="stack_entity"/> <!-- Add new state to list -->
<expire entity="ent1"/> <!-- Expire 1st state -->
<setproxy entity="ent0" target="ent2"/> <!-- Save new list root (2nd state)-->

</else>
</else>
</else>
</onimpact>

</ability>
state.entity


<state
name="State1"
icon="/heroes/pyromancer/ability_03/icon.tga"
>
</state>

ablilities and states 2 and 3 are similar:)



Let's think about Invoke skill

ablility4.entity


<ability
name="Ability_Invoke"

icon="icon.tga"
anim="ability_4"
casttime="0"
castactiontime="0"
maxlevel="4"
requiredlevel="1,2,3,4"

actiontype="target_self"
targetscheme=""

casteffecttype="SuperiorMagic"
casteffect=""

manacost="0"
cooldowntime="500"

frontqueue="true"
inheritmovement="true"
noninterrupting="true"
>
<onimpact>
<compare a="proxy_entity" b="0" op="eq">
<invalidate /> <!-- List is not full - cancel casting-->
</compare>

<pushentityproxy entity="proxy_entity"/> <!-- get 2nd state -->
<setent0 entity="stack_entity"/>

<compare a="stack_entity" b="0" op="eq">
<invalidate /> <!-- List is not full - cancel casting-->
</compare>

<pushentityproxy entity="ent0"/> <!-- get 3rd state -->
<setent1 entity="stack_entity"/>

<compare a="stack_entity" b="0" op="eq">
<invalidate /> <!-- List is not full - cancel casting-->
</compare>

<!-- This [art s not finished yet... thinking about some better way to do it -->
<entitytype target="proxy_entity" type="State1">
<!-- 1st state is State1-->
<entitytype target="ent0" type="State1">
<!-- 2nd state is State1-->
</entitytype>
<else><entitytype target="proxy_entity" type="State2">
<!-- 2nd state is State2-->
</entitytype>
<else>
<!-- 2nd state is State3-->
</else></else>
</entitytype>

<else> <entitytype target="proxy_entity" type="State2">
<!-- 1st state is State2-->
</entitytype>

<else>
<!-- 1st state is State3-->
</else></else>
</onimpact>
</ability>