Looking for code...
Moderator: Forum Moderators
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
Looking for code...
I can't find the code for any of the special weapon attributes(poison, backstab, slow) in the wesnoth/data folder and I wanted to tweak the backstab code to make that dread ability.
You can take the backstab ability...
Remove all that malarky about needing a friendly unit on the other side of the enemy.
Change 'deal double damage' to 'receive half damage' et voila!
I'm pretty sure backstab never works when you're on the defensive even if you have an allied unit on the other side of the enemy as well, right?
Well that fits the dread ability perfectly.
If that isn't how it works, just borrow the code from marksmanship that says 'this only works when you're attacking'.
Or you can modify slow...
As soon as a unit with dread initiates combat (before blows are exchanged), the target becomes afflicted with slow (deals half damage) and then remove the slow afflication once the battle has concluded.
Though this might cause problems with the actual slow ability, I'm sure you can just borrow the slow code but rename it as dread so it doesn't override or interfere with normal slow.
toms was also looking for some help getting our campaign working, someone I don't think I'm the one to help him.
http://www.wesnoth.org/forum/viewtopic. ... 7&start=30
You can take the backstab ability...
Remove all that malarky about needing a friendly unit on the other side of the enemy.
Change 'deal double damage' to 'receive half damage' et voila!
I'm pretty sure backstab never works when you're on the defensive even if you have an allied unit on the other side of the enemy as well, right?
Well that fits the dread ability perfectly.
If that isn't how it works, just borrow the code from marksmanship that says 'this only works when you're attacking'.
Or you can modify slow...
As soon as a unit with dread initiates combat (before blows are exchanged), the target becomes afflicted with slow (deals half damage) and then remove the slow afflication once the battle has concluded.
Though this might cause problems with the actual slow ability, I'm sure you can just borrow the slow code but rename it as dread so it doesn't override or interfere with normal slow.
toms was also looking for some help getting our campaign working, someone I don't think I'm the one to help him.
http://www.wesnoth.org/forum/viewtopic. ... 7&start=30
Code:And unfortunately,
the computer still doesn´t read the campaign.
Help please, I´m stuck.
Code: Select all
#ifdef MULTIPLAYER
{@campaigns/MP_Campaign/scenarios/}
{@campaigns/MP_campaign/maps/}
{@campaigns/MP_campaign/utils.cfg}
#endif
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
Okay let's try this a different way.
Where is the code that makes the ability backstab function the way that it does?
The game doesn't automatically know how 'backstab' works from the description in the game help files, so where it is?
Simple as that.
Where is the code that makes the ability backstab function the way that it does?
The game doesn't automatically know how 'backstab' works from the description in the game help files, so where it is?
Simple as that.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
It's been a long time since I was in college and worked with code but let's see...
Between backstab, slow, and steadfast... Backstab deals with increasing damage, slow deals with reducing damage, and steadfast increases resistances.
Dread's purpose is identical to slow, so let's borrow code from slow.
would probably turn into
Simply exchanging the word 'slow' with 'dread' because we basically want the same effect so why not borrow from slow...
Again to convert to dread, just replace 'slow' with 'dread' everywhere it is listed in this block of code. We still want the exact same effect, what we need to change is the 'how is it applied' timing.
Looks like the code for how 'slow' causes unit damaged to be 'halved'.
Looks like it invokes a lot of other functions too...
Hmm..
I didn't see where the code determines how a unit becomes labeled with 'slow'.
This second bit of code explains what to do with a unit's attack power if it is slowed (halve it), but doesn't seem to deal with afflicting said unit with 'slow', if I'm reading it right.
Where is the code for how an attacking unit attaches the 'slow' effect unto another unit?
Actually... that first bit of code I cut and pasted looks like it might be it...
Is there a way to tell the game to apply this 'slow' (half damage) effect simply by initiating combat instead of applying it after the attacker with the 'slow' ability lands a blow?
We don't need to change slow's affect, we want the damage to be halved, but we need to change the timing of it's application and would also need to remove it at the conclusion of the round of combat.
Would have to modify that code to fit dread...
Instead of the defender needing to be hit with slow, dread would be applied before the first blow is landed, and it would also need to be removed after the defenders last attack.
One question... should it stack with slow? I say why not, but this could be an issue.
Between backstab, slow, and steadfast... Backstab deals with increasing damage, slow deals with reducing damage, and steadfast increases resistances.
Dread's purpose is identical to slow, so let's borrow code from slow.
Code: Select all
static const std::string slow_string("slow");
res.attacker_slows = res.attacker_special == slow_string;
Code: Select all
static const std::string dread_string("dread");
res.attacker_dreads= res.attacker_special == dread_string;
Code: Select all
if (a->second.slowed()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("slowed") << EMPTY_COLUMN << _("Halved");
strings->attack_calculations.push_back(str.str());
}
Looks like the code for how 'slow' causes unit damaged to be 'halved'.
Looks like it invokes a lot of other functions too...
Hmm..
I didn't see where the code determines how a unit becomes labeled with 'slow'.
This second bit of code explains what to do with a unit's attack power if it is slowed (halve it), but doesn't seem to deal with afflicting said unit with 'slow', if I'm reading it right.
Where is the code for how an attacking unit attaches the 'slow' effect unto another unit?
Actually... that first bit of code I cut and pasted looks like it might be it...
Is there a way to tell the game to apply this 'slow' (half damage) effect simply by initiating combat instead of applying it after the attacker with the 'slow' ability lands a blow?
We don't need to change slow's affect, we want the damage to be halved, but we need to change the timing of it's application and would also need to remove it at the conclusion of the round of combat.
Would have to modify that code to fit dread...
Instead of the defender needing to be hit with slow, dread would be applied before the first blow is landed, and it would also need to be removed after the defenders last attack.
One question... should it stack with slow? I say why not, but this could be an issue.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
Writing it out in 'psuedo' code...
Says:
Attacker afflicts target with slow (attacker_slows) is (=) attacker special is the same as (==) slow spell (slow_string)
I think...
Dread code would need to say...
If
Attacker special is dread
Then apply 'dread' [half damage] to defender's retaliation[attack]
Hmm...
Specials like slow and poison rely on a target being struck to apply.
But charge doesn't, it double an attackers (and defenders) damage simply if the attacker is initiating combat.
So let's look at charge code...
Actually, looking at charge right next to slow makes a lot of sense. Let's see if I can't make dread out of the two of them...
Code: Select all
static const std::string slow_string("slow");
res.attacker_slows = res.attacker_special == slow_string;
Attacker afflicts target with slow (attacker_slows) is (=) attacker special is the same as (==) slow spell (slow_string)
I think...
Dread code would need to say...
If
Attacker special is dread
Then apply 'dread' [half damage] to defender's retaliation[attack]
Hmm...
Specials like slow and poison rely on a target being struck to apply.
But charge doesn't, it double an attackers (and defenders) damage simply if the attacker is initiating combat.
So let's look at charge code...
Code: Select all
if (charge) {
bonus *= 2;
if (strings) {
std::stringstream str;
str << _("charge") << EMPTY_COLUMN << _("Doubled");
strings->defend_calculations.push_back(str.str());
}
}
if (d->second.slowed()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("slowed") << EMPTY_COLUMN << _("Halved");
strings->defend_calculations.push_back(str.str());
}
Actually, looking at charge right next to slow makes a lot of sense. Let's see if I can't make dread out of the two of them...
Last edited by SmokemJags on March 11th, 2006, 12:05 pm, edited 1 time in total.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
I noticed the charge code doesn't have the 'a' or 'd' notation that slow carries. It simply is 'if charge'
A and D must be Attacker and Defender, and since charge has neither it must automatically apply to both, not needing seperate definitions... (when an attacker has 'charge' both attacker and defender deal double damage. When an attacker has 'slow' the attacker and defender do NOT both deal half damage. Makes sense.)
Keeping this in mind...
Says attacker is slowed, attacker deals half damage.
Says defender is slowed, defender deals half damage.
Is it possible to...
Now that code reads:
If attacker is afflicted with dread... defender will deal half damage!
Think of the shadow's ability for... what's it called... nightstalk. Whatever makes him invisible.
Dread would be just like that.
The shadow's invisibility is always on... during the night and if he doesn't attack.
Dread would be always on period. It wouldn't ever go away.
And it's effect?
'D' defender would always deal half damage when in combat with a unit possessing/afflicted by 'dread'.
Sounds perfect, in theory. Unfortunately I don't know how to write that code...
Question... if that code could be made to work... would a unit attacking a Draug label the Draug as 'D' (defender) and halve his damage?
If that's the case... the unit would need a string exception that checks...
If 'D' Defender == Unit Draug, do not halve damage.
But that raises the question... what if a draug attacks another draug?
My answer? Undead should be immune to 'dread' just like they are immune to 'poison'. It just makes sense. A skeleton... afraid? Nope.
So this works in a code sense and a gameplay explanation of why draugs attacking draugs don't have any halving damage applied.
A and D must be Attacker and Defender, and since charge has neither it must automatically apply to both, not needing seperate definitions... (when an attacker has 'charge' both attacker and defender deal double damage. When an attacker has 'slow' the attacker and defender do NOT both deal half damage. Makes sense.)
Keeping this in mind...
Code: Select all
if (a->second.slowed()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("slowed") << EMPTY_COLUMN << _("Halved");
strings->attack_calculations.push_back(str.str());
}
Code: Select all
if (d->second.slowed()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("slowed") << EMPTY_COLUMN << _("Halved");
strings->defend_calculations.push_back(str.str());
Is it possible to...
Code: Select all
if (a->second.dread()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("dreadful") << EMPTY_COLUMN << _("Halved");
strings->defend_calculations.push_back(str.str());
}
If attacker is afflicted with dread... defender will deal half damage!
Think of the shadow's ability for... what's it called... nightstalk. Whatever makes him invisible.
Dread would be just like that.
The shadow's invisibility is always on... during the night and if he doesn't attack.
Dread would be always on period. It wouldn't ever go away.
And it's effect?
'D' defender would always deal half damage when in combat with a unit possessing/afflicted by 'dread'.
Sounds perfect, in theory. Unfortunately I don't know how to write that code...
Question... if that code could be made to work... would a unit attacking a Draug label the Draug as 'D' (defender) and halve his damage?
If that's the case... the unit would need a string exception that checks...
If 'D' Defender == Unit Draug, do not halve damage.
But that raises the question... what if a draug attacks another draug?
My answer? Undead should be immune to 'dread' just like they are immune to 'poison'. It just makes sense. A skeleton... afraid? Nope.
So this works in a code sense and a gameplay explanation of why draugs attacking draugs don't have any halving damage applied.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
The first three posts are my train of thought and some brainstorming, this fourth one is the conclusion of those thoughts.
The code that says:
Attacker has ability/is afflicted by dread.
Defender deal half damage.
I think this is the code that is needed to 'define' dread.
Some problems I need help with:
A. Those two pieces of code deal with 'dread' as a weapon 'special' like charge or slow or backstab.
B. I need the code for the ability 'nightstalk'... I think 'dread' should be an ability not a weapon special... though I suppose it could work as either.
Change nightstalk from saying:
C. Apply the tweaks seen in the first block of code in this post (attacker has dread, defender deals half damage) to the ability of dread, not the weapon special dread.
Or maybe it would simply work as a weapon special if I designed it like charge... charge certainly is a weapon special that deals with altering damage yet doesn't require units to be afflicted by it...
I dunno, could use a little help and suggestions at this point.
The code that says:
Attacker has ability/is afflicted by dread.
Defender deal half damage.
Code: Select all
if (a->second.dread()) {
divisor *= 2;
if (strings) {
std::stringstream str;
str << _("dreadful") << EMPTY_COLUMN << _("Halved");
strings->defend_calculations.push_back(str.str());
}
Code: Select all
static const std::string dread_string("dread");
res.attacker_dreadful = res.attacker_special == dread_string;
A. Those two pieces of code deal with 'dread' as a weapon 'special' like charge or slow or backstab.
B. I need the code for the ability 'nightstalk'... I think 'dread' should be an ability not a weapon special... though I suppose it could work as either.
Change nightstalk from saying:
To:The unit becomes invisible during night....
And rewrite the nightstalk code to reflect that change.When this unit attacks, the defending unit deals half damage.
C. Apply the tweaks seen in the first block of code in this post (attacker has dread, defender deals half damage) to the ability of dread, not the weapon special dread.
Or maybe it would simply work as a weapon special if I designed it like charge... charge certainly is a weapon special that deals with altering damage yet doesn't require units to be afflicted by it...
I dunno, could use a little help and suggestions at this point.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
Here's little patch with dread weapon special(if you don't count compiling it took me around 2 minutes). Why weapon special? Because i don't think somebody would fear to shoot fireball at him if he would somehow get ranged attack. I think it needs better name, but here it is:
- Attachments
-
- dread.patch.txt
- remove .txt
- (1007 Bytes) Downloaded 959 times
Since it's more C++ oriented than WML oriented, i moved the thread in IMO a more appropriate forum.
Well about nightstalk, it is in fact the "hides" ability (common to nightstalk & ambush).
Some abilities use terrain/ToD filters defined in unit_type.cpp. Not all filter are wired yet, btw the entire unit classes are being entirely rewritten by Xan, so this stuff should probably change soon.
Well about nightstalk, it is in fact the "hides" ability (common to nightstalk & ambush).
Some abilities use terrain/ToD filters defined in unit_type.cpp. Not all filter are wired yet, btw the entire unit classes are being entirely rewritten by Xan, so this stuff should probably change soon.
-
- Posts: 580
- Joined: February 14th, 2006, 3:24 am
- Location: New Avalon
- Contact:
Still pulling teeth, but at least progress is being made.
Okay so it's a patch to give the draug this weapon special.
How exactly do you apply this patch?
Somehow removing .txt isn't helpful enough.
Knowing what to do with dread.patch and where to put it might be helpful.
Okay so it's a patch to give the draug this weapon special.
How exactly do you apply this patch?
Somehow removing .txt isn't helpful enough.
Knowing what to do with dread.patch and where to put it might be helpful.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."