Adding Ammo Menu help [EDIT]

Discuss modding in thug2. If you want to make something by yourself you can ask how to in here. Also, you can post any thug2 related mod in here.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Adding Ammo Menu help [EDIT]

Postby Anteara » Thu Oct 14, 2010 2:57 am

hi all, I'm trying to make a simple mod, for no reason at all, mainly just to pass the time.

I've so far got a "DEBUG MENU" and a "CUSTOM RESTART" menu in my "Anteara Menu" in the online play pause screen.

I've added an ammo menu, and set tomatoes, cans, apples, etc, but I can't find out what I need to do to make it work.

I'll post my code with some screenshots.

Code: Select all

:i function $create_anteara_menu$
    :i call $make_new_roundbar_menu$ arguments
        $title$ = %s(12,"Anteara Menu")$pad_back_script$ = $generic_menu_pad_back$$pad_back_params$ = :s{$callback$ = $create_pause_menu$:s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(11,"WALLSHUFFLE")$extra_text$ = %GLOBAL%call $hud_text$ arguments
            $id$ = $menu_kevin_ws$$pad_choose_script$ = $wallshuffleon$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(10,"DEBUG MENU")$pad_choose_script$ = $create_debug_options_menu$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(15,"CUSTOM RESTARTS")$pad_choose_script$ = $create_customrestart_menu$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(15,"AMMO MENU")$pad_choose_script$ = $create_myammo_menu$
    :i :s}
    :i $roundbar_menu_finish$
:i endfunction


That is the Anteara Menu code, with the ammo menu, custom restards, debug menu, and wallshuffle option. It all works well.

I was then experimenting with the ammo menu, to see what would happen. But i can't get it to work!

Code: Select all

i function $create_myammo_menu$
    :i call $make_new_roundbar_menu$ arguments
        $title$ = %s(9,"Ammo Menu")$pad_back_script$ = $generic_menu_pad_back$$pad_back_params$ = :s{$callback$ = $create_anteara_menu$:s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(8,"TOMATOES")$pad_choose_script$ = $pickup_tomato$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(9,"PAINTCANS")$pad_choose_script$ = $pickup_spraycan$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(6,"APPLES")$ammo_texture$ = $pickup_apple$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(5,"BEADS")$pad_choose_script$ = $pickup_beads$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(13,"COMBO LETTERS")$pad_choose_script$ = $pickup_apple$
    :i :s}
    :i $add_roundbar_menu_item$:s{$text$ = %s(9,"SMOKEBOMB")$pad_choose_script$ = $pickup_cocktail$
    :i :s}
:i $roundbar_menu_finish$
:i endfunction


Here is a screenshot of what it currently looks like, That's how I would like my ammo menu set out. Image

So, on

Code: Select all

    :i $add_roundbar_menu_item$:s{$text$ = %s(8,"TOMATOES")$pad_choose_script$ = $pickup_tomato$

What would I put after

Code: Select all

:i $add_roundbar_menu_item$:s{$text$ = %s(8,"TOMATOES"
?


Thanks! :)

In summary, as this may be hard to understand, How do I make the ammo menu work? What do i Put after " :i $add_roundbar_menu_item$:s{$text$ = %s(8,"TOMATOES")"
Last edited by Anteara on Thu Oct 21, 2010 4:58 pm, edited 1 time in total.
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: Adding Ammo Menu help

Postby quazz » Thu Oct 14, 2010 6:20 am

In THUG2 Remix for PSP (I'm the only one to ever discover how to get the game to run on scripts :) ;) ) there is an additional projectile in Atlanta, "Records". :lick:
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help

Postby Anteara » Thu Oct 14, 2010 11:37 am

Thanks a lot for helping me Who, I'll +rep you if I can for this.

I've now got a fully functional ammo menu, with all the ammo types, etc.

Even so, I am a noob, and I only understood around 50% of your post. I didn't use the left/right for the selecting of the items, cause I couldn't figure out how to do it. :wat:

I'll show you some screenshots of what i'm up to currently, and if you still have time, might you be able to give me some pointers?

Image

That's the ammo menu, where you can select what you want to throw.

Image

That's the ammo menu, where you can select how much ammo you have and select "Choose Item" where you go to the window in the previous screenshot.

Image

That's just a photo to show that it all works.


Anyway - My problem.
I have no idea why the bottom half of the menus aren't showing. Only the top half is showing.
Also, I don't know how to make it so pressing "escape" will go to the previous window. I had to make an "Exit" button to go back.
Also, I'm assuming my code is messy, as I didn't really follow you 100%, I'll post it here.

Code: Select all

:i function $create_ammoyeah_menu$
:i call $make_new_themed_sub_menu$ arguments
        $title$ = %s(9,"AMMO MENU")

:i $Skater$.$GetAmmo$
:i $theme_menu_add_number_item$:s{
   :i $text$ = %s(10,"Ammo  --  ")
   :i $id$ = $proj_menu_amount$
   :i $min$ = %i(0,00000000)
   :i $max$ = %i(10000,00002710)
   :i $step$ = %i(10,0000000a)
   :i $value$ = %GLOBAL%$ammo$
   :i $pad_choose_script$ = $proj_menu_remove_amount$
   :i $pad_left_script$ = $proj_menu_update_amount$
   :i $pad_right_script$ = $proj_menu_update_amount$
   :i $first_item$
   :i $text_pos$ = %vec2(75.000000,-5.000000)
:i :s}
:i call $theme_menu_add_item$ arguments
        $text$ = %s(11,"Choose Item")$pad_choose_script$ = $create_ammoitem_menu$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(4,"Done")$pad_choose_script$ = $create_anteara_menu$
:i $finish_themed_sub_menu$
:i endfunction


This is the main ammo menu, as seen in the second screenshot.

Code: Select all

i function $create_ammoitem_menu$
:i call $make_new_themed_sub_menu$ arguments
        $title$ = %s(9,"ITEM MENU")
:i call $theme_menu_add_item$ arguments
        $text$ = %s(6,"Tomato")$pad_choose_script$ = $give_me_tomato$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(5,"Apple")$pad_choose_script$ = $give_me_apple$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(9,"Paint Can")$pad_choose_script$ = $give_me_paintcan$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(5,"Beads")$pad_choose_script$ = $give_me_beads$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(6,"Shrimp")$pad_choose_script$ = $give_me_shrimp$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(9,"Smokebomb")$pad_choose_script$ = $give_me_smokebomb$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(9,"Combo O's")$pad_choose_script$ = $give_me_Goal_COMBO_O$
:i call $theme_menu_add_item$ arguments
        $text$ = %s(4,"Done")$pad_choose_script$ = $create_ammoyeah_menu$
:i $finish_themed_sub_menu$
:i endfunction


This is the selecting an item menu, as seen in the first screenshot.

Code: Select all

:i function $proj_menu_update_amount$
   :i $Skater$.$GetAmmo$
   :i $Skater$.$SetAmmo$%GLOBAL%$value$
:i endfunction
:i function $proj_menu_remove_amount$
   :i $Skater$.$GetAmmo$
   :i $Skater$.$SetAmmo$%i(0,00000000)
:i endfunction
:i function $give_me_apple$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$apple$
:i endfunction
:i function $give_me_tomato$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$tomato$
:i endfunction
:i function $give_me_paintcan$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$paintcan$
:i endfunction
:i function $give_me_beads$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$beads$
:i endfunction
:i function $give_me_shrimp$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$shrimp$
:i endfunction
:i function $give_me_smokebomb$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$smokebomb$
:i endfunction
:i function $give_me_Goal_COMBO_O$
:i $Skater$ = %i(100,00000000)
:i $Skater$.$SetAmmoType$$Goal_COMBO_O$
:i endfunction
:i :end


Those are the functions associated with selecting an item.


--

Again, thank you for your amazing help with this. I would have never been able to do it without your help.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Adding Ammo Menu help

Postby Morten1337 » Thu Oct 14, 2010 4:00 pm

add this to the last menu item

Code: Select all

      :i $last_item$
      :i $last_menu_item$ = %i(1,00000001)


Code: Select all

:i call $theme_menu_add_item$ arguments
        $text$ = %s(4,"Done")$pad_choose_script$ = $create_ammoyeah_menu$$last_item$$last_menu_item$ = %i(1,00000001)
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help

Postby Anteara » Fri Oct 15, 2010 5:07 am

Thanks Morten and Who,
I've used what you two said and fixed the menus, so the bottom part is there now.
Image
Image


So, I've tried to simplify the code so it's all in one function, I've removed everything, so in my code there is just "tomato" and "apple".


You should do 1 single function that each of the ammo type buttons call on with a different param
then use a switch statement inside the function.


I tried this, and I've obviously tried to do it wrong.

I searched through projectiles and found this.

Code: Select all

:i switch %GLOBAL%$ammo_type$
        :i case $tomato$


I'm not sure if that's the switch command that you meant, but I tried to use that.

Also, with the "call on with a different param", I tried that too, but probably did it wrong. Heres my code.

Code: Select all

:i call $theme_menu_add_item$ arguments
        $text$ = %s(6,"Tomato")$pad_choose_script$ = $give_me_apple$$pad_choose_params$ = :s{$SetAmmoType$ = $tomato$:s}


Code: Select all

:i function $give_me_apple$
:i $Skater$ = %i(0,00000000)
:i $Skater$.$SetAmmoType$$apple$
:i switch $ammo_type$
:i case $tomato$
:i case $apple$
:i end_switch
:i endfunction


Obviously, It doesn't work - it just crashes my game.

As you can see, I'm clueless. If you don't mind can you tell me what I'm doing wrong?
Obviously, it works with the mega long code, but simplifying the code is the last piece of the puzzle.

I'll keep trying for a little while longer to see if i can get it right.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help

Postby Anteara » Fri Oct 15, 2010 3:11 pm

I fixed the code like you said, and for some reason it doesn't seem to want to work. D:

When I press "tomato" and try to throw it, a combo letter comes out instead of the tomato. It happens for all of them. :S

Sorry for all this trouble, hah.


EDIT: On a side note, with my old, bulky code (The one that is like 50 lines long), I figured out how to throw skateboards. >_< :D
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Adding Ammo Menu help

Postby Morten1337 » Fri Oct 15, 2010 4:51 pm

don't use switch/case for this.

The reason why you are throwing "combo o's'' is because thats the default ammo, switch is very bugged so it dosn't return the ammo_type, because a switch/case need unique values.
This causes the SetAmmoType-function to run with no parameter.
Just use this, using a switch in this function is pointless anyways.

Code: Select all

:i function $give_me_ammo$
:i $Skater$.$SetAmmoType$%GLOBAL%$type$
:i endfunction
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help

Postby Anteara » Fri Oct 15, 2010 6:06 pm

Okay, thanks guys, I've now got it all working, with selecting all the ammo types in one function.

I just have one more problem though, considering I have something on the script and script param for selecting an item, how would I go about redirecting it back to the previous menu?

For example,

Code: Select all

:i call $theme_menu_add_item$ arguments
        $text$ = %s(11,"Choose Item")$pad_choose_script$ = $create_ammoitem_menu$


By clicking on "Choose Item", it sends me to the ammo selecting menu, but i've done that from the "$pad_choose_script$" area.

Code: Select all

:i call $theme_menu_add_item$ arguments
        $text$ = %s(5,"Apple")$pad_choose_script$ = $give_me_ammo$$pad_choose_params$ = :s{$type$ = $apple$:s}


I have it linking to "give_me_ammo" there, so how would I redirect it back to the previous menu?

I tried looking in some other files, and in game, but I couldn't find any menus that give you something, then redirect back to the previous menu.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help

Postby Anteara » Fri Oct 15, 2010 6:25 pm

Okay, That works ^^.

Thanks a lot Who and Morten, I wouldn't been able to do this without the help of you two.


Just another question, now that I know how to do this, if, for example, I wanted to make something like a vehicle menu, such as the one in TheMod.. Would I go about doing it the same way as I did this?
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: Adding Ammo Menu help

Postby Morten1337 » Sat Oct 16, 2010 12:01 am

Anteara wrote:...Just another question, now that I know how to do this, if, for example, I wanted to make something like a vehicle menu, such as the one in TheMod.. Would I go about doing it the same way as I did this?


Yes the menu would work the same way, obviously the parameters for the "vehicle script" would be different, but its the same method.
There is one notch tho', You'll need to import thug1 qb's and make some minor changes for it to work with thug2.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help [EDIT]

Postby Anteara » Thu Oct 21, 2010 4:57 pm

Hi Guys, Thanks for the help with the ammo menu. It's working brilliantly. I've also made some other things, like throwing skateboards and tapes, though it's only client-side.
I've decided to do something that I've seen in some other mods (private), which is an animation menu.

For example - A button press calls for a dance or something.

First of All, I've made a working menu, and have successfully called upon some animations. Though, they're very simple. Things like the double fistin' colours that initiate when you do the trick.

I've been trying to find some more animations, but i literally can't find ANY. I've looked through almost every file in the scripts folder. Perhaps I'm searching for the wrong thing, or, perhaps the "dance" animation isn't defined, and the mod creator defined it himself.

I searched through some mods to see if they had any other similar things (specifically, to gain knowledge, not to steal), and the closest thing I found was "Throw Board" in NG Mod.

Code: Select all

:i function $animation_test1$
    :i $Skater$.$exit_pause_menu$
    :i $Skater$.$SetBoardMissing$
    :i $Skater$.$DiscusThrow$
    :i $Skater$.$Display$
:i endfunction


I can see how that would work. It does throw the board. But I would argue that that isn't technically solely an animation (or is it?).

I searched through some files, searching for $DiscusThrow$ and $Display$, because with ONLY that function in my scripts, the animation works. So I tried to find out what $Display$ and $DiscusThrow$ is, but I couldn't find anything containing those either.

Anyway, this wall of text is mainly to show you guys that I have been trying. I'm not posting here asking for you to hold my hand like some others in the past have.

My question mainly is - considering I have searched through almost every file for animations (I'm probably searching for the wrong thing), which file (or files) would contain the animations?

Also, I don't know if this is possible, but is there a way to figure out (easily) what file would contain specific things, such as which file would contain $DiscusThrow$?
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help [EDIT]

Postby Anteara » Fri Oct 22, 2010 1:47 am

Okay,
I've unpacked some prx's that seem to be relevant and will start my search. Thanks :D
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help [EDITx2]

Postby Anteara » Fri Oct 22, 2010 7:04 pm

Hmm, Well this is definitely confusing. I've searched through a lot of files and i think i've found the animation for the mime in Barcelona.

Code: Select all

   :i function $BA_Mime$
      :i while
         
         :i call $Obj_LookAtObject$ arguments
            $type$ = $skater$$time$ = %f(0.500000)
         :i select(2f,3, 01 00 01 00 01 00) :OFFSET(18):OFFSET(19):OFFSET(20)
            
            :i  :POS(18) $printf$%s(19,"#### mime wall ####")
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_idle2Wall$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Wall2Push$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Push2Wall$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Wall2idle$
            :i
         :BREAKTO(21)
             :POS(19) $printf$%s(19,"#### mime push ####")
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_idle2Push$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Push2Wall$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Wall2Push$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Push2idle$
            :i
         :BREAKTO(21)
             :POS(20) $printf$%s(19,"#### mime pull ####")
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_idle2Pull$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Pull$
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_Pull2idle$
            :i  :POS(21)
         :i call $Obj_LookAtObject$ arguments
            $type$ = $skater$$time$ = %f(0.500000)
         :i while
            
            :i call $Obj_CycleAnim$ arguments
               $anim$ = $PED_Mime_idle$
         :i loop_to %vec2(1.000000,3.000000)
      :i loop_to
   :i endfunction


The only problem is, i have absolutely no idea how to get my skater do this animation, I've tried tons of ways, either it just crashes the game or does nothing.

Just to confirm, is this script the animation for the mime in Barcelona? If so, How would I go about making my skater use the animation? I'm baffled.

PS - I know I'm clearly not knowledgeable enough to be doing this, It's just something I've always wanted to be able to do in THUG2, and since there are no public mods available with an animations menu, I figured I would try make one myself.

http://www.youtube.com/watch?v=7qlh1bByHSU
Heres a video, 1:10.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help [EDIT]

Postby Anteara » Sat Oct 23, 2010 4:48 pm

I haven't tried it yet, but would this be similar to the way to get the skater to do an animation?

Code: Select all

:i function $anteara_pedtest$
:i call $MakeSkaterGoto$ arguments                
      $PedKnockDown$
:i endfunction



EDIT: I think I'm getting somewhere.

Code: Select all

:i function $anteara_pedtest1$
            :i %GLOBAL%$objId$.call $Obj_PlayAnim$ arguments
               $anim$ = $Ped_M_SkateIdle1$$cycle$
:i endfunction


taking this code from the BA scripts gave me the default stance (I don't know what it's called :|)

Image


EDIT2: it does the same thing when i put part of the mime script there.

Code: Select all

:i function $anteara_pedtest1$
            :i $objId$.call $Obj_PlayAnim$ arguments
               $anim$ = $PED_Mime_idle2Wall$$cycle$
:i endfunction


EDIT3: The animation works. But only in Barcelona, and only on Story mode. I have absolutely no idea why it doesn't render the animation in network/online play.
EDIT4: When I try an anim from the file "allanims.qb" - it works in network/online play and in any level. Could it be that the mime script isn't working because it's in a levels qb? If so, would recreating the script in a different qb most likely make it work?
EDIT5: I'm pretty sure this script is the one I'm looking for, as it lets me call any animation. The main problems I have now are;
1) I'm unsure as how to "link" the anims (I.E Idle2Pull - Pull2Wall - Wall2Pull) etc.
2) Some anims are only working in the respective level that the anim i'm calling for is located.


--
By the way, If you're wondering why I'm editing this so much, it's mainly so i can check my progress.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: Adding Ammo Menu help [EDIT]

Postby Anteara » Sat Oct 23, 2010 9:05 pm

Ah,

http://www.youtube.com/watch?v=7qlh1bByHSU

kirill seems to have got some level specific anims working in other levels (like star wars kid)

EDIT: Hmm, I tried to dummy the anims prx in an attempt to make the game load from the anims folder so i could edit the file names in there, but it was a no go, game was crashing due to an incomplete anims folder i'd imagine. I wonder how the guy in the video did it. hmm

Also, I've been trying to make it so the animations can play after eachother, but so far it's only playing the animation on the end. For example;

Code: Select all

:i function $anteara_pedtest1$
            :i $objId$.call $Obj_PlayAnim$ arguments
               $anim$ = $PED_Mime_Wall2Push$
            :i $objId$.call $Obj_PlayAnim$ arguments
               $anim$ = $PED_Mime_Push2Wall$
:i endfunction


In that circumstance, it will only play Push2Wall, instead of playing Wall2Push and then Push2Wall.
I don't really know what a select/while function is too so i tried do it the most logical way i could think of, which was wrong.

Any tips? This would be the last part of the puzzle for this menu, apart from the not being able to play some anims cross levels.
Last edited by Anteara on Sat Nov 27, 2010 7:10 pm, edited 1 time in total.

Return to “THUG2 modding”

Who is online

Users browsing this forum: No registered users and 0 guests