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=604df85104f024a2e2769c76e38a6db4Mé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: attaques ioniques

 
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
 jk2pach
Invité








MessagePosté le: 22/01/10 12:36    Sujet du message: Optimisation: attaques ioniques Citer

Les unités équipées de "ion" (dégâts magique sous warcraft) et détectées par la présence d'une compétence infligent des effets de type "stun" etc de manière aléatoire (pourcentage de chance).

Du coup, le trigger se lance à chaque fois qu'une unité est attaquée.

Est-ce améliorable?
Secret:

Jass:
scope ionweapons initializer init
//=================================================
globals
    private constant string FX = "war3mapImported\\fx_ion_squished.mdx"
    private constant integer IONID1 = 'A00K'
    private constant integer IONID2 = 'A01F'
    private constant integer CHANCEBASE = 15
    private constant integer CHANCECOEFF = 7
    private constant integer RESEARCH = 'R007'
endglobals
//=================================================
private function Conditions takes nothing returns boolean
local integer i = GetRandomInt(0,100)
local integer chance = GetRandomInt(0,100)
local unit attacker = GetAttacker()
local unit target = GetTriggerUnit()
local player owner = GetOwningPlayer(attacker)
local integer chancereq = CHANCEBASE+CHANCECOEFF*GetPlayerTechCount(owner,RESEARCH,true)
local real x = GetUnitX(target)
local real y = GetUnitY(target)
local unit dummy = null
    if  GetUnitAbilityLevel(attacker,IONID1)>=1 or GetUnitAbilityLevel(attacker,IONID2)>=1then
        if chance<=chancereq then
            set dummy = CreateUnit(owner,'o00F',x,y,0.) //Ion Buff on target
            call DestroyEffect(AddSpecialEffect(FX,x,y))
            call UnitApplyTimedLife(dummy,'BTLF',1.)
            call IssueTargetOrder(dummy,"acidbomb",target)
            //Random Effect
            if i <= 20 then//Reduced mana
                 call SetUnitState(target, UNIT_STATE_MANA, GetUnitState(target,UNIT_STATE_MANA)- GetRandomReal(50,GetUnitState(target,UNIT_STATE_MANA)) )
            elseif  i> 20 and i <= 50 then
                set dummy = CreateUnit(owner,'o00D',x,y,0.)//Stun
                call UnitApplyTimedLife(dummy,'BTLF',1.)
                call IssueTargetOrder(dummy,"thunderbolt",target)
            elseif i > 50 and i <= 80 then
                set dummy = CreateUnit(owner,'o00D',x,y,0.) //Slow movement
                call UnitApplyTimedLife(dummy,'BTLF',1.)
                call IssueTargetOrder(dummy,"acidbomb",target)
            elseif i > 80 and i <= 100 then
                set dummy = CreateUnit(owner,'o00E',x,y,0.) //slow attack
                call UnitApplyTimedLife(dummy,'BTLF',1.)
                call IssueTargetOrder(dummy,"acidbomb",target)
            endif
            //Ion particle Fx
            call IonAddFx(target)
        endif
    endif
    set attacker = null
    set owner = null
    set target = null
    set dummy = null
    return false
endfunction
//=================================================
public function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition(t, Condition(function Conditions))
endfunction
//================================================= 
endscope



Fonction IonAddFx: créé des effets quand il y a bien effets de type "ion"
Secret:

Jass:
library ionfxsys needs TimerUtils
//=================================================
globals
    private constant real TIMEOUT = 0.25
    private constant real AOE = 100.
endglobals
//=================================================
private struct str
    unit ship
    integer i
    real x
    real y
endstruct
//=================================================
private function CreateFx takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local str dat = GetTimerData(t)
    local real x = dat.x+GetRandomReal(-AOE,AOE)
    local real y = dat.y+GetRandomReal(-AOE,AOE)
    if dat.i < 10 and GetUnitState(dat.ship, UNIT_STATE_LIFE) > 0then
        set dat.i = dat.i + 1
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldBuff.mdl",x,y))
    else   
        call ReleaseTimer(t)
        call dat.destroy()
    endif
endfunction
//=================================================
function IonAddFx takes unit whichUnit returns nothing
local timer t = NewTimer()
local str  dat = str.create()
    set dat.ship = whichUnit
    set dat.x = GetUnitX(dat.ship)
    set dat.y = GetUnitY(dat.ship)
    set dat.i = 0
    call SetTimerData(t, dat)
    call TimerStart (t, TIMEOUT, true, function CreateFx )
endfunction
//=================================================
endlibrary


_________________
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: 15/03/10 21:30    Sujet du message: Citer

Il est difficile de lier une attaque et le moment où celle ci fait des dégâts, en effet même "à la main" il est facile de se faire produire l'event "une unité est attaqué", tout en interrompant l'attaque, et même tu ne peux pas savoir quelle attaque aboutira avant une autre.

La voie des purs est de coder absolument tous les spells infligeant des dégâts, donc on sait quand une unité subit des dégâts d'un spell, et le reste c'est forcément d'une attaque. (et pour te faciliter la vie éventuellement utiliser un système de détection de dégâts).

PS : Même combat, fusion needed.
_________________
Le violet, c'est moche.
Revenir en haut
Voir le profil de l'utilisateur Envoyer un message privé
 jk2pach
Invité








MessagePosté le: 15/03/10 21:45    Sujet du message: Citer

Laisse tomber ce truc à ce propos, j'ai diminué le nombre d'effets.

Fusion; encore pareil: déjà fait.

Pour ce qui est des attaques: je sais. Mais sur Stars, le problème est résolu (attaque quasi instantanée des unités).

Edit
Pas encore eu le temps d'update la map avec mes connaissances sur Autoindex acquises depuis.


Jass:
scope IonsWeapons initializer init

globals
    //Inonic Mine
    private constant string FX_MINE = "war3mapImported\\fx_stomp_squished.mdx"
    private constant integer DUMMYID = 'o00N'
    private constant integer MINE = 'n006'
    //Ion Weapons
    private constant string FX = "war3mapImported\\fx_ion_squished.mdx"
    private constant integer IONID1 = 'A00K'
    private constant integer IONID2 = 'A01F'
    private constant integer CHANCEBASE = 15
    private constant integer CHANCECOEFF = 7
    private constant integer RESEARCH = 'R007'
    //Ion Fx
    private constant real FX_TIMEOUT = 0.25
    private constant real FX_AOE = 75.
    private constant integer FX_COUNT = 5
    //Ionic Mine Wall
    private constant integer IMW_DUR = 20
    private constant integer IMW_SPELL = 'A02Z'
    private constant real IMW_TIMEOUT = 0.5
endglobals

    private struct s_Ion
        unit ship
        integer i
        real x
        real y
       
            static method operator [] takes unit u returns thistype
                return thistype(GetUnitId(u))
            endmethod
           
            method destroy takes nothing returns nothing
                set .ship = null
            endmethod
    endstruct
   
    private struct s_MineWall
        unit caster
        player owner
        integer i
       
            static method operator [] takes unit u returns thistype
                return thistype(GetUnitId(u))
            endmethod
           
            method destroy takes nothing returns nothing
                set .caster = null
                set .owner = null
            endmethod
           
    endstruct

    private function CreateFx takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local s_Ion dat = GetTimerData(t)
        local real x = dat.x+GetRandomReal(-FX_AOE,FX_AOE)
        local real y = dat.y+GetRandomReal(-FX_AOE,FX_AOE)
            if dat.i < FX_COUNT and GetUnitState(dat.ship, UNIT_STATE_LIFE) > 0then
                set dat.i = dat.i + 1
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\LightningShield\\LightningShieldBuff.mdl",x,y))
            else   
                call ReleaseTimer(t)
                call dat.destroy()
            endif
    endfunction

    private function IonAddFx takes unit whichUnit returns nothing
        local timer t = NewTimer()
        local s_Ion  dat = s_Ion[whichUnit]
            set dat.ship = whichUnit
            set dat.x = GetUnitX(dat.ship)
            set dat.y = GetUnitY(dat.ship)
            set dat.i = 0
            call SetTimerData(t, dat)
            call TimerStart (t, FX_TIMEOUT, true, function CreateFx )
    endfunction

    private function MineWallSpawnMine takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local s_MineWall dat = GetTimerData(t)
    local real x = GetUnitX(dat.caster)
    local real y = GetUnitY(dat.caster)
        if dat.i < IMW_DUR and GetUnitState(dat.caster, UNIT_STATE_LIFE) > 0 then
            set dat.i = dat.i + 1
            call CreateUnit(dat.owner,MINE,x,y,0.)
        else
            call SetUnitPathing(dat.caster,true)
            call ReleaseTimer(t)
            call dat.destroy()
        endif
    endfunction

    private function CastIonicMineWall takes nothing returns nothing
        local timer t = NewTimer()
        local s_MineWall  dat = s_MineWall[SpellEvent.CastingUnit] 
            set dat.caster = SpellEvent.CastingUnit
            set dat.i = 0
            set dat.owner = GetOwningPlayer(dat.caster)
            call SetUnitPathing(dat.caster,false)
            call SetTimerData(t, dat)
            call TimerStart (t,IMW_TIMEOUT,true, function MineWallSpawnMine)
    endfunction

    private function MineDeath takes unit mine returns nothing
        local real x = GetUnitX(mine)
        local real y = GetUnitY(mine)
        local unit dummy = CreateUnit(GetOwningPlayer(mine),DUMMYID,x,y,0.)
                call UnitApplyTimedLife(dummy,'BTLF',1.5)
                call IssueImmediateOrder(dummy,"stomp")
                call DestroyEffect(AddSpecialEffect(FX_MINE,x,y))
                call IonAddFx(dummy)
            set dummy = null
    endfunction
   
    private function CheckMineId takes nothing returns boolean
            if GetUnitTypeId(GetTriggerUnit()) == MINE then
                call MineDeath(GetTriggerUnit())
            endif
            return false
    endfunction
   
    private function IonDealAttack takes unit attacker, unit target returns nothing
        local integer i = GetRandomInt(0,100)
        local integer chance = GetRandomInt(0,100)
        local player owner = GetOwningPlayer(attacker)
        local integer chancereq = CHANCEBASE+CHANCECOEFF*GetPlayerTechCount(owner,RESEARCH,true)
        local real x = GetUnitX(target)
        local real y = GetUnitY(target)
        local unit dummy = null
            if chance<=chancereq then
                set dummy = CreateUnit(owner,'o00F',x,y,0.) //Ion Buff on target
                call DestroyEffect(AddSpecialEffect(FX,x,y))
                call UnitApplyTimedLife(dummy,'BTLF',1.)
                call IssueTargetOrder(dummy,"acidbomb",target)
                //Random Effect
                if i <= 20 then//Reduced mana
                     call SetUnitState(target, UNIT_STATE_MANA, GetUnitState(target,UNIT_STATE_MANA)- GetRandomReal(50,GetUnitState(target,UNIT_STATE_MANA)) )
                elseif  i> 20 and i <= 50 then
                    set dummy = CreateUnit(owner,'o00D',x,y,0.)//Stun
                    call UnitApplyTimedLife(dummy,'BTLF',1.)
                    call IssueTargetOrder(dummy,"thunderbolt",target)
                elseif i > 50 and i <= 80 then
                    set dummy = CreateUnit(owner,'o00D',x,y,0.) //Slow movement
                    call UnitApplyTimedLife(dummy,'BTLF',1.)
                    call IssueTargetOrder(dummy,"acidbomb",target)
                elseif i > 80 and i <= 100 then
                    set dummy = CreateUnit(owner,'o00E',x,y,0.) //slow attack
                    call UnitApplyTimedLife(dummy,'BTLF',1.)
                    call IssueTargetOrder(dummy,"acidbomb",target)
                endif
                //Ion particle Fx
                call IonAddFx(target)
            endif
            set owner = null
            set dummy = null
    endfunction
   
    private function IonCheckAttack takes nothing returns boolean
            if  GetUnitAbilityLevel(GetAttacker(),IONID1)>=1 or GetUnitAbilityLevel(GetAttacker(),IONID2)>=1then
                    call IonDealAttack(GetAttacker(),GetTriggerUnit())
            endif
            return false
    endfunction

    public function init takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
            call RegisterSpellFinishResponse(IMW_SPELL,CastIonicMineWall)
            call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_DEATH )
            call TriggerAddCondition(t1, Condition(function CheckMineId))
            call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_ATTACKED )
            call TriggerAddCondition(t2, Condition(function IonCheckAttack))
    endfunction   
   
endscope

_________________
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
Page 1 sur 1
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