Trying to import a spell and screwed it up...

turok255

New Member
Reaction score
30
I was trying to import Earth Spikes into my map, But I couldn't just use the import functions because I had alot of triggers there already. So... I made the Game Cache variable, Copy / pasted the triggers, Changed the custom text in my map header and copy / pasted the dummy units & spells, The spell works some what...

It will pause the unit and make a special effect on the units position but thats it... No rocks.. No spikes.. No damage. Heres the triggers im using please tell me if you see something ;)


Map Header
JASS:
constant function LocalVars takes nothing returns gamecache
    return udg_gc
endfunction

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function H2S takes handle h returns string
    return I2S(H2I(h))
endfunction

function I2U takes integer i returns unit
    return i
    return null
endfunction

function I2L takes integer i returns location
    return i
    return null
endfunction

function SetHandleHandle takes integer i, handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes integer i, handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes integer i, handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes integer i, handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes integer i, handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction


function GetHandleHandle takes integer i, handle subject, string name returns handle
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes integer i, handle subject, string name returns integer
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes integer i, handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes integer i, handle subject, string name returns real
    return GetStoredReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleString takes integer i, handle subject, string name returns string
    return GetStoredString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes integer i, handle subject, string name returns unit
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes integer i, handle subject, string name returns timer
    return GetStoredInteger(LocalVars(),GetObjectName(i)+ I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes integer i, handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes integer i, handle subject, string name returns effect
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes integer i, handle subject, string name returns group
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes integer i, handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes integer i, handle subject, string name returns widget
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrackable takes integer i, handle subject, string name returns trackable
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTextTag takes integer i, handle subject, string name returns texttag
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction

//Varius Mathfunctions//////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function FlushHandleLocals takes integer i, handle subject returns nothing
    call FlushStoredMission(LocalVars(),GetObjectName(i)+I2S(H2I(subject)) )
endfunction

function AngleXY takes real xa, real ya, real xb, real yb returns real
    return (180/3.14138 * Atan2(yb - ya, xb - xa))
endfunction

function DistanceXY takes real xa, real ya, real xb, real yb returns real
    return SquareRoot((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya))
endfunction

function PolarX takes real x, real dist, real angle returns real
  return (x + dist * Cos(angle * 3.14/180))
endfunction

function PolarY takes real y, real dist, real angle returns real
    return (y + dist * Sin(angle * 3.14/180))
endfunction

function RealMin takes real a, real b returns real
    if (a < b) then
        return a
    else
        return b
    endif
endfunction

function RealMax takes real a, real b returns real
    if (a < b) then
        return b
    else
        return a
    endif
endfunction

Game Cache
JASS:
function Trig_Game_cache_initialization_Actions takes nothing returns nothing
    call FlushGameCache(InitGameCache("testmap"))
    set udg_Cache = InitGameCache("testmap")
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

function InitTrig_Initialization takes nothing returns nothing
    set gg_trg_Initialization = CreateTrigger()
    call TriggerAddAction(gg_trg_Initialization, function Trig_Game_cache_initialization_Actions)
endfunction

Earth Spike Trigger
JASS:
// This function is used to avoid timer nulling
function ES_RockActions takes timer rockActionTimer returns nothing
    local location unitLoc
    local location newLoc
    local location rockLoc
    local real     scalingValue
    local sound    impaleSound
    local unit     caster
    local unit     rock
    local unit     spike
    local unit     target
    local integer  i          = 0
    local string   timerID    = H2S(rockActionTimer)
    local integer  totalRocks = GetStoredInteger(udg_Cache, timerID, "total")
    local location targetLoc  = I2L(GetStoredInteger(udg_Cache, timerID, "targetloc"))
    local integer  callsLeft  = GetStoredInteger(udg_Cache, timerID, "callsleft")
    local unit     caster     = I2U(GetStoredInteger(udg_Cache, timerID, "caster"))
    local unit     target     = I2U(GetStoredInteger(udg_Cache, timerID, "target"))
    
    if (callsLeft <= -100 * 3 or (GetUnitState(target, UNIT_STATE_LIFE) <= 0 and callsLeft > 0)) then
        
        // If target dies while rocks are still moving, or if the spell has been completed

        if (callsLeft <= -100 * 3) then
            
            // If the spell has been completed, explode target location
            call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\NightElf\\NEDeathMedium\\NEDeath.mdl", targetLoc))
            
            call PauseUnit(target, false)
            call SetUnitTimeScale(target, 1)
            
        else

            // If target dies while rocks are still moving, explode rocks
            loop
                exitwhen i == totalRocks
                
                set rock = I2U(GetStoredInteger(udg_Cache, timerID, "rocks" + I2S(i)))
                set rockLoc = GetUnitLoc(rock)
                call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl", rockLoc))
                call RemoveLocation(rockLoc)
                call RemoveUnit(rock)
                
                set i = i + 1
            endloop
            
        endif
        
        call RemoveLocation(targetLoc)
        
        call FlushStoredMission(udg_Cache, timerID)
        call PauseTimer(rockActionTimer)
        call DestroyTimer(rockActionTimer)
    else
        
        if (callsLeft > 0) then
            
            // Rocks are still being moved
            loop
                exitwhen i == totalRocks
                
                set rock = I2U(GetStoredInteger(udg_Cache, timerID, "rocks" + I2S(i)))
                set rockLoc = GetUnitLoc(rock)
                set newLoc = PolarProjectionBJ(rockLoc, 1000 * 0.01, AngleBetweenPoints(rockLoc, targetLoc))
                call SetUnitPositionLoc(rock, newLoc)
                
                // Give it a "dash effect" (reduce it to 1/20x to avoid lag)
                if (GetRandomInt(1, 20) == 1) then
                    call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", rockLoc))
                endif

                call RemoveLocation(rockLoc)
                call RemoveLocation(newLoc)
                
                set i = i + 1
            endloop
            
        elseif (callsLeft == 0) then
            
            // Rocks have reached their destination, and is now impaling the target
            set unitLoc = GetUnitLoc(target)
            
            // Check if target's still inside his spot and is alive
            if (DistanceBetweenPoints(unitLoc, targetLoc) <= 100 and GetUnitState(target, UNIT_STATE_LIFE) > 0) then
                
                // Pause target
                call SetUnitTimeScale(target, 0)
                call PauseUnit(target, true)
                
                // Create spikes
                loop
                    exitwhen i == totalRocks
                    
                    set rock = I2U(GetStoredInteger(udg_Cache, timerID, "rocks" + I2S(i)))
                    set rockLoc = GetUnitLoc(rock)
                    set spike = CreateUnitAtLoc(GetOwningPlayer(caster), 'h018', rockLoc, GetRandomReal(0, 360))
                    set scalingValue = 2 - i * (1.75 / totalRocks)
                    
                    call SetUnitTimeScale(spike, 2)
                    call SetUnitScale(spike, scalingValue, scalingValue, scalingValue)
                    call SetUnitFlyHeight(spike, 400 / totalRocks * i, 1000)
                    call SetUnitAnimation(spike, "birth")
                    call RemoveLocation(rockLoc)
                    call UnitApplyTimedLife(spike, 'BTLF', 3)
                    call UnitApplyTimedLife(rock, 'BTLF', 3)
                    
                    set i = i + 1
                endloop
                
                // SFX as target gets impaled
                set impaleSound = CreateSound("Abilities\\Spells\\Undead\\Impale\\ImpaleHit.wav", false, true, true, 10, 10, "SpellsEAX")
                call SetSoundParamsFromLabel(impaleSound, "ImpaleHit")
                call SetSoundDuration(impaleSound, 1666)
                call SetSoundPosition(impaleSound, GetLocationX(targetLoc), GetLocationY(targetLoc), 0)
                call SetSoundVolume(impaleSound, 127)
                call StartSound(impaleSound)
                call KillSoundWhenDone(impaleSound)
                
            else
                
                // Target escapes the spell, spell gets cancelled
                loop
                    exitwhen i == totalRocks
                    
                    set rock = I2U(GetStoredInteger(udg_Cache, timerID, "rocks" + I2S(i)))
                    call RemoveUnit(rock)
                    
                    set i = i + 1
                endloop
                
                call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\NightElf\\NEDeathMedium\\NEDeath.mdl", targetLoc))
                
                call RemoveLocation(targetLoc)
                
                call FlushStoredMission(udg_Cache, timerID)
                call PauseTimer(rockActionTimer)
                call DestroyTimer(rockActionTimer)
            endif
            
            call RemoveLocation(unitLoc)
            
        elseif (callsLeft == -100 * 0.5) then
            
            // Do piercing damage to target unit 0.5 seconds after the target gets trapped
            call UnitDamageTarget(caster, target, 50 * totalRocks, false, false, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            
        else
            
            // Spikes have already damaged the unit, unit is now in standby for rock to disappear
            
            set unitLoc = GetUnitLoc(target)
            
            if (DistanceBetweenPoints(unitLoc, targetLoc) <= 100) then
                
                // We want to keep the target paused, not allowing other triggers to unpause it as long
                // as it's still inside the rocks
                call SetUnitTimeScale(target, 0)
                call PauseUnit(target, true)
                
            else
                
                // Unpause the victim if he somehow manages to get out of the rocks, but don't remove the rocks
                
                call PauseUnit(target, false)
                call SetUnitTimeScale(target, 1)
                
            endif
            
            call RemoveLocation(unitLoc)
        endif
        
        // Decrement counter
        call StoreInteger(udg_Cache, timerID, "callsleft", callsLeft - 1)
        
    endif
    
    // Variable nulling
    set newLoc      = null
    set rockLoc     = null
    set unitLoc     = null
    set caster      = null
    set rock        = null
    set spike       = null
    set target      = null
    set impaleSound = null
    set targetLoc   = null
    set timerID     = null
    set caster      = null
    set target      = null
endfunction

// This is the timer callback function
function ES_ActionTimerCallback takes nothing returns nothing
    call ES_RockActions(GetExpiredTimer())
endfunction

// The main trigger action
// Event: Unit begins the effect of an ability
// Conditions: None
function ES_TrigActions takes nothing returns nothing
    local unit     target
    local unit     caster
    local integer  abilityLevel
    local integer  i
    local integer  totalRocks
    local location rockLoc
    local location targetLoc
    local real     initialDistance
    local real     rotationOffset
    local sound    spawnSound
    local string   timerID
    local timer    rockActionTimer
    local unit     rock
    
    if (GetSpellAbilityId() == 'A01P') then
        
        // Set the spell variables
        set caster = GetTriggerUnit()
        set target = GetSpellTargetUnit()
        set targetLoc = GetUnitLoc(target)
        set abilityLevel = GetUnitAbilityLevel(caster, 'A01P')
        set initialDistance = 1100 - abilityLevel * 300
        set totalRocks = 4 * abilityLevel
        
        // Create the timer, trigger and start filling in information
        set rockActionTimer = CreateTimer()
        set timerID = H2S(rockActionTimer)
        call StoreInteger(udg_Cache, timerID, "callsleft", R2I((initialDistance - 25) * 100 / 1000))
        call StoreInteger(udg_Cache, timerID, "caster", H2I(caster))
        call StoreInteger(udg_Cache, timerID, "target", H2I(target))
        call StoreInteger(udg_Cache, timerID, "total", totalRocks)
        call StoreInteger(udg_Cache, timerID, "targetloc", H2I(targetLoc))
        
        // Create the rocks and pop them out
        set rotationOffset = GetRandomReal(0, 360)
        set i = 0
        loop
            exitwhen i == totalRocks
            
            set rockLoc = PolarProjectionBJ(targetLoc, initialDistance, rotationOffset + 360 / totalRocks * i)
            set rock = CreateUnitAtLoc(GetOwningPlayer(caster), 'h01H', rockLoc, GetRandomReal(0, 360))
            call SetUnitFlyHeight(rock, 0, 1000)
            call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", rockLoc))
            call StoreInteger(udg_Cache, timerID, "rocks" + I2S(i), H2I(rock))
            call RemoveLocation(rockLoc)
            
            // Create SFX of rocks popping out
            set spawnSound = CreateSound("Abilities\\Spells\\Undead\\DeathandDecay\\DeathAndDecayTarget2.wav", false, true, true, 10, 10, "SpellsEAX")
            call SetSoundParamsFromLabel(spawnSound, "DeathAndDecayTarget")
            call SetSoundDuration(spawnSound, 1235)
            call SetSoundPosition(spawnSound, GetLocationX(rockLoc), GetLocationY(rockLoc), 0)
            call SetSoundVolume(spawnSound, 127)
            call StartSound(spawnSound)
            call KillSoundWhenDone(spawnSound)
            
            set i = i + 1
        endloop
        
        // Let's wait for a while before moving the rock
        call TriggerSleepAction(0.75)
        call TimerStart(rockActionTimer, 0.01, true, function ES_ActionTimerCallback)
        
    endif
    
    // Variable nulling
    set targetLoc = null
    set timerID = null
    set rock = null
    set rockActionTimer = null
    set rockLoc = null
    set spawnSound = null
    set caster = null
    set target = null
endfunction

// Main trigger initialization
function InitTrig_Earth_Spikes takes nothing returns nothing
    local integer i = 0
    
    set gg_trg_Earth_Spikes = CreateTrigger()
    
    loop
        exitwhen i == bj_MAX_PLAYER_SLOTS - 1
        
        call TriggerRegisterPlayerUnitEvent(gg_trg_Earth_Spikes, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        
        set i = i + 1
    endloop
    
    call TriggerAddAction(gg_trg_Earth_Spikes, function ES_TrigActions)
endfunction

The only thing I changed in the triggers was... I added

JASS:

function H2S takes handle h returns string
    return I2S(H2I(h))
endfunction

function I2U takes integer i returns unit
    return i
    return null
endfunction

function I2L takes integer i returns location
    return i
    return null
endfunction
to the map header with some of it I need for other spells
and the raw unit & spell data in the earth spikes trigger.
 

turok255

New Member
Reaction score
30
I used Jasscraft and ctrl + f then put in the raw code of his units & spell with mine. So unless I missed 1 somewhere...

EDIT: Hmm seems my units got their model file changed and couldn't be seen. I changed them back and now it works. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top