| 02-11-2009, 10:48 PM | #1 |
hi guys, here are 3 spells I made. I intend to make a spell pack of them, because they are all fairly simple spells, it wouldn't be a good idea to submit them alone, so I will just place them together and voilá =D I use most stuff Anitarf uses: ADamage, ABuff, xebasic and xedamage. I also use TimedEffects from Moyack, it was approved like two days ago, and I am probably the first guy submitting spells with it =P I also have BloodBound and WolfStrike in versions with IDDS, if anyone is interested. My main idea is not to make a super spell pack, but to show people (and hopefully convince them) that scripts made by other people can be great when placed together: This is from an item, so it has no levels://=========================================================================== //Spell from an item belonging to the Chaos Orc Race. When attacking an enemy //unit it gives the caster a chance of doing to it multiple effects, depending //on the type of the unit. // //@author Flame_Phoenix // //Requires ABuff, ADamage, TimedEffects, xebasic and xedamage // //@credits //- My first teacher of vJASS: Blue_Jeans //- All other people I forgot or ignored // //@version 1.1 //=========================================================================== scope MultiOrb initializer Init //=========================================================================== //=============================SETUP START=================================== //=========================================================================== globals private constant integer DUM_ID = 'h01H' private constant real CHANCE = .1 private constant integer ITEM_ID = 'I00C' private constant integer FREEZE_ID = 'A03U' private constant string FREEZE_ORD = "thunderbolt" private constant integer RUST_ID = 'A00T' private constant real RUST_DUR = 15. private constant real DAM_EXTRA = 100. private constant string HEAL_EFF = "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl" endglobals private function setupDamageOptions takes xedamage d returns nothing set d.dtype = DAMAGE_TYPE_NORMAL set d.atype = ATTACK_TYPE_HERO endfunction //=========================================================================== //=============================SETUP END===================================== //=========================================================================== globals public aBuffType id = 0 private xedamage damageOptions endglobals private function Conditions takes nothing returns boolean return GetRandomReal(0, 1) <= CHANCE and IsUnitType(GetAttacker(), UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(GetAttacker(), ITEM_ID) > 0 endfunction //=========================================================================== private function Create takes aBuff eventBuff returns nothing call UnitAddAbility(eventBuff.target.u, RUST_ID) endfunction //=========================================================================== private function Cleanup takes aBuff eventBuff returns nothing call UnitRemoveAbility(eventBuff.target.u, RUST_ID) endfunction //=========================================================================== private function Actions takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing local unit vic = damagedUnit local unit att = damageSource if GetRandomReal(0, 1) <= CHANCE and IsUnitType(att, UNIT_TYPE_HERO) and GetInventoryIndexOfItemTypeBJ(att, ITEM_ID) > 0 then if (damageOptions.isInUse()==false) then if IsUnitType(vic, UNIT_TYPE_STRUCTURE) == true then set bj_lastCreatedUnit = CreateUnit( GetOwningPlayer(att), DUM_ID, GetUnitX(vic), GetUnitY(vic), 0) call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 3.00) call UnitAddAbility(bj_lastCreatedUnit, FREEZE_ID) call IssueTargetOrder(bj_lastCreatedUnit, FREEZE_ORD, vic) elseif IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == true then //give it the slow buff =D call ABuffApply(id, vic, att, RUST_DUR, 1, 0) elseif IsUnitType(vic, UNIT_TYPE_STRUCTURE) == false and IsUnitType(vic, UNIT_TYPE_MECHANICAL) == false then call StartTimedEffect(AddSpecialEffectTarget(HEAL_EFF, att, "chest"), 2.) //here we cause the damage! call damageOptions.damageTarget(att, vic, DAM_EXTRA) call SetWidgetLife(att, GetWidgetLife(att) + damage) //call SetUnitState(att, UNIT_STATE_LIFE, (GetUnitState(att, UNIT_STATE_MAX_LIFE)*RMaxBJ(0, GetRandomReal(5.00, 10.00))*0.01) + GetWidgetLife(att)) endif endif endif //nulling stuff set vic = null set att = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger MultiOrbTrg = CreateTrigger() local integer index = 0 loop exitwhen index == 16 call TriggerRegisterPlayerUnitEvent(MultiOrbTrg, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null) set index = index + 1 endloop call ADamage_AddResponse( ADamage_Response.Actions ) //setting our globals set id = aBuffType.create() //setting Abuff set id.eventCreate = ABuffEvent_Create.Create set id.eventCleanup = ABuffEvent_Cleanup.Cleanup // Initializing the damage options: set damageOptions=xedamage.create() // first instanciate a xeobject. call setupDamageOptions(damageOptions) // now call the function we saw before. //Preloading effects call Preload(HEAL_EFF) endfunction endscope WolfStrike version with ADamage://=========================================================================== //A JESP spell that causes the attacker to deal extra damage to an enemy unit //on an attack. Nearby allied units are then healed the the damaged caused. // //@author Flame_Phoenix // //Requires Adamage, xebasic and xedamage // //@version 1.1 //=========================================================================== scope WolfStrike initializer Init //=========================================================================== //=============================SETUP START=================================== //=========================================================================== globals private constant integer AID = 'A023' //rw of the hero ability private constant string ALLY_EFFECT = "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" //heal effect that will appear on healed units private constant string ENEMY_EFFECT = "Objects\\Spawnmodels\\Other\\BeastmasterBlood\\BeastmasterBlood.mdl" //Damage effect that will appear on damage units endglobals private function Radius takes integer level returns real //the radius of the heal return level * 200. endfunction private function HealTargets takes unit attacker, unit target returns boolean //the targets that will be healed with the damage caused return IsUnitAlly(target, GetOwningPlayer(attacker)) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false) and (GetWidgetLife(target) > 0.405) endfunction private function Chances takes integer level returns real //the chances the caster has of causing extra damage return level * 0.1 endfunction private function Damage takes real dam, integer level returns real //the extra damage caused return dam * (level + 0.5) endfunction private function setupDamageOptions takes xedamage d returns nothing set d.dtype = DAMAGE_TYPE_NORMAL set d.atype = ATTACK_TYPE_NORMAL endfunction //=========================================================================== //=============================SETUP END===================================== //=========================================================================== globals private group g private boolexpr b private unit tmpAtt private xedamage damageOptions endglobals //=========================================================================== private function Targets takes nothing returns boolean return HealTargets(tmpAtt, GetFilterUnit()) endfunction //=========================================================================== private function Actions takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing local unit att = damageSource //the attacker local unit vic = damagedUnit //the victim local integer lv = GetUnitAbilityLevel(att, AID) //level of the ability local texttag t = CreateTextTag() //the nice textag local unit f if GetRandomReal(0, 1) <= Chances(GetUnitAbilityLevel(att, AID)) then if (damageOptions.isInUse()==false) then //Let's make the unit look as if it is taking fire, how? Let's make a fireball effect explode on them: call DestroyEffect( AddSpecialEffectTarget("Abilities\\Weapons\\RedDragonBreath\\RedDragonMissile.mdl",vic, "origin") ) // We know it is a valid target, let's damage it? // we are retrieving the level from the struct's members, and it is used in // a simple damage formula, for every level the damage increases by 25. call damageOptions.damageTarget(att , vic, Damage(damage, lv)) //call UnitDamageTarget(att, vic, Damage(damage, lv), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null) call DestroyEffect(AddSpecialEffect(ENEMY_EFFECT, GetUnitX(vic), GetUnitY(vic))) set tmpAtt = att call GroupEnumUnitsInRange(g, GetUnitX(att), GetUnitY(att), Radius(lv), b) loop set f = FirstOfGroup(g) exitwhen(f == null) call GroupRemoveUnit(g, f) call SetWidgetLife(f, GetWidgetLife(f) + Damage(damage, lv)) call DestroyEffect(AddSpecialEffect(ALLY_EFFECT, GetUnitX(f), GetUnitY(f))) endloop call SetTextTagText(t, I2S(R2I(Damage(damage, lv)))+"!", 0.024) call SetTextTagPos(t, GetUnitX(att), GetUnitY(att), 0.00) call SetTextTagColor(t, 255, 0, 0, 255) call SetTextTagVelocity(t, 0, 0.04) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2) call SetTextTagLifespan(t, 5) call SetTextTagPermanent(t, false) endif endif set t = null set att = null set vic = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger WolfStrikeTrg = CreateTrigger( ) call ADamage_AddResponse( ADamage_Response.Actions ) // Initializing the damage options: set damageOptions=xedamage.create() // first instanciate a xeobject. call setupDamageOptions(damageOptions) // now call the function we saw before. //setting globals set g = CreateGroup() set b = Condition(function Targets) //Preloading effects call Preload(ALLY_EFFECT) call Preload(ENEMY_EFFECT) endfunction endscope BloodBound, version with ADamage://=========================================================================== //Cause the attacker to deal extra damage on each attack. The extra amount //of damage is the number of dwarf units near the attaking unit multiplied //by a value. // //Requires ADamage, xebasic and xedamage // //@author Flame_Phoenix // //@credits //- My first teacher of vJASS: Blue_Jeans //- All other people I forgot or ignored // //@version 1.1 //=========================================================================== scope BloodBound initializer Init //=========================================================================== //=============================SETUP START=================================== //=========================================================================== globals private constant integer AID = 'A029' endglobals private constant function Radius takes integer level returns real return 300. * level endfunction private function DwarfUnits takes unit attacker, unit filter returns boolean return IsUnitAlly(filter, GetOwningPlayer(attacker)) and ((GetUnitTypeId(filter) == 'H015') or (GetUnitTypeId(filter) == 'H013') or (GetUnitTypeId(filter) == 'H016') or (GetUnitTypeId(filter) == 'Hmkg') or (GetUnitTypeId(filter) == 'hmtm') or (GetUnitTypeId(filter) == 'hgry') or (GetUnitTypeId(filter) == 'hrif')) and (filter != attacker) endfunction private constant function extraDamage takes real damage, integer level, integer nearbyAllies returns real return damage + (level * nearbyAllies) endfunction private function Text takes real damage, integer level, integer nearbyAllies returns string if nearbyAllies != 0 then return "+ " + I2S(level * nearbyAllies) + "!" else return "" endif endfunction private function setupDamageOptions takes xedamage d returns nothing set d.dtype = DAMAGE_TYPE_NORMAL set d.atype = ATTACK_TYPE_HERO endfunction //=========================================================================== //=============================SETUP END===================================== //=========================================================================== globals private group g private boolexpr b private unit tmpAtt private xedamage damageOptions endglobals //=========================================================================== private function Targs takes nothing returns boolean return DwarfUnits(tmpAtt, GetFilterUnit()) endfunction //=========================================================================== private function Actions takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing local unit attacker = damageSource local unit victim = damagedUnit local integer lv = GetUnitAbilityLevel(attacker, AID) local texttag t = CreateTextTag() local integer nearbyAllies = 0 local unit f if (GetUnitAbilityLevel(attacker, AID) > 0) then if (damageOptions.isInUse()==false) then //here we count the number of units near the attacker set tmpAtt = attacker call GroupEnumUnitsInRange(g, GetUnitX(attacker), GetUnitY(attacker), Radius(lv), b) loop set f = FirstOfGroup(g) exitwhen(f == null) call GroupRemoveUnit(g, f) set nearbyAllies = nearbyAllies + 1 endloop //here we cause the damage! call damageOptions.damageTarget(attacker, victim, extraDamage(damage, lv, nearbyAllies)) //now the textag call SetTextTagText(t, Text(damage, lv, nearbyAllies), 0.024) call SetTextTagPos(t, GetUnitX(attacker), GetUnitY(attacker), 0.00) call SetTextTagColor(t, 0, 100, 255, 255) call SetTextTagVelocity(t, 0, 0.04) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2) call SetTextTagLifespan(t, 5) call SetTextTagPermanent(t, false) endif endif set attacker = null set victim = null set t = null endfunction //=========================================================================== private function Init takes nothing returns nothing local trigger BloodBoundTrg = CreateTrigger( ) call ADamage_AddResponse( ADamage_Response.Actions ) // Initializing the damage options: set damageOptions=xedamage.create() // first instanciate a xeobject. call setupDamageOptions(damageOptions) // now call the function we saw before. //setting globals set g = CreateGroup() set b = Condition(function Targs) endfunction endscope Open to criticism and ideas. |
