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

[JASS] Help with Bomb trigger

Status
Not open for further replies.
Level 3
Joined
May 22, 2007
Messages
30
I need to make a bomb that explodes. I have the effects done, but I don't know how to make it hurt units! :hohum:
Any suggestions for a JASS noob?
Here's my script, only with the effect
JASS:
function Trig_Time_Bomb_3_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction
function Trig_Time_Bomb_3_Copy_Actions takes nothing returns nothing
 local integer BombA1IntegerFor
 local location BombPointA
 local location BombPolarPointA
 local location BombPolarPointA2
 local effect BombPointAEffect
 local effect BombPolarPointAEffect
 local effect BombPolarPointA2Effect
 local texttag three
 local texttag two
 local texttag one 
  set BombA1IntegerFor = GetRandomInt(1, 5)
  set BombPointA = GetUnitLoc(GetTriggerUnit())
  set BombPolarPointA = PolarProjectionBJ(BombPointA, 150.00, ( 60.00 * I2R(BombA1IntegerFor) ))
  set BombPolarPointA = PolarProjectionBJ(BombPointA, 150.00, ( 60.00 * I2R(BombA1IntegerFor) ))  
    call TriggerSleepAction( 0.10 )
    call CreateTextTagLocBJ( "TRIGSTR_068", BombPointA, 0, 10, 100, 100, 100, 0 )
     set three =( GetLastCreatedTextTag() )  
    call TriggerSleepAction( 1.00 )
    call DestroyTextTagBJ ( three) 
    call CreateTextTagLocBJ( "TRIGSTR_069", BombPointA, 0, 10, 100, 100, 100, 0 )
     set two =( GetLastCreatedTextTag() )
    call TriggerSleepAction( 1.00 )
    call DestroyTextTagBJ( two)
    call CreateTextTagLocBJ( "TRIGSTR_070", BombPointA, 0, 10, 100, 100, 100, 0 )
     set one =( GetLastCreatedTextTag() )
    call TriggerSleepAction( 1.00 )
    call DestroyTextTagBJ( one)
    call AddSpecialEffectLocBJ( BombPointA, "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
    set BombPointAEffect = GetLastCreatedEffectBJ()
    call TriggerSleepAction( 0.10 )
    call AddSpecialEffectLocBJ( BombPolarPointA, "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
    set BombPolarPointAEffect = GetLastCreatedEffectBJ()
    call TriggerSleepAction( 0.10 )
    call AddSpecialEffectLocBJ( BombPolarPointA2, "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" )
    set BombPolarPointA2Effect = GetLastCreatedEffectBJ()
    call UnitDamagePointLoc( GetTriggerUnit(), 1, 500, BombPointA, 1000.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
    call TriggerSleepAction( 0.10 )
    call RemoveLocation(BombPointA)
    call RemoveLocation(BombPolarPointA)
    call RemoveLocation(BombPolarPointA2)
    call DestroyEffectBJ( BombPointAEffect )
    call DestroyEffectBJ( BombPolarPointAEffect )
    call DestroyEffectBJ( BombPolarPointA2Effect )
endfunction
constant function ExplosionSoundPath takes nothing returns string
     return "Sound\\Buildings\\Death\\BuildingDeathLargeHuman.wav"
  endfunction
//===========================================================================
function InitTrig_Time_Bomb_3_Copy takes nothing returns nothing
    set gg_trg_Time_Bomb_3_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Time_Bomb_3_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Time_Bomb_3_Copy, Condition( function Trig_Time_Bomb_3_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Time_Bomb_3_Copy, function Trig_Time_Bomb_3_Copy_Actions )
endfunction
 
Level 10
Joined
Jun 26, 2005
Messages
236
Looking at this makes me cry. Firstly, instead of

JASS:
function Trig_Time_Bomb_3_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

Do

JASS:
function Trig_Time_Bomb_3_Copy_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

Okay, instead of declaring then setting, you can do it in the same line. For example,

JASS:
local integer BombA1IntegerFor
set BombA1IntegerFor = GetRandomInt(1, 5)

Can become

JASS:
local integer BombA1IntegerFor = GetRandomInt(1, 5)

Also, it is better PROPER to just name locals with one or two letters, that correspond with the handles name.

For example,

JASS:
local integer BombA1IntegerFor

Would be better as,

JASS:
local integer i

Locations are VERY bad to use. Use real x,y co-ordinates.

Instead of using the PolarBJ, you can just do this:

JASS:
local real x = GetUnitX(GetTriggerUnit()) + 150. * Cos(60. * i * bj_DEGTORAD)
local real y = GetUnitY(GetTriggerUnit()) + 150. * Sin(60. * i * bj_DEGTORAD)

One thing I didn't understand is why you did

JASS:
set BombPolarPointA = PolarProjectionBJ(BombPointA, 150.00, ( 60.00 * I2R(BombA1IntegerFor) ))
//Stupid JASS tag bugs?

twice.

You use TriggerSleepAction() in your script. I wouldn't suggest using it, but I'm not changing it for you.

You used GUI, so your strings are stored in a .txt file. It is much easier to just replace "TRIGSTR_068" with "Whatever".

With the Specialeffects, try this:

JASS:
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", x, y))
//Stupid JASS tag bugs?

If that doesn't work, do what I did in the JASS script at the bottom.

You actually had forgotten to null the locals. Remember, all handles except strings, integers and reals SHOULD be nulled. But people often avoid nulling buggy handles such as timers, playercolours and players.

JASS:
function EnumOwnage takes nothing returns nothing
    //d = damage. This is for your easy editing
    local real d = 10000.
    call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), d, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endfunction
function Trig_Time_Bomb_3_Copy_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction
function Trig_Time_Bomb_3_Copy_Actions takes nothing returns nothing
    local effect e
    local group g
    local integer i = GetRandomInt(1, 5)
    local real x = GetUnitX(GetTriggerUnit()) + 150. * Cos(60. * i * bj_DEGTORAD)
    local real y = GetUnitY(GetTriggerUnit()) + 150. * Sin(60. * i * bj_DEGTORAD)
    //tt01
    local texttag tt = CreateTextTag()
    call SetTextTagText(tt, "TRIGSTR_068", 10 * 0.023 / 10)
    call SetTextTagPos(tt, x, y, 0.)
    call SetTextTagColor(tt, 100, 100, 100, 0)
    call TriggerSleepAction(1.)
    call DestroyTextTag(tt)
    //tt02
    set tt = CreateTextTag()
    call SetTextTagText(tt, "TRIGSTR_068", 10 * 0.023 / 10)
    call SetTextTagPos(tt, x, y, 0.)
    call SetTextTagColor(tt, 100, 100, 100, 0)
    call TriggerSleepAction(1.0)
    call DestroyTextTag(tt)
    //tt03
    set tt = CreateTextTag()
    call SetTextTagText(tt, "TRIGSTR_068", 10 * 0.023 / 10)
    call SetTextTagPos(tt, x, y, 0.)
    call SetTextTagColor(tt, 100, 100, 100, 0)
    call TriggerSleepAction(1.0)
    call TriggerSleepAction(1.)
    call DestroyTextTag(tt)
    //e01
    set e = AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", x, y)
    call TriggerSleepAction(0.1)
    call DestroyEffect(e)
    //e02
    set e = AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", x, y)
    call TriggerSleepAction(0.1)
    call DestroyEffect(e)
    //e03
    //JASS tag bug
    set e = AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", x, y)
    //Ehh, I don't get what you wanted to blow up. I'll just leave it at this.
    set g = CreateGroup()
    call GroupEnumUnitsInRange(g, x, y, 512., null)
    //JASS tag bug
    call ForGroup(g, function EnumOwnage)
    call TriggerSleepAction(0.1)
    call DestroyGroup(g)
    //null ftw?
    set g = null
    set e = null
    set tt = null
endfunction
constant function ExplosionSoundPath takes nothing returns string
     return "Sound\\Buildings\\Death\\BuildingDeathLargeHuman.wav"
endfunction
//===========================================================================
function InitTrig_Time_Bomb_3_Copy takes nothing returns nothing
    set gg_trg_Time_Bomb_3_Copy = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Time_Bomb_3_Copy, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Time_Bomb_3_Copy, Condition(function Trig_Time_Bomb_3_Copy_Conditions))
    call TriggerAddAction(gg_trg_Time_Bomb_3_Copy, function Trig_Time_Bomb_3_Copy_Actions)
endfunction

EDIT: JASS tags have so many ANNOYING bugs...
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
The code can be shrunk a lot with the simple usage of a loop.
Do not use 2 TriggerSleepActions, use one with the combined length.
Actually why did you use a second TriggerSleepActions ?
 
Level 3
Joined
May 22, 2007
Messages
30
As I said, I am a noob! So don't expect me to automatically know all this crap. I was asking what I could do to hurt units because I didn't know how to do it so how does "pick units around the bomb and damage them ? -.-" help? Isn't that what I'm trying to ask you guys, how to make it do that?

And the reason I have it twice is to create two different explosion effects besides the main ones. Thanks for pointing out the nulling and shortening stuff. You never really explained how to work the damaging part in EnumOwnage but I guess I'll figure it out with the code. :bored:
I've always used GUI and its worked really well for me, but I'm new to JASS so go easy one me!

EDIT: um your changes make the countdown and the effects not appear right, or not at all, so I'm gonna keep the original way of doing it. Thanks for showing me the damage part though, it helped me figure out how to make the explosion noise play, too!
How are locations bad?
New script that works:
JASS:
function EnumOwnage takes nothing returns nothing
  local real d = 1000.
   call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), d, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endfunction
function ExplosionNoise takes nothing returns nothing
 local sound es = CreateSound( "Sound\\Buildings\\Death\\BuildingDeathLargeHuman.wav", false, false, true, 12700, 12700, "Sound\\Buildings\\Death\\BuildingDeathLargeHuman.wav") 
  call StartSound(es)
  call KillSoundWhenDone(es)
endfunction
function Trig_Time_Bomb_3_Copy_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == 'A000'
endfunction
function Trig_Time_Bomb_3_Copy_Actions takes nothing returns nothing
local group g    
local integer i = GetRandomInt(1, 5) 
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local real AeX = GetUnitX(GetTriggerUnit()) + 150. * Cos(60. * i * bj_DEGTORAD)
local real AeY = GetUnitY(GetTriggerUnit()) + 150. * Sin(60. * i * bj_DEGTORAD)
local real A2eX = GetUnitX(GetTriggerUnit()) + 150. * Cos(60. * i * bj_DEGTORAD)
local real A2eY = GetUnitY(GetTriggerUnit()) + 150. * Sin(60. * i * bj_DEGTORAD)
//these 4 are here to create explosion effects in different places, other than the original spot
local effect Ae
local effect Ape
local effect A2pe 
local texttag tt = CreateTextTag()
 call SetTextTagText(tt, "|c00FF00003|r", 10 * 0.023 / 10)
 call SetTextTagPos(tt, x, y, 0.)    
 call SetTextTagColor(tt, 100, 100, 100, 0)
 call TriggerSleepAction(1.0)
 call DestroyTextTag(tt)
 call TriggerSleepAction(.1)
  set tt = CreateTextTag()
 call SetTextTagText(tt, "|c00FF00002|r", 10 * 0.023 / 10)
 call SetTextTagPos(tt, x, y, 0.)    
 call SetTextTagColor(tt, 100, 100, 100, 0)
 call TriggerSleepAction(1.0)
 call DestroyTextTag(tt)
 call TriggerSleepAction(.1)
  set tt = CreateTextTag()
 call SetTextTagText(tt, "|c00FF00001|r", 10 * 0.023 / 10)    
 call SetTextTagPos(tt, x, y, 0.)    
 call SetTextTagColor(tt, 100, 100, 100, 0)    
 call TriggerSleepAction(1.0)        
 call DestroyTextTag(tt)
 call AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", x, y)    
  set Ae = (GetLastCreatedEffectBJ())
 call TriggerSleepAction(0.1)    
 call DestroyEffect(Ae)
 call AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", AeX, AeY)    
  set Ape = (GetLastCreatedEffectBJ())
 call TriggerSleepAction(0.1)    
 call DestroyEffect(Ape)
 call AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", A2eX, A2eY)
  set A2pe = (GetLastCreatedEffectBJ()) 
 call DestroyEffect(A2pe)
 set g = CreateGroup()    
 call GroupEnumUnitsInRange(g, x, y, 512., null)
 call ForGroup(g, function EnumOwnage)
 call ForGroup (g, function ExplosionNoise)     
 call TriggerSleepAction(0.1)    
 call DestroyGroup(g)
 set g = null    
 set tt = null
 set Ae = null
 set Ape = null                 
 set A2pe = null    
 endfunction
 //===========================================================================
function InitTrig_Time_Bomb_3_Copy takes nothing returns nothing    
 set gg_trg_Time_Bomb_3_Copy = CreateTrigger()    
 call TriggerRegisterAnyUnitEventBJ(gg_trg_Time_Bomb_3_Copy, EVENT_PLAYER_UNIT_SPELL_CAST)    
 call TriggerAddCondition(gg_trg_Time_Bomb_3_Copy, Condition(function Trig_Time_Bomb_3_Copy_Conditions))    
 call TriggerAddAction(gg_trg_Time_Bomb_3_Copy, function Trig_Time_Bomb_3_Copy_Actions)
endfunction
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
As I said, I am a noob! So don't expect me to automatically know all this crap. I was asking what I could do to hurt units because I didn't know how to do it so how does "pick units around the bomb and damage them ? -.-" help? Isn't that what I'm trying to ask you guys, how to make it do that?

The fact that you are new isn't an excuse to not finding functions when you have (or supposed to have) a full list of all the Jass functions with JNGP (you can also look at blizzard.j and common.j but that's nonsense since you should have JNGP).

JASS:
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRange(g, x, y, radius, filter)
// either this
loop
     set u = FirstOfGroup(g)
     exitwhen u = null
     call GroupRemoveUnit(u)
     // damage unit here
endloop
// or for group
 
Level 3
Joined
May 22, 2007
Messages
30
Well how am I suppossed to know how to put everything together right? I had tried the DamageInAOE thing before and a bunch of others, but I could never get them to work. Sure I could search for functions, and I did. But did it tell me how to put them together and have it work at the right time? No. Thats why I asked for help.

I didn't even know that I could make another function work inside another function. I'm a noob, jeez! What do you want from me? I don't even know what JNGP stands for :bored: All I have is JassCraft, and I looked through all the natives dealing with damage, AOE, and groups and attempted to find a way to get them to work right. I had been stuck on this problem for a few hours before I posted for help. So don't tell me I didn't do anything. Now stop posting in this thread, I fixed it. Jeez...
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Now now, guys, don't attack him.

Well how am I suppossed to know how to put everything together right? I had tried the DamageInAOE thing before and a bunch of others, but I could never get them to work. Sure I could search for functions, and I did. But did it tell me how to put them together and have it work at the right time? No. Thats why I asked for help.

Take it easy, you should first take some JASS tutorials. There are plenty of them on this site, on www.wc3campagins.net and on www.thehelper.net. After that, there is a good and short tutorial how you should loop through a group (by KaTTaNa) here.

I don't even know what JNGP stands for

Jass NewGen Pack. But there is 99% chance that you won't find it very useful at this moment (except maybe for the syntax checker).

Now stop posting in this thread, I fixed it. Jeez...

Whoops, I just did, what are you gonna do about it? :)


P.S. Stop jeezing :p
 
Level 3
Joined
May 22, 2007
Messages
30
Thanks. It seems whenever I try to post anything on this site people feel the need to be sarcastic or just be jerks. The only reason alot of them seem to be helping is to prove they are smarter than me or something. First problems with maps and submitting and mods there, now I have moved up a notch: to JASS trigger board noob/target. Yay.

And I have been through the basic tutorials and tried to do it my way: by experimenting with different stuff. So I've been converting GUI to JASS, messing with that and locals, setting the variables, calls, functions, etc. I figured out how to make the effects leakless, but forgot about nulling of course; fixed that now, too. So I'm figuring it out, and I got what I needed, even if its not perfect it still works well. And if GUI works, why are you guys mad at me for basing some script off it? I need to start somewhere and I don't know how to fully make a trigger in just JASS... yet.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
But there is 99% chance that you won't find it very useful at this moment (except maybe for the syntax checker).

I found it quite useful as well for the coloring of different jass functions, spacing and the list of the functions.
Oh, yeah and the font!!
It is just easier to read and understand :)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
I found it quite useful as well for the coloring of different jass functions, spacing and the list of the functions.
Oh, yeah and the font!!
It is just easier to read and understand :)

But any (good) Jass editor has syntax highlighting, sometimes it's more easier for me to code in JassCraft because if I have a lot of parameters they get cut off (in JNGP).

Bettaxx, sure, do whatever you want, these people were just trying to help. It's good that you want to learn JASS, keep it up ;)
 
Status
Not open for further replies.
Top