Map Database  •  FAQ  •  RSS  •  Register  •  Login

Making a group/unit invulnerable

<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2152

Joined: 29 Aug 2007, 22:00

Location: In his dark thunderstormy castle

KaM Skill Level: Veteran

Post 30 Jan 2016, 13:47

Making a group/unit invulnerable

Is it possible to do this? I couldn't find any scripts that could help me to achieve this.
<<

Krom

User avatar

KaM Remake Developer

Posts: 3233

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 30 Jan 2016, 15:10

Re: Making a group/unit invulnerable

IIRC there's no such script command.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2152

Joined: 29 Aug 2007, 22:00

Location: In his dark thunderstormy castle

KaM Skill Level: Veteran

Post 30 Jan 2016, 15:36

Re: Making a group/unit invulnerable

Would you consider adding a script that affects regeneration time of life points? This allows use of 'hero units'... :)
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 30 Jan 2016, 16:42

Re: Making a group/unit invulnerable

The Dark Lord wrote:Would you consider adding a script that affects regeneration time of life points? This allows use of 'hero units'... :)

This should be very easy to do... a States.UnitHealth and an Actions.UnitSetHealth would be enough for this, imho.
  Code:
function TKMUnit.GetHealth: Byte;
begin
  result := fHitPoints;
end;

procedure TKMUnit.SetHealth(aHP: Byte);
begin
  if aHP <= 0 then fHitPoints := 0
  else if aHP >= HitPointsMax then fHitPoints := HitPointsMax
       else fHitPoints := aHP;
end;


Anyway, as far as I know this is what comes closest to that at the moment:
  Code:
procedure OnUnitAfterDied(aUnitType, aOwner, aX, aY);
begin
  if aUnitType >= 14 then Actions.GiveGroup(aOwner, aUnitType, aX, aY, 0, 1, 1)
  else Actions.GiveUnit(aOwner, aUnitType, aX, aY, 0);
end;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Krom

User avatar

KaM Remake Developer

Posts: 3233

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 30 Jan 2016, 18:28

Re: Making a group/unit invulnerable

Problem with that, is that there's no in-game indication of how much HP unit has got and if he is invulnerable.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2152

Joined: 29 Aug 2007, 22:00

Location: In his dark thunderstormy castle

KaM Skill Level: Veteran

Post 30 Jan 2016, 21:28

Re: Making a group/unit invulnerable

There is alsno no in-game indication if I spawn 1000 enemy knights on top of your storehouse at the start of the mission... Except the 1000 knights. Abusers are going to abuse, why punish the righteous? :(
<<

Krom

User avatar

KaM Remake Developer

Posts: 3233

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 31 Jan 2016, 06:58

Re: Making a group/unit invulnerable

The Dark Lord wrote:There is alsno no in-game indication if I spawn 1000 enemy knights on top of your storehouse at the start of the mission... Except the 1000 knights. Abusers are going to abuse, why punish the righteous? :(


There were none and next second there's 1000 - that is indication.

Added to proposals list (https://github.com/Kromster80/kam_remak ... ipting.txt)
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Krom

User avatar

KaM Remake Developer

Posts: 3233

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 31 Jan 2016, 07:04

Re: Making a group/unit invulnerable

Esthlos wrote:
  Code:
procedure TKMUnit.SetHealth(aHP: Byte);
begin
  if aHP <= 0 then fHitPoints := 0                              // Sidenote: type Byte can not possibly be less than 0 by design
  else if aHP >= HitPointsMax then fHitPoints := HitPointsMax
       else fHitPoints := aHP;
end;



There's a better way:

  Code:
procedure TKMUnit.SetHealth(aHP: Byte);
begin
  // We don't want to accidentally kill the unit by setting HP to 0
  fHitPoints := EnsureRange(aHP, 1, HitPointsMax);
end;
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 31 Jan 2016, 09:52

Re: Making a group/unit invulnerable

Krom wrote:There's a better way:

  Code:
procedure TKMUnit.SetHealth(aHP: Byte);
begin
  // We don't want to accidentally kill the unit by setting HP to 0
  fHitPoints := EnsureRange(aHP, 1, HitPointsMax);
end;

Didn't know about the EnsureRange function :$

Why are UnitHPGet and UnitHPMax Actions instead of States? (?)
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

vovets1

User avatar

Sword Fighter

Posts: 356

Joined: 20 May 2012, 08:59

Location: Russia

KaM Skill Level: Veteran

Post 31 Jan 2016, 11:06

Re: Making a group/unit invulnerable

+1 to this idea as a Magic Arena developer.
<<

Rey

User avatar

KaM Remake Developer

Posts: 206

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Fair

Post 08 Nov 2016, 11:06

Re: Making a group/unit invulnerable

Andreas just fix this, PR is on the way. Will see in the next release.
Check it out: https://www.youtube.com/watch?v=x3aV6zEaCXs
<<

Esthlos

User avatar

Knight

Posts: 672

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 08 Nov 2016, 14:51

Re: Making a group/unit invulnerable

Rey wrote:Andreas just fix this, PR is on the way. Will see in the next release.
Check it out: https://www.youtube.com/watch?v=x3aV6zEaCXs

It would also be awesome if the next KaM release also had:
  • Actions.UnitTypeChange (at least for warriors)
  • Actions.CreateFromTile (unit is created by walking in from a tile, so that we can make units exit buildings, caves, or even come in from the map's borders)
  • Actions.KillToTile (the reverse of CreateFromTile, even limiting it to the 4 adjacent tiles would still be nice)

:D
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Ben

User avatar

Prince Lothar

Posts: 3801

Joined: 08 Jan 2009, 23:00

Location: United States of America GMT-5 (Standard Time)

KaM Skill Level: Beginner

Post 09 Nov 2016, 00:59

Re: Making a group/unit invulnerable

Krom wrote:Problem with that, is that there's no in-game indication of how much HP unit has got and if he is invulnerable.


The game Empire Earth has a small graphical indication when a unit or building has been modified by "scripts." Adding such a mechanic to KaM could be quite useful, though it's much harder to do since soldiers are typically controlled as a collective unit rather than individually.

Now, it [i]is[/] possible to select individual soldiers in KaM. Say, for example, that you select a knight within a group of knights. This respective individual knight's stats have been modified. This could be shown by a special icon of sorts on the screen where his condition and commands are shown. This icon could be displayed automatically when a unit is edited or manually through an additional script, whichever is easier/has more support with the community.

Furthermore, a similar feature of changing a soldier's or citizen's name could be quite useful. Best would be replacing the soldier's type with his name (change the label "knight" to "King John." for example). This would be both a very popular and useful feature, as mission makers have already put unique units in their missions.


Whew. There's my wall of text of the week. I typed all of that on my phone so please forgive any silly autocorrections I might have not replaced.
#thunderposting #greentornado
<<

Krom

User avatar

KaM Remake Developer

Posts: 3233

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 09 Nov 2016, 04:22

Re: Making a group/unit invulnerable

Changing units name will be fun indeed :-)
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 293

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 10 Nov 2016, 18:23

Re: Making a group/unit invulnerable

Good idea! States.UnitHp, Actions.UnitSetHp would be nice :) for my maps i use "Respawn" method, but its not cool :P

Return to Dynamic Scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron