• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

convert spell trigger

Status
Not open for further replies.
Hello,
Yes, it's me again^^
I need a convert spell for my map
I will explain all thing i need in this spell
So, first : It's a passive spell
When an unit come in the range of an unit with this spell, the spell begin to effect:
All ennemy units stop to move. The unit who cast the spell (a preacher) will begin to use the Casting spell model. The unit who cast the spell will not move too.
ally units will no more attacks ennemy under the effect of this spell.
All ennemy in the rang will use the stand model.
when an ennemy unit will be 10 seconds under the effect of this spell, it will be converted and will be an ally unit.
Ennemy preacher will not be affected by this spell.
When the preacher is under attacks, the spell will no longer affect ennemy units, who will be able to kill the preacher.

So ill give you an example for people who didnt understaood:
The preacher is walking,
An ennemy is coming.
it come in a range of 600 near trhe preacher.
The ennemy stop moving.
The preacher stop moving and use the Casting Spell alternate model.
We wait 5 seconds
Another ennemy units come.
We wait another 5 seconds, the first unit is converted but not the second one.
We wait 5 seconds
the second unit is converted.
The preacher can move now.
Both converted units come in a range of 600 near an ennemy preacher.
They stop moving and the ennemy preacher begin to use the Casting Spell alternate model.
An ally preacher come, and hurt the ennemy preacher.
Both units who begon to be converted are no longer under the effect of the spell and begin to attacks the ennemy preacher, who can move and attack again.

I hope that you can help me
plz i really need this
thanks^^
 
Level 5
Joined
Nov 22, 2009
Messages
181
i will try but i will probably make mistakes so you should ask someone to check over it. If there are any condidions then tell me and i will modify the script to include the conditions.

Create a unit called Spy.
JASS:
scope Spy initializer Init
    private scope SpyConversion
        private function Condition takes nothing returns boolean
            return GetSpellAbilityId() == //ability rawcode
        endfunction
        private function Actions takes nothing returns nothing
            local unit u = GetTriggerUnit()
            local unit spy
            local real x = GetUnitX(u)
            local real y = GetUnitY(u)
            local integer id = GetPlayerID(GetOwningPlayer(u))
            local real r = GetUnitFacing(u)
                call RemoveUnit(u)
                call CreateUnitByName(id, "Shade", x, y, u)
                set spy = CreateUnitByName(    ,"Spy", x, y-1, r)
                call SetUnitInvulnerability(spy,false)
         endfunction
ill finish it at later
 
kennyman, this should point you in the right direction when you get back:

JASS:
scope Spy initializer Init
    private function Actions takes unit u,player p returns nothing
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local real f = GetUnitFacing(u)
        
        call RemoveUnit(u)
        call CreateUnitByName(p,"Shade",x,y,f)
        call SetUnitInvulnerable(CreateUnitByName(p,"Spy",x,y,f),false)
    endfunction
    private function Conditions takes nothing returns boolean
        if GetSpellAbilityId() == 'A000' then
            call Actions(GetTriggerUnit(),GetTriggerPlayer())
        endif
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t,Condition(function Conditions))
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    endfunction
    
endscope
 
Level 5
Joined
Nov 22, 2009
Messages
181
I was thinking of using a struct for the move and death triggers like this:

JASS:
scope SpyScope
private function SpyDeathActions takes nothing returns nothing
    call Spy.death
endfunction
struct Spy
    unit shade
    unit spy
    trigger death
    boolean isDead = false

    method create takes real x, real y, real f, integer p returns nothing
        call .allocate()
        set .shade = CreateUnitByName(p, "Shade", x, y, f)
        set .spy = CreateUnitByName(/*forgot what id is for neutral passive*/, "Spy", x, y, f)
        call SetUnitInvulnerable(.spy, false)
        call IssueTargetOrder (.spy, "patrol", ".shade" // i am not sure how to use a widget or even what a widget is
        set .death = CreateTrigger()
        call TriggerAddActions(.death, function SpyDeathActions)
        call TriggerRegisterUnitEvent(.death, .spy, EVENT_UNIT_DEATH)
    endmethod
    method death takes nothing returns nothing
        call RemoveUnit (.shade)
        set isDead = true
    endmethod
endstruct
private function SpyConvertActions takes nothing returns nothing
    local unit = GetTriggerUnit()
    local integer id = GetPlayerId(GetOwningPlayer(u)
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u)
    local Spy s 
    local integer i = 0
        call RemoveUnit(u)
        set s = Spy.create(x, y, f, id)
        loop
            exitwhen s.isDead == true
            call TriggerSleepAction(1.00)
        endloop
        call RemoveUnit (s.shade)
        call s.Destroy
endfunction
private function Conditions takes nothing returns boolean
        if GetSpellAbilityId() == 'A000' then
            call Actions(GetTriggerUnit(),GetTriggerPlayer())
        endif
        return false
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddActions(t, function SpyConvertActions)
        call TriggerAddCondition(t,Condition(function Conditions))
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    endfunction
I am not sure if the spy can follow the shade (especially since he is invisible) or if i can even order him to patrol to the shade but it should work and you might want to give the spy truesight.

I would try getting someone to look over it and make the nessecary changes like playernumber for neutral passive and and the change unit color function to the create method.
 
Last edited:
JASS:
struct Spy
 
    static unit spy         = null
 
    unit        shade       = null
    trigger     DeathTrig   = null
 
// The "onDeath" method is horribly flawed and needs to be completely revised.
 
    static method create takes unit u,player p returns nothing
        local thistype this = .allocate()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local real f = GetUnitFacing(u)
 
        call RemoveUnit(u)
        set .shade = CreateUnitByName(p, "Shade", x, y, f)
        set .spy = CreateUnitByName(Player(15), "Spy", x, y, f)
        call IssueTargetOrder(.spy,"move",.shade)
 
        set .DeathTrig=CreateTrigger()
        call TriggerRegisterDeathEvent(.DeathTrig,.spy)
        call TriggerAddCondition(.DeathTrig,Condition(function thistype.onDeath))
    endmethod
 
    static method Setup takes nothing returns boolean
        if GetSpellAbilityId() == 'A000' then
            call .create(GetTriggerUnit(),GetTriggerPlayer())
        endif
        return false
    endmethod
 
    static method onInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerAddCondition(t,Condition(function thistype.Setup))
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    endmethod
 
endstruct

Do you not have access to the game to actually test your code? You'd get syntax errors like crazy.
 
Level 5
Joined
Nov 22, 2009
Messages
181
i did not at the time. what were the issues? please excuse the mistakes. im still very new to this stuff. so im nowhere near good at this stuff. but i try.
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
yeah, i usually only bump once my thread is knocked off the first page, which is usually 2-3 days. (give or take a day)
anyways, It's not even your thread to bump, and you really didn't need a response to your posts.
but now were getting off-topic from the thread.
please let's be friends and get back on topic :thumbs_up:
 
I live in America and was refused a job at Taco Bell because I don't speak Spanish, and it's legal for them to do that. So clearly there's nothing racist about understanding language in order to work with the system.

If I didn't know programming, I couldn't get a job as a programmer. That doesn't make the company that refuses me racist.
 
Level 6
Joined
Oct 10, 2009
Messages
1,425
1) I thought you were from America.(or another largely English speaking country) So, sorry for assuming.

2) I did not come off in an offensive way, in my opinion.
I could have said "check out this f*cking tut you stupid foreign f*ck."
But that would be flaming on so many levels.
Sorry if I offended you, but if you read the tutorial, it states that even native English speakers should read it.
Because 70% of the people in forums need help with English whether they be American, European, Japanese, Alien, or Unknown.
So don't take offense man. I put it there to help you.

3)Bribe, I love that Jass syntax title there :)

4)Let's get this thread back on topic now :)
 
Last edited:
Status
Not open for further replies.
Top