Random Damage Type

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.
User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Random Damage Type

Post by drachefly »

I want to make an attack which deals damage that's of random type, rerandomized on each individual bolt (so a 8-3 randomly hot*/cold could go hot cold hot, for example). I'm willing to sacrifice the damage prediction being accurate.

I'm supposing the general idea is I assign an event to the unit type; and the event reacts to each attack that has this special and changes its damage type just before it goes off?

I'm looking at the EventWML wiki page and figuring out how to do that.
I'm thinking

Code: Select all

[event]
name=attacker hits
[filter_attack]
  special=randomlyhotcold
[/filter_attack]
... what goes here?
[/event]
Okay, so supposing that'd trigger, I don't see anything in DirectActionsWML that would do this unless I implement it as giving the unit an object that'd have an Effect that'd change their damage type. There is a uniqueness restriction on objects, that I don't want. And I don't see what sort of filter I can put on DirectActionsWML that'd indicate which unit is the one doing the attack.

Now, it is not necessary for the damage type to be maintained individually for each unit with the special, as it'll be rerandomized before each hit anyway. But I don't want things to slow to a crawl if 20 low-level pastamancers get into a fight, and I don't want only one of them to be able to get a particular damage type.

So... where do I go from here? Will I need to learn Lua?


* I'm using nonstandard damage types
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Random Damage Type

Post by Mabuse »

so wheres the point of having random damage types ?

answer:
different damages affect different resistances, so there will be different amount of damage done.

so the main goal is to generate DIFFERENT DAMAGE VALUES (assumed the fire/cold resistances of the target are different - if they are not, there wont be any difference)

so if yu cant do REAL random damage types, you can at least SIMULATE it by adusting the damage :)

now im not going to post code here, but thats the approach i would try.


(exchange fire/cold with the damage-types you are ging to use)
The best bet is your own, good Taste.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Random Damage Type

Post by zookeeper »

Code: Select all

[event]
    name=attacker hits
    first_time_only=no
    
    [filter_attack]
        special=randomlyhotcold
    [/filter_attack]
    
    {FOREACH unit.attack i}
        [if]
            [variable]
                name=unit.attack[$i].specials.randomlyhotcolddummy.id
                equals=randomlyhotcold
            [/variable]
            
            [then]
                {RANDOM hot,cold}
                
                {VARIABLE unit.attack[$i].type $random}
            [/then]
        [/if]
    {NEXT i}
    
    [unstore_unit]
        variable=unit
        find_vacant=no
        text= _ "going $random"
    [/unstore_unit]
[/event]
However, it just might not work. Not every kind of attack properties are updated mid-combat, so changing the type might not have any effect until the next fight. That's just what I'd try first.

If the above doesn't work, then the alternative would be something akin to what you'll find in the LessLuck Era, but even more complicated and lots more verbose since attack specials can't change the actual damage type, just the damage. I wouldn't even try to do that as it is.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Random Damage Type

Post by Mabuse »

zookeeper wrote:That's just what I'd try first.
looks great though.
and i think i learned something from looking at it
(concerning the random values ... )
The best bet is your own, good Taste.
User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Re: Random Damage Type

Post by drachefly »

You're unstoring a unit without storing it. Is that kosher?
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
User avatar
PsychoticKittens
Posts: 573
Joined: May 29th, 2006, 8:49 pm

Re: Random Damage Type

Post by PsychoticKittens »

I believe that in that event type "unit" is prestored as the unit attacking. Or sommat like that.
Creator of: Mercenaries Era; Modern Combat
Future Projects: Faunima: Land of Monsters
Temporarily Dropped Projects: Zombie Horde
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Random Damage Type

Post by Gambit »

User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Re: Random Damage Type

Post by drachefly »

Whoopdy-dee and trolly-bazoo! It works!

Thanks a lot!
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Random Damage Type

Post by Mabuse »

awesome.

kinda cool idea if you ask me :)
(and after thinkg a bit about it)

it makes a units attack unpredictable.
The best bet is your own, good Taste.
User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Re: Random Damage Type

Post by drachefly »

Ohoho, I am going to have fun with this! When 0.1.6 comes out, start a fight between some pastamancers and saucerors.
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Random Damage Type

Post by Gambit »

drachefly wrote: When 0.1.6 comes out
:shock: A time traveler... from the past?

It's moments like these that make me love forums.
Even if you meant 1.6.0 you're still a bit behind the times.
User avatar
artisticdude
Moderator Emeritus
Posts: 2424
Joined: December 15th, 2009, 12:37 pm
Location: Somewhere in the middle of everything

Re: Random Damage Type

Post by artisticdude »

I have version 0.1.6 on my computer somewhere (don't ask me why). And I mean 0.1.6, not 1.6.0. :P I even play it occasionally, just to remind myself how far the game has come since its infancy, and to marvel at how much better the graphics are in the recent versions. [/off-topic]
"I'm never wrong. One time I thought I was wrong, but I was mistaken."
User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Re: Random Damage Type

Post by drachefly »

See my sig. 0.1.6 of that.
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
User avatar
Xudo
Posts: 563
Joined: April 3rd, 2009, 5:26 pm

Re: Random Damage Type

Post by Xudo »

Whoopdy-dee and trolly-bazoo! It works!
I think zookepers code must not work completely as you want. You have first strike with no randomness. All other strikes in one fight is really random.

Or I don't know something and event "attacker/defender hits" fires before unit hits?
User avatar
drachefly
Posts: 308
Joined: March 23rd, 2005, 6:01 pm
Location: Philadelphia, PA

Re: Random Damage Type

Post by drachefly »

You are correct. As it stands, you can see the next type of damage you'll deal.

That's... annoying.

Hmm. I could have it trigger on the attack itself before anything happens AND on hits, with only actual hits displaying the damage type (and displaying the old one). Needs different kind of trigger for each.

Anyway, I assume I can get that ironed out. In the mean time, I've added some additional features:
I've extended it to include all 6 damage types (for a different unit). I also made a dummy 'attack animation' that slowed down the attack to the point that you could make out the individual messages instead of having them crammed together. Then I changed the text shown to be representative of the damage type rather than the name of the damage type, using randomly selected representatives. And, perhaps more importantly, colored them to match the type.

Now I'm working on getting it to fire even when the affected unit is defending. That's going to require some indirection, but no more than we'll need to sort out that first issue.

Also, we'll need it not to fire multiple times if there are multiple unit types with this ability in the field. The overlaid text is silly.
What saves a man is to take a step. Then another step. It is always the same step, but you have to take it. -- You-know-who
The Kingdom Of Loathing Era
Post Reply