• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to write this in vjass and is it possible?

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I want to create a passive spell and I call it Brutal Strikes Whenever the hero attacks there is a 30% chance that it would deal 10 extra damage and reduce the target armor by 2 for 5 seconds. Chance rate, extra damage and armor reduction increase per lvl. It looks simple guys, is it possible to write this in vjass and how?
 
Level 13
Joined
Aug 19, 2014
Messages
1,111
I could create this in GUI if I wanted to.

the 30% chance is easy to do if you download a DDS.
deal 10 damage is a normal function/action
you need a dummy ability for reducing armor, like devotion aura with negative armor and 0 area. Give the ability to target unit and remove after X seconds.

Hehehe well I was planning to do it myself, maybe you could show me how if you have some spare time sir?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Done. I did it lazily though, no level support since that's boring to code :p . But it's MUI and works as it should.
  • apply
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (Random integer number between 1 and 10) Less than or equal to 3
    • Actions
      • Custom script: call BrutalStrikes.create(udg_GDD_DamageSource, udg_GDD_DamagedUnit)
      • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing 10.00 damage of attack type Spells and damage type Normal
JASS:
function GroupActions takes nothing returns nothing
	local unit target = GetEnumUnit()
	local integer h = GetHandleId(target)
	local integer id = LoadInteger(BrutalStrikes.hash, h, 1)
	call BrutalStrikes(id).update(target)
endfunction

function loopActions takes nothing returns nothing
	call ForGroup(BrutalStrikes.myGroup, function GroupActions)
endfunction

struct BrutalStrikes
	static hashtable hash
	static group myGroup
	real counter = 0
	
	static method onInit takes nothing returns nothing
		local trigger t = CreateTrigger()
		call TriggerRegisterTimerEvent(t, 0.03, true)
		call TriggerAddAction(t, function loopActions)
		set hash = InitHashtable()
		set myGroup = CreateGroup()
	endmethod
	
	static method create takes unit caster, unit target returns thistype
		local thistype this = thistype.allocate()
		call UnitAddAbility(target, 'A000')
		call SaveInteger(hash, GetHandleId(target), 1, this)
		call GroupAddUnit(myGroup, target)
		return this
	endmethod
	
	method update takes unit u returns nothing
		set .counter = .counter + 0.03
		if .counter >= 5 then
			call GroupRemoveUnit(myGroup, u)
			call UnitRemoveAbility(u, 'A000')
			call deallocate(this)
		endif
	endmethod
endstruct
 

Attachments

  • Brutal Strikes.w3x
    25.2 KB · Views: 23
Level 13
Joined
Aug 19, 2014
Messages
1,111
No, my trigger do that part. However the armor reduction ability only got one level. So it will always reduce armor by 2 no mater which level the spell is. If you remove "call UnitAddAbility(target, 'A000')" from my trigger and add the ability yourself in GUI and then set the ability level to X it should work as intended.

Nice Tnx for the help dude, I'm lucky there's someone like you around :ogre_haosis:
 
Status
Not open for further replies.
Top