How to creat a damaging or healing area?

Interesting mapping tools and mapping help.

Moderator: Morax

How to creat a damaging or healing area?

Postby Ghoustaq » 05 Mar 2018, 14:33

I want to create a damaging or healing area around a blank marker which just effects on mobile units constantly. Is there a mapscript function that can make it realize?
Last edited by Ghoustaq on 05 Mar 2018, 19:41, edited 1 time in total.
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: How to creat a damaging or healing area?

Postby Sprouto » 05 Mar 2018, 14:44

What you are looking for is known as a BuffField.

For more information look at the following files;

BuffField.lua
BuffFieldDefinitions.lua
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: How to creat a damaging or healing area?

Postby stormbeforedawn » 05 Mar 2018, 18:49

I would be very interested in this if you get a method to work.
stormbeforedawn
Crusader
 
Posts: 33
Joined: 30 Aug 2013, 18:44
Has liked: 1 time
Been liked: 0 time
FAF User Name: StormBeforeDawn

Re: How to creat a damaging or healing area?

Postby Ghoustaq » 20 Mar 2018, 18:19

stormbeforedawn wrote:I would be very interested in this if you get a method to work.


@stormbeforedawn

Hello!stormbeforedawn:


here's my method. copy and paste the code to your mapscript. It does work, but still needs improving.

it should be noted that you must place a blankmarker on your map firstly ,and rename it as DAMAGEAREA_1

'cause the damagearea is a rectangle field located around the marker.

Code: Select all
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')

function OnPopulate()
   ScenarioUtils.InitializeArmies()   
end

function OnStart(self)

   ForkThread(HealthAdjustor)
end

   local DAMAGEAREAName
   local location
   local px, py, pz
   local rect
   local units
   local health
   local preAdjHealth

function HealthAdjustor(self)
    while true do
      for k = 1, 1 do
        DAMAGEAREAName = 'DAMAGEAREA_' .. k
        location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
        px, py, pz = unpack(location)
        rect = Rect(px-25, pz-25, px+25, pz+25)
        units = GetUnitsInRect(rect)
      end
      for _, instigator in units do
        if VDist3(instigator:GetPosition(), location) <= 25 then
        health = instigator:GetHealth()
        instigator:AdjustHealth(instigator, -30)
        end
      end

        WaitSeconds(10)
    end
end
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest