Worldedit
  Worldedit
Le site sur l'éditeur de warcraft 3 !
 
  FAQFAQ   RechercherRechercher   Liste des MembresListe des Membres    Groupes d'utilisateursGroupes d'utilisateurs   medals.php?sid=126671fac495dd1f6a17a0267f3e4b54Médailles   S'enregistrerS'enregistrer 
 ProfilProfil   Se connecter pour vérifier ses messages privésSe connecter pour vérifier ses messages privés   ConnexionConnexion 
  FAQFAQ World Editor   UploadUploader une map ou une image    UploadAjouter sa map à l'annuaire   UploadConsulter l'annuaire

Optimisation: Recyclage (Dismantle unit/ Destroy building)
Aller à la page Précédente  1, 2
 
Poster un nouveau sujet   Répondre au sujet    Worldedit Index du Forum -> Aide sur les déclencheurs
Voir le sujet précédent :: Voir le sujet suivant  
Auteur Message
 Troll-Brain
Ri1kamoua


Inscrit le: 23 Aoû 2007
Messages: 7143
Sujets: 147
Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance
Médailles: 2 (En savoir plus...)
Rédacteur de tuto #3 (Quantité : 1) Grand mage créateur de sort (Quantité : 1)

MessagePosté le: 21/03/10 12:48    Sujet du message: Citer

Apocalypse a écrit:
J'utilise ces variables pour le système d'orbites.

Hein ? Je ne les vois pas dans cette library.

Citation:
La solution la plus rapide serait d'utiliser AutoIndex, je suis en train de me dire. Je me trompe?

Je ne sais pas, faut que je regarde le code, mais à priori je dirais nan car c'est un type d'unité et non pas une unité particulière que l'on doit traiter, nan ?
_________________
Le violet, c'est moche.
Revenir en haut
Voir le profil de l'utilisateur Envoyer un message privé
 jk2pach
Invité








MessagePosté le: 21/03/10 12:55    Sujet du message: Citer

Exact pour Autoindex :/

Costname: en fait je ne m'en sers plus.

Code édité; je garde les Costname en comment pour savoir plus vite de quelle unité il s'agit Smile
_________________
Revenir en haut
 jk2pach
Invité








MessagePosté le: 06/04/10 15:06    Sujet du message: Citer

J'ai tenté une nouvelle version en textmacro, avec un hashtable pour pouvoir récupérer les variables stockées par la textmacro (or et bois).

Sauf que ça ne fonctionne pas ingame: les BJDebug renvoient des valeurs d'unités pour l'ID du caster incroyablement grandes, et , par suite, or et bois = 0.
_________________
Revenir en haut
 Troll-Brain
Ri1kamoua


Inscrit le: 23 Aoû 2007
Messages: 7143
Sujets: 147
Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance
Médailles: 2 (En savoir plus...)
Grand mage créateur de sort (Quantité : 1) Rédacteur de tuto #3 (Quantité : 1)

MessagePosté le: 06/04/10 21:36    Sujet du message: Citer

Devrait fonctionner :

Jass:
library RecycleUnitsAndBuildings initializer init needs TimerUtils,TextDisplay,SpellEvent,Resource

globals
    private constant integer RECYCLE_BUILDING = 'A00D'
    private constant integer RECYCLE_UNIT = 'A01M'
    private constant string C1 = "|cff008040"
    private constant string C2 = "|cff80FFFF"
    private constant string C" |r"
    private constant string FX = "Abilities\\Spells\\Orc\\Voodoo\\VoodooAuraTarget.mdl"
    private constant real DURATION = 2.
    private key GOLD_INDEX // juste des constant integer à valeur unique (chaque key à une valeur différente)
    private key LUMBER_INDEX
    private hashtable HashT
endglobals

    //! textmacro t__RecycleSystem_Init takes UNIT_TYPE , UNIT_GOLD, UNIT_LUMBER
        call SaveInteger(HashT,$UNIT_TYPE$,GOLD_INDEX,$UNIT_GOLD$)
        call SaveInteger(HashT,$UNIT_TYPE$,LUMBER_INDEX,$UNIT_LUMBER$)
    //! endtextmacro

    private function SetCostVariables takes nothing returns nothing
            //! runtextmacro t__RecycleSystem_Init("'h00M'","250", "5")
            //! runtextmacro t__RecycleSystem_Init("'h00N'","150", "5")
            //! runtextmacro t__RecycleSystem_Init("'h00O'","200", "5")
            //! runtextmacro t__RecycleSystem_Init("'h01M'","400", "30")
            //! runtextmacro t__RecycleSystem_Init("'h00C'","400", "30")
            //! runtextmacro t__RecycleSystem_Init("'h00G'","400", "30")
            //! runtextmacro t__RecycleSystem_Init("'h00H'","300", "10")
            //! runtextmacro t__RecycleSystem_Init("'h01L'","400", "30")
            //! runtextmacro t__RecycleSystem_Init("'h015'","900", "50")
            //! runtextmacro t__RecycleSystem_Init("'h00L'","600", "150")
            //! runtextmacro t__RecycleSystem_Init("'h00I'","800", "50")
            //! runtextmacro t__RecycleSystem_Init("'h01H'","600", "150")
            //! runtextmacro t__RecycleSystem_Init("'h00Y'","1000", "75")
            //! runtextmacro t__RecycleSystem_Init("'h01D'","750", "75")
            //! runtextmacro t__RecycleSystem_Init("'h00J'","1200", "150")
            //! runtextmacro t__RecycleSystem_Init("'h01N'","1200", "150")
            //! runtextmacro t__RecycleSystem_Init("'h01O'","2000", "100")
            //! runtextmacro t__RecycleSystem_Init("'h00K'","1200", "100")
            //! runtextmacro t__RecycleSystem_Init("'h00A'","2500", "300")
            //! runtextmacro t__RecycleSystem_Init("'h00Z'","500", "0")
            //! runtextmacro t__RecycleSystem_Init("'h00F'","500", "0")
            //! runtextmacro t__RecycleSystem_Init("'h00P'","1500", "300")
            //! runtextmacro t__RecycleSystem_Init("'h01C'","2000", "20")           
            //! runtextmacro t__RecycleSystem_Init("'h017'","2500", "300")
            //! runtextmacro t__RecycleSystem_Init("'h00D'","3500", "400")
            //! runtextmacro t__RecycleSystem_Init("'h006'","250", "50")
            //! runtextmacro t__RecycleSystem_Init("'h00E'","4000", "500")
            //! runtextmacro t__RecycleSystem_Init("'h007'","350", "100")
            //! runtextmacro t__RecycleSystem_Init("'h018'","500", "200")
            //! runtextmacro t__RecycleSystem_Init("'h016'","500", "200")
            //! runtextmacro t__RecycleSystem_Init("'h005'","500", "200")
            //! runtextmacro t__RecycleSystem_Init("'h00B'","5000", "600")
            //! runtextmacro t__RecycleSystem_Init("'h01P'","6000", "700")
            //! runtextmacro t__RecycleSystem_Init("'h00O'","2000", "500")
            //! runtextmacro t__RecycleSystem_Init("'h008'","6000", "700")
            //! runtextmacro t__RecycleSystem_Init("'n004'","1000", "100")
            //! runtextmacro t__RecycleSystem_Init("'n005'","1000", "100")
            //! runtextmacro t__RecycleSystem_Init("'h004'","200", "0")
            //! runtextmacro t__RecycleSystem_Init("'h01R'","200", "0")
            //! runtextmacro t__RecycleSystem_Init("'h00S'","500", "100")
            //! runtextmacro t__RecycleSystem_Init("'h00T'","1000", "200")
            //! runtextmacro t__RecycleSystem_Init("'hO1I'","500", "100")
            //! runtextmacro t__RecycleSystem_Init("'h003'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h01K'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h01A'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h01B'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h014'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h019'","200", "50")
            //! runtextmacro t__RecycleSystem_Init("'h002'","300", "50")
            //! runtextmacro t__RecycleSystem_Init("'h011'","800", "100")
            //! runtextmacro t__RecycleSystem_Init("'h012'","3500", "200")
            //! runtextmacro t__RecycleSystem_Init("'h001'","150", "0")
            //! runtextmacro t__RecycleSystem_Init("'h01E'","500", "50")
            //! runtextmacro t__RecycleSystem_Init("'h010'","150", "0")
            //! runtextmacro t__RecycleSystem_Init("'h01Q'","150", "0")
            //! runtextmacro t__RecycleSystem_Init("'o00I'","3000", "500")
    endfunction   

    private struct str
        effect e
    endstruct

    private function WaitForEffect takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local str dat = GetTimerData(t)
            call DestroyEffect(dat.e)
            call ReleaseTimer(t)
            call dat.destroy()
    endfunction

    private function RecycleBuilding takes nothing returns nothing
        local integer casterId = GetUnitTypeId(SpellEvent.CastingUnit)
        local integer randomGold = R2I(GetRandomReal(0.25,1.00)*LoadInteger(HashT,casterId,GOLD_INDEX))
        local integer randomLumber = R2I(GetRandomReal(0.25,1.00)*LoadInteger(HashT,casterId,LUMBER_INDEX))
        local timer t = NewTimer()
        local str  dat = str.create()
            call BJDebugMsg("id="+I2S(casterId))
            call BJDebugMsg("gold="+I2S(LoadInteger(HashT,casterId,GOLD_INDEX)))
            call BJDebugMsg("lumber="+I2S(LoadInteger(HashT,casterId,LUMBER_INDEX)))
       
            call Text(SpellEvent.CastingUnit,false,C1+I2S(randomGold)+"Pulsars"+C+" -  "+C2+I2S(randomLumber)+"Iron"+C)
            call SetResource(GetOwningPlayer(SpellEvent.CastingUnit),randomGold,randomLumber)
            call UnitRemoveAbility(SpellEvent.CastingUnit,RECYCLE_BUILDING)
            call UnitApplyTimedLife(SpellEvent.CastingUnit,'BTLF',DURATION)
            set dat.e = AddSpecialEffectTarget(FX,SpellEvent.CastingUnit,"origin")
            call SetTimerData(t, dat)
            call TimerStart (t,DURATION, false, function WaitForEffect )
    endfunction
   
    private function RecycleUnit takes nothing returns nothing
        local integer casterId = GetUnitTypeId(SpellEvent.TargetUnit)
        local integer randomGold = R2I(GetRandomReal(0.25,1.00)*LoadInteger(HashT,casterId,GOLD_INDEX))
        local integer randomLumber = R2I(GetRandomReal(0.25,1.00)*LoadInteger(HashT,casterId,LUMBER_INDEX))
        local timer t = NewTimer()
        local str  dat = str.create()
            call BJDebugMsg("id="+I2S(casterId))
            call BJDebugMsg("gold="+I2S(LoadInteger(HashT,casterId,GOLD_INDEX)))
            call BJDebugMsg("lumber="+I2S(LoadInteger(HashT,casterId,LUMBER_INDEX)))
       
            call Text(SpellEvent.TargetUnit,false,C1+I2S(randomGold)+"Pulsars"+C+" -  "+C2+I2S(randomLumber)+"Iron"+C)
            call SetResource(GetOwningPlayer(SpellEvent.TargetUnit),randomGold,randomLumber)
            call UnitRemoveAbility(SpellEvent.TargetUnit,RECYCLE_UNIT)
            call UnitApplyTimedLife(SpellEvent.TargetUnit,'BTLF',DURATION)
            set dat.e = AddSpecialEffectTarget(FX,SpellEvent.TargetUnit,"origin")
            call SetTimerData(t, dat)
            call TimerStart (t,DURATION, false, function WaitForEffect )
    endfunction

    private function init takes nothing returns nothing
            call RegisterSpellCastResponse(RECYCLE_BUILDING,RecycleBuilding)
            call RegisterSpellCastResponse(RECYCLE_UNIT,RecycleUnit)
            set HashT = InitHashtable()
            call SetCostVariables()
    endfunction

endlibrary


Mais sinon utiliser une hashtable rien que pour cela semble to much.
Tu peux simplement utiliser 2 Table, une pour le gold et une pour le lumber avec pour référence l'id de l'unité

Jass:
private Table GoldTable
private Table LumberTable

set GoldTable = Table.create()
set LumberTable = Table.create()
    //! textmacro t__RecycleSystem_Init takes UNIT_TYPE , UNIT_GOLD, UNIT_LUMBER
        set GoldTable[$UNIT_TYPE$] = $UNIT_GOLD$
        set LumberTable[$UNIT_TYPE$] = $UNIT_LUMBER$
    //! endtextmacro

_________________
Le violet, c'est moche.
Revenir en haut
Voir le profil de l'utilisateur Envoyer un message privé
 jk2pach
Invité








MessagePosté le: 06/04/10 21:48    Sujet du message: Citer

Au poil!

Je n'étais pas loin Sad

Merci.
_________________
Revenir en haut
Montrer les messages depuis:   
Poster un nouveau sujet   Répondre au sujet    Worldedit Index du Forum -> Aide sur les déclencheurs Toutes les heures sont au format GMT + 1 Heure
Aller à la page Précédente  1, 2
Page 2 sur 2
La question posée dans ce topic a été résolue !

 
Sauter vers:  
Vous ne pouvez pas poster de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas voter dans les sondages de ce forum


Powered by phpBB © 2001, 2005 phpBB Group
Traduction par : phpBB-fr.com