YEP SKILL CORE QUESTIONS

Hey all, back again with another question. So in my game I am implementing a Ammo system.

So this is what I am currently stuck on. The way I have the System set up is:


The Weapon Assigns a "Max Ammo" in this case its 8, (the variables for max ammo are 221,223 and 225.)
Spoiler: Weapon
1591856197736.png




So The weapon itself give the 'shoot' command as this game has several weapons.

Next is this skill

Spoiler: Skill
1591856446352.png

As you an see, it won't display itself unless variable 222 (player ammo) is greater than 0, It is also set to subtract from 'player ammo' with each shot.


Spoiler: In game
1591856745673.png

Gun hasnt been loaded....

Spoiler: Reloaded
1591856865610.png



After using 1 round.


1591857239783.png


As you can see the player has 8 rounds in this weapon and it reduced to 7 after using a round.

Now this brings me to my question.

Is there a way to check which actor is attacking? Something like

if user.($gameactors) blah blah blah?????

If so I could use the assistance because I want to check for which player to handle the possibility to having multiple team mates who carry Firearms

Thanks in Advance
This is kinda like wut I did, except of course my game is a fantasy setting and its Bow & Arrows instead of Gun & Ammo. Anyways, the way I set it up was make my Arrows an Augment for the Bow, which gives a passive state w/ a counter on it. That way it's already assigned to the actor wielding the Bow/Arrows. I'm also using LTBS as well! ^.^

Your issue is one of the main reasons I try to avoid using variable for combat if possible. It's just...messy imo. I wish I could be of more help, but my JS skills probably isn't much better than urs.
If you're using yanflys skill core, why not adopt the skill cost items plugin? You could easily implement multiple types of ammo for different guns. You could make character-specific ammo.

I don't remember if I've seen a script call for checking the last player to act but I'm sure there's a way to check...
If you're using yanflys skill core, why not adopt the skill cost items plugin? You could easily implement multiple types of ammo for different guns. You could make character-specific ammo.

I don't remember if I've seen a script call for checking the last player to act but I'm sure there's a way to check...
Lol omg why didn't I think of that. -.-
But then if I throw out the Arrows being augments idea, I can't have different kinds of arrows that do different stuff (i.e. flaming arrows, frost arrows, etc...)

Edit: I just realized it actually can be implemented if I use SRD's Skill Extender plugin as well!

Edit2: Nvm didnt work :/
Guess I just gotta hope someone comes along w/ a solution to OP's request...either that or I gotta edit SRD's plugin or go back to the augment + state counter thing.

Edit3: Seems like SRD's Skill Extender doesn't work if the parent skill was from a replace attack thing. Like I have Bows <Replace Attack: 5> w/ "5" being "Shoot". I then put <Extend Skills: 277, 278> in the notebox for "Shoot". 277 & 278 are "Normal Arrow" & "Flame Arrow" just for testing purposes. But they only show up if "Shoot" is used from the normal skill menu and not if it was from where "Attack" used to be.

Seems like OP and I have pretty much the same mechanic, just different flavor: Modern vs Fantasy
If either of us can get this working, the other should be able to as well.
You could still use the augments to change how the weapons that use the arrows behave.
This is kinda like wut I did, except of course my game is a fantasy setting and its Bow & Arrows instead of Gun & Ammo. Anyways, the way I set it up was make my Arrows an Augment for the Bow, which gives a passive state w/ a counter on it. That way it's already assigned to the actor wielding the Bow/Arrows. I'm also using LTBS as well! ^.^

Your issue is one of the main reasons I try to avoid using variable for combat if possible. It's just...messy imo. I wish I could be of more help, but my JS skills probably isn't much better than urs.

I can try that but then it’s also a UI/ UX issue. I like the variables bc I can see how many shots I have remaining from the total amount.

If you're using yanflys skill core, why not adopt the skill cost items plugin? You could easily implement multiple types of ammo for different guns. You could make character-specific ammo.

I don't remember if I've seen a script call for checking the last player to act but I'm sure there's a way to check...

I am, however it only allows you to use an item as ammo. I’m trying to make people have to reload their weapons when they run out
Since you were saying equipping the guns gives a shoot command, I am assuming you are using something like Yanfly Weapon Unleash to change the 'attack' command to a designated skill when the a specific weapon is equipped. Is that correct?

If so, then this thread may answer your question.
I think it’d be easier to check each actor / party slot since I only have 3.

something like:

if user= actor 1....
.......
else
......
I use yanflys weapon unleash to replace the normal attack command with one based on the weapon the user has equipped. I also have a switch statement attached to each skill to control a variable based on who is using the skill. Idk why I didnt think of this before but if this hasn't been fully answered by the time I get home from work I'll post the code.
Since you were saying equipping the guns gives a shoot command, I am assuming you are using something like Yanfly Weapon Unleash to change the 'attack' command to a designated skill when the a specific weapon is equipped. Is that correct?

If so, then this thread may answer your question.

Just read it , it’s close to my idea, but as stated above, I enjoy the clear UI indicator of having a bullet count of shots remaining. I got it to work on just one player. I’ve created variables for the other party members and now need a way to check which party member used the skill. So I can have it subtract from the proper variable.
Lol omg why didn't I think of that. -.-
But then if I throw out the Arrows being augments idea, I can't have different kinds of arrows that do different stuff (i.e. flaming arrows, frost arrows, etc...)

Edit: I just realized it actually can be implemented if I use SRD's Skill Extender plugin as well!

Edit2: Nvm didnt work :/
Guess I just gotta hope someone comes along w/ a solution to OP's request...either that or I gotta edit SRD's plugin or go back to the augment + state counter thing.

Edit3: Seems like SRD's Skill Extender doesn't work if the parent skill was from a replace attack thing. Like I have Bows <Replace Attack: 5> w/ "5" being "Shoot". I then put <Extend Skills: 277, 278> in the notebox for "Shoot". 277 & 278 are "Normal Arrow" & "Flame Arrow" just for testing purposes. But they only show up if "Shoot" is used from the normal skill menu and not if it was from where "Attack" used to be.

Seems like OP and I have pretty much the same mechanic, just different flavor: Modern vs Fantasy
If either of us can get this working, the other should be able to as well.
Did you apply the "normal attack 100%" trait to the replacement skill?
If you make each actor use a different shoot skill, then you could control the variables within the damage formula box. Every time the skill is used, have the designated variable decrease by one.
If you make each actor use a different shoot skill, then you could control the variables within the damage formula box. Every time the skill is used, have the designated variable decrease by one.

im thinking about doing that. It’s just kinda cumbersome to design that way
Okay so what if you set a variable to the actor ID that used the skill within the damage formula box:

v[1]=a._actorId; [dmg formula here]

This would set v[1] to the actor ID that used the skill, then you could use that variable to determine which actor's ammo variable is decreased with conditional branches in a common event (or however you have the ammo thing set up).

If v[1] == 1 then ...
If v[1] == 2 then ...
etc.


This should eliminate the need for multiple skills for each actor.
I like that. I’m at work right now but I’m going to try that out
Did you apply the "normal attack 100%" trait to the replacement skill?
Yes, I've tried it both w/ and w/o the normal attack trait. Still doesn't work if "Shoot" is used thru the attack command, only when its used as a skill.

Edit: I went back to my augment/counters method and got everything working!
Here's the basis of the code I use to control a specific variable based on the user of the skill:
Spoiler
<Post-Damage Eval>
switch (user.actorId()) {
case 1: //code to run when actor Id 1 uses skill
break;
case 2: //code to run when actor Id 2 uses skill;
break;
case 3: //code to run when actor Id 3 uses skill:
}
</Post-Damage Eval>
I put this into the notetag of the skill.
EDIT: I realized I might want to clarify just exactly what this code is and does.
So a switch statement evaluates an expression "(user.actorId())" then checks the expression's value against the case clauses, running the code within any matching cases.

Example: (user.actorId()) as the switch expression of a custom eval skill notetag returns the Id of the actor who used the skill, as a number. When the first actor in the database uses this skill, the case is 1.
I am using this method to create a weapon mastery system where the actors gain bonuses the more they use a given weapon type.

Inside

case 1: //code

I have all the variables linked to actor 1's weapon mastery data. Case 2 contains all actor 2's data, and so on.
After getting home and testing things I’ve realized two things. First @HumanNinjaToo. Yes I can store them that way, thanks for the flexible idea.

However I realized that this still isn’t the best way to do this, reason being. Handling the custom show evaluation and cost displays. It may be better to create different skills as mentioned earlier.

I solved the issue by creating a State for each type of firearm. (Pistol, shotgun, and rifle)

next I duplicated them by 3, so a total of 9 “shoot” commands.
Next I created a common event to swap the “shoot” skill to the correct player.
For example, if actor 1 stare “pistol” is equipped. Then learn skill 38 shoot, 39 for actor 2. And so forth.
But now this way each actor’s firearm has its own ammo count .
Thanks for all the help guys.
1591931662692.png
Here's the basis of the code I use to control a specific variable based on the user of the skill:
Spoiler
<Post-Damage Eval>
switch (user.actorId()) {
case 1: //code to run when actor Id 1 uses skill
break;
case 2: //code to run when actor Id 2 uses skill;
break;
case 3: //code to run when actor Id 3 uses skill:
}
</Post-Damage Eval>
I put this into the notetag of the skill.
EDIT: I realized I might want to clarify just exactly what this code is and does.
So a switch statement evaluates an expression "(user.actorId())" then checks the expression's value against the case clauses, running the code within any matching cases.

Example: (user.actorId()) as the switch expression of a custom eval skill notetag returns the Id of the actor who used the skill, as a number. When the first actor in the database uses this skill, the case is 1.
I am using this method to create a weapon mastery system where the actors gain bonuses the more they use a given weapon type.

Inside

case 1: //code

I have all the variables linked to actor 1's weapon mastery data. Case 2 contains all actor 2's data, and so on.
Could you elaborate on how you implemented your weapon mastery system? I'd love to have such a feature for my game. This is off topic, so I wouldn't mind doing this over PM if need be.
Hey one more question all. So I am working on my Reload skill, and it dawned on me. What if players have more or less ammo than what the weapon can hold? for example gun holds 8 rounds and player has 3 rounds. or vice versa.

I think I have thought of a cleaver way to check it, compare the ammo player has to 'max ammo' variable of said weapon.

if ammo >= max ammo.. changes variable to eaqual 'max ammo' variable
if ammo <= max ammo. changes variable to equal amount of bullets in inventory.

I cobbled the below code together, but i feel i went wrong somewhere....



Spoiler: THE CODE
if ($gameParty.hasItem($dataItems[5]) >= ($gameVariables.value(221)) { {

$gameVariables.setValue(222, $gameVariables.value(221));

} else {

$gameVariables.setValue(222, $dataItems[5]);

}

</Custom Execution>


What did I do wrong here?

Just FYI
Variable 222 = Current Ammo count
Variable 221 = Magazine/ Ammo Max
Data Item 5 = small rounds

Original thread: https://forums.rpgmakerweb.com/threads/yep-skill-core-questions.122710/