Example #1
0
def born_mushrum(spore, room):
    # Se le spore non si trovan più tra gli oggetti allora il gamescript è
    # già scattato in precedenza
    if spore.code not in database["items"]:
        return

    # Rimuove le spore dalla stanza e dal database, abbiamo nella funzione
    # spore che possiamo utilizzare fino alla fine della stessa, poi
    # l'oggetto sarà come se non esistesse più
    spore = spore.extract(1)

    # Crea una nuova entità dal nostro conosciutissimo mushroom passandogli il
    # codice identificativo del prototipo
    mushroom = Mob("torreelementi_mob_faura_01")

    # Imposta tutti i riferimenti per il neonato mushroom, sarà da controllare che
    # siano tutti a posto!
    mushroom.inject(room)

    # Avvisiamo tutti quanti del lieto evento
    mushroom.act(
        "Qualcuno ha fatto l'errore di seminarti tramite $N ma lo raggiungerai",
        TO.ENTITY, spore)
    mushroom.act("L'orrore non avrà dunque mai fine! Ecco enuclearsi $n!",
                 TO.OTHERS, spore)
    mushroom.act("$n 'enuclea ed ora tu te ne devi andare", TO.TARGET, spore)

    # Rendiamo conto della velocità di germinazione con genuina sorpresa
    defer_random_time(15, 30, command_emote, mushroom,
                      "è cresciuto a vista d'occhio!")
def look_for_caterpillar(dust, show_act=True):
    if not dust:
        log.bug("dust non è un parametro valido: %r" % dust)
        return

    caterpillar = dust.find_entity("bruco", dust.location, ["mobs"])
    if not caterpillar:
        if show_act:
            dust.act("My name is $n: niente bruchi" % dust, TO.OTHERS)
            dust.act("My name is $n: niente bruchi" % dust, TO.ENTITY)

        defer(60, look_for_caterpillar, dust)
        return

    if show_act:
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar, TO.OTHERS)
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar, TO.ENTITY)
        command_say(caterpillar, "sa la vist cus'è?")

    #defer(60, look_for_caterpillar, dust)
    # il bruco potrebbe essere soggetto a script che lo potrebbero mutare senza
    # avvisaglie quindi tolgo di mezzo il bruco per sostituirlo con un altro
    # che so non essere afflitto da script
    location = caterpillar.location
    caterpillar.extract(1)
    new_caterpillar = Mob(PROTO_CATERPILLAR_CODE)
    new_caterpillar.inject(location)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.OTHERS)

    dust_eating(dust, new_caterpillar)
def  born_to_be_wild_or_something(brain, room):
    # Se il  cervello non si trova più tra gli oggetti allora il gamescript è
    # già scattato in precedenza
    if brain.code not in  database["items"]:
        return

    # Rimuove il cervello dalla stanza e dal database,  abbiamo nella funzione
    # brain che possiamo utilizzare fino  alla fine della stessa, poi
    # l'oggetto sarà come se non  esistesse più
    brain.extract(1)

    # Crea una nuova entità dal nostro conosciutissimo mindf passandogli il
    # codice identificativo del prototipo
    mindf = Mob("mfdonald_mob_mindflayer_01")

    # Imposta tutti i riferimenti per il neonato mindf, sarà da controllare che
    # siano tutti a posto!
    mindf.inject(room)

    # Avvisiamo tutti quanti del lieto evento
    mindf.act("$n nasce da $N e inizia subito a muovere i tentacolini, che carino!", TO.OTHERS, brain)
    mindf.act("Nasci da $N e inizi subito ad avere un certo languorino; ma la tua non è proprio fame... e solo voglia di qualcosa di buono!", TO.ENTITY, brain)
    mindf.act("$n nasce da te, e ti senti subito molto orGoglione di quello che hai fatto!", TO.TARGET, brain)

    # Ora che è nato facciamogli dire qualcosa di intelligente in un tempo
    # variabili di secondi (qui in realtà sarebbe meglio utilizzare la funzione
    # interpret per inviare i comandi, cosicché mob che, per esempio, dormono
    # si mettono nella posizione alzata per inviare il comando, ma vabbe')
    defer_random_time(15, 30, command_say, mindf, "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl, fhtagn!")
def after_open(player, bozzolo, reverse_target, container_only, behavioured):
    ragnetti = Mob(PROTO_RAGNETTI_CODE)
    ragnetti.inject(player.location)

    player.act("Un brivido ti percorre lungo tutta la schiena mentre senti un urlo lontano.", TO.ENTITY)
    player.act("Un urlo lontano accompagna l'apertura del $N.", TO.OTHERS, bozzolo)

    fight = Fight(ragnetti, player)
    fight.start()
def caterpillar_creation():
    room_code = random.choice(PROTO_ROOMS_CODE)
    print room_code
    injection_room = find_room(room_code)
    if not injection_room:
        log.bug("proto code room non valido: %r" % room_code)
        return

    bruco = Mob(PROTO_CATERPILLAR_BEFORE_CODE)
    bruco.inject(injection_room)
def caterpillar_creation():
    room_code = random.choice(PROTO_ROOMS_CODE) 
    print  room_code
    injection_room = find_room(room_code)
    if not injection_room:
        log.bug("proto code room non valido: %r" % room_code)
        return

    bruco = Mob(PROTO_CATERPILLAR_BEFORE_CODE)
    bruco.inject(injection_room)
def after_open(player, bozzolo, reverse_target, container_only, behavioured):
    ragnetti = Mob(PROTO_RAGNETTI_CODE)
    ragnetti.inject(player.location)

    player.act(
        "Un brivido ti percorre lungo tutta la schiena mentre senti un urlo lontano.",
        TO.ENTITY)
    player.act("Un urlo lontano accompagna l'apertura del $N.", TO.OTHERS,
               bozzolo)

    fight = Fight(ragnetti, player)
    fight.start()
def generate_golem(apprendista, player, choosed_material, room, item):
    # Normale che possa accadere visto che la funzione viene deferrata
    if not apprendista or not player or not room or not item:
        return

    proto_mob_code = GOLEM_PROTO_CODE[choosed_material]
    mob = Mob(proto_mob_code)
    mob.inject(room)

    mob_calibration(mob, player, choosed_material)

    item.act(WAKE_UP[choosed_material], TO.OTHERS, mob)
    item.extract(1)
    apprendista.specials["work_in_progress"] = False
def generate_golem(apprendista, player, choosed_material, room, item):
    # Normale che possa accadere visto che la funzione viene deferrata
    if not apprendista or not player or not room or not item:
        return

    proto_mob_code = GOLEM_PROTO_CODE[choosed_material]
    mob = Mob(proto_mob_code)
    mob.inject(room)

    mob_calibration(mob, player, choosed_material)
   
    item.act(WAKE_UP[choosed_material], TO.OTHERS, mob)
    item.extract(1)
    apprendista.specials["work_in_progress"] = False
def on_sunset(tessitrice):
    barbagianni = Mob(BAGGIA_PROTO_CODE)
    barbagianni.inject(tessitrice.location)

    for content in tessitrice.iter_contains():
        content.from_location()
        content.to_location(barbagianni)

    command_yell(tessitrice, "Aahhh%s Dolore%s" % (random_marks(0, 2), random_marks(0, 3)))

    barbagianni.act("Ti origini da $N e sei $n.", TO.ENTITY, tessitrice)
    barbagianni.act("In un istante $N si trasforma in $n!", TO.OTHERS, tessitrice)
    barbagianni.act("$n si origina da te!", TO.TARGET, tessitrice)

    tessitrice.extract(1)
def inject_if_inexist_on_area(proto_code, location):
    type = proto_code.split("_")[1]

    # Se trova già un'entità esistente nell'area della locazione la recupera per la quest
    # (TD) attenzione che per ora ignora il fatto che vi possano essere più
    # entità in gioco, magari non in quest'area
    for entity in getattr(location.area, type + "s"):
        if not entity.IS_PLAYER and entity.prototype.code == proto_code:
            return entity.split_entity(1)

    if type == "mob":
        entity = Mob(proto_code)
    else:
        entity = Item(proto_code)
    entity.inject(location)
    return entity
def on_sunrise(barbagianni):
    tessy = Mob(TESSY_PROTO_CODE)
    tessy.inject(barbagianni.location)

    for content in barbagianni.iter_contains():
        content.from_location()
        content.to_location(tessy)
        #Nel caso volessi resettare lo slot dell'item:
        #content.wear_mode.clear()

    command_yell(barbagianni, "Screeeh%s Scretch%s" % (random_marks(0, 2), random_marks(0, 3)))

    tessy.act("Ti origini da $N e sei $n.", TO.ENTITY, barbagianni)
    tessy.act("In un istante $N si trasforma in  $n!", TO.OTHERS, barbagianni)
    tessy.act("$n si origina da te!", TO.TARGET, barbagianni)

    #print "barbagianni proto glob qty prima dell'estract", barbagianni.current_global_quantity
    barbagianni.extract(1)
def coming(locanda):
    """
    Controlla non ci siano bimbe in giro e poi la inietta.
    """
    # È possibile visto che questa funzione viene deferrata
    if not locanda:
        return

    for mob in database["mobs"].itervalues():
        if mob.prototype.code == PROTO_MOB_CODE:
            return

    bimba = Mob(PROTO_MOB_CODE)
    bimba.inject(locanda)

    bimba.act("Entri trotterellante in $N", TO.ENTITY, locanda)
    bimba.act("$n entra trotterellando in $N.", TO.OTHERS, locanda)
    bimba.act("Ti senti calpestare dal trotterellare di $n", TO.TARGET,
              locanda)
def on_sunset(dosso):
    if not dosso:
        log.bug("dosso non è un parametro valido: %r" % dosso)
        return

    lupo = Mob(PROTO_LUPO_CODE)
    lupo.inject(dosso.location)

    #for content in tessitrice.iter_contains(use_reversed=True):
    #    content = content.from_location(content.quantity)
    #    content.to_location(barbagianni)

    lupo.act("Ti origini da $N e sei $n.", TO.ENTITY, dosso)
    lupo.act(
        "$N emmette un risonante fruscio e si trasforma improvvisamente in $n!",
        TO.OTHERS, dosso)
    lupo.act("$n si origina da te!", TO.TARGET, dosso)

    dosso.stop_repop()
    dosso.extract(1)
Example #15
0
def look_for_caterpillar(dust, show_act=True):
    if not dust:
        log.bug("dust non è un parametro valido: %r" % dust)
        return

    caterpillar = dust.find_entity("bruco", dust.location, ["mobs"])
    if not caterpillar:
        if show_act:
            dust.act("My name is $n: niente bruchi" % dust, TO.OTHERS)
            dust.act("My name is $n: niente bruchi" % dust, TO.ENTITY)

        defer(60, look_for_caterpillar, dust)
        return

    if show_act:
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar,
                 TO.OTHERS)
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar,
                 TO.ENTITY)
        command_say(caterpillar, "sa la vist cus'è?")

    #defer(60, look_for_caterpillar, dust)
    # il bruco potrebbe essere soggetto a script che lo potrebbero mutare senza
    # avvisaglie quindi tolgo di mezzo il bruco per sostituirlo con un altro
    # che so non essere afflitto da script
    location = caterpillar.location
    caterpillar.extract(1)
    new_caterpillar = Mob(PROTO_CATERPILLAR_CODE)
    new_caterpillar.inject(location)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.OTHERS)

    dust_eating(dust, new_caterpillar)
def on_sunset(dosso):
    if not dosso:
        log.bug("dosso non è un parametro valido: %r" % dosso)
        return

    lupo = Mob(PROTO_LUPO_CODE)
    lupo.inject(dosso.location)

    #for content in tessitrice.iter_contains(use_reversed=True):
    #    content = content.from_location(content.quantity)
    #    content.to_location(barbagianni)

    lupo.act("Ti origini da $N e sei $n.", TO.ENTITY, dosso)
    lupo.act("$N emmette un risonante fruscio e si trasforma improvvisamente in $n!", TO.OTHERS, dosso)
    lupo.act("$n si origina da te!", TO.TARGET, dosso)

    dosso.stop_repop()
    dosso.extract(1)
def look_for_caterpillar(dust, show_act=True):
    if not dust:
        log.bug("dust non è un parametro valido: %r" % dust)
        return
    
    location = dust.location
    caterpillar = dust.find_entity("bruco", location, ["mobs"])
    if not caterpillar: 
        if show_act:
            dust.act("My name is $n: niente bruchi %r" % dust, TO.OTHERS)
            dust.act("My name is $n: niente bruchi %r" % dust, TO.ENTITY)
        
        defer(60, look_for_caterpillar, dust)
        return

    if show_act:
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar, TO.OTHERS)
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar, TO.ENTITY)
        command_say(caterpillar, "sa la vist cus'è?")

    #defer( 60, look_for_caterpillar, dust)
    # il bruco potrebbe essere soggetto a script che lo potrebbero mutare senza avvisaglie quindi
    # tolgo di mezzo il bruco per sostituirlo con un altro che so non essere afflitto da script
    location = caterpillar.location
    caterpillar.extract(1)
    new_caterpillar = Mob(PROTO_CATERPILLAR_CODE)
    if not caterpillar: 
        log.bug("impossibile crare un nuovo bruco: %r" % new_caterpillar)

    new_caterpillar.inject(location)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.OTHERS)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.ENTITY)

    dust_eating(dust, new_caterpillar)
    #ora resta solo da far mangiare la polvere che è bene rimuovere e rimpiazzare con con qualcosaltro
    return
Example #18
0
    def get_money_instance(self, type):
        from src.log  import log
        from src.item import Item
        from src.mob  import Mob

        if not type:
            log.bug("type non è un parametr valido: %r" % type)
            return ""

        # ---------------------------------------------------------------------

        money_code = getattr(self, type + "_coin")
        if "item" in money_code.split("_"):
            return Item(money_code)
        else:
            return Mob(money_code)
def look_for_caterpillar(dust, show_act=True):
    if not dust:
        log.bug("dust non è un parametro valido: %r" % dust)
        return

    location = dust.location
    caterpillar = dust.find_entity("bruco", location, ["mobs"])
    if not caterpillar:
        if show_act:
            dust.act("My name is $n: niente bruchi %r" % dust, TO.OTHERS)
            dust.act("My name is $n: niente bruchi %r" % dust, TO.ENTITY)

        defer(60, look_for_caterpillar, dust)
        return

    if show_act:
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar,
                 TO.OTHERS)
        dust.act("My name is $n, ho visto un bruco: %r" % caterpillar,
                 TO.ENTITY)
        command_say(caterpillar, "sa la vist cus'è?")

    #defer( 60, look_for_caterpillar, dust)
    # il bruco potrebbe essere soggetto a script che lo potrebbero mutare senza avvisaglie quindi
    # tolgo di mezzo il bruco per sostituirlo con un altro che so non essere afflitto da script
    location = caterpillar.location
    caterpillar.extract(1)
    new_caterpillar = Mob(PROTO_CATERPILLAR_CODE)
    if not caterpillar:
        log.bug("impossibile crare un nuovo bruco: %r" % new_caterpillar)

    new_caterpillar.inject(location)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.OTHERS)
    new_caterpillar.act("$n cambia aspetto in modo repentino.", TO.ENTITY)

    dust_eating(dust, new_caterpillar)
    #ora resta solo da far mangiare la polvere che è bene rimuovere e rimpiazzare con con qualcosaltro
    return
Example #20
0
def create_handler(entity, argument, command_name, table_name, can_create_multiple=False):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not command_name:
        log.bug("command_name non è un parametro valido: %r" % command_name)
        return False

    if not table_name:
        log.bug("table_name non è un parametro valido: %r" % table_name)
        return False

    # -------------------------------------------------------------------------

    if not argument:
        syntax = get_command_syntax(entity, command_name)
        entity.send_output(syntax, break_line=False)
        return False

    if can_create_multiple:
        quantity, argument = quantity_argument(argument)
    else:
        quantity = 1
    
    target = None
    if table_name == "players":
        target = search_online_player(argument, only_exact=True)

    if not target:
        target = entity.find_proto(argument, entity_tables=[table_name])
        if not target:
            entity.send_output("Non è stato trovato nessun %s con argomento [green]%s[close]." % (table_name, argument))
            return False

    if quantity == 0:
        quantity = target.quantity

    if not target.IS_PLAYER and target.max_global_quantity > 0 and target.current_global_quantity + quantity > target.max_global_quantity:
        if entity.trust == TRUST.IMPLEMENTOR:
            entity.send_to_admin("Ti è possibile iniettare in gioco %s nonostante questo raggiungerà il suo MaxGlobalQuantity di %d" % (
                target.get_name(looker=entity), target.max_global_quantity))
        else:
            entity.send_output("Non ti è possibile iniettare in gioco questa entità perché ha già raggiunto il suo MaxGlobalQuantity di %d" % target.max_global_quantity)
            return False

    if target.IS_PLAYER:
        result = Mob("limbo_mob_clone-pg")
        copy_existing_attributes(target, result, except_these_attrs=["code", "prototype"])
        result.short = result.name  # (TD) creazione dinamica della short, un po' come la long
        result.incognito = False
    elif target.IS_MOB:
        result = Mob(target.code)
    elif target.IS_ITEM:
        result = Item(target.code)
    else:
        log.bug("Entità base non valida: %s" % target.code)
        entity.send_output("C'è stato un'errore nell'esecuzione del comando.")
        return False

    # Se l'oggetto è uno dell'area rip avrà il tag %material da dover sostituire
    if "%material" in result.short:
        result.short.replace("%material", "qualcosa")
    if "%material" in result.short_night:
        result.short_night.replace("%material", "qualcosa")
    if "%material" in result.name:
        result.name.replace("%material", "qualcosa")

    result.quantity = quantity
    result.inject(entity)

    if entity == target:
        entity.act("Crei dal nulla una copia di te stess$O.", TO.ENTITY, target)
        entity.act("$n crea dal nulla una copia di se stess$O.", TO.OTHERS, target)
    elif entity.location == target.location:
        entity.act("Crei dal nulla una copia di $N.", TO.ENTITY, target)
        entity.act("$n crea dal nulla una copia di $N, ma ora qual'è quello vero?", TO.OTHERS, target)
        entity.act("$n crea dal nulla una copia di te stess$O!", TO.TARGET, target)
    else:
        entity.act("Crei dal nulla una copia di $N.", TO.ENTITY, target)
        entity.act("$n crea dal nulla una copia di $N.", TO.OTHERS, target)

    return True
Example #21
0
def generic_creation(parent, proto_code, show_act=False):
    if not parent:
        log.bug("parent non è un parametro valido: %r" % parent)
        return None

    if not proto_code:
        log.bug("proto_code non è un parametro valido: %r" % proto_code)
        return None

    # Dà una controllatina a chi contiene il parente
    if not parent.location:
        log.bug(
            "parent.location per qualche strano motivo è %r con codice %s e parent %s"
            % (parent.location, proto_code, parent.prototype.code))
        return None

    # Si assicura che il codice passato esista
    if proto_code in database["proto_items"]:
        proto_son = database["proto_items"][proto_code]
    elif proto_code in database["proto_mobs"]:
        proto_son = database["proto_mobs"][proto_code]
    else:
        log.bug("Il codice %s non è stato trovato nel database" % proto_code,
                log_stack=False)
        return None

    if show_act:
        parent.act("My name is $n: preparazione all'evoluzione!", TO.OTHERS)
        parent.act("My name is $n: preparazione all'evoluzione!", TO.ENTITY)

    # Se eccede il numero di entità definito in MaxGlobalQuantity allora esce
    if proto.has_reached_max_global_quantity():
        #if proto_son.max_global_quantity != 0 and proto_son.current_global_quantity >= proto_son.max_global_quantity:
        if show_act:
            parent.act("My name is $n: troppi %s!" % proto_code, TO.OTHERS)
            parent.act("My name is $n: troppi %s!" % proto_code, TO.ENTITY)
        if random.randint(1, 5) == 1:
            # Faccio il death istantaneo per verificare che non sia qui il
            # problema da un certo punto in poi pare che le uova non si
            # schiudano più anche senza che vi sian pulcini
            #defer_random_time(150, 300), death, parent)
            if show_act:
                parent.act("My name is $n: muoio!", TO.OTHERS)
                parent.act("My name is $n: muoio!", TO.ENTITY)
            death(parent)
        else:
            defer_random_time(150, 300, start_deposing, parent)
            if show_act:
                parent.act("My name is $n I'll try later!", TO.OTHERS)
                parent.act("My name is $n I'll try later!", TO.ENTITY)
        # Esce da qui in tutti e due i casi
        return None

    # Crea un nuovo figlio
    type = proto_code.split("_")[1]
    if type == "mob":
        son = Mob(proto_code)
    elif type == "item":
        son = Item(proto_code)
    else:
        log.bug("type non è valido con codice %s: %s" % (proto_code, type))
        return None

    if not son:
        log.bug("Non è stato possibile creare un figlio con codice %s: %r" %
                (proto_code, son),
                log_stack=False)
        return None

    if show_act:
        parent.act("My name is $n: son $N created!", TO.OTHERS, son)
        parent.act("My name is $n: son $N created!", TO.ENTITY, son)

    return son
Example #22
0
def digging_a_location_2(entity, location, verbs, behavioured):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return

    if not location:
        log.bug("location non è un parametro valido: %r" % location)
        return

    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return

    # -------------------------------------------------------------------------

    targets = []
    for target in location.iter_contains():
        if FLAG.BURIED in target.flags:
            targets.append(target)

    # C'è una possibilità su cento che venga trovato qualcosa di interessante
    # (TD) magari la probabilità aumentarla facendola sulla base della skill scava
    # (TD) magari aggiungere un affect per invalidare tentativi robotizzati di scavaggio continuo
    if not targets and random.randint(1, 100) < DIG_PROBABILITY:
        codes = database["areas"]["rip"].proto_items.keys()
        codes += database.randomizable_codes
        codes += database.race_money_codes
        codes += database.seed_codes

        code = random.choice(codes)
        if code.split("_")[1] == "item":
            targets = [Item(code)]
        else:
            targets = [Mob(code)]

        # Per le monete viene impostata anche una quantità casuale.
        # Qui in sostanza viene detto che si possono trovare da 1 a 1000 monete
        # di rame e al massimo solo 1 moneta di mithril, valori intermedi sono
        # inversamente proporzionali al valore della moneta stessa
        if targets[0].money_type:
            copper_value = min(targets[0].money_type.copper_value, 1000)
            targets[0].quantity = random.randint(1, int(1000 / copper_value))

        # (TD) Bisognerebbe inserire un affect nella locazione che impedisca di
        # scavare ancora lì per tot tempo
        targets[0].inject(location)

    # L'esperienza per aver scavato la prima volta nella stanza viene data
    # a prescindere che sia stato trovata un'entità o meno
    if entity.IS_PLAYER and location.IS_ROOM:
        if location.prototype.code in entity.digged_rooms:
            entity.digged_rooms[location.prototype.code] += 1
        else:
            entity.digged_rooms[location.prototype.code] = 1
            reason = "per aver scavato %s" % location.get_name(looker=entity)
            entity.give_experience(location.area.level, reason=reason)

    if not targets:
        entity.act(
            "\n%s ma non trovi proprio nulla di interessante." %
            color_first_upper(verbs["you"]), TO.ENTITY, location)
        entity.act(
            "$n %s una buca in $N senza trovare nulla di interessante." %
            verbs["it"], TO.OTHERS, location)
        entity.act(
            "$n ti %s una buca senza trovare nulla di interessante." %
            verbs["it"], TO.TARGET, location)
        entity.send_prompt()
        entity.action_in_progress = None
        return

    target = random.choice(targets)
    target = target.split_entity(random.randint(1, target.quantity))

    entity.action_in_progress = None

    entity.act("\nFinisci di %s scoprendo $N!" % verbs["infinitive"],
               TO.ENTITY, target)
    entity.act(
        "$n termina di %s dopo che ha scoperto qualcosa." %
        verbs["infinitive"], TO.OTHERS, target)
    entity.act(
        "$n termina di %s dopo che ti ha scoperto nel terreno." %
        verbs["infinitive"], TO.TARGET, target)
    entity.act(
        "$n termina di %s dopo che ha scoperto $a dentro di te." %
        verbs["infinitive"], TO.TARGET, location, target)
    entity.send_prompt()

    target.flags -= FLAG.BURIED
    # Se era un seme o una pianta allora ne ferma la crescita
    if target.seed_type:
        target.seed_type.stop_growth()
    if target.plant_type:
        target.plant_type.stop_growth()

    # (TD) imparare un po' la skill scava dai propri successi

    force_return = check_trigger(entity, "after_dig", entity, location, target,
                                 DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(location, "after_digged", entity, location,
                                 target, DIR.NONE, behavioured)
    if force_return:
        return True
Example #23
0
def create_handler(entity,
                   argument,
                   command_name,
                   table_name,
                   can_create_multiple=False):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not command_name:
        log.bug("command_name non è un parametro valido: %r" % command_name)
        return False

    if not table_name:
        log.bug("table_name non è un parametro valido: %r" % table_name)
        return False

    # -------------------------------------------------------------------------

    if not argument:
        syntax = get_command_syntax(entity, command_name)
        entity.send_output(syntax, break_line=False)
        return False

    if can_create_multiple:
        quantity, argument = quantity_argument(argument)
    else:
        quantity = 1

    target = None
    if table_name == "players":
        target = search_online_player(argument, only_exact=True)

    if not target:
        target = entity.find_proto(argument, entity_tables=[table_name])
        if not target:
            entity.send_output(
                "Non è stato trovato nessun %s con argomento [green]%s[close]."
                % (table_name, argument))
            return False

    if quantity == 0:
        quantity = target.quantity

    if not target.IS_PLAYER and target.max_global_quantity > 0 and target.current_global_quantity + quantity > target.max_global_quantity:
        if entity.trust == TRUST.IMPLEMENTOR:
            entity.send_to_admin(
                "Ti è possibile iniettare in gioco %s nonostante questo raggiungerà il suo MaxGlobalQuantity di %d"
                % (target.get_name(looker=entity), target.max_global_quantity))
        else:
            entity.send_output(
                "Non ti è possibile iniettare in gioco questa entità perché ha già raggiunto il suo MaxGlobalQuantity di %d"
                % target.max_global_quantity)
            return False

    if target.IS_PLAYER:
        result = Mob("limbo_mob_clone-pg")
        copy_existing_attributes(target,
                                 result,
                                 except_these_attrs=["code", "prototype"])
        result.short = result.name  # (TD) creazione dinamica della short, un po' come la long
        result.incognito = False
    elif target.IS_MOB:
        result = Mob(target.code)
    elif target.IS_ITEM:
        result = Item(target.code)
    else:
        log.bug("Entità base non valida: %s" % target.code)
        entity.send_output("C'è stato un'errore nell'esecuzione del comando.")
        return False

    # Se l'oggetto è uno dell'area rip avrà il tag %material da dover sostituire
    if "%material" in result.short:
        result.short.replace("%material", "qualcosa")
    if "%material" in result.short_night:
        result.short_night.replace("%material", "qualcosa")
    if "%material" in result.name:
        result.name.replace("%material", "qualcosa")

    result.quantity = quantity
    result.inject(entity)

    if entity == target:
        entity.act("Crei dal nulla una copia di te stess$O.", TO.ENTITY,
                   target)
        entity.act("$n crea dal nulla una copia di se stess$O.", TO.OTHERS,
                   target)
    elif entity.location == target.location:
        entity.act("Crei dal nulla una copia di $N.", TO.ENTITY, target)
        entity.act(
            "$n crea dal nulla una copia di $N, ma ora qual'è quello vero?",
            TO.OTHERS, target)
        entity.act("$n crea dal nulla una copia di te stess$O!", TO.TARGET,
                   target)
    else:
        entity.act("Crei dal nulla una copia di $N.", TO.ENTITY, target)
        entity.act("$n crea dal nulla una copia di $N.", TO.OTHERS, target)

    return True