Upgrade system

Upgrade system

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Upgrade system

Post by Forboding Angel »

Look I want to do something fairly simple, but I don't know how.

I want to unlock upgrades if a certain unit exists. These upgrades would affect damage taken and dealt

For example, lets say I have 2 categories, weapons and armor.

Having Weapons upgrade 1 adds a modifier in unitdefs post that increases all damage dealt by a percentage, say 5% or something. Triggered by whether a unit exists.

So for example, player builds unit, unitdefs post gets triggered adding the modifier as long as that unit exists.

Is this difficult? Am I over simplifying it?

Basically what I would like is significantly more detailed, but I'm settling for what I might be able to actually pull off. Hopefully that makes sense.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Upgrade system

Post by knorke »

you can not change unitdefs while the game is running, not even with unitdefs_post.
use return value of UnitDamaged to do "quad damage."
http://answers.springlobby.info/questio ... e-upgrades
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Upgrade system

Post by Google_Frog »

Use gadget:UnitPreDamaged for weapons and armour.

You will have to investigate each individual upgrade you wish to include. Some can be done through gadget callins, some can be done with Spring.SetUnitWeaponState, others with Spring.MoveCtrl.SetGroundMoveTypeData and many are probably impossible without a unit swap.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Upgrade system

Post by Forboding Angel »

I'm sorry, I don't mean editing the unitdefs, I mean applying a percentage to them.

For example, the armor system used by evo and gundam will modify damage based upon a unitdef and weapondef entry (entry being what the damagetype is vs armortype) and it modifies it when it happens.

Basically takes the total value and applies a modifier to it. Could that method be used?

Hmm maybe you guys already answered my question and I didn't realize it...
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Upgrade system

Post by smoth »

it can be used at unit predamaged.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Upgrade system

Post by Google_Frog »

Does "applying a percentage to them (unitdefs)" mean anything?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Upgrade system

Post by Forboding Angel »

I just happened to think... Is it even possible to apply boosts to one team or another? The armor stuffs that gundam and evo use are global. I didn't think of that till late last night.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Upgrade system

Post by Google_Frog »

It is possible to do what you want but you seem to be confused about the technicalities. The way you think should be possible is probably not possible.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Upgrade system

Post by Forboding Angel »

Yeah, that's the impression I was getting
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Upgrade system

Post by Google_Frog »

Here, I will write the gadget for you:

Code: Select all

function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponID, attackerID, attackerDefID, attackerTeam)
    local newDamage = damage

    *** ARBITRARY LOGIC ***

    return newDamage
end
The damage value passed to the function takes all the hardcoded engine armour into account. Afair that is armormod, damages vs different armor types and damage falloff from things like AOE and falloff lasers.
Post Reply

Return to “Lua Scripts”