ranged_weapon.c-Dateireferenz

#include <ranged_weapon.h>
#include <properties.h>
#include <defines.h>
#include <combat.h>
#include <new_skills.h>
#include <unit.h>
Include-Abhängigkeitsdiagramm für ranged_weapon.c:

gehe zum Quellcode dieser Datei

Funktionen

void create ()
static void SkillResTransfer (mapping from_M, mapping to_M)
static int shoot_dam (mapping shoot)
static string FindRangedTarget (string str, mapping shoot)
static int cmd_shoot (string str)

Variablen

inherit std weapon
static int last_shoot

Dokumentation der Funktionen

static int cmd_shoot ( string  str  )  [static]

Definiert in Zeile 140 der Datei ranged_weapon.c.

Benutzt absolute_hb_count(), AT_QUIVER, break_string(), DT_PIERCE, FindRangedTarget(), IsUnit(), last_shoot, ME, Name(), name, notify_fail(), P_AMMUNITION, P_ATTACK_BUSY, P_DAM_TYPE, P_DISABLE_ATTACK, P_EQUIP_TIME, P_GHOST, P_NO_ATTACK, P_NOGET, P_SHOOTING_WC, P_STRETCH_TIME, P_WC, P_WEAPON, P_WEAPON_TYPE, P_WIELDED, PL, QueryProp(), shoot_dam(), SI_ENEMY, SI_SKILLDAMAGE_MSG, SI_SKILLDAMAGE_MSG2, SI_SKILLDAMAGE_TYPE, SI_SPELL, U_REQ, WEM, WEN und WER.

00141 {   int    dam;
00142     string no_at;
00143     object quiver;
00144     mapping shoot;
00145 
00146     if ( PL->QueryProp(P_GHOST) )
00147     {
00148         write("Deine immateriellen Finger gleiten durch die Waffe hindurch.\n");
00149         return 1;
00150     }
00151    
00152     if ( !QueryProp(P_NOGET) )
00153     {
00154         // Katapulte oder aehnliches die von Magiern aufgestellt werden
00155         // muessen natuerlich nicht gezueckt werden :).
00156         if ( !QueryProp(P_WIELDED) )
00157         {
00158             notify_fail(break_string("Du solltest "+name(WEN, 1)+
00159                                      " dazu schon zuecken.", 78));
00160             return 0;
00161         }
00162 
00163         if ( (PL->InFight()) && ((PL->PresentPosition())<2) )
00164         {
00165             write(break_string(
00166                 "Du solltest Dich erst etwas weiter zurueckziehen, um mit "+
00167                 name(WEM, 1)+" schiessen zu koennen!", 78));
00168             return 1;
00169         }
00170     }
00171 
00172     if ( ( (QueryProp(P_EQUIP_TIME)+QueryProp(P_STRETCH_TIME)*2) > time() )
00173         || ( (last_shoot+QueryProp(P_STRETCH_TIME)) > absolute_hb_count() ) )
00174     {
00175         write(break_string("Du kannst mit "+name(WEM, 1)+
00176                            " noch nicht wieder schiessen.", 78));
00177         return 1;
00178     }
00179 
00180     if ( (PL->QueryProp(P_DISABLE_ATTACK))>0 )
00181     {
00182         write(break_string("Solange Du noch gelaehmt bist, kannst Du "+
00183                            name(WEN, 1)+" nicht benutzen!", 78));
00184         return 1;
00185     }
00186 
00187     if ( PL->QueryProp(P_ATTACK_BUSY) )
00188     {
00189         write("Nicht so hektisch! So schnell bist Du nicht.\n");
00190         return 1;
00191     }
00192 
00193     // P_ATTACK_BUSY natuerlich auch setzen...
00194     PL->SetProp(P_ATTACK_BUSY,1);
00195 
00196     // Info-Mapping erzeugen
00197     shoot = ([ P_WEAPON       : ME,
00198                P_WEAPON_TYPE  : QueryProp(P_AMMUNITION),
00199                P_STRETCH_TIME : QueryProp(P_STRETCH_TIME),
00200                P_WC           : QueryProp(P_SHOOTING_WC),
00201                SI_SPELL       : 0
00202             ]);
00203 
00204     if ( !stringp(str) || str=="" )
00205       str=shoot[P_WEAPON_TYPE];
00206     else if (str[0..3]=="mit ")
00207       str=str[4..];
00208     else if (str[0..3]=="auf ")
00209       str=shoot[P_WEAPON_TYPE]+" "+str;
00210 
00211     if ( !(str=FindRangedTarget(str,shoot)) )
00212       return 1;
00213 
00214     if ( shoot[SI_ENEMY]->QueryProp(P_GHOST) )
00215     {
00216         write(break_string("Aber "+(shoot[SI_ENEMY]->name(WER, 1))+
00217                            " ist doch ein Geist!", 78));
00218         return 1;
00219     }
00220     else if ( no_at=(shoot[SI_ENEMY]->QueryProp(P_NO_ATTACK)) )
00221     {
00222         if ( stringp(no_at) )
00223           write(no_at);
00224         else
00225           write(break_string("Du kannst "+(shoot[SI_ENEMY]->name(WEN, 1))+
00226                              " nicht angreifen.", 78));
00227         return 1;
00228     }
00229     else if ( shoot[SI_ENEMY]==PL )
00230     {
00231         write("Du kannst doch nicht auf Dich selbst schiessen!\n");
00232         return 1;
00233     }
00234 
00235     if ( !(shoot[P_AMMUNITION]=present(str, PL))
00236         && ( !objectp(quiver=PL->QueryArmourByType(AT_QUIVER))
00237             || !(shoot[P_AMMUNITION]=present(str, quiver)) ) )
00238     {
00239         if ( str==shoot[P_WEAPON_TYPE] )
00240             write(break_string("Du hast keine passende Munition bei Dir, um "+
00241                                "mit "+name(WEM, 1)+" schiessen zu koennen.",
00242                                78));
00243         else
00244           write(break_string("Du hast kein '"+str+"' bei Dir.", 78));
00245         return 1;
00246     }
00247 
00248     if ( !shoot[P_AMMUNITION]->id(shoot[P_WEAPON_TYPE]) )
00249     {
00250         write(break_string((shoot[P_AMMUNITION]->Name(WER))+" kannst Du mit "+
00251                            name(WEM, 1)+" nicht verschiessen.", 78));
00252         return 1;
00253     }
00254 
00255     shoot[P_AMMUNITION]->SetProp(U_REQ, 1);
00256 
00257     shoot[SI_SKILLDAMAGE_MSG]  = shoot[SI_SKILLDAMAGE_MSG2]
00258                                = shoot[P_AMMUNITION]->name(WEN);
00259     shoot[SI_SKILLDAMAGE_TYPE] = ( shoot[P_AMMUNITION]->QueryProp(P_DAM_TYPE)
00260                                   || ({DT_PIERCE}) );
00261 
00262     shoot[P_SHOOTING_WC]  = shoot[P_AMMUNITION]->QueryProp(P_SHOOTING_WC);
00263 
00264     dam=shoot_dam(shoot);
00265 
00266     // Textausgabe
00267     tell_object(PL,break_string(
00268         "Du schiesst "+shoot[SI_SKILLDAMAGE_MSG]+" auf "+
00269         shoot[SI_ENEMY]->name(WEN, 1)+".", 78) );
00270     tell_room(environment(PL), break_string(
00271         PL->Name(WER)+" schiesst "+shoot[SI_SKILLDAMAGE_MSG2]+" auf "+
00272         shoot[SI_ENEMY]->name(WEN, 1)+".", 78),
00273         ({ shoot[SI_ENEMY], PL }) );
00274     if ( environment(PL)!=environment(shoot[SI_ENEMY]) )
00275       tell_room(environment(shoot[SI_ENEMY]),break_string(
00276           PL->Name(WER)+" schiesst "+shoot[SI_SKILLDAMAGE_MSG2]+" auf "+
00277           shoot[SI_ENEMY]->name(WEN, 1)+".", 78),
00278           ({ shoot[SI_ENEMY] }) );
00279     tell_object(shoot[SI_ENEMY], break_string(
00280         PL->Name(WER)+" schiesst "+shoot[SI_SKILLDAMAGE_MSG2]+
00281         " auf Dich ab.",78) );
00282 
00283     shoot[SI_ENEMY]->Defend(dam,shoot[SI_SKILLDAMAGE_TYPE],shoot[SI_SPELL],PL);
00284 
00285     // Munition verbrauchen
00286     if ( shoot[P_AMMUNITION]->IsUnit() )
00287       shoot[P_AMMUNITION]->AddAmount(-1);
00288     else
00289       shoot[P_AMMUNITION]->remove();
00290 
00291     // es wird an dieser stelle absolute_hb_count anstelle von time() benutzt
00292     // um dem Spieler wirklich die vollen 2 sek Zeit zu geben um zu reagieren
00293     // ohne das er dadurch einen Schaden hat (wie er es z.b. bei time() haette)
00294     last_shoot=absolute_hb_count();
00295 
00296     return 1;
00297 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

void create (  ) 

Definiert in Zeile 30 der Datei ranged_weapon.c.

Benutzt AddCmd(), create(), MUN_ARROW, P_AMMUNITION, P_INFO, P_QUALITY, P_RANGE, P_SHOOTING_WC, P_STRETCH_TIME, P_WC, P_WEAPON_TYPE, SetProp() und WT_RANGED_WEAPON.

00031 {
00032     ::create();
00033 
00034     SetProp(P_WEAPON_TYPE, WT_RANGED_WEAPON);
00035     SetProp(P_STRETCH_TIME, 1);
00036     SetProp(P_AMMUNITION, MUN_ARROW);
00037     SetProp(P_SHOOTING_WC, 70);
00038     SetProp(P_RANGE, 50);
00039     SetProp(P_INFO, "Syntax: schiesse WAS auf WEN?\n");
00040     // fuer den Fall, das man den Bogen als Knueppel nutzt...
00041     SetProp(P_WC, 30);
00042     SetProp(P_QUALITY, 100);
00043 
00044     AddCmd( ({"schiess", "schiesse"}), "cmd_shoot");
00045 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

static string FindRangedTarget ( string  str,
mapping  shoot 
) [static]

Definiert in Zeile 100 der Datei ranged_weapon.c.

Benutzt break_string(), name, Name(), P_RANGE, P_SHOOTING_AREA, P_TARGET_AREA, P_WEAPON_TYPE, PL, QueryProp(), SI_ENEMY, WER und WESSEN.

Wird benutzt von cmd_shoot().

00101 {   string wen;
00102     mixed  area;
00103     int    psr;
00104 
00105     if ( sscanf(str, "%s auf %s", str, wen)!=2 )
00106     {
00107         shoot[SI_ENEMY]=PL->SelectFarEnemy(PL->PresentEnemies(),1,4);
00108         str = shoot[P_WEAPON_TYPE];
00109     }
00110     else if ( objectp(shoot[SI_ENEMY]=present(wen, environment(PL))) )
00111     {
00112         return str;
00113     }
00114     else if ( ( (area=(environment(PL)->QueryProp(P_TARGET_AREA)))
00115                || (area=environment(environment(PL))) )
00116              && ( objectp(area)
00117                  || ( stringp(area)
00118                      && objectp(area=find_object(area)) ) )
00119              && (psr=environment(PL)->QueryProp(P_SHOOTING_AREA)) )
00120     {
00121         shoot[SI_ENEMY]=present(wen, area);
00122         if ( shoot[SI_ENEMY] && (psr>QueryProp(P_RANGE)) )
00123         {
00124             write(break_string((shoot[SI_ENEMY]->Name(WER))+
00125                 " ist leider ausserhalb der Reichweite "+name(WESSEN, 1)+".",
00126                78));
00127             return 0;
00128          }        
00129     }
00130 
00131     if ( !shoot[SI_ENEMY] )
00132     {
00133         write("Es ist kein Feind vorhanden auf den Du schiessen koenntest.\n");
00134         return 0;
00135     }
00136 
00137     return str;
00138 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static int shoot_dam ( mapping  shoot  )  [static]

Definiert in Zeile 72 der Datei ranged_weapon.c.

Benutzt A_DEX, P_AMMUNITION, P_HIT_FUNC, P_SHOOTING_WC, P_WC, P_WEAPON_TYPE, PL, QueryProp(), SHOOT, SI_ENEMY, SI_SKILLDAMAGE, SK_SHOOT und SkillResTransfer().

Wird benutzt von cmd_shoot().

00074 {   mixed   res;
00075     object  hitfunc;
00076     closure usk;
00077 
00078     // diesselbe Formel wie bei Nahkampfwaffen, nur das hier DEX anstatt STR
00079     // benutzt wird, und die WC der Munition noch addiert wird
00080     shoot[SI_SKILLDAMAGE] = random(1+( 2*(shoot[P_WC]+shoot[P_SHOOTING_WC])
00081                                      + 10*PL->QueryAttribute(A_DEX) )/3);
00082     // HitFunc der Munition addieren
00083     if ( objectp(hitfunc=(shoot[P_AMMUNITION]->QueryProp(P_HIT_FUNC))) )
00084       shoot[SI_SKILLDAMAGE] += (hitfunc->HitFunc(shoot[SI_ENEMY]));
00085 
00086     usk=symbol_function("UseSkill",PL);
00087 
00088     // Schuss-Skill der Gilde fuer diesen Munitionstyp anwenden
00089     if ( mappingp(res=funcall(usk,SHOOT(shoot[P_WEAPON_TYPE]),
00090                               deep_copy(shoot))) )
00091       SkillResTransfer(res, &shoot);
00092 
00093     // Allgemeinen Schuss-Skill der Gilde anwenden
00094     if ( mappingp(res=funcall(usk,SK_SHOOT,deep_copy(shoot))) )
00095       SkillResTransfer(res, &shoot);
00096 
00097     return shoot[SI_SKILLDAMAGE];
00098 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void SkillResTransfer ( mapping  from_M,
mapping  to_M 
) [static]

Definiert in Zeile 51 der Datei ranged_weapon.c.

Benutzt SI_SKILLDAMAGE, SI_SKILLDAMAGE_MSG, SI_SKILLDAMAGE_MSG2, SI_SKILLDAMAGE_TYPE und SI_SPELL.

00052 {
00053   if ( !mappingp(from_M) || !mappingp(to_M) )
00054     return;
00055 
00056   if ( member(from_M,SI_SKILLDAMAGE) )
00057     to_M[SI_SKILLDAMAGE] = (int)from_M[SI_SKILLDAMAGE];
00058 
00059   if ( member(from_M,SI_SKILLDAMAGE_MSG) )
00060     to_M[SI_SKILLDAMAGE_MSG] = (string)from_M[SI_SKILLDAMAGE_MSG];
00061 
00062   if ( member(from_M,SI_SKILLDAMAGE_MSG2) )
00063     to_M[SI_SKILLDAMAGE_MSG2] = (string)from_M[SI_SKILLDAMAGE_MSG2];
00064 
00065   if ( member(from_M,SI_SKILLDAMAGE_TYPE) )
00066     to_M[SI_SKILLDAMAGE_TYPE] = from_M[SI_SKILLDAMAGE_TYPE];
00067 
00068   if ( member(from_M,SI_SPELL) )
00069     to_M[SI_SPELL] = from_M[SI_SPELL];
00070 }


Variablen-Dokumentation

int last_shoot [static]

Definiert in Zeile 28 der Datei ranged_weapon.c.

Wird benutzt von cmd_shoot().

inherit std weapon

Definiert in Zeile 17 der Datei ranged_weapon.c.

Erzeugt am Thu Jun 3 14:43:01 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3