• 🏆 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!

[JASS] Spell Pokeball (Throw) Missile

Status
Not open for further replies.
Level 4
Joined
Apr 25, 2011
Messages
73
Hi.
I think that this is one of my first posts.
Ok, so what I need help with is making this GUI Trigger into a JASS Trigger...

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Pokeball Throw
    • Actions
      • Set Target_Unit = (Target unit of ability being cast)
      • Unit - Create 1 Rifleman for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Set Pokeball = (Last created unit)
      • Animation - Change Pokeball's animation speed to 500.00% of its original speed
      • Unit - Make Pokeball face (Position of Target_Unit) over 0.00 seconds
      • Unit Group - Add Pokeball to Pokeball_Group
  • Untitled Trigger 003
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Pokeball_Group and do (Actions)
        • Loop - Actions
          • Hashtable - Save (Angle from (Position of Pokeball) to (Position of Target_Unit)) as (Key (Target unit of ability being cast)) of (Key (Triggering unit)) in Pokemon_Hashtable
          • Unit - Move Pokeball instantly to ((Position of Pokeball) offset by 20.00 towards (Load (Key (Target unit of ability being cast)) of (Key (Triggering unit)) from Pokemon_Hashtable) degrees)
          • Unit Group - Pick every unit in (Units within 10.00 of (Position of Pokeball)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Picked unit) Equal to Target_Unit
                • Then - Actions
                  • Special Effect - Create a special effect at (Position of Target_Unit) using Abilities\Spells\Other\Charm\CharmTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Special Effect - Create a special effect at (Position of Target_Unit) using Pokeball2.mdx
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Change ownership of Target_Unit to (Owner of Pokeball) and Change color
                  • Unit - Move Target_Unit instantly to (Center of Pokespace[(Player number of (Owner of Pokeball))])
                  • Unit Group - Remove Pokeball from Pokeball_Group
                  • Unit - Remove Pokeball from the game
                • Else - Actions
GUI works perfectly. Unfortunately it is not MUI. And I think that JASS might be the leakless solution here... I started to learn JASS when I saw how many things can it do. But when I tried making it JASS, I banged my head on the problem: How can I move a local variable to another function. Answer: I can't. Only when a function takes arguments. But the timer function doesn't take any arguments (or that's what I know and what I tried).

I wanted to make it only a function with a Loop. But it just lagged too much. And what I know is that you can't pause a Loop.

I also thought of using my Pokeball, in the loop with the GetLastCreatedUnit(). But this seems to be not MUI. (Although if it is MUI, please let me know so I can start making the trigger (I only thought of it)).

If everything here doesn't work please share your ideas. Or maybe it is already on the site. (I didn't find it though)

Also I'm only at JASS, not the complicated vJASS with structs. Or private functions. I am even afraid to use the
JASS:
globals
endglobals
thing. Because it made my map unplayable when I tested it. It just opened and then got me to the Warcraft III Menu. Also I tried to open it with Create Game. Didn't work. Just brought me to the Local Area Network over and over again.

My last desperate call: Please help!

(I hope this is the right section, though)

PS: I forgot what I did in this trigger. Hashtables mostly.
 
Last edited:
Level 16
Joined
Dec 15, 2011
Messages
1,423
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/

http://www.hiveworkshop.com/forums/...rials-279/things-gui-user-should-know-233242/


You should be staying with GUI for a while more whilst learning the basics of JASS coding. Abrubtly shifting your coding style is not the correct way imho. Btw you should be using dynamic indexing if you want efficient, fast MUI in GUI.

To answer your questions:

1/ Locals are unique to a specific function and cannot be used in another one. However, you can use hashtables to solve this issue by saving/loading data with the timer's handle id as parent key.

2/ Loops can be stopped with the exitwhen statement. In timers, an If-Then-Else will, for instance, check for when the missile hits the target and pause the timer.

3/ GetLastCreatedUnit is not MUI. It will return a different value each time a new unit is created. Store the unit and reuse it later.

4/ The global tag is for JNGP only. You can't use it in normal WE.

I would love to convert the spell for you. Unfortunately, I am on a phone. Sorry.
 
Last edited:
Level 4
Joined
Apr 25, 2011
Messages
73
Why would I want to stick with GUI? It is not that good like JASS...
I am not a beginner with JASS. I can handle it. Most of it. Well not all and not most, but for some basic things it works pretty fine.

1. I know what locals are. I can and know how to use them. Don't know about hashtables.

2. Yeah, but I don't get the effect of the Pokeball moving (you know... the 0.35 movement)... It just lags (meaning the Pokeball moved instantly to it's target) and then it gets out of the loop and do whatever actions are left (I did put a If/Then/Else inside the Loop)

3. That's what I thought so. Unfortunately with locals, I can't use it in different functions. (And globals seem to beat me.)

4. Just found out what JNGP means. I have it though. I just don't like using it, 'cuz it won't open the map when I test it. It just opens Warcraft III, then black screen and after Warcraft III Menu... If you know how to fix this, I would be really thankful. It would make my life easier since I won't have to write JASS in JNGP and after do other stuff in normal WE.

Here is a sample of something simple I did in JASS. I can handle most of it, although I'm still learning.

JASS:
function Hex_C takes nothing returns boolean
    return ( GetSpellAbilityId() == 'AOhx' )
endfunction

function Hex_A takes nothing returns nothing
    local unit tar
    local unit cas
    local real dam
    set tar = GetSpellTargetUnit()
    set cas = GetSpellAbilityUnit()
    set dam = (GetUnitAbilityLevel(cas, 'AOhx')) * 200.00
    call UnitDamageTarget( cas, tar, dam,true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS )
    if ( (GetUnitState( tar, UNIT_STATE_LIFE) <= 0) == true ) then
    call RemoveUnit(tar)
    endif
    set cas = null
    set tar = null
endfunction

//===========================================================================
function InitTrig_Hex takes nothing returns nothing
    local trigger t
    local integer index
    set t = CreateTrigger( )
    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( t, Condition( function Hex_C ) )
    call TriggerAddAction( t, function Hex_A )
    set t = null
endfunction

I'm not really a beginner. (Although if you find any leaks in the code I won't mind if you'd tell me where and which they are)

Back to the topic: I already did it in JASS, but I got mad, deleted the code and made it GUI. If you could help me get out of this I would be grateful.

Oh and I use GUI only for things that are used only once in the map, map initialization or Quests ( JASS seemed not to work on quests so well (but don't worry, it's MUI, although I'm not sure about the memory usage of globals (I think that the map size is influenced by the maximum number of variables (also known as Size)))).
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
I am really sorry I misunderstood. Truly I am. Look I really want to help you out here but unfortunately, as I already mentioned, I cannot write a full spell code. I think that a properly written code by a guy with a computer will help you learn ten times faster than my useless and excessive explanations.

For the JNGP thing, save the map first before testing. Or upgrade to JNGP 2.0 beta.

Once again, my apologies for wasting your time.
 
Level 4
Joined
Apr 25, 2011
Messages
73
~Doomlord~
Don't be sorry for misunderstanding. I like to discuss things over.
Thanks for the tip with the JNGP. It works now, after re-downloading it and after some advices that are on the internet.

~deathismyfriend~
I don't have the time to look on spells right now... I am not looking for general knowledge at JASS. I'm only looking for the thing that I'm interested in... How to move a unit (missile), in JASS, leakless. If you do have a spell that is like that, then please post a link here.

I know MUI (in GUI, 'cuz in JASS locals are MUI). I have, for example, my Quest triggers:
  • TQ
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Stag Q
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PgQ[(((1 - 1) x 12) + (Player number of (Owner of (Buying unit))))] Equal to False
              • (Level of (Buying unit)) Less than or equal to 20
            • Then - Actions
              • Game - Display to (Player group((Owner of (Buying unit)))) the text: It seems your hadac...
              • Set PgQ[(((1 - 1) x 12) + (Player number of (Owner of (Buying unit))))] = True
              • Quest - Create a Required quest titled (Recovery ( + ((Name of (Owner of (Buying unit))) + ))) with the description The Hero said .... ..., using icon path ReplaceableTextures\CommandButtons\BTNMonsterLure.blp
              • Set Q[(((1 - 1) x 12) + (Player number of (Owner of (Buying unit))))] = (Last created quest)
              • Item - Remove (Sold Item)
            • Else - Actions
              • Item - Remove (Sold Item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Pig Q
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PgQ[(((2 - 1) x 12) + (Player number of (Owner of (Buying unit))))] Equal to False
              • (Level of (Buying unit)) Less than or equal to 30
            • Then - Actions
              • Game - Display to (Player group((Owner of (Buying unit)))) the text: As you can see this...
              • Set PgQ[(((2 - 1) x 12) + (Player number of (Owner of (Buying unit))))] = True
              • Quest - Create a Required quest titled (Village's Crysis ( + ((Name of (Owner of (Buying unit))) + ))) with the description The Hero said .... ..., using icon path ReplaceableTextures\CommandButtons\BTNMonsterLure.blp
              • Set Q[(((2 - 1) x 12) + (Player number of (Owner of (Buying unit))))] = (Last created quest)
              • Item - Remove (Sold Item)
            • Else - Actions
              • Item - Remove (Sold Item)
        • Else - Actions
I can't figure out what made you think that I don't get MUI...

I hope someone will help me get this thing done... I don't think that it has never occurred to anyone... So I'm hoping they will post it here.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The best thing here.. is I already made this system

I hope it works for u. Feel free to ask anything you want. It has several details, since i never finished the stetics, but the system works.

To move in JASS, do it in GUI, and replace the bj's. PolarProjectionBj just takes X source + offset * Cos of the (Angle * bj_DEGTORAD). Y takes the Sin of the Angle instead.

The angle is multiplying bj_RADTODEG * Atan2(TargetX - SourceX, TargetY - SourceY)

You can replace bj_RADTODEG and bj_DEGTORAD with the values they represent (PI / 180 and PI * 180)

The best way to move data from one function to another without using globals is using a Hashtable, storing the data in the TimerId, and retrieve the data on Timer expiration. the timer, off course, has to be local.
 

Attachments

  • SpartPokeballSys.w3x
    27.8 KB · Views: 69
Level 20
Joined
Jul 14, 2011
Messages
3,213
I was going to improve that system to make it more easy to configure, but the one i made it for just dissapeared, so i left it as it is.

- I didn't implement specific pokemon catch chance/resistance.
- I didn't implement what happens if the summoner dies while his pokemons are outside.
- I didn't implement what happened if the pokemon dies.
- I didn't make it easy configurable with globals. I ussually do it this way with pure locals, and then I add the globals for configuring purposes.
- I didn't make the code more read-able and add more comments.
- I didn't make the Pokemon Health Center to revive/restore pokemons.

It just catches the pokemon based on Pokeball and Target HP%, and summon/unsummon it (unhide / hide)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
if u want an alternative i have one in GUI. it catches units based on ther percent hp and uses a weight system for each unit type. it uses hashtables. The problem with a percent system is that u can easily break it if u have a pokeball that adds a 60 percent chance and a unit with 40 percent chance to catch. with my system that cant happen. its a weight system. if u need that explained just ask. anyways here it is.

its not 100 precent complete either.
 

Attachments

  • capturing summoning releasing system.w3x
    19.7 KB · Views: 52
Level 20
Joined
Jul 14, 2011
Messages
3,213
My system, DIMF, reduces the Pokeball chance by the Target HP. If You have 60% Pokeball, and target has 50% hp. The 60% is reduced by 50%, turning it to 30% chance and I haven implemented specific Target resistance to catch to make it even more interesting.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
ooo i c how ur doing it. thats a pretty good idea.

mine has a weight chance for a pokeball. a weight chance for the unit to catch and a weight chance for the unit to miss.
lets say the unit has 30 to catch and 30 to miss. basically 50%
but when u add in the pokeball the chance to catch is dependant on the pokeball.
so lets say u have 5 pokeballs 1 has 20, 2 has 40, 3 has 60, 4 has 80, and 5 has 100 chance.

when u calculate the miss chance it will stay the same.
the catch chance however would be like this.
pokeball 1 = 50 / miss = 30 / percent chance to catch = 62.50%
pokeball 2 = 70 / miss = 30 / percent chance to catch = 70.00%
pokeball 3 = 90 / miss = 30 / percent chance to catch = 75.00%
pokeball 4 = 110 / miss = 30 / percent chance to catch = 78.57%
pokeball 5 = 130 / miss = 30 / percent chance to catch = 81.25%

thats also max chance ( when health is next to 0 for the unit)
 
Status
Not open for further replies.
Top