Jump to content

[San Andreas] Adjusting Provoke Gang War # Higher


KC702

Recommended Posts

I was wondering if there was a way to edit the number required to provoke a gang war. I saw there was a post with members attempting to create a code for instant gang wars - I wanted to go in the opposite direction. I was hoping to raise the trigger number to allow for more interaction.

I am not a fan of taking over a territory as it is essentially permanent - I know the territory can still be attacked, just not lost. (Unless there is a mod for this I may have missed?)

 

Wishful thinking, but since coding is a foreign language to me, I hope it is as easy as changing the number "3" to a number "10" in a code line lol.

If it is possible, any guidance would be greatly appreciated.

Link to comment
Share on other sites

{$CLEO .cs}
{edit mode = sa_scr}
//GangWar_Provocation.txt

const Provocation_Threshold = 0x859974, CGangWars_Provocation = 0x96AB5C
float Provocation, Threshold

script_name 'provoke'
WAIT 3000
write_memory Provocation_Threshold size 4 value 4.099999 vp False // default = 2.099999 

while true
    wait 500
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold
end

TERMINATE_THIS_CUSTOM_SCRIPT

 

Edited by OrionSR
  • Like 2
Link to comment
Share on other sites

Thank you very much for the response. For the past couple hours, I have made attempts to learn Sanny Builder and create this script .cs file. I will continue to take cracks at it (I have been following the guide on these forums regarding .cs files). I get the .txt and .cs to pop up in my cleo folder... Unfortunately, I keep crashing on attempts to implement either this script and/or the demotxt example given... so I am missing something.

Link to comment
Share on other sites

This clue is important:
 

{edit mode = sa_scr}

You need to set the edit mode in the lower right corner of Sanny Builder to SCR mode - GTA SA (v1.0 - SCR).

Link to comment
Share on other sites

Wish I had asked sooner lol. That did it, works great! Thank you for the help with the code and the clue. I actually had no idea the provoke meter diminished over time, I always thought it was a set "kill X number within X territory to start a war." Almost two decades with this game and still learning stuff about it.

One last question, is there any way to hide the provoke and threshold meter without me botching the functionality? As it stands, the provocation and threshold meters are displayed throughout all gameplay at the bottom of screen. I attempted to mess with the "float" and "constant" line thinking that was it and ended up spiking an error again.

Link to comment
Share on other sites

16 minutes ago, KC702 said:

is there any way to hide the provoke and threshold meter without me botching the functionality?

Yes. All you really need for the functionality that you requested is this:
 

{$CLEO .cs}
write_memory 0x859974 size 4 value 9.099999 vp False // provocation_threshold, default = 2.099999 
TERMINATE_THIS_CUSTOM_SCRIPT

And usually when asking questions in the forum the answer will only be, in this case, the write memory line. It's up to you to work it into a proper script. It's good that you are experimenting though, for better or for worse.

 

16 minutes ago, KC702 said:

I actually had no idea the provoke meter diminished over time

Yeah, that was news to me too, and I've fiddled with the gang war codes quite a bit over the years. After examining the internal functions this is what I was expecting though, so I added the print loop to display the current provocation level in-game to confirm my suspicions. 

 

The scripts I posted are just examples. It's up to you to develop the script further - I'll help if you want. That crude print loop was super easy to write, appropriate for an example script, but it would work better in it's own draw loop if that's a feature you'd like to keep.

 

Edited by OrionSR
Link to comment
Share on other sites

I may have to take you up on that. When I do make attempts to change, help would definitely be appreciated.

 

I do want to preface this with what I am asking is way beyond my current scope of understanding. I had to look up what a draw loop was lol. However, after sitting with it, the meter is a really cool feature. I will definitely be making attempts to tweak it and see what I can do. A few thoughts came to mind with the script that I wanted to run by you - as a measure of if they are even possible to act out in the game and/or within a .cs file.

 

As I said before, I am very green with Sanny Builder but from the collection of videos I saw it tends to lean of IF/THEN statements. All of my ideas ride on the ability to hide/display the meter. If that is the case, would the below be feasible?

 

1) IF (player) is in combat outside of an opposing gang territory THEN meter display is set to hide (default essentially)

2) IF provocation/threshold meter display is less than 0.00100 THEN meter display set to hide

3) IF a gang war is currently active THEN meter display set to hide

4) IF (player) is in combat within an opposing gang territory THEN meter display is shown until #2 or #3 true

 

Is positioning of the meter display movable? I know in game all the mission briefs and other texts are set to bottom of screen, so I am unsure.

Is text size adjustable?

Link to comment
Share on other sites

12 minutes ago, KC702 said:

I do want to preface this with what I am asking is way beyond my current scope of understanding.

Sometimes it happens like this.. You request something simple and than you realize that it's harder than it looks.. OrionSR is a great teacher and i'm pretty sure you will learn a lot of stuff from him 😉

19 minutes ago, KC702 said:

2) IF provocation/threshold meter display is less than 0.00100 THEN meter display set to hide

My reply won't be your answer but you can decompile the "main.scm" (Game Directory>GTA San Andreas>Data>Script.. BACKUP THE WHOLE SCRIPT FOLDER..) and look for references. Doberman mission for example will be your main target to look for..Especially the warning message about returning to Glen Plark when CJ is standing outside of Zone Coordinates... 🙂

Link to comment
Share on other sites

3 hours ago, KC702 said:

I do want to preface this with what I am asking is way beyond my current scope of understanding.

Sounds to me like your understanding is very good; you're a bit short on experience is all. I suspect coding will come quite naturally to you.

 

3 hours ago, KC702 said:

Is positioning of the meter display movable?

Yes, with print loops you're stuck with the pre-defined print commands that manage where things draw, display time, text formatting, and even how the text fades in and out. With draw/display commands, you can fine tune all that stuff but it's a bit more work. You could even have the text move around the screen if you really wanted to.

 

I had another idea though, something I've been wanting to experiment with anyway. What do you think about displaying a Provoke War meter? It would look very much like a spook-o-meter bar from... Snail Trail or Key to Her Heart missions, iirc. Cleo+ has some nice counter/timer commands which don't require global variables that I've been interested in trying. (Global variables are bad news in cleo scripts, btw. I trust you found the warning when reviewing ZAZ's tutorials.) Or I could write the draw loop part if you prefer. That part is a bit tricky for a first cleo script.

 

3 hours ago, KC702 said:

would the below be feasible?

Excellent psuedo-code. These ideas are awesome! I've got things to do before I can start coding, but in the meantime, you could get started on implementing some of these ideas on the print loop in my larger script. It'll give us a chance to practice exchanging snippets - small sections of code that you could insert into the appropriate location in the larger script and adapt as required.


Start with 2) Hide If provocation is less than X, and reverse the logic to: Display If provocation is greater than 0.0. The script is already managing this information so you don't need to hunt down anything new for this one.

Replace this line:

    print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold

 

... with this high-level IF..THEN..END construct.

    if
        <condition>
    then
        print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold
    end

Then figure out how to replace <condition> with actual codes that do what you want.

 

Um... that might be too easy... If you get that working, change IF to IF AND, and then add additional conditions between IF AND and THEN. Checking if a gang war is active would be less complicated than detecting zone information.

 

Edited by OrionSR
Link to comment
Share on other sites

26 minutes ago, OrionSR said:

displaying a Provoke War meter

I am really glad you mentioned this. I had the same thought but was intimidated by implementing an image (a moving one at that) on my first go-around. I think it would be awesome see the provoke war meter in place of the provocation/threshold number display.

 

Just out of curiosity, would this meter still work alongside the IF/THEN/END construct to hide/display it? Either way, I will get started on it asap. Am eager to tackle it.

 

40 minutes ago, OrionSR said:

Or I could write the draw loop part if you prefer

Honestly, I know I said I looked up what the term "draw loop" meant but I still do not fully understand it. The example I was given involved a saltshaker image and someone managing to string together various images of it to make it look like it was being poured on food... long story short - yes I would definitely appreciate your input on that end.

With the level I am on, if I can manage to get the text to Hide/Display, everyone in my house is getting a high-five lol.

Link to comment
Share on other sites

2 hours ago, KC702 said:

I looked up what the term "draw loop" meant but I still do not fully understand it.

The term "draw loop" is fairly generic, and depends a bit on context. Your salt shaker example is appropriate. The draw commands are used extensively in the video game scripts, like Go Go Space Monkey. If we were to pursue this strategy, we'd be taking advantage of the draw text commands rather than manipulating textures and sprites. 

 

Loop is a consistent term; the section of script that repeats multiple times. The "print loop" shown above is using Print commands. A draw loop would use Draw commands. However, Draw is a term used in the community based command names - edit mode SA v1 or v2. More recently, the official command names have been leaked, and incorporated into new edit modes, like SCR. The official command names usually use Display in the command name instead of Draw.

 

2 hours ago, KC702 said:

intimidated by implementing an image

Fortunately, the Counter bar commands take care of the image processing automatically. We're stuck with the usual bar location though, just below the hud.

 

2 hours ago, KC702 said:

would this meter still work alongside the IF/THEN/END construct to hide/display it?

Yes, one way or another it's going to work only when the appropriate conditions are true. I'm still not sure exactly what form that will take; it might not be quite as simple as the print loop conditions. Either way, any testing you conduct on the print loop will apply directly to the final version.

 

It's Thursday, lots of extra game chores to complete, and I'm behind, so you've got some time to work on that first conditional check - print only if > 0.0. I'm hoping you can finish this part so I can work it into my test scripts without giving away the answer. When you have a script or snippet you'd like to share in the forums, please wrap the code in code tags - the <> icon on the editor's tool bar. If you have a large script, start with a spoiler tag (eyeball on the right) to hide the bulk of the script, and insert the code tags within the spoiler tags.

Edited by OrionSR
Link to comment
Share on other sites

First night

 

Positives:

I was able to get it to compile without an error popping up (and there were many)

I am seeing many avenues to write this script (you will see this again), just unsure how to format statements.

 

Negatives:

I am seeing many avenues to write this script... IF/THEN/END or IF/THEN/ELSE/END or WHILE TRUE/FALSE...

Big negative, all of these crash the game

 

All of these attempts include the same upper half of the original code, just posting the lower half where we replaced with IF/THEN

 

Attempt IfAndThenEnd:

Spoiler
while true
    wait 500
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    if and
        read_memory CGangWars_Provocation size 4 vp False >= 0.001000
        IS_GANG_WAR_FIGHTING_GOING_ON False
    then
        print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold 
    end 
end  

 

 

Attempt IfThenElseEnd:

Spoiler
while true
    wait 500
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    if
        read_memory CGangWars_Provocation size 4 vp False >= 0.001000
    then
        print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold 
    else
    if read_memory CGangWars_Provocation size 4 vp False < 0.001000: IS_GANG_WAR_FIGHTING_GOING_ON True
    end 
end  

TERMINATE_THIS_CUSTOM_SCRIPT

 

Attempt IfThenEnd:

Spoiler
while true
    wait 500
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    if
        read_memory CGangWars_Provocation size 4 vp False >= 0.001000
    then
        print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold only if >= 0.001000
    end 
end 

 

Attempt IfThenEnd:

Spoiler
while true
    wait 500
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    if
        read_memory CGangWars_Provocation size 4 vp False >= 0.001000
    then
        print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold only if read_memory CGangWars_Provocation size 4 vp False >= 0.001000
    end 
end

 

 

Inside the mind of the new guy lol. Will continue to crack at it. I was pretty happy I was able to get files to compile but the crashes in game weigh heavy lol. I am a bit lost at how I tell the program to look for the integer related to CGangWars_Provocation... not fully convinced I am writing that >= line correctly. I think that is what is making me crash.

Also I was not able to get the jump_if_false command to work without an error. I tried tagging a jump_if_false at the end of the IF statement and have to route to the end of script - could not get it to compile. Anyway, I am in my own head thinking it is a lot easier than I am making it. So, will give it a look from different angle tomorrow.

Edited by KC702
forgot to add an attempt
Link to comment
Share on other sites

This here with condition 

 

{$CLEO .cs}
const 
 Provocation_Threshold = 0x859974 
 CGangWars_Provocation = 0x96AB5C
 Provocation  = 0@
 Threshold    = 1@
end
wait  3000
0A8C: write_memory Provocation_Threshold size 4 value 4.099999 vp False // default = 2.099999 
while true
wait  500
0A8D: Provocation = read_ CGangWars_Provocation size 4 vp 0
0A8D: Threshold = read_ Provocation_Threshold size 4 vp 0
if    or  //This here is if one of here has value more than 0 then it will show 
      Provocation  > 0.0
      Threshold    > 0.0 
jf    continue      
if    and //This mean if both has value more than 0.0 this is float then 2 numbers will show
      Provocation > 0.0
      Threshold   > 0.0
then  print_formatted "Provocation %.1f~n~Threshold %.1f" 500  Provocation Threshold
else 
if    Provocation <> 0.0 //if not zero value it will show Provocation or it will show only value Threshold
then  print_formatted "Provocation %.1f" 500  Provocation
else  print_formatted "Threshold %.1f" 500  Threshold
end
end
end
0A93: terminate_this_custom_script

Edited by Strs
add
Link to comment
Share on other sites

12 minutes ago, KC702 said:

Inside the mind of the new guy lol.

No problem, I'm with you. Your comments help.

 

Backing up a bit: There's data in memory on the gangwar provocation level where it's hard to work with. There are no commands that allow you to check if a memory value is greater than or equal to another number, for example. This value needs to be read into a variable where we have more control. Global variables(gvars) start with an $ symbol, are owned my main.scm and accessible to all scripts. If you mess with them incorrectly then the story can break. Local variables (lvars) are specific to your script, and are denoted as a number followed by a @ symbol (0@ thru 31@ in scripts).

 

Number variables can be hard to work with; the number has no meaning, so I usually give them descriptive names. That's what this line is all about.

float Provocation, Threshold

This declares Provocation and Threshold as a float lvar - floating point, they have decimals. Because they were declared first they are assigned to 0@ and 1@, but we don't really need to work about that when declaring all lvars. It helps to know when comparing how other scripts are written.

 

In this line, I'm assigned the address offsets for the memory read command to constants, again so the number have meaning. Sanny will replace Provocation_Threshold with the address wherever it is encountered.

const Provocation_Threshold = 0x859974, CGangWars_Provocation = 0x96AB5C

 

Here we read the values from memory and store them in the specified lvars.

    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory Provocation_Threshold size 4 vp False store_to Threshold

 

Now Provocation and Threshold hold values we can work with, we can pass them to a print command with placeholders for float values (%f).

print_formatted "Provocation %f~n~Threshold %f" 500  Provocation Threshold

 

You can also compare lvars to other variables or values using symbols like == is equal, <> is not equal, > is greater then, etc. You don't need to read the memory value again until the next loop, in case it changes. All you need is the variable, the evaluation symbols, and the number to compare it with.

 

IS_GANG_WAR_FIGHTING_GOING_ON  Great, you found this command. After you get the first condition working, add this command between IF and THEN, and add an AND after IF (IF AND) - case doesn't matter.

 

 

Link to comment
Share on other sites

Correction on the continuation: You'll want to add a NOT operator before the IS_GANG_WAR_FIGHTING_GOING_ON command so it has the opposite effect.

if and
    <condition you're working on>
    NOT IS_GANG_WAR_FIGHTING_GOING_ON
then

 

 

Link to comment
Share on other sites

Figured it out, finally. The counter bar always has a max value of 100, so I had to add a bit of math to normalize Threshold as 100.0% and convert the value to an integer. Everything seems to be working.

 

Warning: This script contains a spoiler for your current puzzler.

Spoiler
{$CLEO .cs}
{$USE CLEO+}
{edit mode = sa_scr}
//GangWar_Provocation.txt

const Provocation_Threshold = 0x859974, CGangWars_Provocation = 0x96AB5C, Bar=1
float Provocation, Threshold, Normalize
int Counter

script_name 'provoke'  // name scripts (7 chars max) that loop indefinitely
WAIT 3000  // let game load before risking a crash                                                                  
add_text_label 'provoke' text "Provoke" // 7 chars max for GXT keys/labels (text can be longer) 
write_memory Provocation_Threshold size 4 value 4.099999 vp False // default = 2.099999 

while true
    wait 100
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    Normalize = 100.0
    Normalize /= Threshold  // So Threshold * Normalize = 100.0%
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    if and
        Provocation > 0.0
        not is_gang_war_going_on  // gang war
//        not is_gang_war_fighting_going_on  // gang war or gang attack
    then
        Provocation *= Normalize  // normalized so Threshold = 100%
        cset_lvar_int_to_lvar_float Counter Provocation  // get integer part of float    
        display_onscreen_counter_with_string_local Counter Bar text 'provoke'  // full bar = 100
        while Counter > 0  // Provocation resets to 0.0 when gang war starts
            wait 100
            read_memory CGangWars_Provocation size 4 vp False store_to Provocation
            Provocation *= Normalize
            cset_lvar_int_to_lvar_float Counter Provocation      
        end
        clear_onscreen_counter_local Counter
   end
end

TERMINATE_THIS_CUSTOM_SCRIPT

 

 

Other notes for later:

const CGangWars__bGangWarsActive = 0x96AB90
0AA7: call_function_return 0x443F80 num_params 1 pop 1 func_params 143 func_ret 0@ // CGangWars__CanPlayerStartAGangWarHere=0x443F80

 

Edited by OrionSR
Link to comment
Share on other sites

He already said 

 

"For the past couple hours, I have made attempts to learn Sanny Builder and create this script .cs file. I will continue to take cracks at it"

"Wishful thinking, but since coding is a foreign language to me" 

"With the level I am on, if I can manage to get the text to Hide/Display, everyone in my house is getting a high-five lol"

"Inside the mind of the new guy lol. Will continue to crack at it"

 

he is learning stage and you giving him hard time to even understand what you giving him 🫡

 

 

 

Link to comment
Share on other sites

9 hours ago, OrionSR said:

Figured it out, finally.

I had to peak at the spoiler lol. Damn this feature is amazing and evolved way past the initial post which is cool. Will note some stuff I played around with on it below if anyone else comes across this. Just had a few observations and Qs for my curiosity/future experiments if you can.

 

1) So, taking a look at it, I would have needed to set provocation as a variable to make it able to read the "provocation > 0.0" line. Like Strs and you have pointed out for local, I could use

Spoiler
15 hours ago, Strs said:

const 
 Provocation_Threshold = 0x859974 
 CGangWars_Provocation = 0x96AB5C
 Provocation  = 0@
 Threshold    = 1@
end

 

and I saw on Sanny Builder that a global variable is annotated with a $. However, I do not see either of those so which line in your code told it to look for the provocation integer?

 

2) How many variables can you add to an IFAND/THEN statement? I ask because, on top of the is_gang_war and provocation > 0.0 lines, I was trying to find and implement a code that essentially shuts it off after starting a mission or while in a mission. Regarding the player is in a mission command, is this the correct one "IS_CHAR_DOING_ANY_IMPORTANT_TASK 1@ include_anims 2@"? Either way, I'm going to take a small victory for at least finding is_gang_war_going_on even though I didn't know how to tell it true/false lol.

 

3) Jumping off question 2, is a variable reset hard coded into the game already? I noticed the meter disappears when starting a mission and stays gone while in the mission (I killed a high # of opposing gangs while in mission), but I do not see any command to tell it to do so.

 

For anyone who comes across this in the future, some really cool stuff I saw when playing around with the provoke meter:

1) You can add and subtract from the 4.099999 value and the meter responded on display accordingly to the kills and initiates a gang war

2) I entered a mission with a nearly full provoke bar - the provoke bar hides/resets and does not display if you kill opposing gangs while in mission

3) I thought this was really cool - the provocation carries over to wherever you are located. What I mean by this is you can fill the bar 90% of the way in territory A, drive over to territory B and finish filling the meter and it starts a gang war in territory B. I have seen numerous posts along the lines of "How do I start a gang war in this territory because not enough of the gang members are spawning?" This easily takes care of that problem.

4) It works with the Beta gangs added (I tested on LS Aztecas, LS Russian Mafia, LV Italian Mafia - did not test Rifas, Biker Gang but I imagine it is the same)

 

So, in the notes for later I see the CanPlayerStartAGangWarHere - I am curious how this will come in to play? Would this conflict with people who manually add gang territories? I have not manually added territories myself, just what came with extended gang wars mod, but saw videos of people doing it through a save editor or something. 

Edit - Nvm, I think I see where it could be used. Would it be applied when gang territories are shut off during the storyline? On one of my saves I just entered LV and territories are currently disabled in the story, yet it triggers the meter when killing the mafia.

Edited by KC702
explained
Link to comment
Share on other sites

Um... Let's start here:

4 hours ago, KC702 said:

I have not manually added territories myself, just what came with extended gang wars mod, but saw videos of people doing it through a save editor or something. 

Woah... Really? This script is working with the extended gang wars mod. I've been worried that special adaptions might be needed for adjusting the gang war threshold offset if the Extended Gang Wars mod was used. This is really good news. Keep in mind that this is a potential source of conflict, but totally worth the extra effort.

 

The GTA SA Savegame Editor v3.x has an awesome gang zone tool. This link is for the original author's version. He's published the source code, which has been adapted by others. I'm not sure which version is best. I've got other more specialized tools for working with save editing.

 

4 hours ago, KC702 said:

You can add and subtract from the 4.099999 value and the meter responded on display accordingly to the kills and initiates a gang war

It should be possible to change the gang war threshold with another script; this script should adjust to the new level the next time the bar becomes active.

 

4 hours ago, KC702 said:

is a variable reset hard coded into the game already? I noticed the meter disappears when starting a mission and stays gone while in the mission (I killed a high # of opposing gangs while in mission), but I do not see any command to tell it to do so.

No... I think I know what you're getting at, but.. The game should not be messing with local and global variables directly. Local variables are reset to 0 when starting a new script. Global variables persist unless acted upon by the game scripts.

 

Gang wars are built into the game engine - hard coded. We can't read main.scm to learn about gang wars. This stuff happens even on a stripped main with no missions or scripts other than what is needed to let the player interact with the environment.

CAN_TRIGGER_GANG_WAR_WHEN_ON_A_MISSION - What I think is happening is that by default, the game suppresses updates to Provocation when on a mission. This command can change how that works in specific missions. We could try adding it after altering the Threshold level early in the script but it may not stick; specific missions will alter this setting. I'm not sure if the setting will persist in a saved game.

can_trigger_gang_war_when_on_a_mission state True

 

Check the above link to this command in the Sanny Builder Library (SBL). One of my current projects is to update this site's documentation with snippets in SBL format. SBL format is similar to, and works with, SCR mode - basically, original R* command names and param order. I'm also working on SBL edit modes that match SBL format even more closely. That's why I'm starting you with this format, even though 99.9% of all documentation on GTAForums is in the older SB, community based format.

 

4 hours ago, KC702 said:

How many variables can you add to an IFAND/THEN statement? I ask because, on top of the is_gang_war and provocation > 0.0 lines, I was trying to find and implement a code that essentially shuts it off after starting a mission or while in a mission.

An IF AND and IF OR constructs can check as many as 8 conditions at a time. I need to clarify variables better... 

 

Checking if the player is on a mission is a very common task. Unfortunately, the process has historically been very difficult without using global variables. Cleo+ has a command to test if the player IS_ON_MISSION, and Cleo+v1.2 has just added a SET_ON_MISSION command. Unfortunately, Cleo+v1.2 won't be included by default in Sanny Builder until the next update, so lets try the old fashioned way using a global variable. (The problem with the global variable strategy is that it won't work correctly on custom a main.scm that doesn't use the same global variable index numbers as a standard main.scm. Most of the time this isn't a problem.) These two cleo+ commands have my new snippets.

if
    $ONMISSION == 0
then
    $ONMISSION = 1
else
    $ONMISSION = 0
end

Note that == is a condition, returns TRUE or FALSE.

A single = is an assignment. Set $ONMISSION equal to 1.

Accidentally using = in an IF condition is a really annoying bug to track down.

 

From SB:\data\sa\CustomVariables.ini

409=ONMISSION

$ONMISSION is the name assigned to global variable $409 in PC scripts, but you usually don't need to know that. Mobile, PS2, and DE versions all use different indexes. These differences can be managed with custom edit modes with CustomVariables.ini specific to each version. The variable's name remains the same, only the number is different. It's also very common to see $PLAYER_CHAR and $PLAYER_ACTOR used in cleo scripts, but there are easy ways to avoid these global variables.

 

In this section of the script's header, I've declared the local variables used in this script. Variables are just place store and work with values. Other than $ONMISSION, they don't have any specific in-game purpose.

float Provocation, Threshold, Normalize
int Counter

Sanny automatically assigns these variable names to 0@, 1@, 2@ and 3@. 

 

This is where the Provocation variable is getting it's value to store.

read_memory CGangWars_Provocation size 4 vp False store_to Provocation

Now we can work with the data.

if Provocation > 0.0

 

This bit reads the value from the memory address into Threshold variable. 

read_memory Provocation_Threshold size 4 vp False store_to Threshold

 

If the value of Threshold is changed, it won't have any effect in-game unless the value is written back into memory.

Threshold += 1.0
write_memory Provocation_Threshold size 4 value Threshold vp False

 

4 hours ago, KC702 said:

CanPlayerStartAGangWarHere - I am curious how this will come in to play? Would this conflict with people who manually add gang territories

I'm not sure this information will be useful. You were speculating about not displaying the provocation bar if the player is not in a valid gang war zone, but your tests suggest that this check will hide important information. Checking if gang wars are enabled at all would probably be a better conditional check, but this situation should be tested first. No, this strategy will not conflict with modified gang zones.

 

So... chew on that for a while. Let me know what's hard to swallow. It's a lot, I know. We can spiral around to the trickier concepts as needed.

 

Edited by OrionSR
Link to comment
Share on other sites

On 10/27/2023 at 3:11 PM, OrionSR said:

Woah... Really? This script is working with the extended gang wars mod.

I am still reading through the above, letting it settle in.

 

I have been playing a campaign with the script to learn/field test. I remember you being surprised it worked with beta gangs, so I did want to update you on something I thought was pretty cool. Previously I had mentioned that I had only tested with a handful of gangs. I have since messed with all of them, including the beta/unused and it works great!

Additionally, I had to watch a few videos on save editor, but was finally able to understand enough to test this script with territory editing. That too, worked great! I added a beta gang territory (SF Rifa) to a blank spot in LS. The meter gained and depleted normally and when the meter filled, gang war provoked and went through all the normal strokes of a gang war.

So, in my experience, it works with Extended gang wars and save edited gang territories.

 

The only hiccup I had seen occurred when territories were not active. During the campaign, when the territory feature is off (i.e. SF missions through LV missions), if you were to kill an opposing gang the meter gains but does not deplete - leaving it on screen. It goes away after a save or mission start, so nothing major. I made a few attempts to fix this, of course it didn't work or I would be typing in all caps and a few "!!!" tied in lol.

 

1) I tried to implement the "notes for later" script posted above in various placements, I was able to get it to compile so I know it reads something, it must be my formatting.

Spoiler
const CGangWars__bGangWarsActive = 0x96AB90
0AA7: call_function_return 0x443F80 num_params 1 pop 1 func_params 143 func_ret 0@ // CGangWars__CanPlayerStartAGangWarHere=0x443F8

 

2) I looked for different kinds of opcodes on SB to tag in. I remember you had said an IfAnd/Then can read 8 conditions, so was plugging stuff in there.

- Has_animation_loaded "gangs" and NOT has_animation_loaded "gangs" did not work, however, the NOT variation did stop the meter from displaying all together

- Set_gang_wars_active and NOT set_gang_wars_active did not work, but learning that that opcode triggered territories active at any point in the story was awesome

 

I will keep at it

Link to comment
Share on other sites

49 minutes ago, KC702 said:

1) I tried to implement the "notes for later" script posted above in various placements

Give this version a try.
 

Spoiler
{$CLEO .cs}
{$USE CLEO+}
{edit mode = sa_sbl}
//GangWar_Provocation.txt

const Provocation_Threshold = 0x859974, CGangWars_Provocation = 0x96AB5C, Bar=1
const CGangWars__bGangWarsActive = 0x96AB90
float Provocation, Threshold, Normalize
int Counter, bGangWarsActive

script_name 'provoke'  // name scripts (7 chars max) that loop indefinitely
WAIT 3000  // let game load before risking a crash                                                                  
add_text_label 'provoke' text "Provoke" // 7 chars max for GXT keys/labels (text can be longer) 
write_memory Provocation_Threshold size 4 value 4.099999 vp False // default = 2.099999 

while true
    wait 100
    read_memory Provocation_Threshold size 4 vp False store_to Threshold
    Normalize = 100.0
    Normalize /= Threshold  // So Threshold * Normalize = 100.0%
    read_memory CGangWars_Provocation size 4 vp False store_to Provocation
    read_memory CGangWars__bGangWarsActive size 1 vp False store_to bGangWarsActive
    if and
        Provocation > 0.0
        not is_gang_war_going_on  // gang war
//        not is_gang_war_fighting_going_on  // gang war or gang attack
        bGangWarsActive <> 0
    then
        Provocation *= Normalize  // normalized so Threshold = 100%
        cset_lvar_int_to_lvar_float Counter Provocation  // get integer part of float    
        display_onscreen_counter_with_string_local Counter Bar text 'provoke'  // full bar = 100
        while Counter > 0  // Provocation resets to 0.0 when gang war starts
            wait 100
            read_memory CGangWars_Provocation size 4 vp False store_to Provocation
            Provocation *= Normalize
            cset_lvar_int_to_lvar_float Counter Provocation      
        end
        clear_onscreen_counter_local Counter
   end
end

TERMINATE_THIS_CUSTOM_SCRIPT

 

Note: I didn't disable the provocation bar during a gang attack because provoking is useful for various territory glitches - hood abuse, satchel trick, mastermind glitch, etc. (It is possible to add gang turfs without editing the save or using cleo scripts.)

Edited by OrionSR
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.