ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Jun 20, 2018 10:43 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat May 02, 2015 3:37 pm 
Offline
Yeek

Joined: Sun Mar 03, 2013 3:07 pm
Posts: 10
does anyone have an idea of how i can add a single ego to a weapon in code?

i have pre-generated an item with

o = game.zone:makeEntity(game.level, "object", filter, nil, true)

and after some checks it decides how good the item is and its at this point i need to add an ego from the newEntity egos list.

i cant use the built in chance of prefix=n and suffix=n in newEntity because i need to be able to add quite a few if the weapon is rolled as a Rare(1-3prefix,1-3suffix but name is random generated) and slightly more complex weighted chance of 25% chance of prefix, 25% chance of both, 50% chance of a suffix if the item is deemed a Magic item.

i did find this which might be what im after so if you know how to use it let me know.
game.zone:applyEgo(e, ego, type, no_name_change)
i just need a way of getting a single ego onto a weapon perhaps you have a better idea and any info will be a big help then i can work out adding more


Top
 Profile  
 
PostPosted: Sun May 03, 2015 4:36 pm 
Offline
Archmage

Joined: Tue Jun 18, 2013 7:24 pm
Posts: 449
Take a look at how Veins does it.

https://github.com/Zireael07/The-Veins-of-the-Earth/blob/master/dialogs/debug/CreateItem2.lua#L121

It relies on https://github.com/Zireael07/The-Veins-of-the-Earth/blob/master/class/Ego.lua#L20 (to get the list of all allowed egos) and https://github.com/Zireael07/The-Veins-of-the-Earth/blob/master/class/Ego.lua#L107 (to actually apply it).

Alternately, if you need just a few egos, you could do it like this:
Code:
local crystalline_ego = Entity.new{

---bla blah whatever you want the ego to do
}

game.zone:applyEgo(o, crystalline_ego, "object", true)
o:resolve()


If you had a few egos, all you had to do to randomize them would be:
Code:
local egos_table = {crystalline_ego, fire_ego, cold_ego}


and use
Code:
local picked_ego = rng.table(egos_table)
game.zone:applyEgo(o, picked_ego, "object", true)


instead.

However, the simple version doesn't differentiate between suffixes and prefixes.

_________________
Working on a T-Engine game
Veins of the Earth

Veins of the Earth ModDB page


Top
 Profile  
 
PostPosted: Sun May 03, 2015 8:01 pm 
Offline
Yeek

Joined: Sun Mar 03, 2013 3:07 pm
Posts: 10
Thanks mate for taking the time to give a good example thats exactly what i needed. :D


Top
 Profile  
 
PostPosted: Sat Jan 23, 2016 6:54 pm 
Offline
Archmage

Joined: Tue Jun 18, 2013 7:24 pm
Posts: 449
I tried to add egos using a force_ego filter and I get Lua errors. Looking through the code, it only seems to be used once for an artifact. Is it broken? Is the method I outlined above the only way to do it currently?

_________________
Working on a T-Engine game
Veins of the Earth

Veins of the Earth ModDB page


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group