Author Topic: newb question. simple check in attack.c?  (Read 3402 times)

Offline argus

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
newb question. simple check in attack.c?
« on: May 15, 2010, 10:11:19 pm »
ok. I am basically doing something that is not entirely necessary, solely for the experience of working with the lib.

I know with ds you can set pk on off as you please etc. What I would like to happen is that when a player or creator attacks an immortal, be it admin or creator, they get a message to the effect of "Attacking an immortal is a bad idea." What I came up with was putting an
 "if(creatorp etc etc...
return 'attacking an immortal..'

am i thinking along the right lines here?
if not could someone point me towards the right path?

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: newb question. simple check in attack.c?
« Reply #1 on: May 15, 2010, 10:33:46 pm »
The simple answer is a check in /verbs/players/attack.c that prevents players
from attacking creators.

There are many ways around this however, such as using the "shoot" verb to
shoot a weapon at a cre, initiating combat.

Or casting an offensive spell at a cre, with the same effect.

As a coding exercise, figuring out how to prevent such things is good practice for
how to think in LPC. Do carry on.

If you're approaching this from an administrative standpoint, that is, "gee this could
really be a problem and I'd like to avoid it", then you pretty much are worried about
something that is trivial and a non-issue.

Either way you haven't provided enough information, because I don't know which of
these contexts you're coming from, and you haven't explained exactly where you plan
to put this check.

-Crat

Offline argus

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
Re: newb question. simple check in attack.c?
« Reply #2 on: May 15, 2010, 10:46:28 pm »
crat. I am doing this more of a coding exercise. I suppose trying to follow a logical path to a solution.

The simple answer is a check in /verbs/players/attack.c that prevents players
from attacking creators.

Nod.Cratylus this is where my logic led me. This check would return the message that I wanted.
I suppose my question is , is there an example that would give me a general idea of syntax for this check.
attack.c IS where i was looking. However, looking at the structure of attack.c I couldnt figure out exactly how to go about this.

p.s. I know there are others. but the shoot verb will be a moot point as it will be unused on Parodox Destiny.

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
Re: newb question. simple check in attack.c?
« Reply #3 on: May 15, 2010, 10:58:01 pm »
Cratylus' point about 'shoot' was just an example. The point is that there are numerous ways to initiate combat in DS. Some of them are plain old attack/kill, casting a spell, using a combat skill, and shooting a ranged weapon. To get the result you want, you will need to tackle each method independently or insert a PrePreCombat function to catch this.

Offline argus

  • Acquaintance
  • *
  • Posts: 24
    • View Profile
Re: newb question. simple check in attack.c?
« Reply #4 on: May 15, 2010, 11:03:04 pm »
understood detah. all this is really a moot point. i understand that each creator can avoid the hassles of some silly player attacking them..easily with pk off etc etc. I was just trying to follow the logic involved and have a silly little message should a player attempt it :) Seeing as how I'm attempting something over my head. I'll just set the mud to non pk :)

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: newb question. simple check in attack.c?
« Reply #5 on: May 15, 2010, 11:08:49 pm »
crat. I am doing this more of a coding exercise. I suppose trying to follow a logical path to a solution.

The simple answer is a check in /verbs/players/attack.c that prevents players
from attacking creators.

Nod.Cratylus this is where my logic led me. This check would return the message that I wanted.
I suppose my question is , is there an example that would give me a general idea of syntax for this check.
attack.c IS where i was looking. However, looking at the structure of attack.c I couldnt figure out exactly how to go about this.

p.s. I know there are others. but the shoot verb will be a moot point as it will be unused on Parodox Destiny.

hokay, so then doing it in attack.c means you want to do it in the do_ functions rather than the can_ functions.

In that verb it looks like the primary do_ function is do_attack_lvs(), meaning that do_attack_lv() (the singular
rather than plural) just sends its argument to do_attack_lvs() in the form of an array.

A check for whether a singular target is a creator should probably go in do_attack_lv(), looking something like

Code: [Select]
if( creatorp(target) ) { return "Nuh uh uhhh!"; }
Obviously this check should be before the part that just sends the argument to do_attack_lvs().

In do_attack_lvs() you should probably do something like this:


Code: [Select]
foreach(mixed target in targets) {
    if( creatorp(target) ) {
        targets -= ({ target });
    }
}

This (if I drunkcoded it sensibly) would remove creators from the list of creatures to kill when
a player issues an "attack all"

NB: These are general guidelines. Exceptions and sneaky ways around this exist. If
the problem is "I worry that my players can kill my immortals" then the solution is different.

-Crat