Weapon Special Absorb

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
PsychoticKittens
Posts: 573
Joined: May 29th, 2006, 8:49 pm

Weapon Special Absorb

Post by PsychoticKittens »

Okay, I'm not sure if its just because drain is hard-coded to the point of being un-editable or not, but; I want to make a drain which has the possibility to extend maximum hp.

This is what I tried with and it didn't work.

Code: Select all

#define PK_WEAPON_SPECIAL_ABSORB

[drains]
        
	id=absorb
        
	name= _ "absorb"
        
	description= _ "Absorb:
This unit absorbs the body of living units, healing itself for half the amount of damage it deals (rounded down). It is able to surpass its maximum health."
 
	violate_max=yes   
[/drains]

#enddef
Creator of: Mercenaries Era; Modern Combat
Future Projects: Faunima: Land of Monsters
Temporarily Dropped Projects: Zombie Horde
User avatar
PsychoticKittens
Posts: 573
Joined: May 29th, 2006, 8:49 pm

Re: Weapon Special Absorb

Post by PsychoticKittens »

Code: Select all

#define PK_WEAPON_SPECIAL_ABSORB

[dummy]
        
	id=absorb
        
	name= _ "absorb"
        
	description= _ "Absorb:
This unit absorbs the body of living units. It is able to surpass its maximum health through draining when attacking."
    
[/dummy]

#enddef
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT1
#define PK_WEAPON_SPECIAL_ABSORB_EVENT1 UNIT_TYPE
    [event]
        name=attack
        first_time_only=no
       
        [filter]
            type={UNIT_TYPE}
        [/filter]
        [store_unit]
            [filter]
                description=$unit.description
            [/filter]
	    variable=temp_var
        [/store_unit]
        [set_variable]
            name=temp_var.max_hitpoints
            value=100000
        [/set_variable]
        [unstore_unit]
            variable=temp_var
        [/unstore_unit]
        {CLEAR_VARIABLE temp_var}
   [/event]
	[event]
           name=attack_end
	   first_time_only=no
      [filter]
          type={UNIT_TYPE}
      [/filter]
      [store_unit]
          variable=temp_var
         [filter]
             x=$x1
             y=$y1
         [/filter]
      [/store_unit]
	   [set_variable]
             name=temp_var.max_hitpoints
             value=10
           [/set_variable]
	   [unstore_unit]
             variable=temp_var
           [/unstore_unit]
	  {CLEAR_VARIABLE temp_var}
	 [/event]
#enddef
#endif
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT2
#define PK_WEAPON_SPECIAL_ABSORB_EVENT2 UNIT_TYPE
    [event]
        name=attack
        first_time_only=no
       
        [filter]
            type={UNIT_TYPE}
        [/filter]
        [store_unit]
            [filter]
                description=$unit.description
            [/filter]
	    variable=temp_var
        [/store_unit]
        [set_variable]
            name=temp_var.max_hitpoints
            value=100000
        [/set_variable]
        [unstore_unit]
            variable=temp_var
        [/unstore_unit]
        {CLEAR_VARIABLE temp_var}
   [/event]
	[event]
           name=attack_end
	   first_time_only=no
      [filter]
          type={UNIT_TYPE}
      [/filter]
      [store_unit]
          variable=temp_var
         [filter]
             x=$x1
             y=$y1
         [/filter]
      [/store_unit]
	   [set_variable]
             name=temp_var.max_hitpoints
             value=24
           [/set_variable]
	   [unstore_unit]
             variable=temp_var
           [/unstore_unit]
	  {CLEAR_VARIABLE temp_var}
	 [/event]
#enddef
#endif
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT3
#define PK_WEAPON_SPECIAL_ABSORB_EVENT3 UNIT_TYPE
    [event]
        name=attack
        first_time_only=no
       
        [filter]
            type={UNIT_TYPE}
        [/filter]
        [store_unit]
            [filter]
                description=$unit.description
            [/filter]
	    variable=temp_var
        [/store_unit]
        [set_variable]
            name=temp_var.max_hitpoints
            value=100000
        [/set_variable]
        [unstore_unit]
            variable=temp_var
        [/unstore_unit]
        {CLEAR_VARIABLE temp_var}
   [/event]
	[event]
           name=attack_end
	   first_time_only=no
      [filter]
          type={UNIT_TYPE}
      [/filter]
      [store_unit]
          variable=temp_var
         [filter]
             x=$x1
             y=$y1
         [/filter]
      [/store_unit]
	   [set_variable]
             name=temp_var.max_hitpoints
             value=30
           [/set_variable]
	   [unstore_unit]
             variable=temp_var
           [/unstore_unit]
	  {CLEAR_VARIABLE temp_var}
	 [/event]
#enddef
#endif
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT4
#define PK_WEAPON_SPECIAL_ABSORB_EVENT4 UNIT_TYPE
    [event]
        name=attack
        first_time_only=no
       
        [filter]
            type={UNIT_TYPE}
        [/filter]
        [store_unit]
            [filter]
                description=$unit.description
            [/filter]
	    variable=temp_var
        [/store_unit]
        [set_variable]
            name=temp_var.max_hitpoints
            value=100000
        [/set_variable]
        [unstore_unit]
            variable=temp_var
        [/unstore_unit]
        {CLEAR_VARIABLE temp_var}
   [/event]
	[event]
           name=attack_end
	   first_time_only=no
      [filter]
          type={UNIT_TYPE}
      [/filter]
      [store_unit]
          variable=temp_var
         [filter]
             x=$x1
             y=$y1
         [/filter]
      [/store_unit]
	   [set_variable]
             name=temp_var.max_hitpoints
             value=28
           [/set_variable]
	   [unstore_unit]
             variable=temp_var
           [/unstore_unit]
	  {CLEAR_VARIABLE temp_var}
	 [/event]
#enddef
#endif
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT5
#define PK_WEAPON_SPECIAL_ABSORB_EVENT5 UNIT_TYPE
    [event]
        name=attack
        first_time_only=no
       
        [filter]
            type={UNIT_TYPE}
        [/filter]
        [store_unit]
            [filter]
                description=$unit.description
            [/filter]
	    variable=temp_var
        [/store_unit]
        [set_variable]
            name=temp_var.max_hitpoints
            value=100000
        [/set_variable]
        [unstore_unit]
            variable=temp_var
        [/unstore_unit]
        {CLEAR_VARIABLE temp_var}
   [/event]
	[event]
           name=attack_end
	   first_time_only=no
      [filter]
          type={UNIT_TYPE}
      [/filter]
      [store_unit]
          variable=temp_var
         [filter]
             x=$x1
             y=$y1
         [/filter]
      [/store_unit]
	   [set_variable]
             name=temp_var.max_hitpoints
             value=40
           [/set_variable]
	   [unstore_unit]
             variable=temp_var
           [/unstore_unit]
	  {CLEAR_VARIABLE temp_var}
	 [/event]
#enddef
#endif
This ability officially works thanks to TL for the idea of Max_Hp increase mixed with regular drain.
Creator of: Mercenaries Era; Modern Combat
Future Projects: Faunima: Land of Monsters
Temporarily Dropped Projects: Zombie Horde
User avatar
krotop
2009 Map Contest Winner
Posts: 433
Joined: June 8th, 2006, 3:05 pm
Location: Bordeaux, France

Re: Weapon Special Absorb

Post by krotop »

I'd have some question about this, for the sake of curiosity or eventually be able to use this method in my own codes :
#ifndef PK_WEAPON_SPECIAL_ABSORB_EVENT1
#define PK_WEAPON_SPECIAL_ABSORB_EVENT1 UNIT_TYPE

I don't understand how you implement this special in a unit. It would seem to me that you never choose the definition of UNIT_TYPE here.
Don't trust me, I'm just average player.
***
Game feedback for the Nightmares of Meloen
Art feedback by mystic x the unknown
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Weapon Special Absorb

Post by AI »

It doesn't show up properly in the attack dialog though. Making [drain] a little more flexible sounds like a reasonable feature to me. Any other opinions?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Weapon Special Absorb

Post by Sapient »

AI wrote:It doesn't show up properly in the attack dialog though. Making [drain] a little more flexible sounds like a reasonable feature to me. Any other opinions?
allowing drain to violate maximum hp would definitely break the current attack prediction code
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
PsychoticKittens
Posts: 573
Joined: May 29th, 2006, 8:49 pm

Re: Weapon Special Absorb

Post by PsychoticKittens »

krotop: to give a weapon special event code you have to define the special event with ifndef and then define, put the event inside that, and at the bottom of the unit code before it ends put {"EVENT_NAME"} some unit definitions have things like WEAPON_TYPE or UNIT_TYPE to define when the special takes effect, sometimes both, in that case it would have the id of the unit after the EVENT_NAME with a space i.e. {PK_WEAPON_SPECIAL_ABSORB_EVENT1 bliblob} is the exact thing you put in the code for the unit with id: bliblob I had to specify the hp of each unit since my other method of storing the units hp didn't work, thats why there's five different ones.
Creator of: Mercenaries Era; Modern Combat
Future Projects: Faunima: Land of Monsters
Temporarily Dropped Projects: Zombie Horde
leko8731
Posts: 17
Joined: May 5th, 2022, 10:24 am

Re: Weapon Special Absorb

Post by leko8731 »

WEAPON_SPECIAL_ABSORB AMT ?
When i use it the ennemy unit gets incredible high attack value (sometimes 125) killing my absorbing unit instantly.
Is this normal . Surely something went wrong or is this normal. As I see it it should give my unit an advantage, not kill it.
I did not enter a number for amt, supposing it would not be necessary, maybe causing the mayhem. Thoughts please, leko8731
Post Reply