[Request] System Remake

tooltiperror

Super Moderator
Reaction score
231
So it just makes it so the summoned unit is not controlled by the player?
 

foodflare

You can change this now in User CP.
Reaction score
32
do you want the summon to be targetable by enemies or no?
 

Hildagarn

Member
Reaction score
20
Yes, it can be attacked and killed and such, but you just can't control it, it's completely independent, like diablo II minions
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
post there instead of here?
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
that link you gave us, its a forum thread

can't you just post there for help?
 

Jesus4Lyf

Good Idea™
Reaction score
397

Hildagarn

Member
Reaction score
20
Readme
JASS:


    Just summons that are owned by the player but not controllable. It abuses the ward 
 classification that removes the interface buttons. Then it just needs these functions
 to block smart (doble click) orders (the only orders that the player is able to give to
 ward-classified units) And also make them have a support AI that follows and protect
 its master.

    Notice that the AI is just about following the master an attacking enemies, if you
 need more you can make it so manually (not difficult, really) Check out the 'Bear Roars'
 example trigger

    Why would you want this system?  I don't know, you are the one that downloaded the map.


    And yes, this map used to be called diablo 2 summons. The AI is based on a function
 made by Grater but I actually modiffied a lot of it.

    Credit is the only prerequisite to use this system on playable maps. If you want to
 include the system in a map that is to be uploaded to any sort of spell section you'd need
 my permission.


 Implement
 ¯¯¯¯¯¯¯¯¯
 - Requires the CSCache module (Part of caster system - <a href="http://wc3campaigns.net/vexorian" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://wc3campaigns.net/vexorian</a> ).

 - Then you must Copy the functions in the &#039;IndieSummon&#039; trigger 

 - Then Copy yhe &#039;IndieSummon Code&#039; trigger

 - Then have a trigger that calls the IndieSummon_SetMaster function (Check the Call category)

 - Make sure every unit  you want to use as summon of this system has the ward classification.

   Note: Units with even point values will get a tank ai, and units with odd point values
         will get a support ai.

                                                                          -Vexorian

   If you still have troubles, feel free to ask at <a href="http://wc3campaigns.net/vexorian" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://wc3campaigns.net/vexorian</a>

 Function guide
 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯  
__________________________________________________________________________________________
 function IndieSummon_SetMaster    takes unit summon, unit master returns nothing
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    Start everything (the smart order blocking + AI) for the unit summon. master 
 determines the master of the summon.

    You can use this function to change the master of an already active
 independant summon.
__________________________________________________________________________________________
 function IndieSummon_GetMaster    takes unit summon returns unit
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    Well if there is Set there should be Get
__________________________________________________________________________________________
 function IndieSummon_StopAI       takes unit summon returns nothing
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    Stops the AI and the smart order trigger for that unit besides of cleaning the
 memory used by them. It is a good idea to use this function before removing it. Although
 exploding the unit instead of removing it is as effective.


_________________________________________________________________________________________

                                Version History

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 Version 1.8 :
    - Uses tables (optimized)
    - Renamed everything and made it more flexible

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 Version 1.7 :
    - Fixed Memory Leaks (InitGameCache and triggeraction leaks)
    - Optimized some code
    - Improved smart order blocking

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 Version 1.6 :
    - Implementation helping tweaks

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
 Version 1.5 :

    - Optimized the main part of the AI.
    - Revamped it to use the handle variables functions
_________________________________________________________________________________________

 Version 1.4 :

    - No longer uses custom values, so feel free to use custom values on your triggers.
    - The Smart order blocking system works better.
    - The summoned units will avoid to lose a target
_________________________________________________________________________________________

 Version 1.3 :

    - Now units with even point value numbers are considered tanks and units 
    with odd point values are considered support.
    - UnitGuardUnitAI is available as a &quot;callable&quot; function again (requested by people
    that used triggers to create units.)
_________________________________________________________________________________________

 Version 1.2 :

    - Fixed a dangerous bug with the smart order trigger
    - Updated UnitGuardAI to make trigger ai possible
    - Merged everything to One Trigger!
    - Calling UnitGuardUnitAI no longer stops the trigger until the summon dies
    - Compatibility with games where players may have multiple heroes
_________________________________________________________________________________________

 Version 1.0 (First release)



Indiesummon
JASS:
function InitTrig_IndieSummon takes nothing returns nothing
endfunction
//##Start##
//**************************************************************************************************
//*
//* IndieSummons (header functions)
//* ¯¯¯¯¯¯¯¯¯¯¯¯
//*     To implement these functions, you must select the contents of this trigger starting
//*   with the //##Start## and finishing with the  //##End##, and copy that TO YOUR MAP&#039;s
//*   CUSTOM SCRIPT SECTION, (it is at the top of the trigger list in the trigger editor)
//*
//*     DON&#039;T JUST COPY THE TRIGGER; copy this to the custom script section
//*
//*   AFTER copying this function to custom script section, copy the next trigger to your map
//*
//**************************************************************************************************

//=================================================================================================
//
// <a href="http://www.wc3jass.com" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www.wc3jass.com</a> : The place with tons of JASS scripts
//
//=================================================================================================

function IndieSummon_SetMaster takes unit summon, unit master returns nothing
 local unit a=bj_ghoul[0]
 local string k=GetAttachmentTable(summon)

    if (HaveStoredInteger(CSCache(),&quot;[IndieSummons]&quot;,k)) then
        call SetTableObject(&quot;[IndieSummons]&quot;,k,master)
    else
        call SetTableObject(&quot;[IndieSummons]&quot;,k,master)
        set bj_ghoul[0]=summon
        call ExecuteFunc(&quot;IndieSummon_loop&quot;)
        set bj_ghoul[0]=a
    endif

 set a=null
endfunction

function IndieSummon_GetMaster takes unit summon returns unit
    return GetStoredInteger(CSCache(),&quot;[IndieSummons]&quot;,GetAttachmentTable(summon))
    return null
endfunction

function IndieSummon_StopAI takes unit summon returns nothing
    call FlushStoredInteger(CSCache(),&quot;[IndieSummons]&quot;,GetAttachmentTable(summon))
endfunction
//##End##


Indiesummon code
JASS:
//**************************************************************************************************
//* 
//* Independant Summons (Code + config)
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* You just need to copy this trigger, notice that these functions do nothing without the other
//* part which has the header functions and you&#039;ll also need to call them.
//*
//**************************************************************************************************


//==================================================================================================
// Independant Summons Configuration:
//
constant function IndieSummon_maxdelay takes nothing returns real
    return 2.5 //* The max delay betwen orders issued to the summon
endfunction

constant function IndieSummon_mindelay takes nothing returns real
    return 1.00 //* The min delay betwen orders issued to the summon
endfunction

constant function IndieSummon_maxdistance takes nothing returns real
    return 1000.0 //* If the distance betwen the summon and the master is greater than this value,
                  //  The summon will move to the position of the master instead of attack move
endfunction

constant function IndieSummon_cometomaxdist takes nothing returns real
    return 500.0 //* Max distance for issued orders to approach the master
endfunction

constant function IndieSummon_cometomindist takes nothing returns real
    return 100.0 //* Min distance for issued orders to approach the master
endfunction

//==================================================================================================
function IndieSummon_Order takes unit summon, unit master returns nothing
 local integer o=GetUnitCurrentOrder(summon)
 local real tx=GetUnitX(master)
 local real ty=GetUnitY(master)
 local real angle
 local real dist

    set dist=Pow(tx-GetUnitX(summon),2) + Pow(ty-GetUnitY(summon),2)
    if (dist &gt; (IndieSummon_maxdistance()*IndieSummon_maxdistance()) )  and (o == 0 or o == OrderId(&quot;attack&quot;) or o == OrderId(&quot;move&quot;) or o == OrderId(&quot;stop&quot;) or o==851971) then
        call IssuePointOrder(summon, &quot;move&quot;, tx,ty) 
    elseif dist &gt;= (IndieSummon_cometomindist()*IndieSummon_cometomindist()) and (o == 0 or o == 851971) then
        set angle = GetRandomReal( GetUnitFacing(master)-80, GetUnitFacing(master)+80)
        if (ModuloInteger(GetUnitPointValue(summon),2)==0) then
            set angle=angle * bj_DEGTORAD
        else
            set angle=- angle * bj_DEGTORAD
        endif

        set dist = GetRandomReal(IndieSummon_cometomindist(), IndieSummon_cometomaxdist() )
        set tx=tx+dist*Cos(angle)
        set ty=ty+dist*Sin(angle)
        if not IssuePointOrder(summon, &quot;attack&quot;, tx, ty ) then
            call IssuePointOrder(summon, &quot;move&quot;, tx, ty )
        endif
    endif
 set summon=null
 set master=null
endfunction

function IndieSummon_AntiSmart_Timer takes nothing returns nothing
 local timer t=GetExpiredTimer()
 local string k=GetAttachmentTable(t)
 local unit s=GetTableUnit(k,&quot;summon&quot;)
    if (GetUnitCurrentOrder(s)!=851971) then
        call ClearTable(k)
        call DestroyTimer(t)
    else
        call IndieSummon_Order( s, GetTableUnit(&quot;[IndieSummons]&quot;,GetAttachmentTable(s)) )
        call TimerStart(t,0.1,false,function IndieSummon_AntiSmart_Timer)
    endif
 set t=null
endfunction


function IndieSummon_AntiSmart takes nothing returns nothing
 local timer t

    if (GetIssuedOrderId() == 851971) then
        set t=CreateTimer()
        call AttachObject(t,&quot;summon&quot;,GetTriggerUnit())
        call TimerStart(t,0,false,function IndieSummon_AntiSmart_Timer)
        set t=null
    endif

endfunction

function IndieSummon_loop takes nothing returns nothing
// Executed in another thread
 local unit summon=bj_ghoul[0]  
 local string k=GetAttachmentTable(summon)
 local unit master
 local trigger smart=CreateTrigger()
 local integer n=0
 local triggeraction ac=TriggerAddAction( smart, function IndieSummon_AntiSmart)

    call TriggerRegisterUnitEvent( smart, summon, EVENT_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterUnitEvent( smart, summon, EVENT_UNIT_ISSUED_POINT_ORDER )
    loop
        exitwhen (GetWidgetLife(summon)&lt;=0)
        set master=GetTableUnit(&quot;[IndieSummons]&quot;,k)
        if (master==null) then
            exitwhen true
        else
            call IndieSummon_Order( summon, master)
            call PolledWait( GetRandomReal( IndieSummon_mindelay(), IndieSummon_maxdelay() ))
        endif
    endloop

    call SetTableObject(&quot;[IndieSummons]&quot;,k,null)
    call TriggerRemoveAction(smart,ac)
    call DestroyTrigger(smart)

 set ac=null
 set summon=null
 set master=null
 set smart=null
endfunction


//===========================================================================
function InitTrig_IndieSummon_Code takes nothing returns nothing
endfunction



Trigger:
  • Make summoned units independant
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • Custom script: call IndieSummon_SetMaster( GetSummonedUnit(), GetSummoningUnit())
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top