LPMuds.net
September 09, 2010, 04:11:27 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: newb question. simple check in attack.c?  (Read 420 times)
argus
Acquaintance
*
Offline Offline

Posts: 20


View Profile
« on: May 16, 2010, 05:11:19 AM »

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?
Logged
cratylus
Your favorite and best
Administrator
***
Offline Offline

Posts: 918


Cratylus@Dead Souls <ds> np


View Profile WWW
« Reply #1 on: May 16, 2010, 05:33:46 AM »

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
Logged
argus
Acquaintance
*
Offline Offline

Posts: 20


View Profile
« Reply #2 on: May 16, 2010, 05:46:28 AM »

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.
Logged
detah
BFF
***
Offline Offline

Posts: 159


Ruler of 2D


View Profile
« Reply #3 on: May 16, 2010, 05:58:01 AM »

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.
Logged
argus
Acquaintance
*
Offline Offline

Posts: 20


View Profile
« Reply #4 on: May 16, 2010, 06:03:04 AM »

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 Smiley Seeing as how I'm attempting something over my head. I'll just set the mud to non pk Smiley
Logged
cratylus
Your favorite and best
Administrator
***
Offline Offline

Posts: 918


Cratylus@Dead Souls <ds> np


View Profile WWW
« Reply #5 on: May 16, 2010, 06:08:49 AM »

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:
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:
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
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!