Pickpocket in reverse example code desired

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
hart02
Posts: 52
Joined: July 15th, 2009, 12:06 am

Pickpocket in reverse example code desired

Post by hart02 » May 14th, 2010, 10:00 pm

Every one has heard of WEAPON_SPECIAL_PICKPOCKET right? I was planning to code a weapon special like pickpocket except in reverse just for some fun. The attacked unit loses gold when attacked and the attacker gets gold from the unit. This would be used with rock creatures.It would be similar to how in mario games he can hit some blocks and can get coins,powerup etc.I could try to make it an ability or trait too.Here is the code which does not have the desired effect.Any help would be appreciated

Code: Select all

#define WEAPON_SPECIAL_SHED

# Canned definition of the pickpocket ability to be included in a

# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[damage]
  id=shed
  name=shed
  description=Shed :Loses money when attacked.
  apply_to=unit
[/damage]
[/specials]
[/attack]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=unit_damaged_from_shed
     mode=append
  [/store_unit]
  [set_variable]
     name=unit_damaged_from_shed.variables.shed_has_worked
     value=yes
  [/set_variable]
  [unstore_unit]
     variable=unit_damaged_from_shed
  [/unstore_unit]   
  {CLEAR_VARIABLE unit_damage_from_shed}
[/event]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=shedder
     mode=append
  [/store_unit]   
  [store_unit]
     [filter]
        x,y=$x2,$y2
     [/filter]
     variable=shedee
     mode=append
  [/store_unit]   
  [if]
     [variable]
        name=shedee.variables.shed_has_worked
        equals=yes
     [/variable]
     [then]
   [gold]
    side=$2
    amount=8
   [/gold]
        [unstore_unit]
           variable=shedder
           text=!
           {COLOR_HARM}
        [/unstore_unit]
     [/then]
  [/if]   
  {CLEAR_VARIABLE sheddee}
  {CLEAR_VARIABLE shedder}
[/event]
[+attack]
[+specials]
#enddef

#define WEAPON_SPECIAL_SHED_2

# Canned definition of the pickpocket ability to be included in a

# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[damage]
  id=shed2
  name=shed2
  description=Shed :Loses money on when attacked.
  apply_to=unit
[/damage]
[/specials]
[/attack]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=unit_damaged_from_shed
     mode=append
  [/store_unit]
  [set_variable]
     name=unit_damaged_from_shed.variables.shed_has_worked
     value=yes
  [/set_variable]
  [unstore_unit]
     variable=unit_damaged_from_shed
  [/unstore_unit]   
  {CLEAR_VARIABLE unit_damage_from_shed}
[/event]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=shedder
     mode=append
  [/store_unit]   
  [store_unit]
     [filter]
        x,y=$x2,$y2
     [/filter]
     variable=shedee
     mode=append
  [/store_unit]   
  [if]
     [variable]
        name=shedee.variables.shed_has_worked
        equals=yes
     [/variable]
     [then]
   [gold]
    side=$2
    amount=16
   [/gold]
        [unstore_unit]
           variable=shedder
           text=!
           {COLOR_HARM}
        [/unstore_unit]
     [/then]
  [/if]   
  {CLEAR_VARIABLE sheddee}
  {CLEAR_VARIABLE shedder}
[/event]
[+attack]
[+specials]
#enddef

#define WEAPON_SPECIAL_SHED_3

# Canned definition of the pickpocket ability to be included in a

# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[damage]
  id=shed3
  name=shed3
  description=Shed :Loses money when attacked.
  apply_to=unit
[/damage]
[/specials]
[/attack]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=unit_damaged_from_shed
     mode=append
  [/store_unit]
  [set_variable]
     name=unit_damaged_from_shed.variables.shed_has_worked
     value=yes
  [/set_variable]
  [unstore_unit]
     variable=unit_damaged_from_shed
  [/unstore_unit]   
  {CLEAR_VARIABLE unit_damage_from_shed}
[/event]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=shedder
     mode=append
  [/store_unit]   
  [store_unit]
     [filter]
        x,y=$x2,$y2
     [/filter]
     variable=shedee
     mode=append
  [/store_unit]   
  [if]
     [variable]
        name=shedee.variables.shed_has_worked
        equals=yes
     [/variable]
     [then]
   [gold]
    side=$2
    amount=24
   [/gold]
        [unstore_unit]
           variable=shedder
           text=!
           {COLOR_HARM}
        [/unstore_unit]
     [/then]
  [/if]   
  {CLEAR_VARIABLE sheddee}
  {CLEAR_VARIABLE shedder}
[/event]
[+attack]
[+specials]
#enddef

#define WEAPON_SPECIAL_GOLDSHED

# Canned definition of the pickpocket ability to be included in a

# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[damage]
  id=goldshed
  name=goldshed
  description=goldshed :Loses money on hitting.
  apply_to=self	
[/damage]
[/specials]
[/attack]
[event]
  name=defender_hits
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=unit_damage_from_goldshed
     mode=append
  [/store_unit]
  [set_variable]
     name=unit_damage_from_goldshed.variables.goldshed_has_worked
     value=yes
  [/set_variable]
  [unstore_unit]
     variable=unit_damage_from_goldshed
  [/unstore_unit]   
  {CLEAR_VARIABLE unit_damage_from_goldshed}
[/event]
[event]
  name=defender_hits
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=goldshedder
     mode=append
  [/store_unit]   
  [store_unit]
     [filter]
        x,y=$x2,$y2
     [/filter]
     variable=goldshedee
     mode=append
  [/store_unit]   
  [if]
     [variable]
        name=goldshedee.variables.goldshed_has_worked
        equals=yes
     [/variable]
     [then]
   [gold]
    side=$side_number
    amount=-16
   [/gold]
        [unstore_unit]
           variable=goldshedder
           text=!
           {COLOR_HARM}
        [/unstore_unit]
     [/then]
  [/if]   
  {CLEAR_VARIABLE goldsheddee}
  {CLEAR_VARIABLE goldshedder}
[/event]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=unit_damaged_from_goldshed
     mode=append
  [/store_unit]
  [set_variable]
     name=unit_damaged_from_goldshed.variables.goldshed_has_worked
     value=yes
  [/set_variable]
  [unstore_unit]
     variable=unit_damaged_from_goldshed
  [/unstore_unit]   
  {CLEAR_VARIABLE unit_damage_from_goldshed}
[/event]
[event]
  name=attack_end
  first_time_only=no     
  [store_unit]
     [filter]
        x,y=$x1,$y1
     [/filter]
     variable=goldshedder
     mode=append
  [/store_unit]   
  [store_unit]
     [filter]
        x,y=$x2,$y2
     [/filter]
     variable=goldshedee
     mode=append
  [/store_unit]   
  [if]
     [variable]
        name=goldshedee.variables.goldshed_has_worked
        equals=yes
     [/variable]
     [then]
   [gold]
    side=$side_number
    amount=-16
   [/gold]
        [unstore_unit]
           variable=goldshedder
           text=!
           {COLOR_HARM}
        [/unstore_unit]
     [/then]
  [/if]   
  {CLEAR_VARIABLE goldsheddee}
  {CLEAR_VARIABLE goldshedder}
[/event]
[+attack]
[+specials]
#enddef
Last edited by hart02 on May 14th, 2010, 10:03 pm, edited 1 time in total.
Smart persons learn out of their mistakes, wise persons learn out of others mistakes! It seems that a select few have a talent learning out of others mistakes which many politicians lack.
Author of Era Of Two Suns

User avatar
Hulavuta
Posts: 1668
Joined: October 11th, 2008, 8:17 pm
Location: United States

Re: Pickpocket in reverse example code desired

Post by Hulavuta » May 14th, 2010, 10:02 pm

Well, I've never heard of Pickpocket....what era/faction/unit is it from?
F:tGJ, Saurian Campaign
The Southern Chains, a fanfic
“The difference between winners and champions is that champions are more consistent."
~Sierra

hart02
Posts: 52
Joined: July 15th, 2009, 12:06 am

Re: Pickpocket in reverse example code desired

Post by hart02 » May 14th, 2010, 10:09 pm

something like it is in bob's rpg era.Scavenger i belive it is called. you also can find it the wiki here
http://wiki.wesnoth.org/WML_Abilities#Pickpocket
Smart persons learn out of their mistakes, wise persons learn out of others mistakes! It seems that a select few have a talent learning out of others mistakes which many politicians lack.
Author of Era Of Two Suns

Post Reply