I'm converting this into a struct'ed spell. This works as is but could be better.
Heads up from the first post. I'll probably end up doing alot of double posts.
Edit: I'm going to convert the below into structs. I haven't done so yet.
I will start by analyzing the spell that I want. The intention is to create a mine that blows up based on the ability clicked. I have 5 different mines. Any player can use it so it needs to be fully MUI and PUI.
All mines have the same actions with some slight differences that can be allowed for with "if/thens" or some other way. The action is as follows:
1. player clicks 1 of 5 mine abilities
2. Mine is created
2a. Mine is activated after a few seconds to allow the triggering unit to move away.
3. Mine will blow up after a certain amount of time - irrespective of type.
3a. Mine can be destroyed and will blow up.
3b. If a hero comes near the mine it will blow up.
4a. Mine Options. Proximity blows up at any hero approach. Homing mine will move slowly towards the nearest hero(including self). Friend or Foe will not blow up at Friendly approach (beware of enemy coming close at this time.) Stealth will be invisible. Acid has extreme damage.
5. Kills need to be counted from Mine kills, but not when a mine destroys another mine. Kills only get counted on heros, so this might not come into the equation.
First Question: Am I being too complicated?
Heads up from the first post. I'll probably end up doing alot of double posts.
Edit: I'm going to convert the below into structs. I haven't done so yet.
JASS:
//-------Mine Spells Integer Block
constant function ProxRawCode takes nothing returns integer
return 039;A00Z039; //Proximity Mine Spell
endfunction
constant function FoFRawCode takes nothing returns integer
return 039;A011039; //FoF Mine Spell
endfunction
constant function HomeRawCode takes nothing returns integer
return 039;A012039; //Homing Mine Spell
endfunction
constant function StealthRawCode takes nothing returns integer
return 039;A014039; //Stealth Mine Spell
endfunction
constant function AcidRawCode takes nothing returns integer
return 039;A015039; //Acid Mine Spell
endfunction
function Trig_CreateProximityMineJass2_Conditions takes nothing returns boolean
if ((GetSpellAbilityId()==ProxRawCode())) then
set udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 1
return GetSpellAbilityId()==ProxRawCode()
endif
if ((GetSpellAbilityId()==FoFRawCode())) then
set udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 2
return GetSpellAbilityId() == FoFRawCode()
endif
if ((GetSpellAbilityId()==HomeRawCode())) then
set udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 3
return GetSpellAbilityId()==HomeRawCode()
endif
if ((GetSpellAbilityId()==StealthRawCode())) then
set udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 4
return GetSpellAbilityId()==StealthRawCode()
endif
if ((GetSpellAbilityId()==AcidRawCode())) then
set udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 5
return GetSpellAbilityId()==AcidRawCode()
endif
return false
endfunction
//--------Mine Units
function MineID takes nothing returns integer
if (udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]) == 1 then
return 039;n003039; //Proximity Mine Spell
endif
if (udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]) == 2 then
return 039;n005039; //FoF Mine Spell
endif
if (udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]) == 3 then
return 039;n002039; //Homing Mine Spell
endif
if (udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]) == 4 then
return 039;n000039; //Stealth Mine Spell
endif
if (udg_LastMine[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]) == 5 then
return 039;n004039; //Acid Mine Spell
endif
return 0
endfunction
//-------Generic Mine stuff
constant function MineFuse takes nothing returns real
return 6.
endfunction
constant function MineBlastRadius takes nothing returns real
return 200. //Mine Blast Radius
endfunction
constant function MineDamage takes nothing returns real
return 300. //Proximity Mine Damage
endfunction
function Trig_CreateProximityMineJass2_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local real CasterX = GetUnitX(Caster)
local real CasterY = GetUnitY(Caster)
local real CasterFace = GetUnitFacing(Caster)
local unit Mine
local unit Explosion
set Mine = CreateUnit(GetOwningPlayer(Caster), MineID(), CasterX, CasterY, bj_UNIT_FACING)
call UnitApplyTimedLife(Mine ,039;BTLF039;, MineFuse())
call TriggerSleepAction(MineFuse())
set Explosion = CreateUnit(GetOwningPlayer(Caster),039;h00Q039;,GetUnitX(Mine),GetUnitY(Mine),bj_UNIT_FACING)
call UnitDamagePoint(Mine, 0, MineBlastRadius(), GetUnitX(Mine), GetUnitY(Mine), MineDamage(), true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitApplyTimedLife(Explosion, 039;BTLF039;, 2)
set Caster = null
set Mine = null
set Explosion = null
endfunction
//===========================================================================
function InitTrig_CreateProximityMineJass2 takes nothing returns nothing
set gg_trg_CreateProximityMineJass2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CreateProximityMineJass2, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_CreateProximityMineJass2, Condition( function Trig_CreateProximityMineJass2_Conditions ) )
call TriggerAddAction( gg_trg_CreateProximityMineJass2, function Trig_CreateProximityMineJass2_Actions )
endfunction
I will start by analyzing the spell that I want. The intention is to create a mine that blows up based on the ability clicked. I have 5 different mines. Any player can use it so it needs to be fully MUI and PUI.
All mines have the same actions with some slight differences that can be allowed for with "if/thens" or some other way. The action is as follows:
1. player clicks 1 of 5 mine abilities
2. Mine is created
2a. Mine is activated after a few seconds to allow the triggering unit to move away.
3. Mine will blow up after a certain amount of time - irrespective of type.
3a. Mine can be destroyed and will blow up.
3b. If a hero comes near the mine it will blow up.
4a. Mine Options. Proximity blows up at any hero approach. Homing mine will move slowly towards the nearest hero(including self). Friend or Foe will not blow up at Friendly approach (beware of enemy coming close at this time.) Stealth will be invisible. Acid has extreme damage.
5. Kills need to be counted from Mine kills, but not when a mine destroys another mine. Kills only get counted on heros, so this might not come into the equation.
First Question: Am I being too complicated?