Schm0ftie
06-10-2011, 07:15 AM
I guess a lot of us know the old method to let players
vote for different game settings in custom maps in
warcraft 3.
For example how much kills are required to win the game
or how long the game will go.
I am trying to create such a method into my map.
What I want:
People are selecting their favorite option by sending their
hero next to the according area (represented by a gadget).
After all players did vote or the time to vote expire the game
will evaluate and set up the settings. Game starts...
What I did:
I have created a gadget for game option A, this gadget has
one passive ability, which is a aura that counts how much
players decided to move next to this gadget (vote). So
it stores the votes for itself.
Used: 1 x gadget, 1 x ability, 1 x state
The same for game option B and C.
Now I made a main game setting gadget. It's task is to
wait until the voting time expires or all players have voted.
After that it compares the number of votes for each option
and set the option with the most votes as the used. Now
the heroes will be ported into the "gaming zone".
So thats the idea behind. Thats the code for it.
CODE
Game Option A
Gadget_Game_Setting_A
<gadget
name="Game_Setting_A"
icon="/items/powerups/damage/icon.tga"
portrait="/items/powerups/damage/icon.tga"
model="/items/powerups/damage/model.mdf"
skin=""
passiveeffect="/items/powerups/damage/effects/passive.effect"
spawneffect="/items/powerups/damage/effects/spawn.effect"
respawneffect=""
selectsound=""
orderconfirmedsound=""
preglobalscale="1.7"
modelscale="1"
effectscale="0.9"
boundsheight="32"
boundsradius="16"
selectionradius="64"
targetoffset="0 0 64"
maxhealth="75"
immunity="DefuseKitImmunity"
attacktype="none"
combattype="Ranged"
corpsetime="300"
corpsefadetime="0"
deathtime="0"
prefertouch="true"
unitwalking="true"
drawonmap="false"
invulnerable="true"
inventory0="Ability_Game_Setting_A"
>
</gadget>
Ability_Game_Setting_A
<ability
name="Ability_Game_Setting_A"
statuseffecttooltip=""
icon=""
maxlevel="1"
baselevel="1"
actiontype="passive"
passiveeffect=""
maxcharges="10"
initialcharges="0"
>
<aura name="State_Game_Setting_A" radius="300" continuous="true" targetscheme="all_heroes" ignoreinvulnerable="true" />
</ability>
State_Game_Setting_A
<state
name="State_Game_Setting_A"
duration="3000"
stunned="true"
>
<oninflict>
<addcharges entity="source_entity" count="1"/>
</oninflict>
</state>
Game Settings
Gadget_Game_Settings
<gadget
name="Gadget_Game_Settings"
model=""
canattack="false"
canrotate="false"
drawonmap="false"
hoveronmap="false"
icon=""
immunity="DefuseKitImmunity"
invisible="true"
invulnerable="true"
isselectable="false"
inventory0="Ability_Game_Settings"
>
</gadget>
Ability_Game_Settings
<ability
name="Ability_Game_Settings"
statuseffecttooltip=""
icon=""
maxlevel="1"
baselevel="1"
actiontype="passive"
passiveeffect=""
maxcharges="30"
invulnerable="true"
>
<onlearn>
<setaccumulator entity="this_entity" value="-1" />
<activatemodifierkey entity="this_entity" name="start_vote" />
</onlearn>
<modifier key="start_vote" modpriority="100">
<aura name="State_Ability_Game_Settings_Timer" radius="300" targetscheme="self" ignoreinvulnerable="true" />
<aura name="State_Ability_Game_Settings_Counter" radius="3000" targetscheme="all_heroes" ignoreinvulnerable="true" />
<onframe>
<pushentitybyname name="Game_Setting_A" />
<pushability source="stack_entity" name="Ability_Game_Setting_A" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="var0" b="result" op="add" />
<pushentitybyname name="Game_Setting_B" />
<pushability source="stack_entity" name="Ability_Game_Setting_B" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="var1" b="result" op="add" />
<pushentitybyname name="Game_Setting_C" />
<pushability source="stack_entity" name="Ability_Game_Setting_C" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="var2" b="result" op="add" />
<setvar3 a="var3" b="0" op="mul" />
<setvar3 a="var0" b="var1" op="add" />
<setvar3 a="var3" b="var2" op="add" />
<compare a="var3" b="accumulator" op="eq" >
<activatemodifierkey entity="this_entity" name="all_voted" />
<applystate name="State_Ability_Game_Settings_All_Voted" target="source_entity" continuous="true" />
</compare>
<compare a="charges" b="30" op="eq" >
<activatemodifierkey entity="this_entity" name="all_voted" />
<applystate name="State_Ability_Game_Settings_All_Voted" target="source_entity" continuous="true" />
</compare>
</onframe>
</modifier>
<modifier key="all_voted" modpriority="100">
<onframe/>
</modifier>
</ability>
State_Ability_Game_Settings_Counter
<state
name="State_Ability_Game_Settings_Counter"
duration="1000"
>
<oninflict>
<changeaccumulator entity="source_entity" b="1" op="add"/>
</oninflict>
</state>
State_Ability_Game_Settings_Timer
<state
name="State_Ability_Game_Settings_Timer"
impactinterval="1000"
maxtotalimpacts="30"
maximpactspertarget="30"
>
<onimpact>
<addcharges entity="source_entity" count="1"/>
</onimpact>
</state>
State_Ability_Game_Settings_All_Voted
<state
name="State_Ability_Game_Settings_All_Voted"
>
<oninflict>
<setaccumulator entity="this_entity" value="0" />
<testnearby radius="3000" targetscheme="all_heroes" ignoreinvulnerable="true" />
<setvar3 a="result" b="var3" op="add" />
<pushentitybyname name="Game_Setting_A" />
<pushability source="stack_entity" name="Ability_Game_Setting_A" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="var0" b="result" op="add" />
<pushentitybyname name="Game_Setting_B" />
<pushability source="stack_entity" name="Ability_Game_Setting_B" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="var1" b="result" op="add" />
<pushentitybyname name="Game_Setting_C" />
<pushability source="stack_entity" name="Ability_Game_Setting_C" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="var2" b="result" op="add" />
<compare a="var0" b="var1" op="gt" >
<changeaccumulator b="var0" op="add" />
</compare>
<else>
<changeaccumulator b="var1" op="add" />
</else>
<compare a="var2" b="accumulator" op="gt" >
<setaccumulator value="var0" />
</compare>
<pushentitybyname name="Hellbourne_Base" />
<pushability source="stack_entity" name="Ability_Lives_Left" />
<setcharges entity="stack_entity" a="accumulator" b="charges" op="add" />
<pushentitybyname name="Legion_Base" />
<pushability source="stack_entity" name="Ability_Lives_Left" />
<setcharges entity="stack_entity" a="accumulator" b="charges" op="add" />
<areaofeffect
radius="3000"
effecttype=""
targetscheme="all_heroes"
targetselection="all"
global="true"
ignoreinvulnerable="true"
>
<compare a="target_team" b="1" op="eq">
<setent0 name="Rune_1" />
<teleport target="ent0" source="target_entity" />
</compare>
<else>
<setent0 name="Rune_2" />
<teleport target="ent0" source="target_entity" />
</else>
</areaofeffect>
</oninflict>
</state>
Now, at the moment it does not work. Even the States of the Auras do
apply to the heroes. I am confused so I decided to ask the forums if this
is good way to implement such things, if it should/could be done in another
even better way and to ask what am I doing wrong =)
I hope it is not to much code and that I did not fail hard ;D
vote for different game settings in custom maps in
warcraft 3.
For example how much kills are required to win the game
or how long the game will go.
I am trying to create such a method into my map.
What I want:
People are selecting their favorite option by sending their
hero next to the according area (represented by a gadget).
After all players did vote or the time to vote expire the game
will evaluate and set up the settings. Game starts...
What I did:
I have created a gadget for game option A, this gadget has
one passive ability, which is a aura that counts how much
players decided to move next to this gadget (vote). So
it stores the votes for itself.
Used: 1 x gadget, 1 x ability, 1 x state
The same for game option B and C.
Now I made a main game setting gadget. It's task is to
wait until the voting time expires or all players have voted.
After that it compares the number of votes for each option
and set the option with the most votes as the used. Now
the heroes will be ported into the "gaming zone".
So thats the idea behind. Thats the code for it.
CODE
Game Option A
Gadget_Game_Setting_A
<gadget
name="Game_Setting_A"
icon="/items/powerups/damage/icon.tga"
portrait="/items/powerups/damage/icon.tga"
model="/items/powerups/damage/model.mdf"
skin=""
passiveeffect="/items/powerups/damage/effects/passive.effect"
spawneffect="/items/powerups/damage/effects/spawn.effect"
respawneffect=""
selectsound=""
orderconfirmedsound=""
preglobalscale="1.7"
modelscale="1"
effectscale="0.9"
boundsheight="32"
boundsradius="16"
selectionradius="64"
targetoffset="0 0 64"
maxhealth="75"
immunity="DefuseKitImmunity"
attacktype="none"
combattype="Ranged"
corpsetime="300"
corpsefadetime="0"
deathtime="0"
prefertouch="true"
unitwalking="true"
drawonmap="false"
invulnerable="true"
inventory0="Ability_Game_Setting_A"
>
</gadget>
Ability_Game_Setting_A
<ability
name="Ability_Game_Setting_A"
statuseffecttooltip=""
icon=""
maxlevel="1"
baselevel="1"
actiontype="passive"
passiveeffect=""
maxcharges="10"
initialcharges="0"
>
<aura name="State_Game_Setting_A" radius="300" continuous="true" targetscheme="all_heroes" ignoreinvulnerable="true" />
</ability>
State_Game_Setting_A
<state
name="State_Game_Setting_A"
duration="3000"
stunned="true"
>
<oninflict>
<addcharges entity="source_entity" count="1"/>
</oninflict>
</state>
Game Settings
Gadget_Game_Settings
<gadget
name="Gadget_Game_Settings"
model=""
canattack="false"
canrotate="false"
drawonmap="false"
hoveronmap="false"
icon=""
immunity="DefuseKitImmunity"
invisible="true"
invulnerable="true"
isselectable="false"
inventory0="Ability_Game_Settings"
>
</gadget>
Ability_Game_Settings
<ability
name="Ability_Game_Settings"
statuseffecttooltip=""
icon=""
maxlevel="1"
baselevel="1"
actiontype="passive"
passiveeffect=""
maxcharges="30"
invulnerable="true"
>
<onlearn>
<setaccumulator entity="this_entity" value="-1" />
<activatemodifierkey entity="this_entity" name="start_vote" />
</onlearn>
<modifier key="start_vote" modpriority="100">
<aura name="State_Ability_Game_Settings_Timer" radius="300" targetscheme="self" ignoreinvulnerable="true" />
<aura name="State_Ability_Game_Settings_Counter" radius="3000" targetscheme="all_heroes" ignoreinvulnerable="true" />
<onframe>
<pushentitybyname name="Game_Setting_A" />
<pushability source="stack_entity" name="Ability_Game_Setting_A" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="var0" b="result" op="add" />
<pushentitybyname name="Game_Setting_B" />
<pushability source="stack_entity" name="Ability_Game_Setting_B" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="var1" b="result" op="add" />
<pushentitybyname name="Game_Setting_C" />
<pushability source="stack_entity" name="Ability_Game_Setting_C" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="var2" b="result" op="add" />
<setvar3 a="var3" b="0" op="mul" />
<setvar3 a="var0" b="var1" op="add" />
<setvar3 a="var3" b="var2" op="add" />
<compare a="var3" b="accumulator" op="eq" >
<activatemodifierkey entity="this_entity" name="all_voted" />
<applystate name="State_Ability_Game_Settings_All_Voted" target="source_entity" continuous="true" />
</compare>
<compare a="charges" b="30" op="eq" >
<activatemodifierkey entity="this_entity" name="all_voted" />
<applystate name="State_Ability_Game_Settings_All_Voted" target="source_entity" continuous="true" />
</compare>
</onframe>
</modifier>
<modifier key="all_voted" modpriority="100">
<onframe/>
</modifier>
</ability>
State_Ability_Game_Settings_Counter
<state
name="State_Ability_Game_Settings_Counter"
duration="1000"
>
<oninflict>
<changeaccumulator entity="source_entity" b="1" op="add"/>
</oninflict>
</state>
State_Ability_Game_Settings_Timer
<state
name="State_Ability_Game_Settings_Timer"
impactinterval="1000"
maxtotalimpacts="30"
maximpactspertarget="30"
>
<onimpact>
<addcharges entity="source_entity" count="1"/>
</onimpact>
</state>
State_Ability_Game_Settings_All_Voted
<state
name="State_Ability_Game_Settings_All_Voted"
>
<oninflict>
<setaccumulator entity="this_entity" value="0" />
<testnearby radius="3000" targetscheme="all_heroes" ignoreinvulnerable="true" />
<setvar3 a="result" b="var3" op="add" />
<pushentitybyname name="Game_Setting_A" />
<pushability source="stack_entity" name="Ability_Game_Setting_A" />
<addcharges entity="stack_entity" count="0" />
<setvar0 a="var0" b="result" op="add" />
<pushentitybyname name="Game_Setting_B" />
<pushability source="stack_entity" name="Ability_Game_Setting_B" />
<addcharges entity="stack_entity" count="0" />
<setvar1 a="var1" b="result" op="add" />
<pushentitybyname name="Game_Setting_C" />
<pushability source="stack_entity" name="Ability_Game_Setting_C" />
<addcharges entity="stack_entity" count="0" />
<setvar2 a="var2" b="result" op="add" />
<compare a="var0" b="var1" op="gt" >
<changeaccumulator b="var0" op="add" />
</compare>
<else>
<changeaccumulator b="var1" op="add" />
</else>
<compare a="var2" b="accumulator" op="gt" >
<setaccumulator value="var0" />
</compare>
<pushentitybyname name="Hellbourne_Base" />
<pushability source="stack_entity" name="Ability_Lives_Left" />
<setcharges entity="stack_entity" a="accumulator" b="charges" op="add" />
<pushentitybyname name="Legion_Base" />
<pushability source="stack_entity" name="Ability_Lives_Left" />
<setcharges entity="stack_entity" a="accumulator" b="charges" op="add" />
<areaofeffect
radius="3000"
effecttype=""
targetscheme="all_heroes"
targetselection="all"
global="true"
ignoreinvulnerable="true"
>
<compare a="target_team" b="1" op="eq">
<setent0 name="Rune_1" />
<teleport target="ent0" source="target_entity" />
</compare>
<else>
<setent0 name="Rune_2" />
<teleport target="ent0" source="target_entity" />
</else>
</areaofeffect>
</oninflict>
</state>
Now, at the moment it does not work. Even the States of the Auras do
apply to the heroes. I am confused so I decided to ask the forums if this
is good way to implement such things, if it should/could be done in another
even better way and to ask what am I doing wrong =)
I hope it is not to much code and that I did not fail hard ;D