• 🏆 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!

Illusion Slash v.1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: deepstrasz
Created by Barathrum
================

Name: Illusion Slash
Type: Passive
Levels: 3
MUI: Yes
Leakless: Should be


The Caster of the spell has a set chance to summon a clone to deal exact damage as the original. You can set it to display how much damage it deals, you can set bonus damage, you can set special effect, an attachment for the effect, and much more! The spell has very much things you can config!

JASS:
scope Combo initializer InitTrig_Illusion_Slash

//  SETTINGS

globals
private constant integer dummy_id = 'h000'                             // the ID of the dummy unit
private constant integer spell_id = 'A000'                             // the ID of the spell
private constant real anim_delay = 1.00                                // the delay before the dummy dies
private constant integer red = 100                                     // the color red of the dummy
private constant integer green = 100                                   // the color green of the dummy
private constant integer blue = 100                                    // the color blue of the dummy
private constant integer alpha = 75                                    // the color transparency of the dummy
private constant integer red_c = 100                                   // the color red of the caster
private constant integer green_c = 100                                 // the color green of the caster
private constant integer blue_c = 100                                  // the color blue of the caster
private constant integer alpha_c = 75                                  // the color transparency of the caster
private constant real tag_red = 100                                    // the text tag color : red
private constant real tag_green = 10                                   // the text tag color : green
private constant real tag_blue = 10                                    // the text tag color : blue
private constant string animation = "slam"                             // the animation the dummy will play
private constant boolean attack = true                                 // is the spell a attack?
private constant boolean ranged = false                                // is the spell ranged?
private constant attacktype atk_type = ATTACK_TYPE_CHAOS               // the attack type of the dummy damage
private constant damagetype dmg_type = DAMAGE_TYPE_NORMAL              // the damage type of the dummy damage
private constant weapontype wep_type = WEAPON_TYPE_WHOKNOWS            // the weapon type of the dummy damage
private constant boolean enable_texttag = true                         // if set to true, it will show the damage dealt by the dummy
private constant string special_effect = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
private constant string attachment_point = "origin"                    // this is where the above special effect is placed
private real array extra_damage                                        // set the extra damage bellow in function Settings
private integer array chance                                           // set the chance bellow in function Settings
endglobals

function Settings takes nothing returns nothing
// set the chances:
set chance[1] = 20
set chance[2] = 40
set chance[3] = 60

// set the extra damage values
set extra_damage[1] = 20
set extra_damage[2] = 35
set extra_damage[3] = 50
endfunction

//  END OF SETTINGS

private function Conditions takes nothing returns boolean
   return GetUnitAbilityLevel(GetEventDamageSource(), spell_id ) >= 1
endfunction

private function Actions takes nothing returns nothing
local unit u = GetEventDamageSource()
local unit t = GetTriggerUnit()
local unit dummy
local integer lvl = GetUnitAbilityLevel(u , spell_id)
local real dmg = GetEventDamage() + extra_damage[lvl]
local real angle = GetUnitFacing(t) + 180
local player owner = GetOwningPlayer(u)
local location l = GetUnitLoc(u)
local location l2
local integer ch = GetRandomInt(1 , 100)
local texttag text
local real pos = 60.

// We call the chance function
call Settings()

if chance[lvl] >= ch then
call AddSpecialEffectTarget(special_effect , u , attachment_point)
call SetUnitVertexColor(u, red_c , green_c, blue_c, alpha_c)
set dummy = CreateUnitAtLoc(owner, dummy_id , l , angle)
set l2 = GetUnitLoc(dummy)
call PauseUnit(dummy, true)
call SetUnitVertexColor(dummy , red , green, blue, alpha)
call SetUnitAnimation(dummy , animation)
if enable_texttag == true then
set text = CreateTextTagLocBJ( R2S(dmg)+"!" , l2, pos, 12, tag_red, tag_green, tag_blue, 0 )
call SetTextTagVelocityBJ( text, 60.00, 90 )
call SetTextTagPermanent( text, false )
call SetTextTagLifespan( text, 1)
call SetTextTagFadepoint( text, 0.1)
endif
call TriggerSleepAction(anim_delay)
call UnitDamageTarget(u, t, dmg, attack, ranged, atk_type , dmg_type , wep_type)
call RemoveUnit(dummy)
call SetUnitVertexColor(u, 255 , 255, 255, 255)
endif

set u = null
set t = null
set dummy = null
call RemoveLocation(l)
call RemoveLocation(l2)
call DestroyTextTag(text)
endfunction

//===========================================================================
private function InitTrig_Illusion_Slash takes nothing returns nothing
  set gg_trg_Illusion_Slash = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Illusion_Slash, Condition( function Conditions ) )
    call TriggerAddAction( gg_trg_Illusion_Slash, function Actions )
endfunction
endscope

Keywords:
Illusions, passive, deal, damage, exact, as, original
Contents

Illusion Slash (Map)

Reviews
12th Dec 2015 IcemanBo: Too long time as NeedsFix. Rejected. 13:44, 21st Mar 2010 TriggerHappy: Indent your code. Don't use BJ's. Don't use locations. Make Settings private. Properly scope everything in AddUnits. Right now it's all public...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long time as NeedsFix. Rejected.

13:44, 21st Mar 2010
TriggerHappy:

Indent your code.
Don't use BJ's.
Don't use locations.
Make Settings private.
Properly scope everything in AddUnits. Right now it's all public and easy to collide with other scripts.

Overall, try asking people for code help before submitting something.
 
Level 18
Joined
Feb 28, 2009
Messages
1,970
JASS:
set gg_trg_Illusion_Slash = CreateTrigger(  )
1. Use local trigger

2. Preload SFX
3. Use tabulators -_-
JASS:
local player owner = GetOwningPlayer(u)
4. I`m not sure but I think player should be nulled too.
5. Don`t use locations
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
1. what's a tabulator
2. I need to use a global for the trigger so that AddUnits trigger can work with it

1) probably TAB, you know, a very useful button that inserts a blank space.
It's very, very, very, very useful when it comes to writing codes (in JASS, C, J-script, whatever language you can imagine).

You start off with 0 tabs and every time you pass "function", or something like a loop or an if-struct, you add 1 tab (and -1 tab if you end those things).
Like this:
JASS:
function TAB takes nothing returns nothing
    local integer i = 0
    local unit u = GetEnumUnit()

    loop
        exitwhen i > 10
        set i = i+1

        if i == 1
            call BJDebugMsg("TAB!")
        elseif i == 2
            call BJDebugMsg("Tabulator")
        endif

    endloop

    set u = null
endfunction
 
Level 1
Joined
Sep 26, 2012
Messages
2
newb here

um...this trigger is new to me. I checkd everything n it was all there,but just wondering does the color of the text i see from your example have to do with anything? because it works for 1 test n after that it says error for both triggers. Mind explaining the problem anyone? ty 4 reading
 
Top