This is state application, that is supposed to trigger like "if both actor at 50% or more HP, state is removed AND if there is only 1 actor alive, if other actor has 50% or more HP, state is removed"
That's what I wanted ig
This is state application, that is supposed to trigger like "if both actor at 50% or more HP, state is removed AND if there is only 1 actor alive, if other actor has 50% or more HP, state is removed"
The logic of what you wrote, and the logic you said you wanted it to follow are not the same. By your description, there are two sets of conditions where you want that state removed. How are they supposed to be separate if when you wrote it, theres only one line to remove the state? and in order to get to it, conditions for both have to be navigated through?
var enemyEvents = $gameMap.events().filter(function(event){return $dataMap.events[event._eventId].meta["enemy"] && !event._erased;});
enemyEvents.forEach(function(enemy){
//???
}
});
That'll be $gameMap.events() (because $dataMap will use where the events were placed in the editor, not necessarily where they are now).
That'll use eventsXy().
let triggered_traps = [];
$gameMap.events().forEach(event => {if (event.meta.enemy)
$gameMap.eventsXy(event.x, event.y).forEach(shared => {if (shared.meta.trap) triggered_traps.push(shared);})});
Thanks for pointing that out. I'm using that script in my game; I'll need to update it.
Ok, so to toggle the self switch A of every trap, something like this
$gameMap.events().forEach(event => {if (event.meta.enemy)
$gameMap.eventsXy(event.x, event.y).forEach(shared => {if (shared.meta.trap) $gameSelfSwitches.setValue([$gameMap._mapId, shared._eventId, 'A'],true);})});
Or you just include it on the events themselves to check after they move whether they've landed on a trap.
Yeah, I guess that's was the problem. Basically it's like priorities, and it should behave like "Check if both actors are above 50% HP. If yes, remove the state", and "If one of actors is dead, check if other actor is above 50% HP. If yes, remove the state". Ig that requires two separate conditions.
<Cast Animation: 121><Cooldown: 10>, how will I get the value of cooldown?Without any context, I'm not sure what you're going for. Do you want the higher or lower level part of it?
someArray.some(a => a.someOtherArray().includes(X)) javascript knows which object you're talking about... like... how does it know?Because you told it?
actor = $gameParty.members()[n]...const GameParty = [
{name: 'Jan', nationality: 'German'},{name: 'Pieter', nationality: 'Dutch'},{name: 'William', nationality: 'British'}
];
alert(GameParty.some(a => a.nationality == 'Dutch'));
const GameParty = [
{name: 'Jan', nationality: 'German'},{name: 'Pieter', nationality: 'Dutch'},{name:'William',nationality:'British'}
];
function SomeFunc(a){
return GameParty[a].nationality == 'Dutch';
}
alert(GameParty.some(SomeFunc(a)));
some is a function that expects another function as an argument. SomeFunc(a) returns a boolean, not a function. You'd need to either do a => SomeFunc(a) or just SomeFunc (without invoking it - this passes the function itself, not its result).a => a.nationality == 'Dutch' by itself is not returning anything (yet). No, not the correct wording but I think I understand. Phew!const GameParty = [
{name: 'Jan', nationality: 'German'},{name: 'Pieter', nationality: 'Dutch'},{name:'William',nationality:'British'}
];
function SomeFunc(a){
return a.nationality == 'Dutch';
}
alert(GameParty.some(SomeFunc));
Have you simply looked up the documentation/tutorials on arrow functions?
Again, I think looking it up is your friend.
Thanks. Yeah, I get that now (or more precisely I decided that it's what it is...), but it really wasn't obvious to me that it assumes "a" or "actor" or whatever you decide to call it as a return value. That part still feels like magic to me.
Original thread: https://forums.rpgmakerweb.com/threads/javascript-questions-that-dont-deserve-their-own-thread.46341/