Forged Alliance Forever Forged Alliance Forever Forums 2018-10-14T18:36:21+02:00 /feed.php?f=41&t=16803 2018-10-14T18:36:21+02:00 2018-10-14T18:36:21+02:00 /viewtopic.php?t=16803&p=168470#p168470 <![CDATA[Re: How to make a unit gain "experience" and level up?]]> I was hoping something like that would be possible.
I can remove wrecks, figure out positions, disable detah animations etc, that's not the problem. What I don't know i figure out through trial and error. This last piece of code, for specific units is exactly what I needed. i shall also look into the Alliance of heroes mod for more info.
Thanx again, man!

Statistics: Posted by DDDX — 14 Oct 2018, 18:36


]]>
2018-10-14T14:45:54+02:00 2018-10-14T14:45:54+02:00 /viewtopic.php?t=16803&p=168469#p168469 <![CDATA[Re: How to make a unit gain "experience" and level up?]]> If you only want a single unit to count then modify only the unitscript like this:

Hooking 'OnKilledUnit' from unitscript:
Code:
local TConstructionUnit = import('/lua/terranunits.lua').TConstructionUnit
local MassKilled = 0

DUMMY0815 = Class(TConstructionUnit) {
    OnKilledUnit = function(self, unitKilled, massKilled)
        -- add the mass of this kill to our mass counter
        MassKilled = MassKilled + massKilled
        -- if we killed over 1,000,000 mass then...
        if MassKilled > 1000000 then
            --do stuff here like creating new unit etc.
        end
        -- call the original function, so we don't break it.
        TConstructionUnit.OnKilledUnit(self, unitKilled, massKilled)
    end,
}
TypeClass = DUMMY0815

Statistics: Posted by Uveso — 14 Oct 2018, 14:45


]]>
2018-10-14T13:29:26+02:00 2018-10-14T13:29:26+02:00 /viewtopic.php?t=16803&p=168467#p168467 <![CDATA[Re: How to make a unit gain "experience" and level up?]]>
The best way to do what to want is to hook the onKilled function in unit.lua
Code:
   OldOnKilledUnit = Unit.OnKilledUnit,
   OnKilledUnit = function(self, unitKilled, massKilled)
      if not massKilled or massKilled == 0 then return end -- Make sure engine calls aren't passed with massKilled == 0
      if IsAlly(self:GetArmy(), unitKilled:GetArmy()) then return end -- No XP for friendly fire...
      self.MassKilled = self.MassKilled + massKilled -- Saving Mass Killed by unit
      -- Your stuff : unit creation or buffing
      ---------------------------------------
      Unit.OldOnKilledUnit(self, unitKilled, massKilled)
    end,


About the replacing system, do you want to keep the current unit graphic model ?

if yes, you can just apply a buff on your unit (that can boost, health, max health, damage, speed, rate of fire, regen...)
If no, you need a new model, you need to kill your unit (without explosion) and create a new graphic model :
for example
Code:
local pos = uniKilled:GetPosition()
local unit = aiBrain:CreateUnitNearSpot('URL0107', pos[1], pos[3])


I'm not sure about pos[3], it's maybe pos[2], cause you have x, y, z position. You need to add some conditions depending of mass killed and unit models...

Ask if you need more information

Statistics: Posted by Franck83 — 14 Oct 2018, 13:29


]]>
2018-10-14T11:35:28+02:00 2018-10-14T11:35:28+02:00 /viewtopic.php?t=16803&p=168466#p168466 <![CDATA[How to make a unit gain "experience" and level up?]]> Need some advice.
For the purpose of making a RPG - style unit, is it possible to code a detection in mass value killed, so that when you have killed let's say 1 million worth of mass with that unit, the map script would then remove the unit in question and replace it with a bigger, better, stronger version of itself?

The part I am having trouble with is the detecting of mass killed. Now, i remember once reading of a mod that plays around with unit stats based on that unit's veterancy, by making it have a shield on higher vet levels or even becoming a different unit altogether when it vets, but I cannot remember what that mod was. If it exists, it would be a good workaround for me if the mass killed thing is not possible to code.

Any ideas? Thanx in advance.

Statistics: Posted by DDDX — 14 Oct 2018, 11:35


]]>