Page 129 of 396

Re: Ask a simple question, get a simple answer

Posted: Tue Jun 21, 2016 5:27 am
by Isaac
This may need work; but test it out.

Code: Select all

defineObject{
   name = "water_shooter",
   baseObject = "base_item",
   components = {
      {
         class = "Model",
         model = "assets/models/items/revolver.fbx",
         material = "zarchton_wand",
      },
      {
         class = "Item",
         uiName = "Water Shooter",
         description = "A strange mechanics makes this weapon compressing water and shooting it out in some kind of a jet.",
         gfxAtlas = "mod_assets/textures/iconatlas/iconatlas.dds",
         gfxIndex = 33,
         weight = 1.5,
         traits = { "weapon", "firearm"},
         primaryAction = "waterbolt",
         secondaryAction = "waterbolt",


      },
      {
         class = "ItemAction",
         name = "waterbolt",
         uiName = "Water Bolt",
         cooldown = 5,
         onAttack = function(self, champion, slot, chainIndex)
              local spl = spawn("water_bolt",party.level,party.x,party.y,party.facing,party.elevation)
              spl.projectile:setIgnoreEntity(party)

              -- Set cast by champion so that experience is awarded for kills.
              local ord = champion:getOrdinal()
              spl.projectile:setCastByChampion(ord)

              -- Simulate the position of a player-cast spell.
              local left = nil
              for i = 1,4 do
                if party.party:getChampion(i):getOrdinal() == ord then
                  left = i == 1 or i == 3
                  break
                end
              end
              local wpos = party:getWorldPosition()
              local dx = nil
              local dz = nil
              if party.facing == 0 then
                dx = left and -0.1 or 0.1
                dz = -1
              elseif party.facing == 1 then
                dz = left and 0.1 or -0.1
                dx = -1
              elseif party.facing == 2 then
                dx = left and 0.1 or -0.1
                dz = 1
              else -- party.facing == 3
                dz = left and -0.1 or 0.1
                dx = 1
              end

              spl:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
            end,
      },

   },
}

Re: Ask a simple question, get a simple answer

Posted: Tue Jun 21, 2016 10:45 am
by THOM
Oh my goodness... It was the primaryAction that was missing! :?

Thanks, Isaac - thanks to all, that helped! Works fine now.


(That took some doing. :roll: )

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 12:28 pm
by THOM
Another question:

I am trying to use the crow and crow_flying object. The flying one just makes circles. Not very impressive but works.

The object simply called "crow" has to be "activated" in some kind. One possibility is that the party passes by. Maybe it is also possible to activate the crow by script - haven't had a closer look on that.

But: Once activated the crow flies a more or less random path over the sky. That's good. At night the crow vanishes. Thats good, because AFAIK birds don't fly at night. But when the morning comes back, the crow is still gone. And I see no way to get it back without respawning.

I even cannot find a crow in the main-campaign. And everything important seems to bee hardcoded (there is an component "CrowController" but I don't know, what it does). Does anyone has any experiences with this crow critter? Do I really have to respawn/reactivate it after a night?

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 4:02 pm
by zimberzimber
A few questions about custom conditions -

How do I force one to make a champion unable to act? (paralyzed/petrified)

How do I force conditions to remove themselves when the champion dies?
onTick() if not champion:isAlive() doesn't work, because it seems like ticks happen only when the hero is alive.

Is there a better way to make Healing Crystals remove negative conditions without defining an onClick function for the object?

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 4:42 pm
by Zo Kath Ra
zimberzimber wrote:How do I force conditions to remove themselves when the champion dies?
onTick() if not champion:isAlive() doesn't work, because it seems like ticks happen only when the hero is alive.
could you use PartyComponent.onDie(self, champion) ?

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 4:49 pm
by zimberzimber
Zo Kath Ra wrote:
zimberzimber wrote:How do I force conditions to remove themselves when the champion dies?
onTick() if not champion:isAlive() doesn't work, because it seems like ticks happen only when the hero is alive.
could you use PartyComponent.onDie(self, champion) ?
Huh, ashamed I didn't think of that...
Then is there a way to check for all conditions and see which are harmful? Something like isHarmful() maybe?

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 7:55 pm
by minmay
THOM wrote:Another question:

I am trying to use the crow and crow_flying object. The flying one just makes circles. Not very impressive but works.

The object simply called "crow" has to be "activated" in some kind. One possibility is that the party passes by. Maybe it is also possible to activate the crow by script - haven't had a closer look on that.

But: Once activated the crow flies a more or less random path over the sky. That's good. At night the crow vanishes. Thats good, because AFAIK birds don't fly at night. But when the morning comes back, the crow is still gone. And I see no way to get it back without respawning.

I even cannot find a crow in the main-campaign. And everything important seems to bee hardcoded (there is an component "CrowController" but I don't know, what it does). Does anyone has any experiences with this crow critter? Do I really have to respawn/reactivate it after a night?
The crow is an unfinished asset that doesn't work (it's missing a correct bounding box, missing a rig and animations, and missing working flight behaviour). Unless you are going to reimplement it from scratch, there is no point in trying to use it.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 8:57 pm
by Zo Kath Ra
zimberzimber wrote:
Zo Kath Ra wrote:
zimberzimber wrote:How do I force conditions to remove themselves when the champion dies?
onTick() if not champion:isAlive() doesn't work, because it seems like ticks happen only when the hero is alive.
could you use PartyComponent.onDie(self, champion) ?
Huh, ashamed I didn't think of that...
Then is there a way to check for all conditions and see which are harmful? Something like isHarmful() maybe?
I don't think there is. You can create a table from this data:
https://github.com/JKos/log2doc/wiki/Conditions
The table would map condition names to categories.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 9:40 pm
by Isaac
This [checkConditions] function returns a table of the PC's current conditions, and whether they are harmful or not.
(Format: name, isHarmful [boolean], name, isHarmful,...)

Custom conditions can be added to the list.

Code: Select all

conditions = { -- Name	--isHarmful
				"burdened", true,
				"cursed", true,
				"dead", true,
				"diseased", true,
				"overloaded", true,
				"paralyzed", true,
				"petrified", true,
				"poison", true,
				"slow", true,
				"starving", true,
				"bear_form", false,
				"haste", false,
				"invisibility", false,
				"level_up", false,
				"rage", false,
				"water_breathing", false,
				"fire_shield", false,
				"frost_shield", false,
				"poison_shield", false,
				"protective_shield", false,
				"shock_shield", false,
				"chest_wound", true,
				"feet_wound", true,
				"head_wound", true,
				"left_hand_wound", true,
				"leg_wound", true,
				"right_hand_wound", true,
				}

function checkConditions(self, championOrdinal)
	if championOrdinal then
		local test = type(championOrdinal)
		if test == "number" and championOrdinal > 0 and championOrdinal < 5 then	
			local champion = party.party:getChampion(championOrdinal)
			local results = {}
			for c = 1, #conditions, 2 do
				if champion:hasCondition(conditions[c]) then
					results[#results+1] = ""
					results[#results] = conditions[c]
					results[#results+1] = conditions[c+1]
				end
			end
			return results
		end
		print("Error: "..self.go.id.."[checkConditions]" ,"Bad champion ordinal, expected number (1 to 4), got:", iff(test == "string", '"'..championOrdinal..'"', championOrdinal))
		return
	end
	print(self.go.id, "checkConditions" ,"Error, no ordinal given")	
end

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 23, 2016 9:48 pm
by zimberzimber
Looks useful, except I have absolutely no idea on how to use tables. :oops:
Help please?