wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-29-2009, 08:15 AM   #1
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default [Help] Keeping a lightning in a damn box

Collapse JASS:
function Trig_Attacks_Actions takes nothing returns nothing
    local integer ATTACK_TYPE = GetSpellAbilityId()
    local unit attacker = GetTriggerUnit()
    local unit attacked = GetSpellTargetUnit()
    local real x1 = GetUnitX(attacker)
    local real y1 = GetUnitY(attacker)
    local real x2 = GetUnitX(attacked)
    local real y2 = GetUnitY(attacked)
    local real x3 = 0
    local real y3 = 0
    local real grad = 0
    local real r = 0
    local integer i = 0
    if ATTACK_TYPE == 'A000' then // Laser attack
         loop
             set i = i + 1
         exitwhen i == udg_LASER_Max or udg_LASER_InUse[i] == false
         endloop
         set udg_LocSPFX = Location(0,0)
         set udg_LASER_Bolt[i] = AddLightningLoc( udg_LASER_Type[GetUnitAbilityLevel(attacker,ATTACK_TYPE)], udg_LocSPFX, udg_LocSPFX )
         set udg_LASER_Fade1[i] = 1.5
         set udg_LASER_Fade2[i] = 0.02
         set udg_LASER_FadeHold[i] = 0
         set udg_LASER_Full[i] = 1.0
         set udg_LASER_InUse[i] = true
         set udg_LASER_R[i] = 1.0
         set udg_LASER_G[i] = 1.0
         set udg_LASER_B[i] = 1.0
         set grad = (y2 - y1) / (x2 - x1)
         set r = y1 - grad * x1
         if x2 < x1 then
             set x3 = GetRectMinX(udg_PlayerRegion[GetPlayerId(GetOwningPlayer(attacker))])
             set y3 = (grad * x3) + r
         else
             set x3 = GetRectMaxX(udg_PlayerRegion[GetPlayerId(GetOwningPlayer(attacker))])
             set y3 = (grad * x3) + r
         endif
         call SetLightningColorBJ( udg_LASER_Bolt[i], 0.25, 1., 1., 1 )
         call MoveLightningEx( udg_LASER_Bolt[i], true, x1, y1, 50, x3, y3, 50 )
    endif
endfunction

//===========================================================================
function InitTrig_Attacks takes nothing returns nothing
    set gg_trg_Attacks = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Attacks, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Attacks, function Trig_Attacks_Actions )
endfunction

The issue with the highlighted section is that it confines stuff into an infinite rectangle involving the maximum and minimum Y, but not into a finite square involving the maximum and minimum X.

What the problem is:
I have a square and I have several laser-shooting units inside it. The laser is confined with a maximum distance to the left and right, but there are no constrictions for the top and bottom.

What I need to fix it is:
Solved - An accurate formula that gets a line going through 2 points, starting from the "first one" of them, but still staying inside the square
- A way of "closing" the laser from going through the top and bottom boundaries of the square

Old info

What I need is:
- How to confine it to inside the square

Another big problem:
The accuracy of my "angler" is way off, it worked before but for some reason not now.

__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.

Last edited by Tide-Arc Ephemera : 04-29-2009 at 12:00 PM.
Tide-Arc Ephemera is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-29-2009, 11:11 AM   #2
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

[jass]
known:x1,x2,y1,y2

local real m = (y2-y1)/(x2-x1)
local real b = y1 - m * x1
Bobo_The_Kodo is offline   Reply With Quote
Old 04-29-2009, 11:56 AM   #3
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default

Okay, that fixes the accuracy PERFECTLY. Now all I need is a how-to-confine-into-box-along-the-y-axes.
__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.
Tide-Arc Ephemera is offline   Reply With Quote
Old 04-30-2009, 05:55 AM   #4
Tide-Arc Ephemera
Overdoses result in death
 
Tide-Arc Ephemera's Avatar
 
Join Date: Jan 2007
Posts: 2,365

Submissions (3)

Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)Tide-Arc Ephemera is a jewel in the rough (206)

Default

Bump.

EDIT!
Explanatory diagram attached.
Attached Images
File Type: jpg Untitled-1.jpg (98.8 KB, 4 views)
__________________
Before asking for help with triggers... read this and check your trigger!

If you're having troubles getting help on WC3C or anywhere at all, please have a look at...
The WRONG way to ask for help and The CORRECT way to ask for help.

Quote:
Originally Posted by Alevice
You may never stop our bioweapon! We mexicans shall rule the third world! Mwahahahahahahaha!
Please acknowledge that I use Mac and avoid suggesting vJass and other tools that don't work on it. Thank you.

Last edited by Tide-Arc Ephemera : 04-30-2009 at 10:34 AM.
Tide-Arc Ephemera is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 01:02 PM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services