Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Code that allow to use "compare" in skill's "cost".

A topic by AleDerXan created 35 days ago Views: 437 Replies: 10
Viewing posts 1 to 4
(19 edits) (+1)

module Battle_System

alias_method :process_skill_cost_base_MODNAME, :process_skill_cost

def process_skill_cost(skill)

# process_skill_cost_base_MODNAME(skill)

process_skill_cost_compare_MODNAME(skill)

end

def process_skill_cost_compare_MODNAME(skill)

skill.cost.each{

|cost|

cost_val = self.battle_stat.get_stat(cost.base.attr,cost.base.attr_type)

cost_val = get_affected_attr(cost.base) - get_affected_attr(cost.compare)

self.battle_stat.set_stat(cost.base.attr,cost_val,cost.base.attr_type)

}

end

alias_method :process_skill_cost_reverse_base_MODNAME, :process_skill_cost_reverse

def process_skill_cost_reverse(skill)

# process_skill_cost_reverse_base_MODNAME(skill)

process_skill_cost_reverse_compare_MODNAME(skill)

end

def process_skill_cost_reverse_compare_MODNAME(skill)

skill.cost.each{

|cost|

cost_val1=self.battle_stat.get_stat(cost.base.attr,cost.base.attr_type)

cost_val2= cost_val1 - ( get_affected_attr(cost.base) - get_affected_attr(cost.compare) )

cost_val2= (cost_val2*0.5).to_i

cost_val3=cost_val1+cost_val2

self.battle_stat.set_stat(cost.base.attr,cost_val3,cost.base.attr_type)

}

end

end



—————————

Simply use this code as mod. This method allow to use value of another stat (or percent of it), to decrease (or increase) base cost of skill. Using compare in skill's cost data.

I found that "cost" - "compare" in skills data doesn't work. And then i fixed it, or figured out a way to use it.

For example, now you can use (one percent of?) constitution trait to decrease (or increase) cost (in sta) of skill. Or ony another stat instead of constitution trait.

Or you can do something strange.

First cost [{}] in sta (cost=3), compare with constitution trait * (0.01). But second cost [{}] in this skill in sta too, but base cost=0, and compare in mood * (0.01). And it's gonna go like this, constitution trait will decrease cost, and positive mood wil decrease too, but negative mood will increase cost.

Eccma wants a skill json sample you used for this since he is thinking of making this official if it works properly.

(+1)

Ok.

(4 edits) (+1)

For example.


{

"item_name": "FireN",

"message2":"", 

"description":"", 

"name":"FireN", 

"occasion":0, 

"icon_index":680, 

"message1":"", 

"scope":1, 

"animation_id":0, 

"tag_main_settings":{"tag":"FireN","flag":"FireN","type":"other"}

"mp_cost":0, 

"speed":0, 

"features":[], 

"effects":[], 

"type":0, 

"element_id":0, 

"formula":"0", 

"variance":20, 

"critical":false, 

"success_rate":100, 

"hit_type":0, 

"stype_id":1, 

"tp_cost":0, 

"required_wtype_id1":0, 

"required_wtype_id2":0, 

"repeats":1, 

"tp_gain":0,

"textFlag": {

"folder": "Text",

"name": "DataSkill:FireStaffNormal/item_name",

"description": "DataSkill:FireStaffNormal/description"

},

"CHS_animation": "animation_casting_mh_long",

"wait_hit_frame": true,

"range": 5,

"back_stab":1,

"stealth": false,

"hit_frame":10,

"summon_user": "EffectCastingFireMagic",

"summon_hold": "EffectFireMagicShortHold",

"summon_hit": "FireBallMissileProjectile",

"no_parry":true,

"no_dodge":false,

"sap":false,

"hold_type": "energizing",

"hold_animation": "animation_hold_casting_mh",

"hit_detection":"Missile",

"projectile_type": 1,

"effect_since" : 5,

"launch_since" : 30,

"launch_max" : 31,

"ai_value": {

"assulter": 100,

"killer": 100,

"fucker": 100

},

"cost": [{

"base": {

"attribute_name": "sta",

"attribute_type": "current",

"adjustor": "-",

"adjustment": "4",

"lowest_req" : "0",

"highest_req" : "65535"

},

"compare": {

"attribute_name": "wisdom_trait",

"attribute_type": "current",

"adjustor": "*",

"adjustment": "-0.02"

}

},{

"base": {

"attribute_name": "mood",

"attribute_type": "current",

"adjustor": "-",

"adjustment": "1",

"lowest_req" : "-200",

"highest_req" : "65535"

},

"compare": {

"attribute_name": "wisdom_trait",

"attribute_type": "current",

"adjustor": "*",

"adjustment": "-0.01"

}

}],

"effect": [],

"add_state": [],

"hit_gate": "-1",

"hit_chance": []

}

(15 edits) (+1)

But, now, i think only about "-" or "+" in code and in json files.

What type will be more useful?

1) 

def process_skill_cost(skill):

cost_val = get_affected_attr(cost.base) - get_affected_attr(cost.compare)

def process_skill_cost_reverse(skill):

cost_val2= cost_val1 - ( get_affected_attr(cost.base) - get_affected_attr(cost.compare) )

OR:

2) 

def process_skill_cost(skill):

cost_val = get_affected_attr(cost.base) + get_affected_attr(cost.compare)

def process_skill_cost_reverse(skill):

cost_val2= cost_val1 - ( get_affected_attr(cost.base) + get_affected_attr(cost.compare) )

Json code above will propertly works with 1).
If use 2) ruby-code, i will need to use "0.02" ("0.01" for mood) instead of "-0.02" ("-0.01" for mood) in compare with wisdom_trait to decrease cost.

It's just a matter of convenience. Eccma can decide for himself which option he likes best.

(1 edit) (+1)

Or, you can use something like this:

{
"base": {
    "attribute_name": "sta",
    "attribute_type": "current",
    "adjustor": "*",
    "adjustment": "1",
    "lowest_req" : "0",
    "highest_req" : "65535"
},
"compare": {
    "attribute_name": "health",
    "attribute_type": "current",
    "adjustor": "*",
    "adjustment": "0.01"
}
}

This method will create cost in "sta" fully depend on current health.  More "health" more cost of skill. Zero "health", zero cost of skill, (in this part of fully cost).

And use zero change in base part of cost, you can do it many times in one skill, and make cost in "sta" depending from many other stats.

eccma has the post i will tell him that you updated it

(6 edits) (+1)

My sample of json now in the game as sample for everyone.

But since I posted it, Eccma changed a little rules about skills.

I'm aboust "stype_id". In my sample it is Fixnym.

Eccma now use Strings. But when i posted sample, stype_id was a strange thing in rvdata2, that was copied by me from rvdata as is. To have a full info about skill. From json and from rvdata.

Now sample in main game need to be updated.

(1 edit) (+1)

Eccma417 says: yeap... because string is more humie readable

Eccma417 says: string  read for humie > translate to array in json loader

(13 edits)

I understand this.
Strings better for eyes and for mind.

Next one is about code of barters.

I thing, that

def manual_barters(tmpTradeID)
    ...
    ...
end

- is good.

But something like this will be better:

def manual_barters(tmpTradeID=get_character(0).npc_name)
    ...
    ...
end

Or this:

def manual_barters(tmpTradeID) 
    if !tmpTradeID || !$data_barters[tmpTradeID]
        tmpTradeID = get_character(0).npc_name
    end
    ...
    ...
end
(1 edit) (+1)

oh yes and this is in reply to your post on F95 about the mod manager between nyx and ultra mod manager since i don't have an account or wish to get one 

eccma passes on a bit about why the ultra mod manager was switched to: the primary reason he uses the ultra mod manager and nyx is now deprecated is because he doesn't have the source code to be able to alter where the mod manager checks the mod ban list
and he also primarily uses linux now and also lacks the dotnet file used to compile the nyx manager